From 1b611768183375e51256177086c580d75d32e0f3 Mon Sep 17 00:00:00 2001 From: Jamie Curnow Date: Mon, 16 Jan 2023 16:13:38 +1000 Subject: [PATCH] Basis for create certificate dialog --- .../src/modals/CertificateCreateModal.tsx | 93 +++++++++++++------ 1 file changed, 64 insertions(+), 29 deletions(-) diff --git a/frontend/src/modals/CertificateCreateModal.tsx b/frontend/src/modals/CertificateCreateModal.tsx index 07a4f45..59cab44 100644 --- a/frontend/src/modals/CertificateCreateModal.tsx +++ b/frontend/src/modals/CertificateCreateModal.tsx @@ -1,5 +1,8 @@ +import { useState } from "react"; + import { Button, + ButtonGroup, FormControl, FormErrorMessage, FormLabel, @@ -29,9 +32,15 @@ function CertificateCreateModal({ isOpen, onClose, }: CertificateCreateModalProps) { + const [certType, setCertType] = useState(""); const toast = useToast(); const { mutate: setCertificate } = useSetCertificate(); + const onModalClose = () => { + onClose(); + setCertType(""); + }; + const onSubmit = async ( payload: Certificate, { setErrors, setSubmitting }: any, @@ -60,13 +69,13 @@ function CertificateCreateModal({ showErr(err.message); } }, - onSuccess: () => onClose(), + onSuccess: () => onModalClose(), onSettled: () => setSubmitting(false), }); }; return ( - + - - - {({ field, form }: any) => ( - - - {intl.formatMessage({ - id: "name", - })} - - - {form.errors.name} - - )} - - + {certType === "" ? ( + + + Select the Certificate Validation method + + + + + + + ) : null} + + {certType !== "" ? ( + + + {({ field, form }: any) => ( + + + {intl.formatMessage({ + id: "name", + })} + + + + {form.errors.name} + + + )} + + + ) : null} - - {intl.formatMessage({ id: "form.save" })} - -