fix delete customer on demo page

This commit is contained in:
Matthias Nannt
2023-02-21 14:14:21 +01:00
parent 97dcccd6fc
commit b3007249df
2 changed files with 7 additions and 2 deletions

View File

@@ -28,7 +28,12 @@ export default function DeleteCustomerModal({
const deleteCustomerAction = async (e) => {
setDeletingCustomer(true);
e.preventDefault();
await deleteCustomer(customerId, organisationId);
const res = await deleteCustomer(customerId, organisationId);
if (!res.ok) {
toast.error("Something went wrong while deleting the user.");
setOpen(false);
return;
}
toast("User successfully deleted.");
router.push(`/organisations/${organisationId}/customers`);
};

View File

@@ -28,7 +28,7 @@ export const useCustomer = (organisationId: string, customerId: string) => {
export const deleteCustomer = async (email: string, organisationId: string) => {
try {
await fetch(`/api/organisations/${organisationId}/customers/${email}`, {
return await fetch(`/api/organisations/${organisationId}/customers/${email}`, {
method: "DELETE",
});
} catch (error) {