feat:add checkbox all SPIT
This commit is contained in:
parent
ca1ab00b9a
commit
6504adfcc3
|
|
@ -394,6 +394,33 @@ export default function FormConvertSPIT() {
|
|||
return temp;
|
||||
};
|
||||
|
||||
// const setupPlacement = (
|
||||
// index: number,
|
||||
// category: string,
|
||||
// isChecked: boolean
|
||||
// ) => {
|
||||
// setFilePlacements((prev) =>
|
||||
// prev.map((placement, i) =>
|
||||
// i === index
|
||||
// ? isChecked
|
||||
// ? [...new Set([...placement, category])] // Tambahkan kategori jika belum ada
|
||||
// : placement.filter((item) => item !== category) // Hapus kategori jika ada
|
||||
// : placement
|
||||
// )
|
||||
// );
|
||||
// };
|
||||
|
||||
const handleSelectAll = (category: string, isChecked: boolean) => {
|
||||
setFilePlacements((prev: string[][]) =>
|
||||
prev.map(
|
||||
(placement: string[]) =>
|
||||
isChecked
|
||||
? Array.from(new Set([...placement, category])) // Konversi Set ke array dengan Array.from()
|
||||
: placement.filter((item: string) => item !== category) // Hapus jika ada
|
||||
)
|
||||
);
|
||||
};
|
||||
|
||||
const save = async (data: {
|
||||
contentTitle: string;
|
||||
contentDescription: string;
|
||||
|
|
@ -785,6 +812,66 @@ export default function FormConvertSPIT() {
|
|||
<div className="mt-3">
|
||||
<Label className="text-xl">Penempatan file</Label>
|
||||
</div>
|
||||
{files.length > 1 && (
|
||||
<div className="flex flex-wrap gap-2 mt-2">
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="all-content"
|
||||
onCheckedChange={(e) =>
|
||||
handleSelectAll("all", Boolean(e))
|
||||
}
|
||||
/>
|
||||
<label
|
||||
htmlFor="all-content"
|
||||
className="text-xs font-medium"
|
||||
>
|
||||
All
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="all-nasional"
|
||||
onCheckedChange={(e) =>
|
||||
handleSelectAll("mabes", Boolean(e))
|
||||
}
|
||||
/>
|
||||
<label
|
||||
htmlFor="all-nasional"
|
||||
className="text-xs font-medium"
|
||||
>
|
||||
All Nasional
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="all-wilayah"
|
||||
onCheckedChange={(e) =>
|
||||
handleSelectAll("polda", Boolean(e))
|
||||
}
|
||||
/>
|
||||
<label
|
||||
htmlFor="all-wilayah"
|
||||
className="text-xs font-medium"
|
||||
>
|
||||
All Wilayah
|
||||
</label>
|
||||
</div>
|
||||
<div className="flex items-center space-x-2">
|
||||
<Checkbox
|
||||
id="all-international"
|
||||
onCheckedChange={(e) =>
|
||||
handleSelectAll("international", Boolean(e))
|
||||
}
|
||||
/>
|
||||
<label
|
||||
htmlFor="all-international"
|
||||
className="text-xs font-medium"
|
||||
>
|
||||
All Internasional
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{files?.map((file, index) => (
|
||||
<div
|
||||
key={file.contentId}
|
||||
|
|
|
|||
|
|
@ -150,6 +150,7 @@ export default function FormContestDetail() {
|
|||
mabes: false,
|
||||
polda: false,
|
||||
polres: false,
|
||||
satker: false,
|
||||
});
|
||||
|
||||
const {
|
||||
|
|
@ -231,6 +232,7 @@ export default function FormContestDetail() {
|
|||
mabes: outputSet.has(1),
|
||||
polda: outputSet.has(2),
|
||||
polres: outputSet.has(3),
|
||||
satker: outputSet.has(4),
|
||||
});
|
||||
}
|
||||
}, [detail?.targetOutput]);
|
||||
|
|
@ -265,6 +267,7 @@ export default function FormContestDetail() {
|
|||
mabes: "1",
|
||||
polda: "2",
|
||||
polres: "3",
|
||||
satker: "4",
|
||||
};
|
||||
|
||||
const assignmentPurposeString = Object.keys(unitSelection)
|
||||
|
|
|
|||
Loading…
Reference in New Issue