fix: issue when selecting all phase and employee

This commit is contained in:
ValdiANS
2026-01-30 11:18:39 +07:00
parent de8fda9360
commit 7956ce5b6f
@@ -535,14 +535,6 @@ export function DailyChecklistContent() {
} }
}; };
const toggleSelectAllAbk = () => {
if (tempSelectedEmployees.length === employees.length) {
setTempSelectedEmployees([]);
} else {
setTempSelectedEmployees([...employees]);
}
};
const applyAbkSelection = async () => { const applyAbkSelection = async () => {
if (!dailyChecklistId) { if (!dailyChecklistId) {
toast.error('Checklist belum tersedia'); toast.error('Checklist belum tersedia');
@@ -853,10 +845,34 @@ export function DailyChecklistContent() {
); );
const isAllAbkSelected = 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 = const isAllPhasesSelected =
tempSelectedPhaseIds.length === availablePhases.length && tempSelectedPhaseIds.length === filteredPhases.length &&
availablePhases.length > 0; 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 // Group activities by PHASE → TIME_TYPE → ACTIVITIES
const groupActivitiesByPhase = () => { const groupActivitiesByPhase = () => {
@@ -1519,14 +1535,14 @@ export function DailyChecklistContent() {
setTempSelectedPhaseIds([]); setTempSelectedPhaseIds([]);
} else { } else {
setTempSelectedPhaseIds( setTempSelectedPhaseIds(
availablePhases.map((p) => String(p.id)) filteredPhases.map((p) => String(p.id))
); );
} }
}} }}
className='checkbox-clean' className='checkbox-clean'
/> />
<span className='text-sm font-medium text-gray-700 group-hover:text-gray-900'> <span className='text-sm font-medium text-gray-700 group-hover:text-gray-900'>
Pilih Semua ({availablePhases.length} Fase) Pilih Semua ({filteredPhases.length} Fase)
</span> </span>
</label> </label>
</div> </div>
@@ -1621,7 +1637,7 @@ export function DailyChecklistContent() {
/> />
</div> </div>
{employees.length > 0 && ( {filteredEmployees.length > 0 && (
<div className='flex items-center gap-3 px-1 py-2'> <div className='flex items-center gap-3 px-1 py-2'>
<label className='flex items-center gap-2 cursor-pointer group'> <label className='flex items-center gap-2 cursor-pointer group'>
<input <input
@@ -1631,7 +1647,7 @@ export function DailyChecklistContent() {
className='checkbox-clean' className='checkbox-clean'
/> />
<span className='text-sm font-medium text-gray-700 group-hover:text-gray-900'> <span className='text-sm font-medium text-gray-700 group-hover:text-gray-900'>
Pilih Semua ({employees.length} ABK) Pilih Semua ({filteredEmployees.length} ABK)
</span> </span>
</label> </label>
</div> </div>