diff --git a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx index 37430354..b99842bd 100644 --- a/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx +++ b/src/figma-make/components/pages/daily-checklist/DailyChecklistContent.tsx @@ -535,14 +535,6 @@ export function DailyChecklistContent() { } }; - const toggleSelectAllAbk = () => { - if (tempSelectedEmployees.length === employees.length) { - setTempSelectedEmployees([]); - } else { - setTempSelectedEmployees([...employees]); - } - }; - const applyAbkSelection = async () => { if (!dailyChecklistId) { toast.error('Checklist belum tersedia'); @@ -853,10 +845,34 @@ export function DailyChecklistContent() { ); const isAllAbkSelected = - tempSelectedEmployees.length === employees.length && employees.length > 0; + tempSelectedEmployees.length === filteredEmployees.length && + filteredEmployees.length > 0 && + tempSelectedEmployees.every((tempSelectedEmployee) => { + return ( + filteredEmployees.findIndex( + (filteredEmployee) => filteredEmployee.id === tempSelectedEmployee.id + ) >= 0 + ); + }); const isAllPhasesSelected = - tempSelectedPhaseIds.length === availablePhases.length && - availablePhases.length > 0; + tempSelectedPhaseIds.length === filteredPhases.length && + filteredPhases.length > 0 && + tempSelectedPhaseIds.every((tempSelectedPhaseId) => { + return ( + filteredPhases.findIndex( + (filteredPhase) => + String(filteredPhase.id) === String(tempSelectedPhaseId) + ) >= 0 + ); + }); + + const toggleSelectAllAbk = () => { + if (isAllAbkSelected) { + setTempSelectedEmployees([]); + } else { + setTempSelectedEmployees([...filteredEmployees]); + } + }; // Group activities by PHASE → TIME_TYPE → ACTIVITIES const groupActivitiesByPhase = () => { @@ -1519,14 +1535,14 @@ export function DailyChecklistContent() { setTempSelectedPhaseIds([]); } else { setTempSelectedPhaseIds( - availablePhases.map((p) => String(p.id)) + filteredPhases.map((p) => String(p.id)) ); } }} className='checkbox-clean' /> - Pilih Semua ({availablePhases.length} Fase) + Pilih Semua ({filteredPhases.length} Fase) @@ -1621,7 +1637,7 @@ export function DailyChecklistContent() { /> - {employees.length > 0 && ( + {filteredEmployees.length > 0 && (