/* =========================================================== Forja 3D — Catálogo de produtos & Histórico de impressões =========================================================== */ function ProductForm({ initial, filaments, onSave, onClose }) { const [p, setP] = useState(initial || { name: '', filamentId: filaments[0]?.id || null, weightG: 50, printTimeMin: 180, price: '' }); const set = (k, v) => setP((x) => ({ ...x, [k]: v })); const h = Math.floor((p.printTimeMin || 0) / 60), m = (p.printTimeMin || 0) % 60; return ( <> set('name', v)} placeholder="Ex: Vaso geométrico G" />
set('product', e.target.value)} placeholder="Ex: Vaso geométrico G" /> {products.map((x) =>
set('date', e.target.value)} />
Registrar consome a gramagem do estoque do filamento.
); } function History() { const s = useStore(); const [modal, setModal] = useState(false); const [filt, setFilt] = useState('todas'); const list = s.prints.filter((p) => filt === 'todas' || p.status === filt).sort((a, b) => (b.date > a.date ? 1 : -1)); const totG = s.prints.reduce((a, p) => a + p.grams, 0); const totH = s.prints.reduce((a, p) => a + p.timeMin, 0) / 60; const ok = s.prints.filter((p) => p.status === 'sucesso').length; const taxa = s.prints.length ? (ok / s.prints.length) * 100 : 0; return (
setModal(true)}>Registrar impressão} />
{(totG / 1000).toFixed(2).replace('.', ',')} kg} /> {totH.toFixed(0)} h} /> = 90 ? 'g' : 'r'} value={fmt.pct(taxa)} />
{[['todas', 'Todas'], ['sucesso', 'Sucessos'], ['falha', 'Falhas']].map(([v, l]) => )}
{list.length === 0 ? setModal(true)}>Registrar impressão}>Acompanhe cada job da sua impressora. : ( {list.map((p) => { const fil = s.filaments.find((f) => f.id === p.filamentId); return ( ); })}
PeçaFilamentoDataMaterialTempoResultado
{p.product} {fil?.name || '—'} {fmt.dateFull(p.date)} {fmt.num(p.grams)}g {fmt.hm(p.timeMin)} {p.status === 'sucesso' ? Sucesso : Falha} store.removePrint(p.id)} />
)}
setModal(false)} title="Registrar impressão"> setModal(false)} />
); } window.History = History;