feat(clients): refresh clients page layout and toast feedback
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { useState } from "react";
|
||||
import { type Client } from "../types/client";
|
||||
import { useState } from "react";
|
||||
import { toast } from "sonner";
|
||||
import { type Client } from "../types/client";
|
||||
import { deleteClient } from "../api/clients";
|
||||
import { useTranslation } from "../hooks/useTranslation";
|
||||
import { Button } from "./ui/button";
|
||||
@@ -19,16 +20,18 @@ export default function DeleteClientModal({ isOpen, onClose, onSuccess, client }
|
||||
const handleDelete = async () => {
|
||||
if (!client) return;
|
||||
setIsLoading(true);
|
||||
try {
|
||||
await deleteClient(client.id);
|
||||
onSuccess();
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(t.clients.errors.deleteFailed, error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
try {
|
||||
await deleteClient(client.id);
|
||||
toast.success(t.clients.deleteSuccess);
|
||||
onSuccess();
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(t.clients.errors.deleteFailed, error);
|
||||
toast.error(t.clients.errors.deleteFailed);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const footer = (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user