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 (