From 77880dfc3cf8c1226cb8ef2d7539390d9e04cab6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Wed, 18 Dec 2024 19:08:46 +0100 Subject: [PATCH 01/44] fix: unchecked asset filters (#95) --- .../assetsView/filters/AssetsViewRentStatusFilter.tsx | 7 ++++++- .../assetsView/filters/AssetsViewRmmStatusFilter.tsx | 8 +++++++- src/components/assetsView/filters/AssetsViewSort.tsx | 7 ++++++- .../assetsView/filters/AssetsViewSubsidyFilter.tsx | 8 +++++++- .../assetsView/filters/AssetsViewUserProtocolFilter.tsx | 7 ++++++- .../assetsView/filters/AssetsViewUserStatusFilter.tsx | 7 ++++++- 6 files changed, 38 insertions(+), 6 deletions(-) diff --git a/src/components/assetsView/filters/AssetsViewRentStatusFilter.tsx b/src/components/assetsView/filters/AssetsViewRentStatusFilter.tsx index fe905d9b..d40b18db 100644 --- a/src/components/assetsView/filters/AssetsViewRentStatusFilter.tsx +++ b/src/components/assetsView/filters/AssetsViewRentStatusFilter.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next' import { Select } from '@mantine/core' +import { assetsViewDefaultFilter } from 'src/states' import { OtherRealtoken, UserRealtoken, @@ -50,7 +51,11 @@ export const AssetsViewRentStatusFilter: FC< data={viewOptions} value={filter.rentStatus} onChange={(value) => - onChange({ rentStatus: value as AssetRentStatusType }) + onChange({ + rentStatus: + (value as AssetRentStatusType) ?? + assetsViewDefaultFilter.rentStatus, + }) } classNames={inputClasses} /> diff --git a/src/components/assetsView/filters/AssetsViewRmmStatusFilter.tsx b/src/components/assetsView/filters/AssetsViewRmmStatusFilter.tsx index aa68f88f..adc05b69 100644 --- a/src/components/assetsView/filters/AssetsViewRmmStatusFilter.tsx +++ b/src/components/assetsView/filters/AssetsViewRmmStatusFilter.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next' import { Select } from '@mantine/core' +import { assetsViewDefaultFilter } from 'src/states' import { OtherRealtoken, UserRealtoken, @@ -46,7 +47,12 @@ export const AssetsViewRmmStatusFilter: FC = ({ label={t('label')} data={viewOptions} value={filter.rmmStatus} - onChange={(value) => onChange({ rmmStatus: value as AssetRmmStatusType })} + onChange={(value) => + onChange({ + rmmStatus: + (value as AssetRmmStatusType) ?? assetsViewDefaultFilter.rmmStatus, + }) + } classNames={inputClasses} /> ) diff --git a/src/components/assetsView/filters/AssetsViewSort.tsx b/src/components/assetsView/filters/AssetsViewSort.tsx index b4fa4506..c4e4e762 100644 --- a/src/components/assetsView/filters/AssetsViewSort.tsx +++ b/src/components/assetsView/filters/AssetsViewSort.tsx @@ -4,6 +4,7 @@ import { useSelector } from 'react-redux' import { Grid, Select, Switch } from '@mantine/core' +import { assetsViewDefaultFilter } from 'src/states' import { selectTransfersIsLoaded } from 'src/store/features/transfers/transfersSelector' import { OtherRealtoken, @@ -73,7 +74,11 @@ export const AssetsViewSort: FC = ({ data={sortOptions} value={filter.sortBy} onChange={(value) => - onChange({ ...filter, sortBy: value as AssetSortType }) + onChange({ + ...filter, + sortBy: + (value as AssetSortType) ?? assetsViewDefaultFilter.sortBy, + }) } classNames={inputClasses} /> diff --git a/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx b/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx index 92aed5e6..1d2270cf 100644 --- a/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx +++ b/src/components/assetsView/filters/AssetsViewSubsidyFilter.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next' import { Select } from '@mantine/core' +import { assetsViewDefaultFilter } from 'src/states' import { OtherRealtoken, UserRealtoken, @@ -66,7 +67,12 @@ export const AssetsViewSubsidyFilter: FC = ({ label={t('label')} data={viewOptions} value={filter.subsidy} - onChange={(value) => onChange({ subsidy: value as AssetSubsidyType })} + onChange={(value) => + onChange({ + subsidy: + (value as AssetSubsidyType) ?? assetsViewDefaultFilter.subsidy, + }) + } classNames={inputClasses} /> ) diff --git a/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx b/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx index 533880e5..8c56e6d8 100644 --- a/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx +++ b/src/components/assetsView/filters/AssetsViewUserProtocolFilter.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next' import { Select } from '@mantine/core' +import { assetsViewDefaultFilter } from 'src/states' import { OtherRealtoken, UserRealtoken, @@ -54,7 +55,11 @@ export const AssetsViewUserProtocolFilter: FC< data={viewOptions} value={filter.userProtocol} onChange={(value) => - onChange({ userProtocol: value as AssetUserProtocolType }) + onChange({ + userProtocol: + (value as AssetUserProtocolType) ?? + assetsViewDefaultFilter.userProtocol, + }) } classNames={inputClasses} /> diff --git a/src/components/assetsView/filters/AssetsViewUserStatusFilter.tsx b/src/components/assetsView/filters/AssetsViewUserStatusFilter.tsx index fd30fcf1..c85e7ae1 100644 --- a/src/components/assetsView/filters/AssetsViewUserStatusFilter.tsx +++ b/src/components/assetsView/filters/AssetsViewUserStatusFilter.tsx @@ -3,6 +3,7 @@ import { useTranslation } from 'react-i18next' import { Select } from '@mantine/core' +import { assetsViewDefaultFilter } from 'src/states' import { OtherRealtoken, UserRealtoken, @@ -58,7 +59,11 @@ export const AssetsViewUserStatusFilter: FC< data={viewOptions} value={filter.userStatus} onChange={(value) => - onChange({ userStatus: value as AssetUserStatusType }) + onChange({ + userStatus: + (value as AssetUserStatusType) ?? + assetsViewDefaultFilter.userStatus, + }) } classNames={inputClasses} /> From 7f35422968c1c6113d19e551dcbc211495a522ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Wed, 18 Dec 2024 21:53:59 +0100 Subject: [PATCH 02/44] merge master in develop (#103) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Revert "Master" * merge preprod <> master (#67) * add dropdown * simplify selector and add all token option * feat: change allPage value to Infinity * feat: estimate the fully rented rent * feat: add fully rented estimation to asset cards * refactor: move hook calls to top of the page * fix: propInfo definition * fix: last rent condition * feat: add estimation for property with not fully rented history * feat: get fully rented APR * apply max APR method * rename variable and functions * feat: add RWA token * feat: re-enable property onClick * feat: add rwa valuation on the rwa card * fix: missing property * feat: add rwa to summary card * define useRWA * take into account user currency * feat: add RWA value to net value calculation * remove comment * refactor: clean imports * feat: include RWA on Ethereum * fix: en communs * feat: update filter to support RWA token * fix: prettier * fix: other prettier errors * let prettier add strange semi-column * fix: imports * use hook * add fallback * switch for a useMemo * feat: add real time fully rented APR * feat: add gloabl metric fully rented APR * feat: add disclaimer * feat: add disclaimer * feat: update disclaimer message * fix: disclaimer message * improve message * feat: create yam statics stics page * feat: add yam statistics for all RealT Tokens on Gnosis (who have Gnosis chain contract prop) * feat: mask tokens with no volume * fix: add token name * feat: add pagination * feat: improve style * feat: change token per page to 100 * feat: add fully rented APR to asset grid * refactor: remove logs * feat: add fully rented APR to property details * fix: reset current page when tokens changed * fix: reset current page when user change page size * feat: add translation for YAM statistics hearder label * fix: yamStatistics: use selected currency for token price * feat: yamStatistics: add owned | all filter * feat: yamStatistics: add subsidized, fullySubsidized and notSubsidized filters * add additional fallbacks RPC URLs * fix: RPC initialization on currencies file --------- Co-authored-by: Nandy Bâ * merge preprod <> master (#77) * add dropdown * simplify selector and add all token option * feat: change allPage value to Infinity * feat: estimate the fully rented rent * feat: add fully rented estimation to asset cards * refactor: move hook calls to top of the page * fix: propInfo definition * fix: last rent condition * feat: add estimation for property with not fully rented history * feat: get fully rented APR * apply max APR method * rename variable and functions * feat: add RWA token * feat: re-enable property onClick * feat: add rwa valuation on the rwa card * fix: missing property * feat: add rwa to summary card * define useRWA * take into account user currency * feat: add RWA value to net value calculation * remove comment * refactor: clean imports * feat: include RWA on Ethereum * fix: en communs * feat: update filter to support RWA token * fix: prettier * fix: other prettier errors * let prettier add strange semi-column * fix: imports * use hook * add fallback * switch for a useMemo * feat: add real time fully rented APR * feat: add gloabl metric fully rented APR * feat: add disclaimer * feat: add disclaimer * feat: update disclaimer message * fix: disclaimer message * improve message * feat: create yam statics stics page * feat: add yam statistics for all RealT Tokens on Gnosis (who have Gnosis chain contract prop) * feat: mask tokens with no volume * fix: add token name * feat: add pagination * feat: improve style * feat: change token per page to 100 * feat: add fully rented APR to asset grid * refactor: remove logs * feat: add fully rented APR to property details * fix: reset current page when tokens changed * fix: reset current page when user change page size * feat: add translation for YAM statistics hearder label * fix: yamStatistics: use selected currency for token price * feat: yamStatistics: add owned | all filter * feat: yamStatistics: add subsidized, fullySubsidized and notSubsidized filters * add additional fallbacks RPC URLs * fix: RPC initialization on currencies file * feat: YamStatistic: add Yamp Volume's number of days * fix: fullyRentedAPR: fix french disclaimer text * fix: second disclaimer text small error * feat: fullyRentedAPR: manage VEFA properties * refactore: improve comment * feat: show VEFA properties forced fully rented APR only if property do not have tenants * fix: RWA table view * feat: add bridge link on header (#74) * fix: VEFA Realtime APR --------- Co-authored-by: Nandy Bâ Co-authored-by: Yohann Durand * Revert "merge preprod <> master (#77)" This reverts commit 68daad55434377c91e0224a580528e9a501e392f. * fix: APY fully rented for properties before start rent day (#85) Co-authored-by: alex <123092072+AlexRLT@users.noreply.github.com> * Change NS for RealToken (#89) (#90) --------- Co-authored-by: Sigri Co-authored-by: Kurtisone <104103601+Kurtisone@users.noreply.github.com> Co-authored-by: jycssu-com <110905167+jycssu-com@users.noreply.github.com> Co-authored-by: alex <123092072+AlexRLT@users.noreply.github.com> Co-authored-by: Jycssu Co-authored-by: Yohann Durand --- src/hooks/useFullyRentedAPR.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts index 20454c26..d303399e 100644 --- a/src/hooks/useFullyRentedAPR.ts +++ b/src/hooks/useFullyRentedAPR.ts @@ -19,8 +19,8 @@ const fullyRentedAPREstimation = ( return getVEFAFullRentedAPR(token, rentCalculation) } + // Case of fully rented property if (token.rentedUnits === token.totalUnits) { - // Case of fully rented property return token.annualPercentageYield } From 0d7f8fe57af5fceeb1d7939d190f1225ff8c5362 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 19 Dec 2024 00:25:57 +0100 Subject: [PATCH 03/44] feat: restrict merges to preprod (#104) --- .github/workflows/branch-check-preprod.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/branch-check-preprod.yml diff --git a/.github/workflows/branch-check-preprod.yml b/.github/workflows/branch-check-preprod.yml new file mode 100644 index 00000000..f743b6c9 --- /dev/null +++ b/.github/workflows/branch-check-preprod.yml @@ -0,0 +1,17 @@ +name: Restrict merges to preprod + +on: + pull_request: + branches: + - preprod + +jobs: + check-branch: + runs-on: ubuntu-latest + steps: + - name: Check if the source branch is develop + run: | + if [ "${{ github.event.pull_request.head.ref }}" != "develop" ]; then + echo "Pull requests to preprod must come from develop branch." + exit 1 + fi From f81f456a7fad4216cd64f9984fc071c323d9ab75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 19 Dec 2024 02:17:33 +0100 Subject: [PATCH 04/44] merge develop into master (#102) (#107) * Change NS for RealToken (#89) * chore: install required sharp dependency for production * chore(deps): bump body-parser from 1.20.2 to 1.20.3 (#87) Bumps [body-parser](https://github.com/expressjs/body-parser) from 1.20.2 to 1.20.3. - [Release notes](https://github.com/expressjs/body-parser/releases) - [Changelog](https://github.com/expressjs/body-parser/blob/master/HISTORY.md) - [Commits](https://github.com/expressjs/body-parser/compare/1.20.2...1.20.3) --- updated-dependencies: - dependency-name: body-parser dependency-type: indirect ... * feat: add new assets REG, REG Vote Power (#91) * first version : Assets as rows * 'other' assets display switch; 'other' assets shown in Summary 'other' assets = tokens others than RealTokens = RWA, REG, ... - Display switch for hiding 'other' assets in table rows - 'other' assets figures added to Summary section * contracts utils * use contract utils for fetching balances * Eth provider removed: REG Voting Power is not deployed on Eth * batchCallOneFunction not fully tested * error args * comments * wrong 'inheritance' * smol fix: properly throw 'User not found' error * style/comments * settings labels and icons * unitIcon: optional + alignment with other units * Filter 'other' assets in Grid view * Settings: switch icons, section names * fix: lint warning * fix: lint warning * fix: build error ? * fix: build error #2 ? * fix: build error #3 ? * fix: build error #4 ? * fix: build error #5 ? * Fix: existing filter error when filtering on "Owned on" * fix: avoid fetching others assets balances if user wallet was not set * feat: add other token price on cards and fix decimals rounds for total invest * fix: improve subsudy filter for exclude other realtokens * fix: fix last changes filter and use correct typing in filters for avoid futurs errors * feat: set initial launch date for RWA token * feat: initialize rpc provider only once * feat: include reg tokens locked inside the incentive vault * fix: fix eslint warnings and add missing translations * Update .gitignore exclude pnpm lockfile * Create .nvmrc add .nvmrc for switching between node versions * Update contract.ts optional parameters for customizing batch calls: batch max and min size, number of attempts before giving up * Regvotingpower: icon orange, size grows depending on amount * unused import * Usdc currency/rate * Voting power size & fill color depending on power amount * Voting power size & fill color depending on power amount * Fixes: token prices in USD, avoid fetching REG vault balances on Eth - Tokens values fix: Updated assets prices by using currenciesRates and user currency rate (previously considering usdc = usd and xdai = usd as well), now assets prices are converted from their respective currencies (e.g. usdc, xdai) to usd, then total value is priced in user choosen currency. - Smol fix: getAddressesLockedBalances was fetching vault balances on Eth, throwing errors as there is not such vault on Eth. Added parameters for fetching any number of vault by provider(s). * comment * Check Providers ability to handle requests - Check Providers ability to handle requests - Additionnal providers https://rpc.ankr.com/eth and https://eth-pokt.nodies.app currently fail to handle concurrent requests * Assets hooks moved in index for avoiding duplicate requests - Both SummaryCard and AssetsView use the same hooks for getting their data, leading to duplicate web3 requests Moving hooks in parent components prevents this form happening. * prettier * Avoid divide by zero in case asset.totalUnits is unknown/zero * "Clean" scripts * Assets filtering moved to the right place filter has to be in assetsView/AssetsView.tsx * Paging translation labels: placeholder, All * simplify pageSize handling * Assets filtering fix (causing pagination issues) OtherAssets filtering was improperly implemented into the map loops by skipping non "others assets" value, causing holes in display (missing cards). Filtering is now done in AssetsView where it should have been in the first place * Revert changes: realtime/global labels for rents calculation switch --------- * fix: API URLs issue #97 (#98) * addresses issue #97 Moves api urls to (.)ENV set utls to new api.realtoken.community domain (previously api.realt.community) * Update .env.sample missing update of sample .env * Update .env.sample * NEXT_PUBLIC_ prefix removed for REALTOKENAPI ENV vars * feat: update yarn lock (#99) * feat: add new API urls to deployment workflow (#100) * feat: pass new env variables to docker env (#101) * fix: unchecked asset filters (#95) * merge master in develop (#103) * Revert "Master" * merge preprod <> master (#67) * add dropdown * simplify selector and add all token option * feat: change allPage value to Infinity * feat: estimate the fully rented rent * feat: add fully rented estimation to asset cards * refactor: move hook calls to top of the page * fix: propInfo definition * fix: last rent condition * feat: add estimation for property with not fully rented history * feat: get fully rented APR * apply max APR method * rename variable and functions * feat: add RWA token * feat: re-enable property onClick * feat: add rwa valuation on the rwa card * fix: missing property * feat: add rwa to summary card * define useRWA * take into account user currency * feat: add RWA value to net value calculation * remove comment * refactor: clean imports * feat: include RWA on Ethereum * fix: en communs * feat: update filter to support RWA token * fix: prettier * fix: other prettier errors * let prettier add strange semi-column * fix: imports * use hook * add fallback * switch for a useMemo * feat: add real time fully rented APR * feat: add gloabl metric fully rented APR * feat: add disclaimer * feat: add disclaimer * feat: update disclaimer message * fix: disclaimer message * improve message * feat: create yam statics stics page * feat: add yam statistics for all RealT Tokens on Gnosis (who have Gnosis chain contract prop) * feat: mask tokens with no volume * fix: add token name * feat: add pagination * feat: improve style * feat: change token per page to 100 * feat: add fully rented APR to asset grid * refactor: remove logs * feat: add fully rented APR to property details * fix: reset current page when tokens changed * fix: reset current page when user change page size * feat: add translation for YAM statistics hearder label * fix: yamStatistics: use selected currency for token price * feat: yamStatistics: add owned | all filter * feat: yamStatistics: add subsidized, fullySubsidized and notSubsidized filters * add additional fallbacks RPC URLs * fix: RPC initialization on currencies file --------- * merge preprod <> master (#77) * add dropdown * simplify selector and add all token option * feat: change allPage value to Infinity * feat: estimate the fully rented rent * feat: add fully rented estimation to asset cards * refactor: move hook calls to top of the page * fix: propInfo definition * fix: last rent condition * feat: add estimation for property with not fully rented history * feat: get fully rented APR * apply max APR method * rename variable and functions * feat: add RWA token * feat: re-enable property onClick * feat: add rwa valuation on the rwa card * fix: missing property * feat: add rwa to summary card * define useRWA * take into account user currency * feat: add RWA value to net value calculation * remove comment * refactor: clean imports * feat: include RWA on Ethereum * fix: en communs * feat: update filter to support RWA token * fix: prettier * fix: other prettier errors * let prettier add strange semi-column * fix: imports * use hook * add fallback * switch for a useMemo * feat: add real time fully rented APR * feat: add gloabl metric fully rented APR * feat: add disclaimer * feat: add disclaimer * feat: update disclaimer message * fix: disclaimer message * improve message * feat: create yam statics stics page * feat: add yam statistics for all RealT Tokens on Gnosis (who have Gnosis chain contract prop) * feat: mask tokens with no volume * fix: add token name * feat: add pagination * feat: improve style * feat: change token per page to 100 * feat: add fully rented APR to asset grid * refactor: remove logs * feat: add fully rented APR to property details * fix: reset current page when tokens changed * fix: reset current page when user change page size * feat: add translation for YAM statistics hearder label * fix: yamStatistics: use selected currency for token price * feat: yamStatistics: add owned | all filter * feat: yamStatistics: add subsidized, fullySubsidized and notSubsidized filters * add additional fallbacks RPC URLs * fix: RPC initialization on currencies file * feat: YamStatistic: add Yamp Volume's number of days * fix: fullyRentedAPR: fix french disclaimer text * fix: second disclaimer text small error * feat: fullyRentedAPR: manage VEFA properties * refactore: improve comment * feat: show VEFA properties forced fully rented APR only if property do not have tenants * fix: RWA table view * feat: add bridge link on header (#74) * fix: VEFA Realtime APR --------- * Revert "merge preprod <> master (#77)" This reverts commit 68daad55434377c91e0224a580528e9a501e392f. * fix: APY fully rented for properties before start rent day (#85) * Change NS for RealToken (#89) (#90) --------- --------- Signed-off-by: dependabot[bot] Co-authored-by: Sigri Co-authored-by: Jycssu Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: BenoistP <75934369+BenoistP@users.noreply.github.com> Co-authored-by: Kurtisone <104103601+Kurtisone@users.noreply.github.com> Co-authored-by: jycssu-com <110905167+jycssu-com@users.noreply.github.com> Co-authored-by: alex <123092072+AlexRLT@users.noreply.github.com> Co-authored-by: Yohann Durand From db548743754512fb96bfcc51bf8e9e8c6978bb88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Sat, 21 Dec 2024 15:16:42 +0100 Subject: [PATCH 05/44] feat: add workflow to restrict merges to master (#108) --- .github/workflows/branch-check-master.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/workflows/branch-check-master.yml diff --git a/.github/workflows/branch-check-master.yml b/.github/workflows/branch-check-master.yml new file mode 100644 index 00000000..92d2ad8e --- /dev/null +++ b/.github/workflows/branch-check-master.yml @@ -0,0 +1,17 @@ +name: Restrict merges to master + +on: + pull_request: + branches: + - master + +jobs: + check-branch-master: + runs-on: ubuntu-latest + steps: + - name: Check if the source branch is preprod + run: | + if [ "${{ github.event.pull_request.head.ref }}" != "preprod" ]; then + echo "Pull requests to master must come from preprod branch." + exit 1 + fi From d31c2aba68f3cba679f5db3f7848d5a4cb93238b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Sat, 21 Dec 2024 15:17:56 +0100 Subject: [PATCH 06/44] feat: add product type filter (#94) * 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 --- .../filters/AssetsViewFilterModal.tsx | 23 +++++ .../filters/AssetsViewFilterProductType.tsx | 83 +++++++++++++++++++ .../assetsView/filters/useFilters.ts | 4 + .../assetsView/types/assetProduct.type.ts | 6 ++ src/components/assetsView/types/index.ts | 1 + src/hooks/useREG.ts | 2 + src/hooks/useREGVotingPower.ts | 2 + src/hooks/useRWA.ts | 2 + src/i18next/locales/en/common.json | 9 ++ src/i18next/locales/fr/common.json | 9 ++ src/states/index.ts | 3 + src/store/features/wallets/walletsSelector.ts | 7 +- 12 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 src/components/assetsView/filters/AssetsViewFilterProductType.tsx create mode 100644 src/components/assetsView/types/assetProduct.type.ts diff --git a/src/components/assetsView/filters/AssetsViewFilterModal.tsx b/src/components/assetsView/filters/AssetsViewFilterModal.tsx index 8125e21e..5bcd75fd 100644 --- a/src/components/assetsView/filters/AssetsViewFilterModal.tsx +++ b/src/components/assetsView/filters/AssetsViewFilterModal.tsx @@ -1,5 +1,7 @@ import { FC, useCallback, useState } from 'react' import { useTranslation } from 'react-i18next' +import { useSelector } from 'react-redux' +import { useDispatch } from 'react-redux' import { Button, Flex, Stack } from '@mantine/core' import { ContextModalProps } from '@mantine/modals' @@ -11,7 +13,11 @@ import { assetsViewDefaultFilter, assetsViewFilterAtom, } from 'src/states' +import { selectUserIncludesOtherAssets } from 'src/store/features/settings/settingsSelector' +import { userIncludesOtherAssetsChanged } from 'src/store/features/settings/settingsSlice' +import { AssetProductType } from '../types' +import { AssetsViewProductTypeFilter } from './AssetsViewFilterProductType' import { AssetsViewRentStatusFilter } from './AssetsViewRentStatusFilter' import { AssetsViewRmmStatusFilter } from './AssetsViewRmmStatusFilter' import { AssetsViewSort } from './AssetsViewSort' @@ -49,11 +55,22 @@ export const AssetsViewFilterModal: FC = ({ const [filterModel, setFilterModel] = useState(activeFilter) + const userIncludesOtherAssets = useSelector(selectUserIncludesOtherAssets) + const dispatch = useDispatch() + const setUserIncludesOtherAssets = (value: boolean) => + dispatch(userIncludesOtherAssetsChanged(value)) + const onClose = useCallback(() => { context.closeModal(id) }, [context, id]) const onSubmit = () => { + if ( + filterModel.productType === AssetProductType.EQUITY_TOKEN && + !userIncludesOtherAssets + ) { + setUserIncludesOtherAssets(true) // as all equity token are part of other assets we automatically activate their fetch if the user selects equity token + } applyFilter(filterModel) onClose() } @@ -76,6 +93,12 @@ export const AssetsViewFilterModal: FC = ({ setFilterModel({ ...filterModel, ...value }) }} /> + { + setFilterModel({ ...filterModel, ...value }) + }} + /> { diff --git a/src/components/assetsView/filters/AssetsViewFilterProductType.tsx b/src/components/assetsView/filters/AssetsViewFilterProductType.tsx new file mode 100644 index 00000000..197a3aef --- /dev/null +++ b/src/components/assetsView/filters/AssetsViewFilterProductType.tsx @@ -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 ( + + onChange({ + issuePriority: + (value as AssetIssuePriorityType) ?? + assetsViewDefaultFilter.issuePriority, + }) + } + classNames={inputClasses} + /> + ) +} +AssetsViewIssuePriorityFilter.displayName = 'AssetsViewIssuePriorityFilter' + +export function useAssetsViewIssuePriorityFilter( + filter: AssetsViewIssuePriorityFilterModel, +) { + function assetIssuePriorityFilterFunction( + asset: UserRealtoken | OtherRealtoken, + ) { + const Asset = asset as UserRealtoken + switch (filter.issuePriority) { + case AssetIssuePriorityType.ALL: + return true + case AssetIssuePriorityType.NONE: + return ( + Asset.extraData?.pitsBI?.actions?.priority === + RealTokenToBeRepairedPriority.None || + Asset.extraData?.pitsBI?.actions?.priority === undefined + ) + case AssetIssuePriorityType.HIGH: + return ( + Asset.extraData?.pitsBI?.actions?.priority === + RealTokenToBeRepairedPriority.High + ) + case AssetIssuePriorityType.MEDIUM: + return ( + Asset.extraData?.pitsBI?.actions?.priority === + RealTokenToBeRepairedPriority.Medium + ) + case AssetIssuePriorityType.LOW: + return ( + Asset.extraData?.pitsBI?.actions?.priority === + RealTokenToBeRepairedPriority.Low + ) + } + } + + return { assetIssuePriorityFilterFunction } +} diff --git a/src/components/assetsView/filters/AssetsViewIssuesStatusFilter.tsx b/src/components/assetsView/filters/AssetsViewIssuesStatusFilter.tsx new file mode 100644 index 00000000..628f5ac1 --- /dev/null +++ b/src/components/assetsView/filters/AssetsViewIssuesStatusFilter.tsx @@ -0,0 +1,97 @@ +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 { RealTokenToBeFixedStatus } from 'src/types/APIPitsBI' + +import { useInputStyles } from '../../inputs/useInputStyles' +import { AssetIssueStatusType } from '../types' + +interface AssetsViewIssueStatusFilterModel { + issueStatus: AssetIssueStatusType +} + +interface AssetsViewIssueStatusFilterProps { + filter: AssetsViewIssueStatusFilterModel + onChange: (value: AssetsViewIssueStatusFilterModel) => void +} +export const AssetsViewIssueStatusFilter: FC< + AssetsViewIssueStatusFilterProps +> = ({ filter, onChange }) => { + const { t } = useTranslation('common', { keyPrefix: 'assetIssueStatus' }) + const { classes: inputClasses } = useInputStyles() + + const viewOptions = [ + { + value: AssetIssueStatusType.ALL, + label: t('options.all'), + }, + { + value: AssetIssueStatusType.NOEXHIBIT, + label: t('options.noExhibit'), + }, + { + value: AssetIssueStatusType.UPGRADEDANDREADY, + label: t('options.upgradedAndReady'), + }, + { + value: AssetIssueStatusType.SCHEDULED, + label: t('options.scheduled'), + }, + ] + + return ( +