|
|
|
@ -68,25 +68,23 @@ export default function SubmitResumeForm() {
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const [title, setTitle] = useState('');
|
|
|
|
|
const [role, setRole] = useState(roleItems[0].label);
|
|
|
|
|
const [experience, setExperience] = useState(experienceItems[0].label);
|
|
|
|
|
const [location, setLocation] = useState(locationItems[0].label);
|
|
|
|
|
const [resumeFile, setResumeFile] = useState<File | null>(null);
|
|
|
|
|
const [resumeFile, setResumeFile] = useState<File | null>();
|
|
|
|
|
const [invalidFileUploadError, setInvalidFileUploadError] = useState<
|
|
|
|
|
string | null
|
|
|
|
|
>(null);
|
|
|
|
|
const [additionalInfo, setAdditionalInfo] = useState('');
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
|
register,
|
|
|
|
|
handleSubmit,
|
|
|
|
|
setValue,
|
|
|
|
|
reset,
|
|
|
|
|
formState: { errors },
|
|
|
|
|
} = useForm<IFormInput>();
|
|
|
|
|
|
|
|
|
|
// TODO: Add Create resume mutation
|
|
|
|
|
const onSubmit: SubmitHandler<IFormInput> = (data) => {
|
|
|
|
|
alert(JSON.stringify(data));
|
|
|
|
|
onClickReset();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onUploadFile = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
@ -102,6 +100,11 @@ export default function SubmitResumeForm() {
|
|
|
|
|
setResumeFile(file);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const onClickReset = () => {
|
|
|
|
|
reset();
|
|
|
|
|
setResumeFile(null);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fileUploadError = useMemo(() => {
|
|
|
|
|
if (invalidFileUploadError != null) {
|
|
|
|
|
return invalidFileUploadError;
|
|
|
|
@ -111,15 +114,6 @@ export default function SubmitResumeForm() {
|
|
|
|
|
}
|
|
|
|
|
}, [errors?.file, invalidFileUploadError]);
|
|
|
|
|
|
|
|
|
|
const onReset = () => {
|
|
|
|
|
setTitle('');
|
|
|
|
|
setLocation(locationItems[0].label);
|
|
|
|
|
setExperience(experienceItems[0].label);
|
|
|
|
|
setRole(roleItems[0].label);
|
|
|
|
|
setResumeFile(null);
|
|
|
|
|
setAdditionalInfo('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<Head>
|
|
|
|
@ -135,11 +129,11 @@ export default function SubmitResumeForm() {
|
|
|
|
|
<div className="mb-4">
|
|
|
|
|
<TextInput
|
|
|
|
|
{...register('title', { required: true })}
|
|
|
|
|
defaultValue=""
|
|
|
|
|
errorMessage={errors?.title && 'Title cannot be empty!'}
|
|
|
|
|
label="Title"
|
|
|
|
|
placeholder={TITLE_PLACEHOLDER}
|
|
|
|
|
value={title}
|
|
|
|
|
onChange={setTitle}
|
|
|
|
|
onChange={(val) => setValue('title', val)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="mb-4">
|
|
|
|
@ -147,8 +141,7 @@ export default function SubmitResumeForm() {
|
|
|
|
|
{...register('role', { required: true })}
|
|
|
|
|
label="Role"
|
|
|
|
|
options={roleItems}
|
|
|
|
|
value={role}
|
|
|
|
|
onChange={setRole}
|
|
|
|
|
onChange={(val) => setValue('role', val)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="mb-4">
|
|
|
|
@ -156,8 +149,7 @@ export default function SubmitResumeForm() {
|
|
|
|
|
{...register('experience', { required: true })}
|
|
|
|
|
label="Experience Level"
|
|
|
|
|
options={experienceItems}
|
|
|
|
|
value={experience}
|
|
|
|
|
onChange={setExperience}
|
|
|
|
|
onChange={(val) => setValue('experience', val)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="mb-4">
|
|
|
|
@ -166,8 +158,7 @@ export default function SubmitResumeForm() {
|
|
|
|
|
label="Location"
|
|
|
|
|
name="location"
|
|
|
|
|
options={locationItems}
|
|
|
|
|
value={location}
|
|
|
|
|
onChange={setLocation}
|
|
|
|
|
onChange={(val) => setValue('location', val)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-sm font-medium text-slate-700">
|
|
|
|
@ -207,10 +198,10 @@ export default function SubmitResumeForm() {
|
|
|
|
|
{/* TODO: Use TextInputArea instead */}
|
|
|
|
|
<TextInput
|
|
|
|
|
{...register('additionalInformation')}
|
|
|
|
|
defaultValue=""
|
|
|
|
|
label="Additional Information"
|
|
|
|
|
placeholder={ADDITIONAL_INFO_PLACEHOLDER}
|
|
|
|
|
value={additionalInfo}
|
|
|
|
|
onChange={setAdditionalInfo}
|
|
|
|
|
onChange={(val) => setValue('additionalInformation', val)}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
<div className="mt-4 flex justify-end gap-4">
|
|
|
|
@ -220,7 +211,7 @@ export default function SubmitResumeForm() {
|
|
|
|
|
label="Clear"
|
|
|
|
|
size="md"
|
|
|
|
|
variant="tertiary"
|
|
|
|
|
onClick={onReset}
|
|
|
|
|
onClick={onClickReset}
|
|
|
|
|
/>
|
|
|
|
|
<Button
|
|
|
|
|
addonPosition="start"
|
|
|
|
|