From 3980879f0aeed7fc990f416108ff2fad482195e6 Mon Sep 17 00:00:00 2001 From: Keane Chan Date: Wed, 5 Oct 2022 21:04:21 +0800 Subject: [PATCH] [resumes][feat] add submit and clear buttons --- apps/portal/src/pages/resumes/submit.tsx | 37 ++++++++++++++++++------ 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/portal/src/pages/resumes/submit.tsx b/apps/portal/src/pages/resumes/submit.tsx index 6b427dda..feb96535 100644 --- a/apps/portal/src/pages/resumes/submit.tsx +++ b/apps/portal/src/pages/resumes/submit.tsx @@ -6,6 +6,8 @@ import { Button, Select, TextInput } from '@tih/ui'; const TITLE_PLACEHOLDER = 'e.g. Applying for Company XYZ, please help me to review!'; const ADDITIONAL_INFO_PLACEHOLDER = `e.g. I’m applying for company XYZ. I have been resume-rejected by N companies that I have applied for. Please help me to review so company XYZ gives me an interview!`; +const FILE_UPLOAD_ERROR = 'Please upload a PDF file that is less than 10MB.'; + const MAX_FILE_SIZE_LIMIT = 10485760; export default function SubmitResumeForm() { @@ -59,6 +61,7 @@ export default function SubmitResumeForm() { const [experience, setExperience] = useState(experienceItems[0].label); const [location, setLocation] = useState(locationItems[0].label); const [resumeFile, setResumeFile] = useState(null); + const [invalidFileUploadError, setInvalidFileUploadError] = useState(''); const onUploadFile = (event: React.ChangeEvent) => { const file = event.target.files?.item(0); @@ -66,8 +69,10 @@ export default function SubmitResumeForm() { return; } if (file.type !== 'application/pdf' || file.size > MAX_FILE_SIZE_LIMIT) { + setInvalidFileUploadError(FILE_UPLOAD_ERROR); return; } + setInvalidFileUploadError(''); setResumeFile(file); }; @@ -122,6 +127,11 @@ export default function SubmitResumeForm() {

Upload resume (PDF format) + {invalidFileUploadError && ( + + {invalidFileUploadError} + + )}

@@ -147,7 +157,6 @@ export default function SubmitResumeForm() {

PDF up to 10MB

-

Additional Information

@@ -156,14 +165,24 @@ export default function SubmitResumeForm() { name="additonal_information" placeholder={ADDITIONAL_INFO_PLACEHOLDER} /> -