Merge pull request 'p4-hotfixes' (#16) from p4-hotfixes into master
Reviewed-on: http://10.2.0.2:3000/jason/cpas/pulls/16
This commit was merged in pull request #16.
This commit is contained in:
@@ -4,24 +4,150 @@ import CpasBadge, { getTier } from './CpasBadge';
|
|||||||
import NegateModal from './NegateModal';
|
import NegateModal from './NegateModal';
|
||||||
|
|
||||||
const s = {
|
const s = {
|
||||||
overlay: { position: 'fixed', inset: 0, background: 'rgba(0,0,0,0.75)', zIndex: 1000, display: 'flex', alignItems: 'flex-start', justifyContent: 'flex-end' },
|
overlay: {
|
||||||
panel: { background: '#111217', color: '#f8f9fa', width: '680px', maxWidth: '95vw', height: '100vh', overflowY: 'auto', boxShadow: '-4px 0 24px rgba(0,0,0,0.7)', display: 'flex', flexDirection: 'column' },
|
position: 'fixed',
|
||||||
header: { background: 'linear-gradient(135deg, #000000, #151622)', color: 'white', padding: '24px 28px', position: 'sticky', top: 0, zIndex: 10, borderBottom: '1px solid #222' },
|
inset: 0,
|
||||||
closeBtn: { float: 'right', background: 'none', border: 'none', color: 'white', fontSize: '22px', cursor: 'pointer', lineHeight: 1, marginTop: '-2px' },
|
background: 'rgba(0,0,0,0.75)',
|
||||||
body: { padding: '24px 28px', flex: 1 },
|
zIndex: 1000,
|
||||||
scoreRow: { display: 'flex', gap: '12px', flexWrap: 'wrap', marginBottom: '24px' },
|
display: 'flex',
|
||||||
scoreCard: { flex: '1', minWidth: '100px', background: '#181924', borderRadius: '8px', padding: '14px', textAlign: 'center', border: '1px solid #2a2b3a' },
|
alignItems: 'flex-start',
|
||||||
scoreNum: { fontSize: '26px', fontWeight: 800 },
|
justifyContent: 'flex-end',
|
||||||
scoreLbl: { fontSize: '11px', color: '#b5b5c0', marginTop: '3px' },
|
},
|
||||||
sectionHd: { fontSize: '13px', fontWeight: 700, color: '#f8f9fa', textTransform: 'uppercase', letterSpacing: '0.5px', marginBottom: '10px', marginTop: '24px' },
|
panel: {
|
||||||
table: { width: '100%', borderCollapse: 'collapse', fontSize: '12px', background: '#181924', borderRadius: '6px', overflow: 'hidden', border: '1px solid #2a2b3a' },
|
background: '#111217',
|
||||||
th: { background: '#050608', padding: '8px 10px', textAlign: 'left', color: '#f8f9fa', fontWeight: 600, fontSize: '11px', textTransform: 'uppercase' },
|
color: '#f8f9fa',
|
||||||
td: { padding: '9px 10px', borderBottom: '1px solid #202231', verticalAlign: 'top', color: '#f8f9fa' },
|
width: '680px',
|
||||||
negatedRow: { background: '#151622', color: '#9ca0b8' },
|
maxWidth: '95vw',
|
||||||
actionBtn: (color) => ({ background: 'none', border: `1px solid ${color}`, color, borderRadius: '4px', padding: '3px 8px', fontSize: '11px', cursor: 'pointer', marginRight: '4px', fontWeight: 600 }),
|
height: '100vh',
|
||||||
resTag: { display: 'inline-block', padding: '2px 8px', borderRadius: '10px', fontSize: '10px', fontWeight: 700, background: '#053321', color: '#9ef7c1', border: '1px solid #0f5132' },
|
overflowY: 'auto',
|
||||||
pdfBtn: { background: 'none', border: '1px solid #d4af37', color: '#ffd666', borderRadius: '4px', padding: '3px 8px', fontSize: '11px', cursor: 'pointer', fontWeight: 600 },
|
boxShadow: '-4px 0 24px rgba(0,0,0,0.7)',
|
||||||
deleteConfirm: { background: '#3c1114', border: '1px solid #f5c6cb', borderRadius: '6px', padding: '12px', marginTop: '8px', fontSize: '12px', color: '#ffb3b8' },
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
},
|
||||||
|
header: {
|
||||||
|
background: 'linear-gradient(135deg, #000000, #151622)',
|
||||||
|
color: 'white',
|
||||||
|
padding: '24px 28px',
|
||||||
|
position: 'sticky',
|
||||||
|
top: 0,
|
||||||
|
zIndex: 10,
|
||||||
|
borderBottom: '1px solid #222',
|
||||||
|
},
|
||||||
|
closeBtn: {
|
||||||
|
float: 'right',
|
||||||
|
background: 'none',
|
||||||
|
border: 'none',
|
||||||
|
color: 'white',
|
||||||
|
fontSize: '22px',
|
||||||
|
cursor: 'pointer',
|
||||||
|
lineHeight: 1,
|
||||||
|
marginTop: '-2px',
|
||||||
|
},
|
||||||
|
body: {
|
||||||
|
padding: '24px 28px',
|
||||||
|
flex: 1,
|
||||||
|
},
|
||||||
|
scoreRow: {
|
||||||
|
display: 'flex',
|
||||||
|
gap: '12px',
|
||||||
|
flexWrap: 'wrap',
|
||||||
|
marginBottom: '24px',
|
||||||
|
},
|
||||||
|
scoreCard: {
|
||||||
|
flex: '1',
|
||||||
|
minWidth: '100px',
|
||||||
|
background: '#181924',
|
||||||
|
borderRadius: '8px',
|
||||||
|
padding: '14px',
|
||||||
|
textAlign: 'center',
|
||||||
|
border: '1px solid #2a2b3a',
|
||||||
|
},
|
||||||
|
scoreNum: {
|
||||||
|
fontSize: '26px',
|
||||||
|
fontWeight: 800,
|
||||||
|
},
|
||||||
|
scoreLbl: {
|
||||||
|
fontSize: '11px',
|
||||||
|
color: '#b5b5c0',
|
||||||
|
marginTop: '3px',
|
||||||
|
},
|
||||||
|
sectionHd: {
|
||||||
|
fontSize: '13px',
|
||||||
|
fontWeight: 700,
|
||||||
|
color: '#f8f9fa',
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
letterSpacing: '0.5px',
|
||||||
|
marginBottom: '10px',
|
||||||
|
marginTop: '24px',
|
||||||
|
},
|
||||||
|
table: {
|
||||||
|
width: '100%',
|
||||||
|
borderCollapse: 'collapse',
|
||||||
|
fontSize: '12px',
|
||||||
|
background: '#181924',
|
||||||
|
borderRadius: '6px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
border: '1px solid #2a2b3a',
|
||||||
|
},
|
||||||
|
th: {
|
||||||
|
background: '#050608',
|
||||||
|
padding: '8px 10px',
|
||||||
|
textAlign: 'left',
|
||||||
|
color: '#f8f9fa',
|
||||||
|
fontWeight: 600,
|
||||||
|
fontSize: '11px',
|
||||||
|
textTransform: 'uppercase',
|
||||||
|
},
|
||||||
|
td: {
|
||||||
|
padding: '9px 10px',
|
||||||
|
borderBottom: '1px solid #202231',
|
||||||
|
verticalAlign: 'top',
|
||||||
|
color: '#f8f9fa',
|
||||||
|
},
|
||||||
|
negatedRow: {
|
||||||
|
background: '#151622',
|
||||||
|
color: '#9ca0b8',
|
||||||
|
},
|
||||||
|
actionBtn: (color) => ({
|
||||||
|
background: 'none',
|
||||||
|
border: `1px solid ${color}`,
|
||||||
|
color,
|
||||||
|
borderRadius: '4px',
|
||||||
|
padding: '3px 8px',
|
||||||
|
fontSize: '11px',
|
||||||
|
cursor: 'pointer',
|
||||||
|
marginRight: '4px',
|
||||||
|
fontWeight: 600,
|
||||||
|
}),
|
||||||
|
resTag: {
|
||||||
|
display: 'inline-block',
|
||||||
|
padding: '2px 8px',
|
||||||
|
borderRadius: '10px',
|
||||||
|
fontSize: '10px',
|
||||||
|
fontWeight: 700,
|
||||||
|
background: '#053321',
|
||||||
|
color: '#9ef7c1',
|
||||||
|
border: '1px solid #0f5132',
|
||||||
|
},
|
||||||
|
pdfBtn: {
|
||||||
|
background: 'none',
|
||||||
|
border: '1px solid #d4af37',
|
||||||
|
color: '#ffd666',
|
||||||
|
borderRadius: '4px',
|
||||||
|
padding: '3px 8px',
|
||||||
|
fontSize: '11px',
|
||||||
|
cursor: 'pointer',
|
||||||
|
fontWeight: 600,
|
||||||
|
},
|
||||||
|
deleteConfirm: {
|
||||||
|
background: '#3c1114',
|
||||||
|
border: '1px solid #f5c6cb',
|
||||||
|
borderRadius: '6px',
|
||||||
|
padding: '12px',
|
||||||
|
marginTop: '8px',
|
||||||
|
fontSize: '12px',
|
||||||
|
color: '#ffb3b8',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function EmployeeModal({ employeeId, onClose }) {
|
export default function EmployeeModal({ employeeId, onClose }) {
|
||||||
@@ -38,19 +164,27 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
|||||||
axios.get('/api/employees'),
|
axios.get('/api/employees'),
|
||||||
axios.get(`/api/employees/${employeeId}/score`),
|
axios.get(`/api/employees/${employeeId}/score`),
|
||||||
axios.get(`/api/violations/employee/${employeeId}?limit=100`),
|
axios.get(`/api/violations/employee/${employeeId}?limit=100`),
|
||||||
]).then(([empRes, scoreRes, violRes]) => {
|
])
|
||||||
const emp = empRes.data.find(e => e.id === employeeId);
|
.then(([empRes, scoreRes, violRes]) => {
|
||||||
|
const emp = empRes.data.find((e) => e.id === employeeId);
|
||||||
setEmployee(emp || null);
|
setEmployee(emp || null);
|
||||||
setScore(scoreRes.data);
|
setScore(scoreRes.data);
|
||||||
setViolations(violRes.data);
|
setViolations(violRes.data);
|
||||||
}).finally(() => setLoading(false));
|
})
|
||||||
|
.finally(() => setLoading(false));
|
||||||
}, [employeeId]);
|
}, [employeeId]);
|
||||||
|
|
||||||
useEffect(() => { load(); }, [load]);
|
useEffect(() => {
|
||||||
|
load();
|
||||||
|
}, [load]);
|
||||||
|
|
||||||
const handleDownloadPdf = async (violId, empName, date) => {
|
const handleDownloadPdf = async (violId, empName, date) => {
|
||||||
const response = await axios.get(`/api/violations/${violId}/pdf`, { responseType: 'blob' });
|
const response = await axios.get(`/api/violations/${violId}/pdf`, {
|
||||||
const url = window.URL.createObjectURL(new Blob([response.data], { type: 'application/pdf' }));
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
const url = window.URL.createObjectURL(
|
||||||
|
new Blob([response.data], { type: 'application/pdf' }),
|
||||||
|
);
|
||||||
const link = document.createElement('a');
|
const link = document.createElement('a');
|
||||||
link.href = url;
|
link.href = url;
|
||||||
link.download = `CPAS_${(empName || '').replace(/[^a-z0-9]/gi, '_')}_${date}.pdf`;
|
link.download = `CPAS_${(empName || '').replace(/[^a-z0-9]/gi, '_')}_${date}.pdf`;
|
||||||
@@ -84,32 +218,60 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const tier = score ? getTier(score.active_points) : null;
|
const tier = score ? getTier(score.active_points) : null;
|
||||||
const active = violations.filter(v => !v.negated);
|
const active = violations.filter((v) => !v.negated);
|
||||||
const negated = violations.filter(v => v.negated);
|
const negated = violations.filter((v) => v.negated);
|
||||||
|
|
||||||
|
const handleOverlayClick = (e) => {
|
||||||
|
if (e.target === e.currentTarget) onClose();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={s.overlay} onClick={e => { if (e.target === e.currentTarget) onClose(); }}>
|
<div style={s.overlay} onClick={handleOverlayClick}>
|
||||||
<div style={s.panel}>
|
<div style={s.panel}>
|
||||||
<div style={s.header}>
|
<div style={s.header}>
|
||||||
<button style={s.closeBtn} onClick={onClose}>✕</button>
|
<button style={s.closeBtn} onClick={onClose}>
|
||||||
|
✕
|
||||||
|
</button>
|
||||||
<div style={{ fontSize: '20px', fontWeight: 700 }}>
|
<div style={{ fontSize: '20px', fontWeight: 700 }}>
|
||||||
{loading ? 'Loading…' : (employee?.name || 'Employee Profile')}
|
{loading ? 'Loading…' : employee?.name || 'Employee Profile'}
|
||||||
</div>
|
</div>
|
||||||
{employee && (
|
{employee && (
|
||||||
<div style={{ fontSize: '12px', opacity: 0.8, marginTop: '4px' }}>
|
<div style={{ fontSize: '12px', opacity: 0.8, marginTop: '4px' }}>
|
||||||
{[employee.department, employee.supervisor ? `Supervisor: ${employee.supervisor}` : null].filter(Boolean).join(' · ')}
|
{[employee.department, employee.supervisor ? `Supervisor: ${employee.supervisor}` : null]
|
||||||
|
.filter(Boolean)
|
||||||
|
.join(' · ')}
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={s.body}>
|
<div style={s.body}>
|
||||||
{loading ? (
|
{loading ? (
|
||||||
<p style={{ color: '#77798a', textAlign: 'center', paddingTop: '40px' }}>Loading…</p>
|
<p
|
||||||
) : (<>
|
style={{
|
||||||
|
color: '#77798a',
|
||||||
|
textAlign: 'center',
|
||||||
|
paddingTop: '40px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Loading…
|
||||||
|
</p>
|
||||||
|
) : (
|
||||||
|
<>
|
||||||
<div style={s.scoreRow}>
|
<div style={s.scoreRow}>
|
||||||
<div style={{ ...s.scoreCard, borderTop: `3px solid ${tier?.color}` }}>
|
<div
|
||||||
<div style={{ ...s.scoreNum, color: tier?.color }}>{score?.active_points ?? 0}</div>
|
style={{
|
||||||
|
...s.scoreCard,
|
||||||
|
borderTop: `3px solid ${tier?.color}`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
...s.scoreNum,
|
||||||
|
color: tier?.color,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{score?.active_points ?? 0}
|
||||||
|
</div>
|
||||||
<div style={s.scoreLbl}>Active Points</div>
|
<div style={s.scoreLbl}>Active Points</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={s.scoreCard}>
|
<div style={s.scoreCard}>
|
||||||
@@ -121,21 +283,53 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
|||||||
<div style={s.scoreLbl}>Total On Record</div>
|
<div style={s.scoreLbl}>Total On Record</div>
|
||||||
</div>
|
</div>
|
||||||
<div style={s.scoreCard}>
|
<div style={s.scoreCard}>
|
||||||
<div style={{ ...s.scoreNum, color: '#ffd666' }}>{negated.length}</div>
|
<div
|
||||||
|
style={{
|
||||||
|
...s.scoreNum,
|
||||||
|
color: '#ffd666',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{negated.length}
|
||||||
|
</div>
|
||||||
<div style={s.scoreLbl}>Negated</div>
|
<div style={s.scoreLbl}>Negated</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{tier && (
|
{tier && (
|
||||||
<div style={{ background: '#181924', borderRadius: '6px', padding: '10px 14px', marginBottom: '16px', fontSize: '13px', border: `1px solid ${tier.color}33` }}>
|
<div
|
||||||
|
style={{
|
||||||
|
background: '#181924',
|
||||||
|
borderRadius: '6px',
|
||||||
|
padding: '10px 14px',
|
||||||
|
marginBottom: '16px',
|
||||||
|
fontSize: '13px',
|
||||||
|
border: `1px solid ${tier.color}33`,
|
||||||
|
}}
|
||||||
|
>
|
||||||
<strong style={{ color: tier.color }}>{tier.label}</strong>
|
<strong style={{ color: tier.color }}>{tier.label}</strong>
|
||||||
<span style={{ color: '#b5b5c0', marginLeft: '10px', fontSize: '12px' }}>Rolling 90-day window · Points expire automatically</span>
|
<span
|
||||||
|
style={{
|
||||||
|
color: '#b5b5c0',
|
||||||
|
marginLeft: '10px',
|
||||||
|
fontSize: '12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Rolling 90-day window · Points expire automatically
|
||||||
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div style={s.sectionHd}>Active Violations</div>
|
<div style={s.sectionHd}>Active Violations</div>
|
||||||
{active.length === 0 ? (
|
{active.length === 0 ? (
|
||||||
<p style={{ color: '#77798a', fontSize: '13px', fontStyle: 'italic' }}>No active violations on record.</p>
|
<p
|
||||||
|
style={{
|
||||||
|
color: '#77798a',
|
||||||
|
fontSize: '13px',
|
||||||
|
fontStyle: 'italic',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
No active violations on record.
|
||||||
|
</p>
|
||||||
) : (
|
) : (
|
||||||
<table style={s.table}>
|
<table style={s.table}>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -147,29 +341,96 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{active.map(v => (
|
{active.map((v) => (
|
||||||
<tr key={v.id}>
|
<tr key={v.id}>
|
||||||
<td style={s.td}>{v.incident_date}</td>
|
<td style={s.td}>{v.incident_date}</td>
|
||||||
<td style={s.td}>
|
<td style={s.td}>
|
||||||
<div style={{ fontWeight: 600 }}>{v.violation_name}</div>
|
<div style={{ fontWeight: 600 }}>{v.violation_name}</div>
|
||||||
<div style={{ color: '#b5b5c0', fontSize: '11px' }}>{v.category}</div>
|
<div
|
||||||
{v.details && <div style={{ color: '#d1d3e0', fontSize: '11px', marginTop: '3px', fontStyle: 'italic' }}>{v.details}</div>}
|
style={{
|
||||||
|
color: '#b5b5c0',
|
||||||
|
fontSize: '11px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{v.category}
|
||||||
|
</div>
|
||||||
|
{v.details && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
color: '#d1d3e0',
|
||||||
|
fontSize: '11px',
|
||||||
|
marginTop: '3px',
|
||||||
|
fontStyle: 'italic',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{v.details}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
style={{
|
||||||
|
...s.td,
|
||||||
|
fontWeight: 700,
|
||||||
|
color: '#ff8a80',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{v.points}
|
||||||
</td>
|
</td>
|
||||||
<td style={{ ...s.td, fontWeight: 700, color: '#ff8a80' }}>{v.points}</td>
|
|
||||||
<td style={s.td}>
|
<td style={s.td}>
|
||||||
<button style={s.actionBtn('#ffd666')} onClick={() => setNegating(v)}>⊘ Negate</button>
|
<button
|
||||||
<button style={s.pdfBtn} onClick={() => handleDownloadPdf(v.id, employee?.name, v.incident_date)}>PDF</button>
|
style={s.actionBtn('#ffd666')}
|
||||||
|
onClick={() => setNegating(v)}
|
||||||
|
>
|
||||||
|
⊘ Negate
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
style={s.pdfBtn}
|
||||||
|
onClick={() =>
|
||||||
|
handleDownloadPdf(
|
||||||
|
v.id,
|
||||||
|
employee?.name,
|
||||||
|
v.incident_date,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
>
|
||||||
|
PDF
|
||||||
|
</button>
|
||||||
<br />
|
<br />
|
||||||
{confirmDel === v.id ? (
|
{confirmDel === v.id ? (
|
||||||
<div style={s.deleteConfirm}>
|
<div style={s.deleteConfirm}>
|
||||||
<strong>Permanently delete?</strong> This cannot be undone.
|
<strong>Permanently delete?</strong> This cannot be
|
||||||
<div style={{ marginTop: '8px', display: 'flex', gap: '8px' }}>
|
undone.
|
||||||
<button style={s.actionBtn('#ffb3b8')} onClick={() => handleHardDelete(v.id)}>Confirm Delete</button>
|
<div
|
||||||
<button style={s.actionBtn('#9ca0b8')} onClick={() => setConfirmDel(null)}>Cancel</button>
|
style={{
|
||||||
|
marginTop: '8px',
|
||||||
|
display: 'flex',
|
||||||
|
gap: '8px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
style={s.actionBtn('#ffb3b8')}
|
||||||
|
onClick={() => handleHardDelete(v.id)}
|
||||||
|
>
|
||||||
|
Confirm Delete
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
style={s.actionBtn('#9ca0b8')}
|
||||||
|
onClick={() => setConfirmDel(null)}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button style={{ ...s.actionBtn('#c0392b'), marginTop: '4px' }} onClick={() => setConfirmDel(v.id)}>✕ Delete</button>
|
<button
|
||||||
|
style={{
|
||||||
|
...s.actionBtn('#c0392b'),
|
||||||
|
marginTop: '4px',
|
||||||
|
}}
|
||||||
|
onClick={() => setConfirmDel(v.id)}
|
||||||
|
>
|
||||||
|
✕ Delete
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -178,7 +439,8 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
|||||||
</table>
|
</table>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
{negated.length > 0 && (<>
|
{negated.length > 0 && (
|
||||||
|
<>
|
||||||
<div style={s.sectionHd}>Negated / Resolved Violations</div>
|
<div style={s.sectionHd}>Negated / Resolved Violations</div>
|
||||||
<table style={s.table}>
|
<table style={s.table}>
|
||||||
<thead>
|
<thead>
|
||||||
@@ -191,40 +453,103 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{negated.map(v => (
|
{negated.map((v) => (
|
||||||
<tr key={v.id} style={s.negatedRow}>
|
<tr key={v.id} style={s.negatedRow}>
|
||||||
<td style={s.td}>{v.incident_date}</td>
|
<td style={s.td}>{v.incident_date}</td>
|
||||||
<td style={s.td}>
|
<td style={s.td}>
|
||||||
<div style={{ textDecoration: 'line-through' }}>{v.violation_name}</div>
|
<div style={{ textDecoration: 'line-through' }}>
|
||||||
<div style={{ fontSize: '11px', color: '#9ca0b8' }}>{v.category}</div>
|
{v.violation_name}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
fontSize: '11px',
|
||||||
|
color: '#9ca0b8',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{v.category}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
<td
|
||||||
|
style={{
|
||||||
|
...s.td,
|
||||||
|
textDecoration: 'line-through',
|
||||||
|
color: '#9ca0b8',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{v.points}
|
||||||
</td>
|
</td>
|
||||||
<td style={{ ...s.td, textDecoration: 'line-through', color: '#9ca0b8' }}>{v.points}</td>
|
|
||||||
<td style={s.td}>
|
<td style={s.td}>
|
||||||
<span style={s.resTag}>{v.resolution_type}</span>
|
<span style={s.resTag}>{v.resolution_type}</span>
|
||||||
{v.resolution_details && <div style={{ fontSize: '11px', marginTop: '3px', color: '#d1d3e0' }}>{v.resolution_details}</div>}
|
{v.resolution_details && (
|
||||||
{v.resolved_by && <div style={{ fontSize: '10px', color: '#9ca0b8' }}>by {v.resolved_by}</div>}
|
<div
|
||||||
|
style={{
|
||||||
|
fontSize: '11px',
|
||||||
|
marginTop: '3px',
|
||||||
|
color: '#d1d3e0',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{v.resolution_details}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{v.resolved_by && (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
fontSize: '10px',
|
||||||
|
color: '#9ca0b8',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
by {v.resolved_by}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</td>
|
</td>
|
||||||
<td style={s.td}>
|
<td style={s.td}>
|
||||||
<button style={s.actionBtn('#9ef7c1')} onClick={() => handleRestore(v.id)}>↩ Restore</button>
|
<button
|
||||||
|
style={s.actionBtn('#9ef7c1')}
|
||||||
|
onClick={() => handleRestore(v.id)}
|
||||||
|
>
|
||||||
|
↩ Restore
|
||||||
|
</button>
|
||||||
{confirmDel === v.id ? (
|
{confirmDel === v.id ? (
|
||||||
<div style={s.deleteConfirm}>
|
<div style={s.deleteConfirm}>
|
||||||
<strong>Permanently delete?</strong>
|
<strong>Permanently delete?</strong>
|
||||||
<div style={{ marginTop: '8px', display: 'flex', gap: '8px' }}>
|
<div
|
||||||
<button style={s.actionBtn('#ffb3b8')} onClick={() => handleHardDelete(v.id)}>Confirm</button>
|
style={{
|
||||||
<button style={s.actionBtn('#9ca0b8')} onClick={() => setConfirmDel(null)}>Cancel</button>
|
marginTop: '8px',
|
||||||
|
display: 'flex',
|
||||||
|
gap: '8px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<button
|
||||||
|
style={s.actionBtn('#ffb3b8')}
|
||||||
|
onClick={() => handleHardDelete(v.id)}
|
||||||
|
>
|
||||||
|
Confirm
|
||||||
|
</button>
|
||||||
|
<button
|
||||||
|
style={s.actionBtn('#9ca0b8')}
|
||||||
|
onClick={() => setConfirmDel(null)}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<button style={s.actionBtn('#c0392b')} onClick={() => setConfirmDel(v.id)}>✕ Delete</button>
|
<button
|
||||||
|
style={s.actionBtn('#c0392b')}
|
||||||
|
onClick={() => setConfirmDel(v.id)}
|
||||||
|
>
|
||||||
|
✕ Delete
|
||||||
|
</button>
|
||||||
)}
|
)}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</>)}
|
</>
|
||||||
|
)}
|
||||||
</>)}
|
</>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const s = {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
zIndex: 1100,
|
zIndex: 2000,
|
||||||
},
|
},
|
||||||
modal: {
|
modal: {
|
||||||
width: '480px',
|
width: '480px',
|
||||||
@@ -115,6 +115,7 @@ export default function NegateModal({ violation, onConfirm, onCancel }) {
|
|||||||
if (!violation) return null;
|
if (!violation) return null;
|
||||||
|
|
||||||
const handleConfirm = () => {
|
const handleConfirm = () => {
|
||||||
|
if (!onConfirm) return;
|
||||||
onConfirm({
|
onConfirm({
|
||||||
resolution_type: resolutionType,
|
resolution_type: resolutionType,
|
||||||
details,
|
details,
|
||||||
@@ -122,8 +123,12 @@ export default function NegateModal({ violation, onConfirm, onCancel }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleOverlayClick = (e) => {
|
||||||
|
if (e.target === e.currentTarget && onCancel) onCancel();
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={s.overlay} onClick={e => { if (e.target === e.currentTarget) onCancel(); }}>
|
<div style={s.overlay} onClick={handleOverlayClick}>
|
||||||
<div style={s.modal}>
|
<div style={s.modal}>
|
||||||
<div style={s.header}>
|
<div style={s.header}>
|
||||||
<div style={s.title}>⊘ Negate Violation Points</div>
|
<div style={s.title}>⊘ Negate Violation Points</div>
|
||||||
@@ -173,10 +178,18 @@ export default function NegateModal({ violation, onConfirm, onCancel }) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div style={s.footer}>
|
<div style={s.footer}>
|
||||||
<button type="button" style={s.btnCancel} onClick={onCancel}>
|
<button
|
||||||
|
type="button"
|
||||||
|
style={s.btnCancel}
|
||||||
|
onClick={() => onCancel && onCancel()}
|
||||||
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</button>
|
</button>
|
||||||
<button type="button" style={s.btnConfirm} onClick={handleConfirm}>
|
<button
|
||||||
|
type="button"
|
||||||
|
style={s.btnConfirm}
|
||||||
|
onClick={handleConfirm}
|
||||||
|
>
|
||||||
Confirm Negation
|
Confirm Negation
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user