fix: remove empty kandang date

This commit is contained in:
ValdiANS
2026-04-30 11:02:09 +07:00
parent a54dd1fa9e
commit ef9009b304
2 changed files with 1 additions and 34 deletions
@@ -103,7 +103,6 @@ export function DailyChecklistContent() {
searchParams.get('category') || ''
);
const [emptyKandang, setEmptyKandang] = useState(false);
const [emptyKandangEndDate, setEmptyKandangEndDate] = useState('');
const isKandangEmpty = selectedCategory === 'empty_kandang';
@@ -239,7 +238,6 @@ export function DailyChecklistContent() {
useEffect(() => {
if (!emptyKandang) {
setEmptyKandangEndDate('');
setSelectedCategory('');
return;
}
@@ -314,16 +312,6 @@ export function DailyChecklistContent() {
return;
}
if (emptyKandang && !emptyKandangEndDate) {
setDailyChecklistId(null);
setChecklistStatus('DRAFT');
setSelectedPhaseIds([]);
setActivitiesByPhase({});
setTaskIdsByPhaseActivityId({});
setAssignments({});
return;
}
try {
const checklist = await DailyChecklistApi.create({
date,
@@ -331,7 +319,6 @@ export function DailyChecklistContent() {
category: emptyKandang ? 'empty_kandang' : selectedCategory,
status: 'DRAFT',
empty_kandang: emptyKandang,
empty_kandang_end_date: emptyKandang ? emptyKandangEndDate : '',
});
if (isResponseError(checklist)) {
@@ -388,7 +375,7 @@ export function DailyChecklistContent() {
};
checkAndLoadChecklist();
}, [date, kandangId, selectedCategory, emptyKandang, emptyKandangEndDate]);
}, [date, kandangId, selectedCategory, emptyKandang]);
// Load activities and tasks when phases change
useEffect(() => {
@@ -1176,24 +1163,6 @@ export function DailyChecklistContent() {
/>
<span>Kandang Kosong</span>
</label>
{emptyKandang && (
<div className='w-full md:max-w-md'>
<Label htmlFor='empty_kandang_end_date'>
Tanggal Akhir Kandang Kosong{' '}
<span className='text-red-500'>*</span>
</Label>
<div className='mt-1.5'>
<DatePicker
date={emptyKandangEndDate}
onDateChange={setEmptyKandangEndDate}
disabled={!isChecklistStatusDraft}
placeholder='Pilih tanggal akhir kandang kosong'
formatDisplay={formatDateForDisplay}
/>
</div>
</div>
)}
</div>
</div>