diff --git a/UI/src/pages/ProjectsDetail.tsx b/UI/src/pages/ProjectsDetail.tsx index c96445c..2c23f17 100644 --- a/UI/src/pages/ProjectsDetail.tsx +++ b/UI/src/pages/ProjectsDetail.tsx @@ -828,9 +828,22 @@ const ProjectDetailsPage: React.FC<{ projectId: number }> = ({ projectId }) => { const handleArchiveProject = async () => { if (project?.project_id === undefined) return; - await archiveProject(project?.project_id, !archive); - queryClient.invalidateQueries({ queryKey: ["projects"] }); - navigate("/"); + try { + await archiveProject(project?.project_id, !archive); + toast({ + variant: "success", + title: archive ? "Project restored successfully!" : "Project deleted successfully!", + }); + queryClient.invalidateQueries({ queryKey: ["projects"] }); + navigate("/"); + } catch (error) { + console.log("error", error); + toast({ + variant: "destructive", + title: + error instanceof Error ? error?.message : "Failed to perform operation", + }); + } }; const handleDownloadProject = async () => { diff --git a/UI/src/store/useProjectStore.ts b/UI/src/store/useProjectStore.ts index 72e0cc3..8ad8d24 100644 --- a/UI/src/store/useProjectStore.ts +++ b/UI/src/store/useProjectStore.ts @@ -905,6 +905,7 @@ export const useProjectDetailsStore = create( } catch (error) { console.error("Failed to archive project:", error); set({ error: "Error archiving project." }); + throw error; } finally { set({ isLoading: false }); }