Skip to content
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

Admin delete #215

Merged
merged 19 commits into from
Feb 16, 2025
Merged

Admin delete #215

merged 19 commits into from
Feb 16, 2025

Conversation

blwelsh
Copy link
Collaborator

@blwelsh blwelsh commented Feb 11, 2025

Developer: Brady Welsh

Closes #199 #200

Pull Request Summary

  • Users are now able to delete their own account
  • On this self deletion, the user is signed out first and redirected to the main page
  • Admin are able to delete accounts (on the admin user page)
  • This deletion both works in MongoDB and Clerk
  • Upon clicking "Delete User", a modal pops up to confirm the deletion
  • All groups which contain the deleted user's id will have that ID removed
  • All events which the user attended or registered for will replace their id with a null ID (to preserve the total number of attendees for an event while preventing a reference to user that doesn't exist)
  • The "Make Admin" button is now green (to contrast with the red delete) and matches the theme
  • Upon admin deletion, useEffect is called to immediately update the user page (and remove that user)

Modifications

  • /components/DeleteConfirmation.tsx created: this component was created to contain the delete button, and the confirmation modal once the button is pressed
  • api/user/[userId]/route.ts modified: a DELETE api call was created to handle the deletion (which deletes the user in both MongoDB and Clerk as described above)
  • components/UserProfile.tsx updated: the user page/component was updated to add in the Delete button, so a user can delete their own account
  • styles/profile/profile.module.css updated: the styles for the UserProfile were updated so that the Delete button would be placed properly
  • components/SingleVisitorComponent.tsx updated: updated this component (a row on the admin user table) to have the Delete button appear when clicking on "Details" for a user. The button appears next to the "Make Admin" button.
  • admin/users/page.tsx updated: the admin page was updated to have the user table immediately update upon a user deletion

Testing Considerations

  • I have tested a user deleting their own account and an admin deleting another account pretty thoroughly. However, I didn't really get a chance to test if the group/event objects will update accordingly (and I am not 100% certain if this is the exact way deletion should have been implemented with those objects).

Screenshots/Screencast

image image image image

@blwelsh blwelsh linked an issue Feb 11, 2025 that may be closed by this pull request
Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
slo-beaver-brigade ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 16, 2025 5:16am
slo-beaver-brigade-dummy ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 16, 2025 5:16am

@blwelsh blwelsh linked an issue Feb 11, 2025 that may be closed by this pull request
Copy link
Collaborator

@SilveerDusk SilveerDusk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look at slack dm for the log, and I would probably suggest running the prettier extension once you fix the error/s, it looks like it might be needed here.

Copy link
Collaborator

@SilveerDusk SilveerDusk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

W feature, delete works as intended at least from my testing of deleting three users and I know you did more thorough testing.

@SilveerDusk SilveerDusk merged commit 4171f93 into main Feb 16, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Delete Account For My Account Page Delete User Button for User List
2 participants