Skip to content

Commit

Permalink
LF-4558 Improve animalsExistOnFarm logic
Browse files Browse the repository at this point in the history
  • Loading branch information
SayakaOno committed Dec 6, 2024
1 parent 2079561 commit 1d5839e
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ import useQueries from '../../../hooks/api/useQueries';
const useAnimalsExist = () => {
const { data, isLoading } = useQueries([
{ label: 'animals', hook: useGetAnimalsQuery },
{ label: 'batches', hook: useGetAnimalBatchesQuery },
{ label: 'animalBatches', hook: useGetAnimalBatchesQuery },
]);

const animalsExistOnFarm =
!isLoading &&
[...data.animals, ...data.batches].filter((entity) => !entity.animal_removal_reason_id).length;
[...data.animals, ...data.animalBatches].some((entity) => !entity.animal_removal_reason_id);

return { animalsExistOnFarm };
};
Expand Down

0 comments on commit 1d5839e

Please sign in to comment.