From 8a6a06ebd5e76ea6e7e6ea0192ca8789677a896b Mon Sep 17 00:00:00 2001 From: ItzTJSV2 Date: Mon, 4 Aug 2025 16:12:49 +0700 Subject: [PATCH] Added message for successful uploads and currently held filename --- .../app/dashboard/(application)/cv/page.tsx | 29 ++++++++++++++++++- common/src/types/application.ts | 1 + .../application/application-handlers.ts | 2 ++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/client/src/app/dashboard/(application)/cv/page.tsx b/client/src/app/dashboard/(application)/cv/page.tsx index fdd55072..aaa315ed 100644 --- a/client/src/app/dashboard/(application)/cv/page.tsx +++ b/client/src/app/dashboard/(application)/cv/page.tsx @@ -89,6 +89,8 @@ function CvForm({ application }: { application: Application }) { const router = useRouter() const { mutateApplication } = useApplicationContext() const [showForm, setShowForm] = React.useState(() => application?.cvUploadChoice === "upload") + const [successMessage, setSuccessMessage] = React.useState(null) + const [statusMessage, setStatusMessage] = React.useState(null) const form = useForm>({ resolver: zodResolver>(cvFormSchema), @@ -97,7 +99,15 @@ function CvForm({ application }: { application: Application }) { cvFiles: [], }, }) + + React.useEffect(() => { + if (application.cvUploadChoice === "upload" && application.cvFileName != null) { + setStatusMessage(`We have your CV: (${application.cvFileName})`) + } + }, [application.cvUploadChoice, application.cvFileName]) + + async function onSubmit(values: z.infer): Promise { const formData = new FormData() formData.append("cvUploadChoice", values.cvUploadChoice) @@ -110,9 +120,10 @@ function CvForm({ application }: { application: Application }) { await updateApplication("cv", formData) } catch { // todo: what about network errors? this handles too broadly - form.setError("cvUploadChoice", { message: "CV file was rejected (try uploading a PDF)!" }) + form.setError("cvUploadChoice", { message: "CV file was rejected (try uploading an A4 PDF)!" }) return } + setSuccessMessage("CV successfully saved!") await mutateApplication({ ...application, cvUploadChoice: values.cvUploadChoice }) if (application.cvUploadChoice === "indeterminate") router.push("/dashboard/submit") @@ -169,6 +180,14 @@ function CvForm({ application }: { application: Application }) { )} /> + {successMessage && ( +
+ {successMessage} +
+ )} +
    + +
    )} /> + +
    +
    + {statusMessage && ( +
    + {statusMessage} +
    + )}
    Save Progress diff --git a/common/src/types/application.ts b/common/src/types/application.ts index a39d249c..6b5882d7 100644 --- a/common/src/types/application.ts +++ b/common/src/types/application.ts @@ -38,6 +38,7 @@ export type Application = { countryOfResidence: string | null consents: Consent[] cvUploadChoice: "indeterminate" | "upload" | "remind" | "no-upload" + cvFileName: string | null tShirtSize: "xs" | "sm" | "md" | "lg" | "xl" | "2xl" | "3xl" | "prefer-not-to-answer" | null hackathonExperience: "zero" | "up-to-two" | "three-to-seven" | "eight-or-more" | null dietaryRequirements: null | DietaryRequirement[] diff --git a/server/src/routes/application/application-handlers.ts b/server/src/routes/application/application-handlers.ts index 2dbbc257..2d10047c 100644 --- a/server/src/routes/application/application-handlers.ts +++ b/server/src/routes/application/application-handlers.ts @@ -143,6 +143,7 @@ class ApplicationHandlers { userInfo: true, userConsents: true, userFlags: true, + userCv: true, }, }) assert(user) @@ -180,6 +181,7 @@ class ApplicationHandlers { lastNames: lastNames, applicationStatus: adaptApplicationStatusFromDatabase(userInfo?.applicationStatus), cvUploadChoice: adaptCvUploadChoiceFromDatabase(userInfo?.cvUploadChoice), + cvFileName: user.userCv?.filename ?? null, age: userInfo?.age ?? null, gender: adaptGenderFromDatabase(userInfo?.gender), ethnicity: adaptEthnicityFromDatabase(userInfo?.ethnicity),