refactor(FE): Use projectFlockKandangId for next-day recording

This commit is contained in:
rstubryan
2026-01-21 13:29:35 +07:00
parent fd4b584ccd
commit 507f53ace8
@@ -552,23 +552,17 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
);
const nextDayRecordingUrl = useMemo(() => {
if (!selectedProjectFlock) return null;
const projectFlockId =
typeof selectedProjectFlock.value === 'string'
? parseInt(selectedProjectFlock.value, 10)
: selectedProjectFlock.value;
return `${RecordingApi.basePath}/next-day?project_flock_id=${projectFlockId}`;
}, [selectedProjectFlock]);
if (!projectFlockKandangLookup) return null;
const projectFlockKandangId = projectFlockKandangLookup.id;
return `${RecordingApi.basePath}/next-day?project_flock_kandang_id=${projectFlockKandangId}`;
}, [projectFlockKandangLookup]);
const { data: nextDayRecordingData } = useSWR(
nextDayRecordingUrl,
nextDayRecordingUrl
? () => {
const projectFlockId =
typeof selectedProjectFlock!.value === 'string'
? parseInt(selectedProjectFlock!.value, 10)
: selectedProjectFlock!.value;
return RecordingApi.nextDayRecording(projectFlockId);
const projectFlockKandangId = projectFlockKandangLookup!.id;
return RecordingApi.nextDayRecording(projectFlockKandangId);
}
: null
);