|
|
@ -40,6 +40,7 @@ export default function SubmitResumeForm() {
|
|
|
|
const router = useRouter();
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
|
|
const [resumeFile, setResumeFile] = useState<File | null>();
|
|
|
|
const [resumeFile, setResumeFile] = useState<File | null>();
|
|
|
|
|
|
|
|
const [isLoading, setIsLoading] = useState(false);
|
|
|
|
const [invalidFileUploadError, setInvalidFileUploadError] = useState<
|
|
|
|
const [invalidFileUploadError, setInvalidFileUploadError] = useState<
|
|
|
|
string | null
|
|
|
|
string | null
|
|
|
|
>(null);
|
|
|
|
>(null);
|
|
|
@ -50,12 +51,18 @@ export default function SubmitResumeForm() {
|
|
|
|
setValue,
|
|
|
|
setValue,
|
|
|
|
reset,
|
|
|
|
reset,
|
|
|
|
formState: { errors },
|
|
|
|
formState: { errors },
|
|
|
|
} = useForm<IFormInput>();
|
|
|
|
} = useForm<IFormInput>({
|
|
|
|
|
|
|
|
defaultValues: {
|
|
|
|
|
|
|
|
isChecked: false,
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const onSubmit: SubmitHandler<IFormInput> = async (data) => {
|
|
|
|
const onSubmit: SubmitHandler<IFormInput> = async (data) => {
|
|
|
|
if (resumeFile == null) {
|
|
|
|
if (resumeFile == null) {
|
|
|
|
|
|
|
|
console.error('Resume file is empty');
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setIsLoading(true);
|
|
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
const formData = new FormData();
|
|
|
|
formData.append('key', RESUME_STORAGE_KEY);
|
|
|
|
formData.append('key', RESUME_STORAGE_KEY);
|
|
|
@ -68,15 +75,27 @@ export default function SubmitResumeForm() {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const { url } = res.data;
|
|
|
|
const { url } = res.data;
|
|
|
|
|
|
|
|
|
|
|
|
await resumeCreateMutation.mutate({
|
|
|
|
resumeCreateMutation.mutate(
|
|
|
|
additionalInfo: data.additionalInfo,
|
|
|
|
{
|
|
|
|
experience: data.experience,
|
|
|
|
additionalInfo: data.additionalInfo,
|
|
|
|
location: data.location,
|
|
|
|
experience: data.experience,
|
|
|
|
role: data.role,
|
|
|
|
location: data.location,
|
|
|
|
title: data.title,
|
|
|
|
role: data.role,
|
|
|
|
url,
|
|
|
|
title: data.title,
|
|
|
|
});
|
|
|
|
url,
|
|
|
|
router.push('/resumes');
|
|
|
|
},
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
onError: (error) => {
|
|
|
|
|
|
|
|
console.error(error);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSettled: () => {
|
|
|
|
|
|
|
|
setIsLoading(false);
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
|
|
|
router.push('/resumes');
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const onUploadFile = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
|
const onUploadFile = (event: React.ChangeEvent<HTMLInputElement>) => {
|
|
|
@ -255,6 +274,7 @@ export default function SubmitResumeForm() {
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
addonPosition="start"
|
|
|
|
addonPosition="start"
|
|
|
|
display="inline"
|
|
|
|
display="inline"
|
|
|
|
|
|
|
|
isLoading={isLoading}
|
|
|
|
label="Submit"
|
|
|
|
label="Submit"
|
|
|
|
size="md"
|
|
|
|
size="md"
|
|
|
|
type="submit"
|
|
|
|
type="submit"
|
|
|
|