Initial scaffold: Expo SDK 56, expo-router, expo-sqlite, NativeWind

This commit is contained in:
2026-06-18 16:50:27 +02:00
parent f12febf122
commit 8388f49fd4
24 changed files with 10060 additions and 0 deletions
+45
View File
@@ -0,0 +1,45 @@
import { useState, useCallback } from "react";
import {
getIncidents,
createIncident,
updateIncident,
deleteIncident,
} from "@/lib/db";
import type { Incident, IncidentDraft } from "@/types/incident";
export function useIncidents() {
const [incidents, setIncidents] = useState<Incident[]>([]);
const [loading, setLoading] = useState(false);
const refresh = useCallback(async (limit = 10) => {
setLoading(true);
const data = await getIncidents(limit);
setIncidents(data);
setLoading(false);
}, []);
const add = useCallback(async (draft: IncidentDraft) => {
const created = await createIncident(draft);
setIncidents((prev) => [created, ...prev]);
return created;
}, []);
const update = useCallback(
async (id: string, updates: Partial<IncidentDraft>) => {
await updateIncident(id, updates);
setIncidents((prev) =>
prev.map((inc) =>
inc.id === id ? { ...inc, ...updates, updatedAt: new Date().toISOString() } : inc
)
);
},
[]
);
const remove = useCallback(async (id: string) => {
await deleteIncident(id);
setIncidents((prev) => prev.filter((inc) => inc.id !== id));
}, []);
return { incidents, loading, refresh, add, update, remove };
}