|
|
@ -2,11 +2,19 @@ import axios from 'axios';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import clsx from 'clsx';
|
|
|
|
import Head from 'next/head';
|
|
|
|
import Head from 'next/head';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import { useRouter } from 'next/router';
|
|
|
|
import { useMemo, useState } from 'react';
|
|
|
|
import { useSession } from 'next-auth/react';
|
|
|
|
|
|
|
|
import { useEffect, useMemo, useState } from 'react';
|
|
|
|
import type { SubmitHandler } from 'react-hook-form';
|
|
|
|
import type { SubmitHandler } from 'react-hook-form';
|
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
import { useForm } from 'react-hook-form';
|
|
|
|
import { PaperClipIcon } from '@heroicons/react/24/outline';
|
|
|
|
import { PaperClipIcon } from '@heroicons/react/24/outline';
|
|
|
|
import { Button, CheckboxInput, Select, TextArea, TextInput } from '@tih/ui';
|
|
|
|
import {
|
|
|
|
|
|
|
|
Button,
|
|
|
|
|
|
|
|
CheckboxInput,
|
|
|
|
|
|
|
|
Dialog,
|
|
|
|
|
|
|
|
Select,
|
|
|
|
|
|
|
|
TextArea,
|
|
|
|
|
|
|
|
TextInput,
|
|
|
|
|
|
|
|
} from '@tih/ui';
|
|
|
|
|
|
|
|
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
EXPERIENCE,
|
|
|
|
EXPERIENCE,
|
|
|
@ -36,6 +44,7 @@ type IFormInput = {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
export default function SubmitResumeForm() {
|
|
|
|
export default function SubmitResumeForm() {
|
|
|
|
|
|
|
|
const { data: session, status } = useSession();
|
|
|
|
const resumeCreateMutation = trpc.useMutation('resumes.resume.user.create');
|
|
|
|
const resumeCreateMutation = trpc.useMutation('resumes.resume.user.create');
|
|
|
|
const router = useRouter();
|
|
|
|
const router = useRouter();
|
|
|
|
|
|
|
|
|
|
|
@ -44,13 +53,22 @@ export default function SubmitResumeForm() {
|
|
|
|
const [invalidFileUploadError, setInvalidFileUploadError] = useState<
|
|
|
|
const [invalidFileUploadError, setInvalidFileUploadError] = useState<
|
|
|
|
string | null
|
|
|
|
string | null
|
|
|
|
>(null);
|
|
|
|
>(null);
|
|
|
|
|
|
|
|
const [isDialogShown, setIsDialogShown] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (status !== 'loading') {
|
|
|
|
|
|
|
|
if (session?.user?.id == null) {
|
|
|
|
|
|
|
|
router.push('/api/auth/signin');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [router, session, status]);
|
|
|
|
|
|
|
|
|
|
|
|
const {
|
|
|
|
const {
|
|
|
|
register,
|
|
|
|
register,
|
|
|
|
handleSubmit,
|
|
|
|
handleSubmit,
|
|
|
|
setValue,
|
|
|
|
setValue,
|
|
|
|
reset,
|
|
|
|
reset,
|
|
|
|
formState: { errors },
|
|
|
|
formState: { errors, isDirty },
|
|
|
|
} = useForm<IFormInput>({
|
|
|
|
} = useForm<IFormInput>({
|
|
|
|
defaultValues: {
|
|
|
|
defaultValues: {
|
|
|
|
isChecked: false,
|
|
|
|
isChecked: false,
|
|
|
@ -112,6 +130,13 @@ export default function SubmitResumeForm() {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const onClickReset = () => {
|
|
|
|
const onClickReset = () => {
|
|
|
|
|
|
|
|
if (isDirty || resumeFile != null) {
|
|
|
|
|
|
|
|
setIsDialogShown(true);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onClickProceedDialog = () => {
|
|
|
|
|
|
|
|
setIsDialogShown(false);
|
|
|
|
reset();
|
|
|
|
reset();
|
|
|
|
setResumeFile(null);
|
|
|
|
setResumeFile(null);
|
|
|
|
};
|
|
|
|
};
|
|
|
@ -134,6 +159,28 @@ export default function SubmitResumeForm() {
|
|
|
|
<section
|
|
|
|
<section
|
|
|
|
aria-labelledby="primary-heading"
|
|
|
|
aria-labelledby="primary-heading"
|
|
|
|
className="flex h-full min-w-0 flex-1 flex-col lg:order-last">
|
|
|
|
className="flex h-full min-w-0 flex-1 flex-col lg:order-last">
|
|
|
|
|
|
|
|
<Dialog
|
|
|
|
|
|
|
|
isShown={isDialogShown}
|
|
|
|
|
|
|
|
primaryButton={
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
display="block"
|
|
|
|
|
|
|
|
label="OK"
|
|
|
|
|
|
|
|
variant="primary"
|
|
|
|
|
|
|
|
onClick={onClickProceedDialog}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
secondaryButton={
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
|
|
|
display="block"
|
|
|
|
|
|
|
|
label="Cancel"
|
|
|
|
|
|
|
|
variant="tertiary"
|
|
|
|
|
|
|
|
onClick={() => setIsDialogShown(false)}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
title="Are you sure you want to clear?"
|
|
|
|
|
|
|
|
onClose={() => setIsDialogShown(false)}>
|
|
|
|
|
|
|
|
Note that your current input will not be saved!
|
|
|
|
|
|
|
|
</Dialog>
|
|
|
|
<div className="mx-20 space-y-4 py-8">
|
|
|
|
<div className="mx-20 space-y-4 py-8">
|
|
|
|
<form onSubmit={handleSubmit(onSubmit)}>
|
|
|
|
<form onSubmit={handleSubmit(onSubmit)}>
|
|
|
|
<h1 className="mb-4 text-2xl font-bold">Upload a resume</h1>
|
|
|
|
<h1 className="mb-4 text-2xl font-bold">Upload a resume</h1>
|
|
|
|