feat(clients): refresh clients page layout and toast feedback

This commit is contained in:
2026-04-28 21:53:26 +03:30
parent 2b5ee2abf1
commit 36a8c0e24c
6 changed files with 207 additions and 166 deletions

View File

@@ -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 = (
<>