From b6e0b40e5857066d60fa6b68bed75686ed085e34 Mon Sep 17 00:00:00 2001 From: BenoistP Date: Thu, 12 Dec 2024 18:37:59 +0100 Subject: [PATCH] Avoid divide by zero in case asset.totalUnits is unknown/zero --- src/components/assetsView/filters/AssetsViewSort.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/assetsView/filters/AssetsViewSort.tsx b/src/components/assetsView/filters/AssetsViewSort.tsx index 9997dac9..b4fa4506 100644 --- a/src/components/assetsView/filters/AssetsViewSort.tsx +++ b/src/components/assetsView/filters/AssetsViewSort.tsx @@ -131,8 +131,8 @@ export function useAssetsViewSort(filter: AssetsViewSortFilter) { return (b.rentedUnits ?? 0) - (a.rentedUnits ?? 0) case AssetSortType.OCCUPANCY: return ( - (b.rentedUnits ?? 0) / (b.totalUnits ?? 0) - - (a.rentedUnits ?? 0) / (a.totalUnits ?? 0) + (b.rentedUnits ?? 0) / (b.totalUnits ?? 1) - + (a.rentedUnits ?? 0) / (a.totalUnits ?? 1) ) case AssetSortType.INITIAL_LAUNCH: return (b.initialLaunchDate?.date ?? '').localeCompare(