-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Delete List Functionality #44
Conversation
Hey Iryna, when I went to review this it looks like the button doesn't have any functionality. When I click the delete buttons there is no confirmation message pop up nor do any of the lists get deleted. |
226d930
to
c347406
Compare
Visit the preview URL for this PR (updated for commit e96ab50): https://tcl-73-smart-shopping-list--pr44-it-delete-single-lis-dyydgd2z.web.app (expires Thu, 11 Apr 2024 16:43:31 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 99eed22fcca8bd9874e77f7b7f7d1eeb554a1666 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @trushmi!
Awesome job making the new FireStore api to delete the list and items!
I realized that this only works for new lists, so we will all need to remember to clean up our FireStore before demos!
I left some comments in the code that relate to styling the delete button, so it matches how I have styled it on the List
page.
Nice work!
return ( | ||
<div className="SingleList"> | ||
<li> | ||
<button onClick={handleClick}>{name}</button> | ||
<button aria-label={`Delete ${name}`} onClick={deleteSelectedList}> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you put className="delete-btn"
here, when this issue and my issue for the List
styling is merged, the same styling I applied to the delete buttons on the List
page will be applied.
I made a delete-btn
global rule in the index.css
, as I knew you were adding a delete button on the Home page, and that we would want the styling to be the same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rachelspencer, I have removed the 'Delete' text and will also add the className="delete-btn" to maintain consistency in our styling!
src/components/SingleList.jsx
Outdated
return ( | ||
<div className="SingleList"> | ||
<li> | ||
<button onClick={handleClick}>{name}</button> | ||
<button aria-label={`Delete ${name}`} onClick={deleteSelectedList}> | ||
<FontAwesomeIcon icon={faTrashCan} /> Delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also removed the Delete
text in between the opening and closing tag.
Our aria label makes the icon accessible, so I removed the text, to make a cleaner UI, and to be closer to our wireframe designs.
If you do this also, our delete button styling will be consistent :-).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works great!! Thanks for getting this done Iryna! :3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good @trushmi! We'll have to remember to remove really old lists since this only works with lists that were created recently.
One issue I have with the list page in general is that right now there's no way to differentiate owned lists vs shared lists, you have to click into a list and see who the owner is.
Perhaps we could do something like add badges (like the purchase urgency badges) to shared lists that mark them as being shared, and at the same time, either disable the delete buttons or conditionally render them based on if the user is the owner or not.
@rachelspencer @sillytsundere What are your thoughts?
Thanks for pointing this out @sillytsundere ! I fixed this issue! |
Hi @jaguilar89 Thank you for bringing this to my attention! It's a great observation and definitely worth investigating further! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job implementing this functionality. I left a few non-blocking comments.
src/api/firebase.js
Outdated
const userDoc = await getDoc(userRef); | ||
|
||
if (listDoc.data().ownerID !== userDoc.data().uid) { | ||
throw new Error('You are not the owner of this list.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job! If you wanted to be even more explicit, you could add "You can't delete this list because you are not the owner."
It also brings up an interesting use-case. Perhaps in the future, you could give the user the option to hide a list if it's not theirs. It's not something I would tackle this week, as you are all busy meeting deadlines, but something interesting to consider if you choose to work on this once the cohort is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @polly89! I will make the text more explicit and consider this use case!
return { success: true, message: 'List successfully deleted' }; | ||
} catch (error) { | ||
throw new Error(`Could not delete currunt list. An error: ${error}`); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nitpick
- there's a small typo in the word "current".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Fixed!
src/index.jsx
Outdated
@@ -2,7 +2,6 @@ import { StrictMode } from 'react'; | |||
import { createRoot } from 'react-dom/client'; | |||
import { Theme } from '@radix-ui/themes'; | |||
import { App } from './App'; | |||
import { Theme } from '@radix-ui/themes'; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually deleted this line and pushed it to main earlier, as I had seen a comment regarding this on Slack.
if ( | ||
window.confirm( | ||
`Are you sure you want to delete the ${name} list? This action cannot be undone and all items in this list will be deleted.`, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know you all are using a library for the modals, but it would be great if we could change the "OK" button in this message in particular to "Delete" and make it red
, since that's the industry standard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this recommendation, @polly89! I'll take the time to explore that further.
Description
Currently, users can create lists on the home page, but there is no option to remove them if they are no longer needed. This PR aims to enhance the user experience by adding a delete option for lists on the home page.
When users click the delete button, they'll receive a confirmation message reminding them that deleting the list will also delete all items within it. This extra step helps prevent accidental deletions and gives users a chance to reconsider. With this feature, users will have more control over managing their lists and the opportunity to delete a list if they no longer need it.
Related Issue
Closes #17
Acceptance Criteria
Type of Changes
enhancement
Updates
Before
After
Note:
User can delete only their own list:
Testing Steps / QA Criteria
git pull
git checkout it-delete-single-list
npm ci
npm start