update : selection box user levels

This commit is contained in:
hanif salafi 2025-08-19 08:01:20 +07:00
parent c12dbf1596
commit 78239c5f9d
1 changed files with 13 additions and 3 deletions

View File

@ -310,8 +310,18 @@ export default function FormContestDetail() {
const handleCheckboxChange = (levelId: number) => {
setCheckedLevels((prev) => {
const updatedLevels = new Set(prev);
if (updatedLevels.has(levelId)) {
const isCurrentlyChecked = updatedLevels.has(levelId);
if (isCurrentlyChecked) {
updatedLevels.delete(levelId);
// Jika ini adalah POLDA yang di-unchecklist, unchecklist juga semua polres di bawahnya
const poldaItem = listDest.find((item: any) => item.id === levelId);
if (poldaItem && poldaItem.subDestination) {
poldaItem.subDestination.forEach((polres: any) => {
updatedLevels.delete(polres.id);
});
}
} else {
updatedLevels.add(levelId);
}
@ -840,7 +850,7 @@ export default function FormContestDetail() {
}}
/>
<Label htmlFor={key}>
{key.charAt(0).toUpperCase() + key.slice(1)}
{key === "allUnit" ? "Semua Unit" : key.charAt(0).toUpperCase() + key.slice(1)}
</Label>
</div>
))}
@ -897,7 +907,7 @@ export default function FormContestDetail() {
}}
/>
<Label htmlFor={key}>
{key.charAt(0).toUpperCase() + key.slice(1)}
{key === "allUnit" ? "Semua Unit" : key.charAt(0).toUpperCase() + key.slice(1)}
</Label>
</div>
))}