|
|
@ -41,16 +41,19 @@ export default function ResumeCommentsForm({
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const trpcContext = trpc.useContext();
|
|
|
|
const trpcContext = trpc.useContext();
|
|
|
|
const reviewCreateMutation = trpc.useMutation('resumes.reviews.user.create', {
|
|
|
|
const commentCreateMutation = trpc.useMutation(
|
|
|
|
onSuccess: () => {
|
|
|
|
'resumes.comments.user.create',
|
|
|
|
// New review added, invalidate query to trigger refetch
|
|
|
|
{
|
|
|
|
trpcContext.invalidateQueries(['resumes.reviews.list']);
|
|
|
|
onSuccess: () => {
|
|
|
|
|
|
|
|
// New Comment added, invalidate query to trigger refetch
|
|
|
|
|
|
|
|
trpcContext.invalidateQueries(['resumes.comments.list']);
|
|
|
|
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Give a feedback to the user if the action succeeds/fails
|
|
|
|
// TODO: Give a feedback to the user if the action succeeds/fails
|
|
|
|
const onSubmit: SubmitHandler<IFormInput> = async (data) => {
|
|
|
|
const onSubmit: SubmitHandler<IFormInput> = async (data) => {
|
|
|
|
return await reviewCreateMutation.mutate(
|
|
|
|
return await commentCreateMutation.mutate(
|
|
|
|
{
|
|
|
|
{
|
|
|
|
resumeId,
|
|
|
|
resumeId,
|
|
|
|
...data,
|
|
|
|
...data,
|
|
|
@ -89,7 +92,7 @@ export default function ResumeCommentsForm({
|
|
|
|
<div className="mt-4 space-y-4">
|
|
|
|
<div className="mt-4 space-y-4">
|
|
|
|
<TextArea
|
|
|
|
<TextArea
|
|
|
|
{...(register('general'), {})}
|
|
|
|
{...(register('general'), {})}
|
|
|
|
disabled={reviewCreateMutation.isLoading}
|
|
|
|
disabled={commentCreateMutation.isLoading}
|
|
|
|
label="General"
|
|
|
|
label="General"
|
|
|
|
placeholder="General comments about the resume"
|
|
|
|
placeholder="General comments about the resume"
|
|
|
|
onChange={(value) => onValueChange('general', value)}
|
|
|
|
onChange={(value) => onValueChange('general', value)}
|
|
|
@ -97,7 +100,7 @@ export default function ResumeCommentsForm({
|
|
|
|
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
<TextArea
|
|
|
|
{...(register('education'), {})}
|
|
|
|
{...(register('education'), {})}
|
|
|
|
disabled={reviewCreateMutation.isLoading}
|
|
|
|
disabled={commentCreateMutation.isLoading}
|
|
|
|
label="Education"
|
|
|
|
label="Education"
|
|
|
|
placeholder="Comments about the Education section"
|
|
|
|
placeholder="Comments about the Education section"
|
|
|
|
onChange={(value) => onValueChange('education', value)}
|
|
|
|
onChange={(value) => onValueChange('education', value)}
|
|
|
@ -105,7 +108,7 @@ export default function ResumeCommentsForm({
|
|
|
|
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
<TextArea
|
|
|
|
{...(register('experience'), {})}
|
|
|
|
{...(register('experience'), {})}
|
|
|
|
disabled={reviewCreateMutation.isLoading}
|
|
|
|
disabled={commentCreateMutation.isLoading}
|
|
|
|
label="Experience"
|
|
|
|
label="Experience"
|
|
|
|
placeholder="Comments about the Experience section"
|
|
|
|
placeholder="Comments about the Experience section"
|
|
|
|
onChange={(value) => onValueChange('experience', value)}
|
|
|
|
onChange={(value) => onValueChange('experience', value)}
|
|
|
@ -113,7 +116,7 @@ export default function ResumeCommentsForm({
|
|
|
|
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
<TextArea
|
|
|
|
{...(register('projects'), {})}
|
|
|
|
{...(register('projects'), {})}
|
|
|
|
disabled={reviewCreateMutation.isLoading}
|
|
|
|
disabled={commentCreateMutation.isLoading}
|
|
|
|
label="Projects"
|
|
|
|
label="Projects"
|
|
|
|
placeholder="Comments about the Projects section"
|
|
|
|
placeholder="Comments about the Projects section"
|
|
|
|
onChange={(value) => onValueChange('projects', value)}
|
|
|
|
onChange={(value) => onValueChange('projects', value)}
|
|
|
@ -121,7 +124,7 @@ export default function ResumeCommentsForm({
|
|
|
|
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
<TextArea
|
|
|
|
{...(register('skills'), {})}
|
|
|
|
{...(register('skills'), {})}
|
|
|
|
disabled={reviewCreateMutation.isLoading}
|
|
|
|
disabled={commentCreateMutation.isLoading}
|
|
|
|
label="Skills"
|
|
|
|
label="Skills"
|
|
|
|
placeholder="Comments about the Skills section"
|
|
|
|
placeholder="Comments about the Skills section"
|
|
|
|
onChange={(value) => onValueChange('skills', value)}
|
|
|
|
onChange={(value) => onValueChange('skills', value)}
|
|
|
@ -130,7 +133,7 @@ export default function ResumeCommentsForm({
|
|
|
|
|
|
|
|
|
|
|
|
<div className="flex justify-end space-x-2 pt-4">
|
|
|
|
<div className="flex justify-end space-x-2 pt-4">
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
disabled={reviewCreateMutation.isLoading}
|
|
|
|
disabled={commentCreateMutation.isLoading}
|
|
|
|
label="Cancel"
|
|
|
|
label="Cancel"
|
|
|
|
type="button"
|
|
|
|
type="button"
|
|
|
|
variant="tertiary"
|
|
|
|
variant="tertiary"
|
|
|
@ -138,8 +141,8 @@ export default function ResumeCommentsForm({
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
<Button
|
|
|
|
disabled={!isDirty || reviewCreateMutation.isLoading}
|
|
|
|
disabled={!isDirty || commentCreateMutation.isLoading}
|
|
|
|
isLoading={reviewCreateMutation.isLoading}
|
|
|
|
isLoading={commentCreateMutation.isLoading}
|
|
|
|
label="Submit"
|
|
|
|
label="Submit"
|
|
|
|
type="submit"
|
|
|
|
type="submit"
|
|
|
|
variant="primary"
|
|
|
|
variant="primary"
|
|
|
|