Skip to content

Commit

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

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

return { animalsExistOnFarm };
};
Expand Down

0 comments on commit dcabcb0

Please sign in to comment.