import {friendlyError,resultLabel} from './userLanguage.mjs'; import React,{useState} from 'react'; import {decisionLabel,reviewBody,reviewStatuses,reviewDecisions} from './workflow.mjs'; export default function ReviewForm({current,onSave,disabled=false,demo=false}){ const [status,setStatus]=useState(current?.status||'Needs review'); const [decision,setDecision]=useState(current?.decision||'Pending'); const [note,setNote]=useState(''),[busy,setBusy]=useState(false),[error,setError]=useState(''); return

{demo?'Demo review · this browser only':'Staff review'}

{demo&&

Try recording a review here. It stays with this demo result and is not an official Staff review, Team decision or corrective action.

} {current&&

{current.status} · {decisionLabel(current.decision)} · {current.reviewer} · {new Date(current.created_at).toLocaleString()}{current.note&&<>
{current.note}}

}
{e.preventDefault();setBusy(true);setError('');try{reviewBody(status,decision,note);await onSave({status,decision,note});setNote('')}catch(err){setError(err.message)}finally{setBusy(false)}}}>
setNote(e.target.value)}/>
{error&&

{friendlyError(error)}

}
; }