Skip to content

Commit

Permalink
feat(admin): wrapped certification additional information mutation ca…
Browse files Browse the repository at this point in the history
…ll in a try catch with an error toast
  • Loading branch information
agarbe committed Dec 24, 2024
1 parent f3270d8 commit 5c40f01
Showing 1 changed file with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { useForm } from "react-hook-form";
import { File as GQLFile } from "@/graphql/generated/graphql";
import { useMemo } from "react";
import { graphqlErrorToast } from "@/components/toast/toast";

export default function CertificationAdditionalInfoPage() {
const { certificationId } = useParams<{ certificationId: string }>();
Expand Down Expand Up @@ -115,18 +116,22 @@ const AdditionalInfoForm = ({
});

const onFormSubmit = async (data: FormData) => {
const dossierDeValidationTemplate =
data.dossierDeValidationTemplate?.[0] ?? null;
await updateCertificationAdditionalInfo({
certificationId: certification.id,
additionalInfo: {
...data,
dossierDeValidationTemplate,
},
});
router.push(
`/responsable-certifications/certifications/${certification.id}`,
);
try {
const dossierDeValidationTemplate =
data.dossierDeValidationTemplate?.[0] ?? null;
await updateCertificationAdditionalInfo({
certificationId: certification.id,
additionalInfo: {
...data,
dossierDeValidationTemplate,
},
});
router.push(
`/responsable-certifications/certifications/${certification.id}`,
);
} catch (e) {
graphqlErrorToast(e);
}
};

return (
Expand Down

0 comments on commit 5c40f01

Please sign in to comment.