From b885e3445feee105a1b17cf4e62e6791c0f6bb1c Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Mon, 17 Oct 2022 19:07:19 +0800 Subject: [PATCH] [resumes][feat] remove updating of pdf on edit (#385) * [resumes][feat] remove updating of pdf on edit * [resumes][fix] remove nit --- apps/portal/src/pages/resumes/submit.tsx | 154 ++++++++++------------- 1 file changed, 67 insertions(+), 87 deletions(-) diff --git a/apps/portal/src/pages/resumes/submit.tsx b/apps/portal/src/pages/resumes/submit.tsx index b6ee74d8..613d841c 100644 --- a/apps/portal/src/pages/resumes/submit.tsx +++ b/apps/portal/src/pages/resumes/submit.tsx @@ -124,28 +124,6 @@ export default function SubmitResumeForm({ onDrop: onFileDrop, }); - const fetchFilePdf = useCallback(async () => { - const fileUrl = initFormDetails?.url; - - if (fileUrl == null) { - return; - } - - const data = await axios - .get(fileUrl, { - responseType: 'blob', - }) - .then((res) => res.data); - - const keyAndFileName = fileUrl.substring(fileUrl.indexOf('resumes')); - const fileName = keyAndFileName.substring(keyAndFileName.indexOf('-') + 1); - - const file = new File([data], fileName); - setValue('file', file, { - shouldDirty: false, - }); - }, [initFormDetails?.url, setValue]); - // Route user to sign in if not logged in useEffect(() => { if (status !== 'loading') { @@ -155,11 +133,6 @@ export default function SubmitResumeForm({ } }, [router, session, status]); - // Fetch initial file PDF for edit form - useEffect(() => { - fetchFilePdf(); - }, [fetchFilePdf]); - const onSubmit: SubmitHandler = async (data) => { setIsLoading(true); let fileUrl = initFormDetails?.url ?? ''; @@ -313,71 +286,78 @@ export default function SubmitResumeForm({ /> ))} - {/* Upload Resume Section */} -

- Upload resume (PDF format) - -

- {/* Upload Resume Box */} -
-
-
-
- {resumeFile == null ? ( - - ) : ( + {/* Upload resume form */} + {isNewForm && ( + <> +

+ Upload resume (PDF format) + +

+
+
+
-

- {resumeFile.name} -

+ {resumeFile == null ? ( + + ) : ( +
+

+ {resumeFile.name} +

+
+ )}
- )} -
-
-
-

- PDF up to {FILE_SIZE_LIMIT_MB}MB -

+ {fileUploadError && ( +

+ {fileUploadError} +

+ )}
-
- {fileUploadError && ( -

{fileUploadError}

- )} -
+ + )} {/* Additional Info Section */}