mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-25 15:55:48 +00:00
refactor(FE): Handle missing selectedRecordDate and next-day data
This commit is contained in:
@@ -554,6 +554,7 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
|
|
||||||
const nextDayRecordingUrl = useMemo(() => {
|
const nextDayRecordingUrl = useMemo(() => {
|
||||||
if (!projectFlockKandangLookup) return null;
|
if (!projectFlockKandangLookup) return null;
|
||||||
|
if (!selectedRecordDate) return null;
|
||||||
const projectFlockKandangId = projectFlockKandangLookup.id;
|
const projectFlockKandangId = projectFlockKandangLookup.id;
|
||||||
return `${RecordingApi.basePath}/next-day?project_flock_kandang_id=${projectFlockKandangId}&record_date=${selectedRecordDate}`;
|
return `${RecordingApi.basePath}/next-day?project_flock_kandang_id=${projectFlockKandangId}&record_date=${selectedRecordDate}`;
|
||||||
}, [projectFlockKandangLookup, selectedRecordDate]);
|
}, [projectFlockKandangLookup, selectedRecordDate]);
|
||||||
@@ -583,7 +584,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
} else if (nextDayRecordingData?.status === 'error') {
|
} else if (nextDayRecordingData?.status === 'error') {
|
||||||
setNextDayRecording(null);
|
setNextDayRecording(null);
|
||||||
if (!nextDayErrorShown) {
|
if (!nextDayErrorShown) {
|
||||||
toast.error(nextDayRecordingData.message || 'Terjadi kesalahan saat memuat data hari berikutnya', { duration: Infinity });
|
toast.error(
|
||||||
|
nextDayRecordingData.message ||
|
||||||
|
'Terjadi kesalahan saat memuat data hari berikutnya',
|
||||||
|
{ duration: Infinity }
|
||||||
|
);
|
||||||
setNextDayErrorShown(true);
|
setNextDayErrorShown(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1900,8 +1905,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
|||||||
<div>
|
<div>
|
||||||
<span className='text-sm text-gray-600'>Umur</span>
|
<span className='text-sm text-gray-600'>Umur</span>
|
||||||
<p className='font-semibold'>
|
<p className='font-semibold'>
|
||||||
{nextDayRecording
|
{type === 'add'
|
||||||
? `Hari ke-${nextDayRecording.next_day} (Minggu ke-${Math.ceil(nextDayRecording.next_day / 7)})`
|
? nextDayRecording
|
||||||
|
? `Hari ke-${nextDayRecording.next_day} (Minggu ke-${Math.ceil(nextDayRecording.next_day / 7)})`
|
||||||
|
: '-'
|
||||||
: initialValues?.day
|
: initialValues?.day
|
||||||
? `Hari ke-${initialValues.day} (Minggu ke-${Math.ceil(initialValues.day / 7)})`
|
? `Hari ke-${initialValues.day} (Minggu ke-${Math.ceil(initialValues.day / 7)})`
|
||||||
: '-'}
|
: '-'}
|
||||||
|
|||||||
Reference in New Issue
Block a user