feat: delete + deactivate for sites, zones, and trucks; harden incident API error handling

- zones: add active column (migration 20260713000005)
- sites/zones API: PATCH (toggle active) + DELETE (blocked when incidents reference it)
- trucks API: PATCH + DELETE with same pattern
- admin page: select active for sites + zones
- site-zone-manager + truck-manager: deactivate toggle + delete button per row with busyId
- incidents API: reject reports on deactivated zone/site; wrap handler in top-level try-catch so unhandled errors return JSON (not HTML)
- report-form: parse JSON separately so HTTP status code surfaces instead of generic "Something went wrong"

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CPf5Rc8QPx6V8KLEEgfKEQ
This commit is contained in:
2026-07-13 16:05:36 +08:00
co-authored by Claude Sonnet 4.6
parent 370b985375
commit 690485f74e
8 changed files with 307 additions and 30 deletions
+1 -1
View File
@@ -23,7 +23,7 @@ export default async function AdminHome() {
.order('created_at', { ascending: false }),
supabase
.from('sites')
.select('id, name, address, zones (id, name, qr_code_token)')
.select('id, name, address, active, zones (id, name, qr_code_token, active)')
.order('name'),
supabase
.from('trucks')