Skip to content
Snippets Groups Projects
Commit 73f4b9af authored by 한동현's avatar 한동현
Browse files

feat: 인증서 삭제 실패 권한 오류 메시지 추가

parent d089e9e0
Branches
No related tags found
No related merge requests found
...@@ -49,20 +49,24 @@ export default function CertificateList() { ...@@ -49,20 +49,24 @@ export default function CertificateList() {
}); });
}, [authFetch, selectedProject, searchParams]); }, [authFetch, selectedProject, searchParams]);
const handleDelete = () => { const handleDelete = async () => {
if (selectedCertificate === null) throw Error('selectedCertificate is null'); 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', method: 'DELETE',
}).then((response) => { });
if (!response.ok) { if (!response.ok) {
console.error(response); const { code } = await response.json();
if (code == 'UNAUTHORIZED_USER') {
toast.error('SSL 인증서를 삭제할 권한이 없습니다');
} else {
toast.error('SSL 인증서 삭제에 실패했습니다'); toast.error('SSL 인증서 삭제에 실패했습니다');
}
} else { } else {
toast.warning('SSL 인증서가 삭제되었습니다'); toast.warning('SSL 인증서가 삭제되었습니다');
setCertificates((prev) => prev!.filter((certificate) => certificate.id !== selectedCertificate.id)); setCertificates((prev) => prev!.filter((certificate) => certificate.id !== selectedCertificate.id));
} }
});
}; };
return ( return (
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment