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') || '' searchParams.get('category') || ''
); );
const [emptyKandang, setEmptyKandang] = useState(false); const [emptyKandang, setEmptyKandang] = useState(false);
const [emptyKandangEndDate, setEmptyKandangEndDate] = useState('');
const isKandangEmpty = selectedCategory === 'empty_kandang'; const isKandangEmpty = selectedCategory === 'empty_kandang';
@@ -239,7 +238,6 @@ export function DailyChecklistContent() {
useEffect(() => { useEffect(() => {
if (!emptyKandang) { if (!emptyKandang) {
setEmptyKandangEndDate('');
setSelectedCategory(''); setSelectedCategory('');
return; return;
} }
@@ -314,16 +312,6 @@ export function DailyChecklistContent() {
return; return;
} }
if (emptyKandang && !emptyKandangEndDate) {
setDailyChecklistId(null);
setChecklistStatus('DRAFT');
setSelectedPhaseIds([]);
setActivitiesByPhase({});
setTaskIdsByPhaseActivityId({});
setAssignments({});
return;
}
try { try {
const checklist = await DailyChecklistApi.create({ const checklist = await DailyChecklistApi.create({
date, date,
@@ -331,7 +319,6 @@ export function DailyChecklistContent() {
category: emptyKandang ? 'empty_kandang' : selectedCategory, category: emptyKandang ? 'empty_kandang' : selectedCategory,
status: 'DRAFT', status: 'DRAFT',
empty_kandang: emptyKandang, empty_kandang: emptyKandang,
empty_kandang_end_date: emptyKandang ? emptyKandangEndDate : '',
}); });
if (isResponseError(checklist)) { if (isResponseError(checklist)) {
@@ -388,7 +375,7 @@ export function DailyChecklistContent() {
}; };
checkAndLoadChecklist(); checkAndLoadChecklist();
}, [date, kandangId, selectedCategory, emptyKandang, emptyKandangEndDate]); }, [date, kandangId, selectedCategory, emptyKandang]);
// Load activities and tasks when phases change // Load activities and tasks when phases change
useEffect(() => { useEffect(() => {
@@ -1176,24 +1163,6 @@ export function DailyChecklistContent() {
/> />
<span>Kandang Kosong</span> <span>Kandang Kosong</span>
</label> </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>
</div> </div>
-2
View File
@@ -13,7 +13,6 @@ export type BaseDailyChecklist = {
category: string; category: string;
date: string; date: string;
empty_kandang?: boolean; empty_kandang?: boolean;
empty_kandang_end_date?: string | null;
kandang?: Pick<BaseKandang, 'id' | 'name' | 'status' | 'capacity'>; kandang?: Pick<BaseKandang, 'id' | 'name' | 'status' | 'capacity'>;
total_phase: number; total_phase: number;
total_activity: number; total_activity: number;
@@ -60,7 +59,6 @@ export type CreateDailyChecklistPayload = {
category: string; category: string;
status: string; status: string;
empty_kandang: boolean; empty_kandang: boolean;
empty_kandang_end_date: string;
}; };
export type PerformanceOverviewItem = { export type PerformanceOverviewItem = {