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, useEffect } from "react";
import { type Client } from "../types/client";
import { useState, useEffect } from "react";
import { toast } from "sonner";
import { type Client } from "../types/client";
import { updateClient } from "../api/clients";
import { useTranslation } from "../hooks/useTranslation";
import { Button } from "./ui/button";
@@ -30,16 +31,18 @@ export default function EditClientModal({ isOpen, onClose, onSuccess, client }:
const handleSubmit = async () => {
if (!client || !name.trim()) return;
setIsLoading(true);
try {
await updateClient(client.id, { name, notes });
onSuccess();
onClose();
} catch (error) {
console.error(t.clients.errors.updateFailed, error);
} finally {
setIsLoading(false);
}
};
try {
await updateClient(client.id, { name, notes });
toast.success(t.clients.updateSuccess);
onSuccess();
onClose();
} catch (error) {
console.error(t.clients.errors.updateFailed, error);
toast.error(t.clients.errors.updateFailed);
} finally {
setIsLoading(false);
}
};
const footer = (
<>
@@ -78,4 +81,4 @@ export default function EditClientModal({ isOpen, onClose, onSuccess, client }:
</div>
</Modal>
);
}
}