// Employees.jsx — Master Data › Employees. Operators & Riggers master records. // Admin: full CRUD + certification editing. Other roles: view-only. // Modal to record/renew an operator's certifications and their expiry dates. function CertEditModal({ operator, onClose, onSave }) { const [rows, setRows] = React.useState(() => { const byCode = Object.fromEntries((operator.certs || []).map(c => [c.code, c.exp])); return CERT_LEGEND.map(l => ({ code: l.code, label: l.label, color: l.color, held: l.code in byCode, exp: byCode[l.code] || '' })); }); const update = (code, patch) => setRows(rs => rs.map(r => r.code === code ? { ...r, ...patch } : r)); const incomplete = rows.some(r => r.held && !r.exp); const save = () => { const certs = rows.filter(r => r.held && r.exp).map(r => ({ code: r.code, exp: r.exp })); onSave(certs); }; return (
| ID | Name | Phone | License | Certifications | Status | |
|---|---|---|---|---|---|---|
| {o.id} | {o.name} | {o.phone} | {o.license} |
{active.length === 0 ? None valid : null}
{active.map(c => {
const exp = certState(c.exp) === 'expiring';
return (
{c.code}
);
})}
{soon > 0 ? · {soon} renew soon : null}
{expired.length > 0 ? c.code + ' expired ' + fmtCertDate(c.exp)).join(', ')} style={{fontSize: 10.5, color: 'var(--color-danger)', fontWeight: 600}}>· {expired.length} expired : null}
|
{o.status} | {isAdmin ? : null} |
| ID | Name | Phone | Cert | Status | |
|---|---|---|---|---|---|
| {r.id} | {r.name} | {r.phone} | {r.cert} | {r.status} | {isAdmin ? : null} |