mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2025-07-29 05:02:52 +08:00
[resumes][feat] remove updating of pdf on edit (#385)
* [resumes][feat] remove updating of pdf on edit * [resumes][fix] remove nit
This commit is contained in:
@ -124,28 +124,6 @@ export default function SubmitResumeForm({
|
|||||||
onDrop: onFileDrop,
|
onDrop: onFileDrop,
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchFilePdf = useCallback(async () => {
|
|
||||||
const fileUrl = initFormDetails?.url;
|
|
||||||
|
|
||||||
if (fileUrl == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = await axios
|
|
||||||
.get(fileUrl, {
|
|
||||||
responseType: 'blob',
|
|
||||||
})
|
|
||||||
.then((res) => res.data);
|
|
||||||
|
|
||||||
const keyAndFileName = fileUrl.substring(fileUrl.indexOf('resumes'));
|
|
||||||
const fileName = keyAndFileName.substring(keyAndFileName.indexOf('-') + 1);
|
|
||||||
|
|
||||||
const file = new File([data], fileName);
|
|
||||||
setValue('file', file, {
|
|
||||||
shouldDirty: false,
|
|
||||||
});
|
|
||||||
}, [initFormDetails?.url, setValue]);
|
|
||||||
|
|
||||||
// Route user to sign in if not logged in
|
// Route user to sign in if not logged in
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (status !== 'loading') {
|
if (status !== 'loading') {
|
||||||
@ -155,11 +133,6 @@ export default function SubmitResumeForm({
|
|||||||
}
|
}
|
||||||
}, [router, session, status]);
|
}, [router, session, status]);
|
||||||
|
|
||||||
// Fetch initial file PDF for edit form
|
|
||||||
useEffect(() => {
|
|
||||||
fetchFilePdf();
|
|
||||||
}, [fetchFilePdf]);
|
|
||||||
|
|
||||||
const onSubmit: SubmitHandler<IFormInput> = async (data) => {
|
const onSubmit: SubmitHandler<IFormInput> = async (data) => {
|
||||||
setIsLoading(true);
|
setIsLoading(true);
|
||||||
let fileUrl = initFormDetails?.url ?? '';
|
let fileUrl = initFormDetails?.url ?? '';
|
||||||
@ -313,7 +286,9 @@ export default function SubmitResumeForm({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
{/* Upload Resume Section */}
|
{/* Upload resume form */}
|
||||||
|
{isNewForm && (
|
||||||
|
<>
|
||||||
<p className="text-sm font-medium text-slate-700">
|
<p className="text-sm font-medium text-slate-700">
|
||||||
Upload resume (PDF format)
|
Upload resume (PDF format)
|
||||||
<span aria-hidden="true" className="text-danger-500">
|
<span aria-hidden="true" className="text-danger-500">
|
||||||
@ -321,12 +296,13 @@ export default function SubmitResumeForm({
|
|||||||
*
|
*
|
||||||
</span>
|
</span>
|
||||||
</p>
|
</p>
|
||||||
{/* Upload Resume Box */}
|
|
||||||
<div className="mb-4">
|
<div className="mb-4">
|
||||||
<div
|
<div
|
||||||
{...getRootProps()}
|
{...getRootProps()}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
fileUploadError ? 'border-danger-600' : 'border-gray-300',
|
fileUploadError
|
||||||
|
? 'border-danger-600'
|
||||||
|
: 'border-gray-300',
|
||||||
'mt-2 flex justify-center rounded-md border-2 border-dashed px-6 pt-5 pb-6',
|
'mt-2 flex justify-center rounded-md border-2 border-dashed px-6 pt-5 pb-6',
|
||||||
)}>
|
)}>
|
||||||
<div className="space-y-1 text-center">
|
<div className="space-y-1 text-center">
|
||||||
@ -375,9 +351,13 @@ export default function SubmitResumeForm({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{fileUploadError && (
|
{fileUploadError && (
|
||||||
<p className="text-danger-600 text-sm">{fileUploadError}</p>
|
<p className="text-danger-600 text-sm">
|
||||||
|
{fileUploadError}
|
||||||
|
</p>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
{/* Additional Info Section */}
|
{/* Additional Info Section */}
|
||||||
<div className="mb-8">
|
<div className="mb-8">
|
||||||
<TextArea
|
<TextArea
|
||||||
|
Reference in New Issue
Block a user