Skip to content

Commit

Permalink
feat: allow to filter on different subsidy programs
Browse files Browse the repository at this point in the history
  • Loading branch information
jycssu-com committed Nov 22, 2023
1 parent e5550c5 commit 61d377e
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 8 deletions.
33 changes: 30 additions & 3 deletions src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,29 @@ export const AssetsViewSubsidyFilter: FC<AssetsViewSubsidyFilterProps> = ({
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,
Expand All @@ -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'
}
Expand Down
6 changes: 5 additions & 1 deletion src/components/assetsView/types/assetSubsidy.type.ts
Original file line number Diff line number Diff line change
@@ -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',
}
8 changes: 6 additions & 2 deletions src/i18next/locales/en/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down
8 changes: 6 additions & 2 deletions src/i18next/locales/fr/common.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
Expand Down

0 comments on commit 61d377e

Please sign in to comment.