-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: add product type filter * refactor: change filter file name * feat: add product type i18n translations * feat: update REG and RWA type to support new filter * feat: automatically activate other assets fetch it equity token filter is selected * feat: add default value for product type filter if user un-checked it
- Loading branch information
Showing
12 changed files
with
150 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
src/components/assetsView/filters/AssetsViewFilterProductType.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import { FC } from 'react' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { Select } from '@mantine/core' | ||
|
||
import { assetsViewDefaultFilter } from 'src/states' | ||
import { | ||
OtherRealtoken, | ||
UserRealtoken, | ||
} from 'src/store/features/wallets/walletsSelector' | ||
import { APIRealTokenProductType } from 'src/types/APIRealToken' | ||
|
||
import { useInputStyles } from '../../inputs/useInputStyles' | ||
import { AssetProductType } from '../types' | ||
|
||
interface AssetsViewFilterType { | ||
productType: AssetProductType | ||
} | ||
|
||
interface AssetsViewProductTypeFilterProps { | ||
filter: AssetsViewFilterType | ||
onChange: (value: AssetsViewFilterType) => void | ||
} | ||
export const AssetsViewProductTypeFilter: FC< | ||
AssetsViewProductTypeFilterProps | ||
> = ({ filter, onChange }) => { | ||
const { t } = useTranslation('common', { keyPrefix: 'assetProductType' }) | ||
const { classes: inputClasses } = useInputStyles() | ||
|
||
const viewOptions = [ | ||
{ | ||
value: AssetProductType.ALL, | ||
label: t('options.all'), | ||
}, | ||
{ | ||
value: AssetProductType.REAL_EASTATE_RENTAL, | ||
label: t('options.realEstateRental'), | ||
}, | ||
{ | ||
value: AssetProductType.LOAN_INCOME, | ||
label: t('options.loanIncome'), | ||
}, | ||
{ | ||
value: AssetProductType.EQUITY_TOKEN, | ||
label: t('options.equityToken'), | ||
}, | ||
] | ||
|
||
return ( | ||
<Select | ||
label={t('label')} | ||
data={viewOptions} | ||
value={filter.productType} | ||
onChange={(value) => | ||
onChange({ | ||
productType: | ||
(value as AssetProductType) ?? assetsViewDefaultFilter.productType, | ||
}) | ||
} | ||
classNames={inputClasses} | ||
/> | ||
) | ||
} | ||
AssetsViewProductTypeFilter.displayName = 'AssetsViewProductTypeFilter' | ||
|
||
export function useAssetsViewProductTypeFilter(filter: AssetsViewFilterType) { | ||
function assetProductTypeFilterFunction( | ||
asset: UserRealtoken | OtherRealtoken, | ||
) { | ||
switch (filter.productType) { | ||
case AssetProductType.ALL: | ||
return true | ||
case AssetProductType.REAL_EASTATE_RENTAL: | ||
return asset.productType === APIRealTokenProductType.RealEstateRental | ||
case AssetProductType.LOAN_INCOME: | ||
return asset.productType === APIRealTokenProductType.LoanIncome | ||
case AssetProductType.EQUITY_TOKEN: | ||
return asset.productType === APIRealTokenProductType.EquityToken | ||
} | ||
} | ||
|
||
return { assetProductTypeFilterFunction } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export enum AssetProductType { | ||
ALL = 'all', | ||
REAL_EASTATE_RENTAL = 'real_estate_rental', | ||
EQUITY_TOKEN = 'equity_token', | ||
LOAN_INCOME = 'loan_income', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters