From 6ba25749a2cc45843c3f3c7ed753aeda38eab443 Mon Sep 17 00:00:00 2001 From: "gpt-engineer-app[bot]" <159125892+gpt-engineer-app[bot]@users.noreply.github.com> Date: Mon, 20 Apr 2026 00:15:50 +0000 Subject: [PATCH] Changes Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com> --- src/routes/collections.$collectionId.tsx | 33 ++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/routes/collections.$collectionId.tsx b/src/routes/collections.$collectionId.tsx index 3e61d2d..73714a0 100644 --- a/src/routes/collections.$collectionId.tsx +++ b/src/routes/collections.$collectionId.tsx @@ -272,6 +272,39 @@ function CollectionDetailRoute() { else refreshTasks(); }; + const closeCollection = async () => { + if (!collection) return; + if (!confirm("Close this collection? Open tasks will be hidden but data is preserved. You can reopen anytime.")) return; + setClosingBusy(true); + const { error } = await supabase + .from("collections") + .update({ status: "closed", closed_at: new Date().toISOString().slice(0, 10) }) + .eq("id", collection.id); + setClosingBusy(false); + if (error) { + toast.error("Could not close", { description: error.message }); + return; + } + toast.success("Collection closed"); + setReload((r) => r + 1); + }; + + const reopenCollection = async () => { + if (!collection) return; + setClosingBusy(true); + const { error } = await supabase + .from("collections") + .update({ status: "late_notice", closed_at: null }) + .eq("id", collection.id); + setClosingBusy(false); + if (error) { + toast.error("Could not reopen", { description: error.message }); + return; + } + toast.success("Collection reopened"); + setReload((r) => r + 1); + }; + if (loading) { return (