From 73f4b9afceb0142f32d28debe1f6df9cb4a4e4eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=ED=95=9C=EB=8F=99=ED=98=84?= <hando1220@ajou.ac.kr> Date: Mon, 19 May 2025 00:27:53 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=EC=9D=B8=EC=A6=9D=EC=84=9C=20=EC=82=AD?= =?UTF-8?q?=EC=A0=9C=20=EC=8B=A4=ED=8C=A8=20=EA=B6=8C=ED=95=9C=20=EC=98=A4?= =?UTF-8?q?=EB=A5=98=20=EB=A9=94=EC=8B=9C=EC=A7=80=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/certificate/List.tsx | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/pages/certificate/List.tsx b/src/pages/certificate/List.tsx index 10400b3..5ae6088 100644 --- a/src/pages/certificate/List.tsx +++ b/src/pages/certificate/List.tsx @@ -49,20 +49,24 @@ export default function CertificateList() { }); }, [authFetch, selectedProject, searchParams]); - const handleDelete = () => { + const handleDelete = async () => { if (selectedCertificate === null) throw Error('selectedCertificate is null'); - authFetch(`/api/certificate?certificateId=${selectedCertificate.id}`, { + const response = await authFetch(`/api/certificate?certificateId=${selectedCertificate.id}`, { method: 'DELETE', - }).then((response) => { - if (!response.ok) { - console.error(response); - toast.error('SSL 인증서 삭제에 실패했습니다'); + }); + + if (!response.ok) { + const { code } = await response.json(); + if (code == 'UNAUTHORIZED_USER') { + toast.error('SSL 인증서를 삭제할 권한이 없습니다'); } else { - toast.warning('SSL 인증서가 삭제되었습니다'); - setCertificates((prev) => prev!.filter((certificate) => certificate.id !== selectedCertificate.id)); + toast.error('SSL 인증서 삭제에 실패했습니다'); } - }); + } else { + toast.warning('SSL 인증서가 삭제되었습니다'); + setCertificates((prev) => prev!.filter((certificate) => certificate.id !== selectedCertificate.id)); + } }; return ( -- GitLab