import { createFileRoute } from "@tanstack/react-router"; import { useEffect, useState } from "react"; import { Card, CardContent } from "@/components/ui/card"; export const Route = createFileRoute("/admin")({ head: () => ({ meta: [ { title: "Admin — Contact Submissions" }, { name: "robots", content: "noindex" }, ], }), component: AdminContactsPage, }); function AdminContactsPage() { const [items, setItems] = useState>([]); async function load() { try { const res = await fetch('/data/contacts'); if (!res.ok) throw new Error('failed to fetch'); const json = await res.json(); setItems(json || []); } catch (err) { console.error(err); // fallback to localStorage try { const key = 'safesight:contact_submissions'; const existing = JSON.parse(localStorage.getItem(key) || '[]'); setItems(existing); } catch (e) { setItems([]); } } } useEffect(() => { load(); }, []); return (

Admin: Contact Submissions

No password required. Anyone with this page URL may view submissions.

Submissions ({items.length})

{items.length === 0 ? ( No submissions yet. ) : ( items.map((it, i) => (

{it.subject}

From: {it.name} — {it.email}

{it.createdAt ? new Date(it.createdAt).toLocaleString() : "—"}
{it.message}
)) )}
); }