feat(projects): add client strip filtering and page refresh
This commit is contained in:
@@ -58,36 +58,44 @@ export const ProjectEditModal: React.FC<ProjectEditModalProps> = ({ isOpen, onCl
|
||||
if (!project || !formData.name) return;
|
||||
|
||||
setLoading(true);
|
||||
try {
|
||||
const updated = await updateProject(project.id, {
|
||||
name: formData.name,
|
||||
description: formData.description,
|
||||
color: formData.color,
|
||||
client: formData.client || null,
|
||||
});
|
||||
|
||||
window.dispatchEvent(new CustomEvent("project_updated", { detail: updated }));
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
try {
|
||||
const updated = await updateProject(project.id, {
|
||||
name: formData.name,
|
||||
description: formData.description,
|
||||
color: formData.color,
|
||||
client: formData.client || null,
|
||||
});
|
||||
|
||||
toast.success(t.projects?.updateSuccess || "Project updated successfully.");
|
||||
window.dispatchEvent(new CustomEvent("project_updated", { detail: updated }));
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error(t.projects?.updateError || "Failed to update project.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleArchiveToggle = async () => {
|
||||
if (!project) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const updated = await toggleArchiveProject(project.id);
|
||||
window.dispatchEvent(new CustomEvent("project_updated", { detail: updated }));
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
try {
|
||||
const updated = await toggleArchiveProject(project.id);
|
||||
toast.success(
|
||||
project?.is_archived
|
||||
? t.projects?.restoreSuccess || t.projects?.updateSuccess || "Project updated successfully."
|
||||
: t.projects?.archiveSuccess || t.projects?.updateSuccess || "Project updated successfully.",
|
||||
);
|
||||
window.dispatchEvent(new CustomEvent("project_updated", { detail: updated }));
|
||||
onClose();
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
toast.error(t.projects?.updateError || "Failed to update project.");
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const footer = (
|
||||
<div className="flex justify-between w-full">
|
||||
|
||||
Reference in New Issue
Block a user