1 import { useMemo } from 'react';
3 const getMaxForCountry = (country: string, remainingCount: number, deletedInCountries: Record<string, number>) =>
5 Object.keys(deletedInCountries).reduce(
6 (count, otherCountry) => count + (country === otherCountry ? 0 : deletedInCountries[country]),
10 export const useSpecificCountryCount = (
11 model: { quantities?: Record<string, number> },
12 remainingCount: number,
13 deletedInCountries: Record<string, number>
17 Object.keys(model.quantities || {}).reduce(
22 (model.quantities?.[country] || 0) -
23 getMaxForCountry(country, remainingCount, deletedInCountries)
27 [model, remainingCount, deletedInCountries]