From 634073342ba8bc9d8251ce3fd06332f021dc40e8 Mon Sep 17 00:00:00 2001 From: Ardeman Date: Wed, 12 Mar 2025 19:25:36 +0800 Subject: [PATCH] feat: improve error handling --- app/pages/form-contents/index.tsx | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/pages/form-contents/index.tsx b/app/pages/form-contents/index.tsx index c8f8bec..7d7461d 100644 --- a/app/pages/form-contents/index.tsx +++ b/app/pages/form-contents/index.tsx @@ -97,11 +97,15 @@ export const FormContentsPage = (properties: TProperties) => { const watchTags = watch('tags') useEffect(() => { + if (fetcher.data?.sucess) { + toast.error(fetcher.data?.message) + return + } + if (fetcher.data?.success) { toast.success(`Artikel berhasil ${newsData ? 'diupdate' : 'dibuat'}!`) navigate('/lg-admin/contents') - } else { - toast.error(fetcher.data?.message) + return } // eslint-disable-next-line react-hooks/exhaustive-deps }, [fetcher.data])