Skip to content

Commit

Permalink
Avoid divide by zero in case asset.totalUnits is unknown/zero
Browse files Browse the repository at this point in the history
  • Loading branch information
BenoistP committed Dec 12, 2024
1 parent af0e0a8 commit b6e0b40
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/components/assetsView/filters/AssetsViewSort.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit b6e0b40

Please sign in to comment.