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(() => { const nextDayRecordingUrl = useMemo(() => {
if (!selectedProjectFlock) return null; if (!projectFlockKandangLookup) return null;
const projectFlockId = const projectFlockKandangId = projectFlockKandangLookup.id;
typeof selectedProjectFlock.value === 'string' return `${RecordingApi.basePath}/next-day?project_flock_kandang_id=${projectFlockKandangId}`;
? parseInt(selectedProjectFlock.value, 10) }, [projectFlockKandangLookup]);
: selectedProjectFlock.value;
return `${RecordingApi.basePath}/next-day?project_flock_id=${projectFlockId}`;
}, [selectedProjectFlock]);
const { data: nextDayRecordingData } = useSWR( const { data: nextDayRecordingData } = useSWR(
nextDayRecordingUrl, nextDayRecordingUrl,
nextDayRecordingUrl nextDayRecordingUrl
? () => { ? () => {
const projectFlockId = const projectFlockKandangId = projectFlockKandangLookup!.id;
typeof selectedProjectFlock!.value === 'string' return RecordingApi.nextDayRecording(projectFlockKandangId);
? parseInt(selectedProjectFlock!.value, 10)
: selectedProjectFlock!.value;
return RecordingApi.nextDayRecording(projectFlockId);
} }
: null : null
); );