mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +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(() => {
|
||||
if (!projectFlockKandangLookup) return null;
|
||||
if (!selectedRecordDate) return null;
|
||||
const projectFlockKandangId = projectFlockKandangLookup.id;
|
||||
return `${RecordingApi.basePath}/next-day?project_flock_kandang_id=${projectFlockKandangId}&record_date=${selectedRecordDate}`;
|
||||
}, [projectFlockKandangLookup, selectedRecordDate]);
|
||||
@@ -583,7 +584,11 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
} else if (nextDayRecordingData?.status === 'error') {
|
||||
setNextDayRecording(null);
|
||||
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);
|
||||
}
|
||||
} else {
|
||||
@@ -1900,8 +1905,10 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
<div>
|
||||
<span className='text-sm text-gray-600'>Umur</span>
|
||||
<p className='font-semibold'>
|
||||
{nextDayRecording
|
||||
{type === 'add'
|
||||
? nextDayRecording
|
||||
? `Hari ke-${nextDayRecording.next_day} (Minggu ke-${Math.ceil(nextDayRecording.next_day / 7)})`
|
||||
: '-'
|
||||
: initialValues?.day
|
||||
? `Hari ke-${initialValues.day} (Minggu ke-${Math.ceil(initialValues.day / 7)})`
|
||||
: '-'}
|
||||
|
||||
Reference in New Issue
Block a user