From c0905aa97e52b6c8f4f505e50e32b6f14f4c3a56 Mon Sep 17 00:00:00 2001 From: KetanKBaboo Date: Fri, 31 Oct 2025 11:34:54 +0530 Subject: [PATCH 1/2] show toast message while deleting and restoring --- UI/src/pages/ProjectsDetail.tsx | 20 +++++++++++++++++--- UI/src/store/useProjectStore.ts | 1 + 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/UI/src/pages/ProjectsDetail.tsx b/UI/src/pages/ProjectsDetail.tsx index c96445c..824df80 100644 --- a/UI/src/pages/ProjectsDetail.tsx +++ b/UI/src/pages/ProjectsDetail.tsx @@ -828,9 +828,23 @@ 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!", + }); + } catch (error) { + console.log("error", error); + toast({ + variant: "destructive", + title: + error instanceof Error ? error?.message : "Failed to perform operation", + }); + } finally { + queryClient.invalidateQueries({ queryKey: ["projects"] }); + navigate("/"); + } }; 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 }); } From 7d4b73bb0fe4d7f0ba38ff7edb53262d8d8815cf Mon Sep 17 00:00:00 2001 From: KetanKBaboo Date: Fri, 31 Oct 2025 11:38:55 +0530 Subject: [PATCH 2/2] minor fix --- UI/src/pages/ProjectsDetail.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/UI/src/pages/ProjectsDetail.tsx b/UI/src/pages/ProjectsDetail.tsx index 824df80..2c23f17 100644 --- a/UI/src/pages/ProjectsDetail.tsx +++ b/UI/src/pages/ProjectsDetail.tsx @@ -834,6 +834,8 @@ const ProjectDetailsPage: React.FC<{ projectId: number }> = ({ projectId }) => { variant: "success", title: archive ? "Project restored successfully!" : "Project deleted successfully!", }); + queryClient.invalidateQueries({ queryKey: ["projects"] }); + navigate("/"); } catch (error) { console.log("error", error); toast({ @@ -841,9 +843,6 @@ const ProjectDetailsPage: React.FC<{ projectId: number }> = ({ projectId }) => { title: error instanceof Error ? error?.message : "Failed to perform operation", }); - } finally { - queryClient.invalidateQueries({ queryKey: ["projects"] }); - navigate("/"); } };