feat(clients): refresh clients page layout and toast feedback
This commit is contained in:
@@ -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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user