From 5612c2b455291d1f0ed7df16e452e69a4517a98e Mon Sep 17 00:00:00 2001 From: Mamadou DICKO <63923024+mamadoudicko@users.noreply.github.com> Date: Wed, 30 Aug 2023 11:04:03 +0200 Subject: [PATCH] feat: add name missing error in new brain modal (#1055) * feat: update toast z index * feat(brain modal): add name missing message --- .../components/AddBrainModal/hooks/useAddBrainModal.ts | 9 +++++++-- frontend/lib/components/ui/Toast/components/Toast.tsx | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/frontend/lib/components/AddBrainModal/hooks/useAddBrainModal.ts b/frontend/lib/components/AddBrainModal/hooks/useAddBrainModal.ts index 0b4d94c20..e2f0080d1 100644 --- a/frontend/lib/components/AddBrainModal/hooks/useAddBrainModal.ts +++ b/frontend/lib/components/AddBrainModal/hooks/useAddBrainModal.ts @@ -59,6 +59,11 @@ export const useAddBrainModal = () => { const { name, description, setDefault } = getValues(); if (name.trim() === "" || isPending) { + publish({ + variant: "danger", + text: t("nameRequired", { ns: "config" }), + }); + return; } @@ -80,7 +85,7 @@ export const useAddBrainModal = () => { if (createdBrainId === undefined) { publish({ variant: "danger", - text: t("errorCreatingBrain",{ns:"brain"}) + text: t("errorCreatingBrain", { ns: "brain" }), }); return; @@ -99,7 +104,7 @@ export const useAddBrainModal = () => { reset(defaultValues); publish({ variant: "success", - text: t("brainCreated",{ns:"brain"}) + text: t("brainCreated", { ns: "brain" }), }); } catch (err) { if (axios.isAxiosError(err) && err.response?.status === 429) { diff --git a/frontend/lib/components/ui/Toast/components/Toast.tsx b/frontend/lib/components/ui/Toast/components/Toast.tsx index b446d1ce7..e8e8cf530 100644 --- a/frontend/lib/components/ui/Toast/components/Toast.tsx +++ b/frontend/lib/components/ui/Toast/components/Toast.tsx @@ -19,7 +19,7 @@ export const Toast = ({ children?: ReactNode; } & ToastPrimitive.ToastProviderProps): JSX.Element => { const { publish, toasts, toggleToast } = useToastBuilder(); - const {t, i18n} = useTranslation(); + const { t } = useTranslation(); return ( @@ -62,7 +62,7 @@ export const Toast = ({ ); })} - + );