Hotfixes
This commit is contained in:
@@ -24,20 +24,13 @@ const s = {
|
||||
deleteConfirm: { background: '#f8d7da', border: '1px solid #f5c6cb', borderRadius: '6px', padding: '12px', marginTop: '8px', fontSize: '12px' },
|
||||
};
|
||||
|
||||
const RESOLUTION_TYPES = [
|
||||
'Corrective Training Completed',
|
||||
'Management Discretion',
|
||||
'Data Entry Error',
|
||||
'Successfully Appealed',
|
||||
];
|
||||
|
||||
export default function EmployeeModal({ employeeId, onClose }) {
|
||||
const [employee, setEmployee] = useState(null);
|
||||
const [score, setScore] = useState(null);
|
||||
const [violations, setViolations] = useState([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [negating, setNegating] = useState(null); // violation object being soft-negated
|
||||
const [confirmDel, setConfirmDel] = useState(null); // violation id pending hard delete
|
||||
const [negating, setNegating] = useState(null);
|
||||
const [confirmDel, setConfirmDel] = useState(null);
|
||||
|
||||
const load = useCallback(() => {
|
||||
setLoading(true);
|
||||
@@ -70,12 +63,18 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
||||
const handleHardDelete = async (id) => {
|
||||
await axios.delete(`/api/violations/${id}`);
|
||||
setConfirmDel(null);
|
||||
load();
|
||||
load(); // ← refetch employee list, score, and violations
|
||||
};
|
||||
|
||||
const handleRestore = async (id) => {
|
||||
await axios.patch(`/api/violations/${id}/restore`);
|
||||
load();
|
||||
load(); // ← refetch employee list, score, and violations
|
||||
};
|
||||
|
||||
const handleNegate = async ({ resolution_type, details, resolved_by }) => {
|
||||
await axios.patch(`/api/violations/${negating.id}/negate`, { resolution_type, details, resolved_by });
|
||||
setNegating(null);
|
||||
load(); // ← CRITICAL FIX: refetch score immediately after negation
|
||||
};
|
||||
|
||||
const tier = score ? getTier(score.active_points) : null;
|
||||
@@ -232,11 +231,7 @@ export default function EmployeeModal({ employeeId, onClose }) {
|
||||
{negating && (
|
||||
<NegateModal
|
||||
violation={negating}
|
||||
onConfirm={async ({ resolution_type, details, resolved_by }) => {
|
||||
await axios.patch(`/api/violations/${negating.id}/negate`, { resolution_type, details, resolved_by });
|
||||
setNegating(null);
|
||||
load();
|
||||
}}
|
||||
onConfirm={handleNegate}
|
||||
onCancel={() => setNegating(null)}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user