import { useState, useEffect } from 'react' import Layout from '@/components/layout/Layout' import { Card, EmptyState, Btn, Field, Input, showToast } from '@/components/ui' import { useApp } from '@/lib/context' export default function ShippingStandardPage() { const { user } = useApp() const [items, setItems] = useState([]) const [loading, setLoading] = useState(true) const [newText, setNewText] = useState('') const [adding, setAdding] = useState(false) const canEdit = user && (user.role === 'ADMIN' || user.role === 'QC') useEffect(() => { load() }, []) async function load() { setLoading(true) const res = await fetch('/api/shipping-standard') if (res.ok) { const { data } = await res.json(); setItems(data || []) } setLoading(false) } async function addItem() { if (!newText.trim()) return setAdding(true) const res = await fetch('/api/shipping-standard', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ text: newText, source: 'Baseline' }), }) setAdding(false) if (res.ok) { setNewText('') showToast('Added to shipping standard') load() } else { showToast('Failed to add', 'error') } } return (

Living shipping standard

What must be true before a product ships. Updates automatically when a client-reported quality escape is resolved.

{loading ? (
Loading…
) : items.length === 0 ? ( ) : items.map((item: any, i: number) => (
{i + 1}
{item.text}
Source: {item.source === 'Baseline' ? 'Baseline' : {item.source}} {item.source !== 'Baseline' && <> · {new Date(item.createdAt).toLocaleDateString()}}
))} {canEdit && (
setNewText(e.target.value)} placeholder="Add a baseline check…"/>
{adding ? 'Adding…' : 'Add'}
)}
) }