From 61d377ea64887679cf7d96aa5674aae2435e3594 Mon Sep 17 00:00:00 2001 From: Jycssu Date: Wed, 22 Nov 2023 15:43:03 +0100 Subject: [PATCH] feat: allow to filter on different subsidy programs --- .../filters/AssetsViewSubsidyFilter.tsx | 33 +++++++++++++++++-- .../assetsView/types/assetSubsidy.type.ts | 6 +++- src/i18next/locales/en/common.json | 8 +++-- src/i18next/locales/fr/common.json | 8 +++-- 4 files changed, 47 insertions(+), 8 deletions(-) diff --git a/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx b/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx index fe285d5..86f21af 100644 --- a/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx +++ b/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx @@ -28,13 +28,29 @@ export const AssetsViewSubsidyFilter: FC = ({ value: AssetSubsidyType.ALL, label: t('options.all'), }, + { + value: AssetSubsidyType.SUBSIDIZED, + label: t('options.subsidized'), + }, { value: AssetSubsidyType.FULLY_SUBSIDIZED, label: t('options.fullySubsidized'), }, { - value: AssetSubsidyType.SUBSIDIZED, - label: t('options.subsidized'), + value: AssetSubsidyType.PARTIALLY_SUBSIDIZED, + label: t('options.partiallySubsidized'), + }, + { + value: AssetSubsidyType.SECTION_8, + label: t('options.section8'), + }, + { + value: AssetSubsidyType.SECTION_42, + label: t('options.section42'), + }, + { + value: AssetSubsidyType.OTHER_SUBSIDY, + label: t('options.otherSubsidy'), }, { value: AssetSubsidyType.NOT_SUBSIDIZED, @@ -61,10 +77,21 @@ export function useAssetsViewSubsidyFilter( switch (filter.subsidy) { case AssetSubsidyType.ALL: return true + case AssetSubsidyType.SUBSIDIZED: + return asset.subsidyStatus !== 'no' case AssetSubsidyType.FULLY_SUBSIDIZED: return asset.subsidyStatus === 'yes' && !!asset.subsidyStatusValue - case AssetSubsidyType.SUBSIDIZED: + case AssetSubsidyType.PARTIALLY_SUBSIDIZED: return asset.subsidyStatus !== 'no' && !!asset.subsidyStatusValue + case AssetSubsidyType.SECTION_8: + return asset.subsidyStatus !== 'no' && asset.subsidyBy === 'Section 8' + case AssetSubsidyType.SECTION_42: + return asset.subsidyStatus !== 'no' && asset.subsidyBy === 'Section 42' + case AssetSubsidyType.OTHER_SUBSIDY: + return ( + asset.subsidyStatus !== 'no' && + !['Section 8', 'Section 42'].includes(asset.subsidyBy ?? '') + ) case AssetSubsidyType.NOT_SUBSIDIZED: return !asset.subsidyStatus || asset.subsidyStatus === 'no' } diff --git a/src/components/assetsView/types/assetSubsidy.type.ts b/src/components/assetsView/types/assetSubsidy.type.ts index 31fce09..bb0d652 100644 --- a/src/components/assetsView/types/assetSubsidy.type.ts +++ b/src/components/assetsView/types/assetSubsidy.type.ts @@ -1,6 +1,10 @@ export enum AssetSubsidyType { - FULLY_SUBSIDIZED = 'fullySubsidized', SUBSIDIZED = 'Subsidized', + FULLY_SUBSIDIZED = 'fullySubsidized', + PARTIALLY_SUBSIDIZED = 'partiallySubsidized', NOT_SUBSIDIZED = 'notSubsidized', + SECTION_8 = 'section8', + SECTION_42 = 'section42', + OTHER_SUBSIDY = 'otherSubsidy', ALL = 'all', } diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index c30c4e4..ef36343 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -96,8 +96,12 @@ "label": "All", "options": { "all": "No filtered", - "fullySubsidized": "Subsidized", - "subsidized": "Partially subsidized", + "subsidized": "Subsidized", + "fullySubsidized": "Fully subsidized", + "partiallySubsidized": "Partially subsidized", + "section8": "Section 8", + "section42": "Section 42", + "otherSubsidy": "Other subsidy types", "notSubsidized": "Not subsidized" } }, diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index 4aca067..141d8c0 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -96,8 +96,12 @@ "label": "Loyers subventionnés", "options": { "all": "Tous", - "fullySubsidized": "Subventionnés", - "subsidized": "Partiellement subventionnés", + "subsidized": "Subventionnés", + "fullySubsidized": "Entièrement subventionnés", + "partiallySubsidized": "Partiellement subventionnés", + "section8": "Section 8", + "section42": "Section 42", + "otherSubsidy": "Autres types de subventions", "notSubsidized": "Non subventionnés" } },