diff --git a/package-lock.json b/package-lock.json index 8b9f229..8f96ea3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "@trpc/next": "10.37.1", "@trpc/react-query": "10.37.1", "@trpc/server": "10.37.1", + "@uidotdev/usehooks": "2.4.1", "@uzh-bf/design-system": "2.4.3", "axios": "1.5.1", "cross-fetch": "3.1.5", @@ -2225,6 +2226,18 @@ "url": "https://opencollective.com/typescript-eslint" } }, + "node_modules/@uidotdev/usehooks": { + "version": "2.4.1", + "resolved": "https://registry.npmjs.org/@uidotdev/usehooks/-/usehooks-2.4.1.tgz", + "integrity": "sha512-1I+RwWyS+kdv3Mv0Vmc+p0dPYH0DTRAo04HLyXReYBL9AeseDWUJyi4THuksBJcu9F0Pih69Ak150VDnqbVnXg==", + "engines": { + "node": ">=16" + }, + "peerDependencies": { + "react": ">=18.0.0", + "react-dom": ">=18.0.0" + } + }, "node_modules/@uzh-bf/design-system": { "version": "2.4.3", "resolved": "https://registry.npmjs.org/@uzh-bf/design-system/-/design-system-2.4.3.tgz", diff --git a/package.json b/package.json index aa75058..90f9af6 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@trpc/next": "10.37.1", "@trpc/react-query": "10.37.1", "@trpc/server": "10.37.1", + "@uidotdev/usehooks": "2.4.1", "@uzh-bf/design-system": "2.4.3", "axios": "1.5.1", "cross-fetch": "3.1.5", diff --git a/src/components/AcceptProposalForm.tsx b/src/components/AcceptProposalForm.tsx index dccbd3c..1ccdb60 100644 --- a/src/components/AcceptProposalForm.tsx +++ b/src/components/AcceptProposalForm.tsx @@ -12,12 +12,14 @@ interface AcceptProposalFormProps { proposalName: string proposalId: string supervisorEmail: string + setProvidedFeedback: (value: string) => void } export default function AcceptProposalForm({ proposalName, proposalId, supervisorEmail, + setProvidedFeedback, }: AcceptProposalFormProps) { const SignupSchema = Yup.object().shape({ comment: Yup.string().required('Required'), @@ -36,9 +38,9 @@ export default function AcceptProposalForm({ }} validationSchema={SignupSchema} onSubmit={async (values, { resetForm }) => { - await submitFeedback.mutateAsync(values) - + setProvidedFeedback('ACCEPT') resetForm() + await submitFeedback.mutateAsync(values) toast.success('Proposal accepted successfully!') }} > @@ -49,7 +51,7 @@ export default function AcceptProposalForm({ assigned to you for supervision. You will work directly with the student to finalize the proposal and get the thesis process started. -
+
-
+
Your message will be sent to the student alongside your acceptance notification.
diff --git a/src/components/DeclineProposalForm.tsx b/src/components/DeclineProposalForm.tsx index f9264ba..18dbcd8 100644 --- a/src/components/DeclineProposalForm.tsx +++ b/src/components/DeclineProposalForm.tsx @@ -13,12 +13,14 @@ interface DeclineProposalFormProps { proposalName: string proposalId: string supervisorEmail: string + setProvidedFeedback: (value: string) => void } export default function DeclineProposalForm({ proposalName, proposalId, supervisorEmail, + setProvidedFeedback, }: DeclineProposalFormProps) { const SignupSchema = Yup.object().shape({ reason: Yup.string().required('Required'), @@ -31,7 +33,7 @@ export default function DeclineProposalForm({ { - await submitFeedback.mutateAsync(values) - resetForm() + setProvidedFeedback('DECLINE') + await submitFeedback.mutateAsync(values) toast.success('Proposal declined successfully!') }} > @@ -50,7 +52,7 @@ export default function DeclineProposalForm({ Declining this proposal because of a mismatch of interests or a high workload on your side will keep it available for other supervisors.
-
+
-
+
Why do you decline this proposal specifically? Your comment will not be shown to the student.
diff --git a/src/components/ProposalMeta.tsx b/src/components/ProposalMeta.tsx index 6de6bc1..3543b20 100644 --- a/src/components/ProposalMeta.tsx +++ b/src/components/ProposalMeta.tsx @@ -68,7 +68,7 @@ export default function ProposalMeta({ proposalDetails }: ProposalMetaProps) {
{proposalDetails.typeKey === 'STUDENT' && ( -
+
{proposalDetails.attachments.map((attachment: any) => ( (proposalDetails.id, null) if ( - proposalDetails?.typeKey === 'STUDENT' && - proposalDetails?.statusKey === 'MATCHED_TENTATIVE' + (proposalDetails?.typeKey === 'STUDENT' && + proposalDetails?.statusKey === 'MATCHED_TENTATIVE') || + providedFeedback === 'ACCEPT_TENTATIVE' ) { return ( <> -
- - This proposal is tentatively matched with a student. Please accept - or reject the proposal. - -
+ + This proposal is tentatively matched with a student. Please accept or + reject the proposal. +
@@ -44,6 +47,7 @@ export default function ProposalStatusForm({ proposalName={proposalDetails?.title} proposalId={proposalDetails?.id} supervisorEmail={session?.user?.email as string} + setProvidedFeedback={setProvidedFeedback} /> @@ -67,11 +72,13 @@ export default function ProposalStatusForm({ } else if ( (proposalDetails?.typeKey === 'STUDENT' && proposalDetails?.statusKey === 'MATCHED') || - proposalDetails?.receivedFeedbacks?.length > 0 + proposalDetails?.receivedFeedbacks?.length > 0 || + providedFeedback ) { return (
- {proposalDetails?.applications?.[0].statusKey === 'ACCEPTED' + {providedFeedback === 'ACCEPT' || + proposalDetails?.applications?.[0].statusKey === 'ACCEPTED' ? 'You have already accepted this proposal!' : 'You have already provided feedback to this proposal!'}
@@ -102,6 +109,7 @@ export default function ProposalStatusForm({ proposalName={proposalDetails?.title} proposalId={proposalDetails?.id} supervisorEmail={session?.user?.email as string} + setProvidedFeedback={setProvidedFeedback} />
) - } else { - return null } } diff --git a/src/components/RejectProposalForm.tsx b/src/components/RejectProposalForm.tsx index 5a9100f..0065a87 100644 --- a/src/components/RejectProposalForm.tsx +++ b/src/components/RejectProposalForm.tsx @@ -13,12 +13,14 @@ interface RejectProposalFormProps { proposalName: string proposalId: string supervisorEmail: string + setProvidedFeedback: (value: string) => void } export default function RejectProposalForm({ proposalName, proposalId, supervisorEmail, + setProvidedFeedback, }: RejectProposalFormProps) { const SignupSchema = Yup.object().shape({ reason: Yup.string().required('Required'), @@ -31,7 +33,7 @@ export default function RejectProposalForm({ { - await submitFeedback.mutateAsync(values) - resetForm() + setProvidedFeedback('REJECT') + await submitFeedback.mutateAsync(values) toast.success('Proposal rejected successfully!') }} > @@ -51,7 +53,7 @@ export default function RejectProposalForm({ requirements will cause review by the thesis coordinator. The student will need to improve and resubmit the proposal.
-
+
-
+
Why do you recommend this proposal for rejection? Your comment will not be shown to the student.
diff --git a/src/components/TentativeAcceptProposalForm.tsx b/src/components/TentativeAcceptProposalForm.tsx index 100b248..2b45601 100644 --- a/src/components/TentativeAcceptProposalForm.tsx +++ b/src/components/TentativeAcceptProposalForm.tsx @@ -12,12 +12,14 @@ interface TentativeAcceptProposalFormProps { proposalName: string proposalId: string supervisorEmail: string + setProvidedFeedback: (value: string) => void } export default function TentativeAcceptProposalForm({ proposalName, proposalId, supervisorEmail, + setProvidedFeedback, }: TentativeAcceptProposalFormProps) { const SignupSchema = Yup.object().shape({ comment: Yup.string().required('Required'), @@ -36,9 +38,9 @@ export default function TentativeAcceptProposalForm({ }} validationSchema={SignupSchema} onSubmit={async (values, { resetForm }) => { - await submitFeedback.mutateAsync(values) - resetForm() + setProvidedFeedback('ACCEPT_TENTATIVE') + await submitFeedback.mutateAsync(values) toast.success('Proposal tentatively accepted successfully!') }} > @@ -48,7 +50,7 @@ export default function TentativeAcceptProposalForm({ your feedback and is required to improve the proposal before you finally accept the proposal for supervision.
-
+
-
+
Your message will be sent to the student alongside your notification of interest.