Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion client/src/app/dashboard/(application)/cv/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ function CvForm({ application }: { application: Application }) {
const router = useRouter()
const { mutateApplication } = useApplicationContext()
const [showForm, setShowForm] = React.useState<boolean>(() => application?.cvUploadChoice === "upload")
const [successMessage, setSuccessMessage] = React.useState<string | null>(null)
const [statusMessage, setStatusMessage] = React.useState<string | null>(null)

const form = useForm<CvFormFields, unknown, z.infer<typeof cvFormSchema>>({
resolver: zodResolver<CvFormFields, unknown, z.infer<typeof cvFormSchema>>(cvFormSchema),
Expand All @@ -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<typeof cvFormSchema>): Promise<void> {
const formData = new FormData()
formData.append("cvUploadChoice", values.cvUploadChoice)
Expand All @@ -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")
Expand Down Expand Up @@ -169,6 +180,14 @@ function CvForm({ application }: { application: Application }) {
)}
/>
</div>
{successMessage && (
<div className="mb-6 rounded-md bg-green-100 p-4 text-center text-sm text-green-800">
{successMessage}
</div>
)}
<ul></ul>


<div className={cn("mb-4", showForm ? "" : "hidden")}>
<FormField
control={form.control}
Expand Down Expand Up @@ -200,6 +219,14 @@ function CvForm({ application }: { application: Application }) {
</FormItem>
)}
/>

</div>
<div className ="flex justify-center">
{statusMessage && (
<div>
{statusMessage}
</div>
)}
</div>
<div className="mt-16 flex justify-center">
<FormSubmitButton type="submit">Save Progress</FormSubmitButton>
Expand Down
1 change: 1 addition & 0 deletions common/src/types/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down
2 changes: 2 additions & 0 deletions server/src/routes/application/application-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class ApplicationHandlers {
userInfo: true,
userConsents: true,
userFlags: true,
userCv: true,
},
})
assert(user)
Expand Down Expand Up @@ -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),
Expand Down