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 (
|
return (
|
||||||
<>
|
<>
|
||||||
{(detailsQuery.isError || detailsQuery.data === null) && ErrorPage}
|
{(detailsQuery.isError || detailsQuery.data === null) && ErrorPage}
|
||||||
{detailsQuery.isLoading && (
|
{detailsQuery.isFetching && (
|
||||||
<div className="w-full pt-4">
|
<div className="w-full pt-4">
|
||||||
{' '}
|
{' '}
|
||||||
<Spinner display="block" size="lg" />{' '}
|
<Spinner display="block" size="lg" />{' '}
|
||||||
|
@ -96,7 +96,7 @@ export default function SubmitResumeForm({
|
|||||||
handleSubmit,
|
handleSubmit,
|
||||||
setValue,
|
setValue,
|
||||||
reset,
|
reset,
|
||||||
formState: { errors, isDirty },
|
formState: { errors, isDirty, dirtyFields },
|
||||||
} = useForm<IFormInput>({
|
} = useForm<IFormInput>({
|
||||||
defaultValues: {
|
defaultValues: {
|
||||||
isChecked: false,
|
isChecked: false,
|
||||||
@ -170,17 +170,21 @@ export default function SubmitResumeForm({
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
|
let fileUrl = initFormDetails?.url ?? '';
|
||||||
|
|
||||||
const formData = new FormData();
|
// Only update file in fs when it changes
|
||||||
formData.append('key', RESUME_STORAGE_KEY);
|
if (dirtyFields.file) {
|
||||||
formData.append('file', resumeFile);
|
const formData = new FormData();
|
||||||
|
formData.append('key', RESUME_STORAGE_KEY);
|
||||||
|
formData.append('file', resumeFile);
|
||||||
|
|
||||||
const res = await axios.post('/api/file-storage', formData, {
|
const res = await axios.post('/api/file-storage', formData, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'multipart/form-data',
|
'Content-Type': 'multipart/form-data',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
const { url } = res.data;
|
fileUrl = res.data.url;
|
||||||
|
}
|
||||||
|
|
||||||
resumeUpsertMutation.mutate(
|
resumeUpsertMutation.mutate(
|
||||||
{
|
{
|
||||||
@ -190,7 +194,7 @@ export default function SubmitResumeForm({
|
|||||||
location: data.location,
|
location: data.location,
|
||||||
role: data.role,
|
role: data.role,
|
||||||
title: data.title,
|
title: data.title,
|
||||||
url,
|
url: fileUrl,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onError(error) {
|
onError(error) {
|
||||||
|
Reference in New Issue
Block a user