mirror of
https://gitlab.com/mbugroup/lti-web-client.git
synced 2026-05-20 13:32:00 +00:00
refactor(FE-137): optimize recordedProjectFlockIds calculation to filter today's recordings
This commit is contained in:
@@ -99,8 +99,19 @@ const RecordingForm = ({ type = 'add', initialValues }: RecordingFormProps) => {
|
||||
|
||||
const recordedProjectFlockIds = useMemo(() => {
|
||||
if (!isResponseSuccess(existingRecordings)) return new Set<number>();
|
||||
return new Set(existingRecordings?.data.map(rec => rec.project_flock_kandang_id) || []);
|
||||
}, [existingRecordings]);
|
||||
|
||||
const todayRecordings = existingRecordings?.data || [];
|
||||
const recordedIds = new Set<number>();
|
||||
|
||||
todayRecordings.forEach(recording => {
|
||||
const recordingDate = recording.record_date?.split('T')[0];
|
||||
if (recordingDate === today) {
|
||||
recordedIds.add(recording.project_flock_kandang_id);
|
||||
}
|
||||
});
|
||||
|
||||
return recordedIds;
|
||||
}, [existingRecordings, today]);
|
||||
|
||||
const { data: stockProducts, isLoading: isLoadingStockProducts } = useSWR(
|
||||
stockProductsUrl,
|
||||
|
||||
Reference in New Issue
Block a user