mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-28 20:52:00 +08:00
[resumes][feat] skip upload of file if not changed (#380)
This commit is contained in:
@ -101,7 +101,7 @@ export default function ResumeReviewPage() {
|
||||
return (
|
||||
<>
|
||||
{(detailsQuery.isError || detailsQuery.data === null) && ErrorPage}
|
||||
{detailsQuery.isLoading && (
|
||||
{detailsQuery.isFetching && (
|
||||
<div className="w-full pt-4">
|
||||
{' '}
|
||||
<Spinner display="block" size="lg" />{' '}
|
||||
|
@ -96,7 +96,7 @@ export default function SubmitResumeForm({
|
||||
handleSubmit,
|
||||
setValue,
|
||||
reset,
|
||||
formState: { errors, isDirty },
|
||||
formState: { errors, isDirty, dirtyFields },
|
||||
} = useForm<IFormInput>({
|
||||
defaultValues: {
|
||||
isChecked: false,
|
||||
@ -170,7 +170,10 @@ export default function SubmitResumeForm({
|
||||
return;
|
||||
}
|
||||
setIsLoading(true);
|
||||
let fileUrl = initFormDetails?.url ?? '';
|
||||
|
||||
// Only update file in fs when it changes
|
||||
if (dirtyFields.file) {
|
||||
const formData = new FormData();
|
||||
formData.append('key', RESUME_STORAGE_KEY);
|
||||
formData.append('file', resumeFile);
|
||||
@ -180,7 +183,8 @@ export default function SubmitResumeForm({
|
||||
'Content-Type': 'multipart/form-data',
|
||||
},
|
||||
});
|
||||
const { url } = res.data;
|
||||
fileUrl = res.data.url;
|
||||
}
|
||||
|
||||
resumeUpsertMutation.mutate(
|
||||
{
|
||||
@ -190,7 +194,7 @@ export default function SubmitResumeForm({
|
||||
location: data.location,
|
||||
role: data.role,
|
||||
title: data.title,
|
||||
url,
|
||||
url: fileUrl,
|
||||
},
|
||||
{
|
||||
onError(error) {
|
||||
|
Reference in New Issue
Block a user