From 2a6da690e2b43c59b2d0a7e4ed2375efbeb3f7db Mon Sep 17 00:00:00 2001 From: Jycssu Date: Sat, 18 Nov 2023 14:16:12 +0100 Subject: [PATCH] feat: allow to filter on owned protocol --- .../filters/AssetsViewFilterModal.tsx | 7 ++ .../filters/AssetsViewUserProtocolFilter.tsx | 81 +++++++++++++++++++ .../assetsView/filters/useFilters.ts | 4 + .../types/assetUserProtocol.type.ts | 7 ++ src/components/assetsView/types/index.ts | 1 + src/i18next/locales/en/common.json | 10 +++ src/i18next/locales/fr/common.json | 10 +++ src/states/index.ts | 3 + 8 files changed, 123 insertions(+) create mode 100644 src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx create mode 100644 src/components/assetsView/types/assetUserProtocol.type.ts diff --git a/src/components/assetsView/filters/AssetsViewFilterModal.tsx b/src/components/assetsView/filters/AssetsViewFilterModal.tsx index de4246f..22474be 100644 --- a/src/components/assetsView/filters/AssetsViewFilterModal.tsx +++ b/src/components/assetsView/filters/AssetsViewFilterModal.tsx @@ -16,6 +16,7 @@ import { AssetsViewRentStatusFilter } from './AssetsViewRentStatusFilter' import { AssetsViewRmmStatusFilter } from './AssetsViewRmmStatusFilter' import { AssetsViewSort } from './AssetsViewSort' import { AssetsViewSubsidyFilter } from './AssetsViewSubsidyFilter' +import { AssetsViewUserProtocolFilter } from './AssetsViewUserProtocolFilter' import { AssetsViewUserStatusFilter } from './AssetsViewUserStatusFilter' export const AssetsViewFilterModal: FC = ({ @@ -56,6 +57,12 @@ export const AssetsViewFilterModal: FC = ({ setFilterModel({ ...filterModel, ...value }) }} /> + { + setFilterModel({ ...filterModel, ...value }) + }} + /> { diff --git a/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx b/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx new file mode 100644 index 0000000..c7b883d --- /dev/null +++ b/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx @@ -0,0 +1,81 @@ +import { FC } from 'react' +import { useTranslation } from 'react-i18next' + +import { Select } from '@mantine/core' + +import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' + +import { useInputStyles } from '../../inputs/useInputStyles' +import { AssetUserProtocolType } from '../types' + +interface AssetsViewUserProtocolFilterModel { + userProtocol: AssetUserProtocolType +} + +interface AssetsViewUserProtocolFilterProps { + filter: AssetsViewUserProtocolFilterModel + onChange: (value: AssetsViewUserProtocolFilterModel) => void +} +export const AssetsViewUserProtocolFilter: FC< + AssetsViewUserProtocolFilterProps +> = ({ filter, onChange }) => { + const { t } = useTranslation('common', { keyPrefix: 'assetUserProtocol' }) + const { classes: inputClasses } = useInputStyles() + + const viewOptions = [ + { + value: AssetUserProtocolType.ALL, + label: t('options.all'), + }, + { + value: AssetUserProtocolType.ETHEREUM, + label: t('options.ethereum'), + }, + { + value: AssetUserProtocolType.GNOSIS, + label: t('options.gnosis'), + }, + { + value: AssetUserProtocolType.RMM, + label: t('options.rmm'), + }, + { + value: AssetUserProtocolType.LEVINSWAP, + label: t('options.levinSwap'), + }, + ] + + return ( +