feat: add update-user form #16
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/update-user-form"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
feat/update-user-formto feat: add update-user formGreat work on extracting the user management actions into separate components! This improves maintainability and readability of the page. Here are my findings:
🔴 Bug: Missing
awaitinupdateUserFormIn
src/routes/admin/users/_forms.remote.ts, theupdateUserFormdoes notawaittheuser.updateProfile(profile)call:Since
updateProfileis anasyncmethod, the function returns before the database update completes. This means:Fix: Add
awaitbeforeuser.updateProfile(profile).🟡 UX Issue: Delete dialog doesn't close after success
In
src/routes/admin/users/_components/DeleteUserButton.svelte, theFormcomponent has noonresulthandler, so the dialog stays open after a successful deletion. Compare withUpdateUserButton.sveltewhich correctly closes the dialog:Fix: Either bind the dialog state like
UpdateUserButtondoes, or add anonresulthandler to close the dialog after deletion.💡 Minor: Redundant
preflightschemaIn
UpdateUserButton.svelte, the form already hasupdateUserFormSchemabaked in, yetpreflight(updateUserFormSchema)is called with the same schema:This is consistent with
AddUserButtonin+page.svelte(addUserForm.preflight(addUserFormSchema)), so it's a pattern already in the codebase. Not a bug, but worth noting thatpreflightwith the same schema is redundant — the schema is already part of the form definition.@ -0,0 +25,4 @@<h2>Elimina utente</h2><p>Conferma di voler eliminare l'utente {user.data.username}</p>Dialog doesn't close after successful deletion. Consider adding onresult handler or binding dialog state like UpdateUserButton does.
@ -28,4 +44,4 @@invalid(issue.username("Esiste già un altro utente con questo nome"));}const profile = { ...data, password: data._password };Missing await on async user.updateProfile() call — function returns before DB update completes.
Great work on extracting the user management actions into separate components! This improves maintainability and readability of the page. Here are my findings:
🔴 Bug: Missing
awaitinupdateUserFormIn
src/routes/admin/users/_forms.remote.ts, theupdateUserFormdoes notawaittheuser.updateProfile(profile)call:Since
updateProfileis anasyncmethod, the function returns before the database update completes. This means:Fix: Add
awaitbeforeuser.updateProfile(profile).🟡 UX Issue: Delete dialog doesn't close after success
In
src/routes/admin/users/_components/DeleteUserButton.svelte, theFormcomponent has noonresulthandler, so the dialog stays open after a successful deletion. Compare withUpdateUserButton.sveltewhich correctly closes the dialog:Fix: Either bind the dialog state like
UpdateUserButtondoes, or add anonresulthandler to close the dialog after deletion.💡 Minor: Redundant
preflightschemaIn
UpdateUserButton.svelte, the form already hasupdateUserFormSchemabaked in, yetpreflight(updateUserFormSchema)is called with the same schema. This is consistent withAddUserButtonin+page.svelte, so it's a pattern already in the codebase. Not a bug, but worth noting thatpreflightwith the same schema is redundant — the schema is already part of the form definition.Good work extracting user actions into separate components. Two issues found:
Bug (critical):
user.updateProfile(profile)in_forms.remote.tsis not awaited. SinceupdateProfileis async, the function returns before the DB update completes, meaning logging happens before the update and errors won't propagate properly.UX issue:
DeleteUserButton.sveltedoesn't close the dialog after successful deletion (noonresulthandler), unlikeUpdateUserButtonwhich correctly closes the dialog.