Add form deletion with confirmation and clean up form settings layout - #428
Merged
Merged
Conversation
✅ Deploy Preview for ubclaunchpad ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. 1 Skipped Deployment
|
Contributor
Author
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Features and Changes
Admins can now delete a form from its Settings tab.
Because a form can hold applicant data, deletion needs extra confirmation when the form has responses.
The Settings tab layout was also cleaned up, since its sections used mismatched widths, spacing, and header styles.
Form deletion flow
deleteFormSection.tsx).On confirm, the submission count is fetched from the server, so the check never relies on stale client state.
The same screen has a text box, and "Delete form permanently" (and Enter) stays disabled until
delete formis typed.router.replace, so Back does not return to the deleted form.Server actions (
src/app/portal/admin/actions.ts)getFormSubmissionCount(id): admin-only count of all submissions for the form, including pending ones.deleteForm(id, confirmation?): admin-only.It counts submissions again on the server and refuses to delete a form that has any unless
confirmationmatchesdelete form, so the typed check cannot be skipped by calling the action directly.db.forms.delete.Submissions, applications, and
application_status_historyrows are removed by the existingON DELETE CASCADEforeign keys.revalidatePath("/portal/admin", "layout")clears the router cache so the forms list does not show the deleted form.DELETE_FORM_CONFIRMATIONconstant lives insrc/lib/utils/forms/helpers.ts, because a"use server"file may only export async functions.Settings layout
max-w-4xlcolumn with even spacing between sections.It replaces a mix of full-width and narrow blocks, stacked
px-4padding, and sticky headers with no background.SettingsSectioncomponent gives every section the same heading, description, optional action button, and divider.Its styling follows the redesigned forms list (
font-heading,text-neutral-400,border-background-500).Bug fixes found along the way
Preview state now tracks which template was clicked.
It now clears both the selected applicant and the search box.
Screenshots / Screen Recordings
None yet.
This PR changes the UI, so screenshots of the new Settings layout and both delete dialogs should be added before review.
Testing your changes
npx eslinton the settings folder andactions.ts: no errors.npx prettier --checkon the changed files: passes.npx tsc --noEmit: no errors in the new files.The settings files have the same type errors (implicit
any,unknowntemplate configs) before and after this change, confirmed by comparing error lists withmain.next.config.mjssetsignoreBuildErrors: true.Steps on how to test your changes
It should be deleted after one confirmation and you should land on the forms list without it.
The warning should show the correct response count.
delete formis typed, then delete.The form and its submissions should be gone, and Back should not return to the deleted form.
Other Notes
If recovery is ever needed, a soft-delete flag would be a follow-up.