From ca241d3980f35dbde91bcbdf0d8fd786ebb1f546 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 8 Aug 2024 21:33:16 +0200 Subject: [PATCH 01/22] feat: estimate the fully rented rent --- src/components/cards/main/PropertiesCard.tsx | 36 ++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/src/components/cards/main/PropertiesCard.tsx b/src/components/cards/main/PropertiesCard.tsx index 1556e15..6f02df2 100644 --- a/src/components/cards/main/PropertiesCard.tsx +++ b/src/components/cards/main/PropertiesCard.tsx @@ -23,6 +23,42 @@ import { const RentedUnitsField: FC<{ label: string; realtokens: UserRealtoken[] }> = ( props, ) => { + console.log({ realtokens: props.realtokens }) + console.log({ + units: props.realtokens + .filter((r) => r.rentedUnits !== r.totalUnits) + .map((r) => { + if (r.history.length > 0) { + let propInfo = r.history[0].values + const history = r.history.map((h) => { + return { ...propInfo, ...h.values } + }) + + // Find last rent from history where property was fully rented + for (const h of history.reverse()) { + if (h.rentedUnits === r.totalTokens && h.netRentYear) { + return { + total: r.totalUnits, + rented: r.rentedUnits, + yearlyRentPerTokenIfFullyRented: h.netRentYear / r.totalTokens, + } + } + } + } + + // If no history, use current values + // please note that this estimation is most of the time underestimating the real value + // because maintenance cost is take into account but not shared between all the units + return { + total: r.totalUnits, + rented: r.rentedUnits, + netRentYearPerToken: r.netRentYearPerToken, + yearlyRentPerTokenIfFullyRented: r.rentedUnits + ? (r.netRentYearPerToken * r.totalUnits) / r.rentedUnits + : NaN, + } + }), + }) const { t } = useTranslation('common', { keyPrefix: 'numbers' }) const totalValue = _sumBy(props.realtokens, 'totalUnits') From c779b47d938e12db9779316bc83dde1e624bdb07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 8 Aug 2024 21:55:11 +0200 Subject: [PATCH 02/22] feat: add fully rented estimation to asset cards --- src/components/cards/AssetCard.tsx | 33 ++++++++++++++++++ src/components/cards/main/PropertiesCard.tsx | 36 -------------------- src/i18next/locales/en/common.json | 1 + src/i18next/locales/fr/common.json | 1 + 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index 9d3dc84..6d70d10 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -150,6 +150,13 @@ const AssetCardComponent: FC = (props) => { +
+
{t('fullyRentedEstimation')}*
+
+ {useCurrencyValue(fullyRentedRentEstimation(props.value))} +
+
+
@@ -158,4 +165,30 @@ const AssetCardComponent: FC = (props) => { ) } +const fullyRentedRentEstimation = (token: UserRealtoken) => { + const rentPerToken = () => { + if (token.history.length > 0) { + let propInfo = token.history[0].values + const history = token.history.map((h) => { + return { ...propInfo, ...h.values } + }) + + // Find last rent from history where property was fully rented + for (const h of history.reverse()) { + if (h.rentedUnits === token.totalTokens && h.netRentYear) { + return h.netRentYear / token.totalTokens + } + } + } + + // If no history, use current values + // please note that this estimation is most of the time underestimating the real value + // because maintenance cost is take into account but not shared between all the units + return token.rentedUnits + ? (token.netRentYearPerToken * token.totalUnits) / token.rentedUnits + : NaN + } + return rentPerToken() * token.amount +} + export const AssetCard = memo(AssetCardComponent) diff --git a/src/components/cards/main/PropertiesCard.tsx b/src/components/cards/main/PropertiesCard.tsx index 6f02df2..1556e15 100644 --- a/src/components/cards/main/PropertiesCard.tsx +++ b/src/components/cards/main/PropertiesCard.tsx @@ -23,42 +23,6 @@ import { const RentedUnitsField: FC<{ label: string; realtokens: UserRealtoken[] }> = ( props, ) => { - console.log({ realtokens: props.realtokens }) - console.log({ - units: props.realtokens - .filter((r) => r.rentedUnits !== r.totalUnits) - .map((r) => { - if (r.history.length > 0) { - let propInfo = r.history[0].values - const history = r.history.map((h) => { - return { ...propInfo, ...h.values } - }) - - // Find last rent from history where property was fully rented - for (const h of history.reverse()) { - if (h.rentedUnits === r.totalTokens && h.netRentYear) { - return { - total: r.totalUnits, - rented: r.rentedUnits, - yearlyRentPerTokenIfFullyRented: h.netRentYear / r.totalTokens, - } - } - } - } - - // If no history, use current values - // please note that this estimation is most of the time underestimating the real value - // because maintenance cost is take into account but not shared between all the units - return { - total: r.totalUnits, - rented: r.rentedUnits, - netRentYearPerToken: r.netRentYearPerToken, - yearlyRentPerTokenIfFullyRented: r.rentedUnits - ? (r.netRentYearPerToken * r.totalUnits) / r.rentedUnits - : NaN, - } - }), - }) const { t } = useTranslation('common', { keyPrefix: 'numbers' }) const totalValue = _sumBy(props.realtokens, 'totalUnits') diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index d6c4a1b..f048918 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -187,6 +187,7 @@ "rentedUnits": "Rented units", "propertyValue": "Property value", "rentStartDate": "Rent Start", + "fullyRentedEstimation": "Estimated annual rent if fully rented", "rentNotStarted": "Rent not started yet", "isRmmAvailable": "RMM", "rentStatus": { diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index 7513492..6521c57 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -187,6 +187,7 @@ "rentedUnits": "Logements loués", "propertyValue": "Valeur de la propriété", "rentStartDate": "Date du premier loyer", + "fullyRentedEstimation": "Estimation loyer annuel si loué à 100%", "rentNotStarted": "Le loyer n'a pas débuté", "isRmmAvailable": "RMM", "rentStatus": { From 554c16a03ce3174e59d737c1eda8163e5fc0e889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 8 Aug 2024 22:11:35 +0200 Subject: [PATCH 03/22] refactor: move hook calls to top of the page --- src/components/cards/AssetCard.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index 6d70d10..c4c60b6 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -48,6 +48,10 @@ const AssetCardComponent: FC = (props) => { const yearlyAmount = props.value.amount * props.value.netRentYearPerToken const totalInvestment = props.value.totalInvestment + const fullyRentedRentEstimationValue = useCurrencyValue( + fullyRentedRentEstimation(props.value), + ) + return ( = (props) => {
{t('fullyRentedEstimation')}*
-
- {useCurrencyValue(fullyRentedRentEstimation(props.value))} -
+
{fullyRentedRentEstimationValue}
From 0b9d73296a880aba5d6d14f9dc809f9a95d0281d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 8 Aug 2024 22:20:45 +0200 Subject: [PATCH 04/22] fix: propInfo definition --- src/components/cards/AssetCard.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index c4c60b6..a0c20c5 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -172,7 +172,8 @@ const fullyRentedRentEstimation = (token: UserRealtoken) => { if (token.history.length > 0) { let propInfo = token.history[0].values const history = token.history.map((h) => { - return { ...propInfo, ...h.values } + propInfo = { ...propInfo, ...h.values } + return propInfo }) // Find last rent from history where property was fully rented From bcd085b42eb62023b43b04bb972f708fe5b44617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 8 Aug 2024 23:23:16 +0200 Subject: [PATCH 05/22] fix: last rent condition --- src/components/cards/AssetCard.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index a0c20c5..af7d7c0 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -178,7 +178,7 @@ const fullyRentedRentEstimation = (token: UserRealtoken) => { // Find last rent from history where property was fully rented for (const h of history.reverse()) { - if (h.rentedUnits === token.totalTokens && h.netRentYear) { + if (h.rentedUnits === token.totalUnits && h.netRentYear) { return h.netRentYear / token.totalTokens } } From d8586f49afe365064978907eef60cb65202fd47a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 9 Aug 2024 00:18:28 +0200 Subject: [PATCH 06/22] feat: add estimation for property with not fully rented history --- src/components/cards/AssetCard.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index af7d7c0..464ac41 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -182,6 +182,14 @@ const fullyRentedRentEstimation = (token: UserRealtoken) => { return h.netRentYear / token.totalTokens } } + + // If no fully rented history, use last history + const lastHistory = history.reverse()[0] + if (lastHistory.netRentYear && lastHistory.rentedUnits) + return ( + (lastHistory.netRentYear * token.totalUnits) / + (token.totalTokens * lastHistory.rentedUnits) + ) } // If no history, use current values From 6860e2bbfad03d8b93f8a6e1992bd976824495b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 9 Aug 2024 01:13:50 +0200 Subject: [PATCH 07/22] feat: get fully rented APR --- src/components/cards/AssetCard.tsx | 58 ++++++++++++++++++++---------- src/i18next/locales/en/common.json | 2 +- src/i18next/locales/fr/common.json | 2 +- 3 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index 464ac41..23a4e6d 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -48,9 +48,8 @@ const AssetCardComponent: FC = (props) => { const yearlyAmount = props.value.amount * props.value.netRentYearPerToken const totalInvestment = props.value.totalInvestment - const fullyRentedRentEstimationValue = useCurrencyValue( - fullyRentedRentEstimation(props.value), - ) + const fullyRentedRentEstimationValue = + Math.floor(fullyRentedRentEstimation(props.value) * 100) / 100 return ( = (props) => {
{t('fullyRentedEstimation')}*
-
{fullyRentedRentEstimationValue}
+
{fullyRentedRentEstimationValue} %
@@ -168,7 +167,15 @@ const AssetCardComponent: FC = (props) => { } const fullyRentedRentEstimation = (token: UserRealtoken) => { - const rentPerToken = () => { + if (token.rentedUnits === 0 && token.annualPercentageYield !== 0) { + return token.annualPercentageYield + } + + if (token.rentedUnits !== 0 && token.annualPercentageYield !== 0) { + return (token.annualPercentageYield * token.totalUnits) / token.rentedUnits + } + + const APREstimation = () => { if (token.history.length > 0) { let propInfo = token.history[0].values const history = token.history.map((h) => { @@ -178,28 +185,41 @@ const fullyRentedRentEstimation = (token: UserRealtoken) => { // Find last rent from history where property was fully rented for (const h of history.reverse()) { - if (h.rentedUnits === token.totalUnits && h.netRentYear) { - return h.netRentYear / token.totalTokens + if ( + h.rentedUnits === token.totalUnits && + h.netRentYear && + h.tokenPrice + ) { + return (h.netRentYear / (token.totalTokens * h.tokenPrice)) * 100 } } // If no fully rented history, use last history - const lastHistory = history.reverse()[0] - if (lastHistory.netRentYear && lastHistory.rentedUnits) + const lastHistory = history + .reverse() + .find( + (h) => + h.netRentYear && + h.rentedUnits && + h.tokenPrice && + token.rentedUnits !== 0, + ) + if ( + lastHistory && + lastHistory.netRentYear && + lastHistory.rentedUnits != 0 && + lastHistory.tokenPrice + ) return ( - (lastHistory.netRentYear * token.totalUnits) / - (token.totalTokens * lastHistory.rentedUnits) + (token.totalUnits / token.rentedUnits) * + (lastHistory.netRentYear / + (token.totalTokens * lastHistory.tokenPrice)) * + 100 ) } - - // If no history, use current values - // please note that this estimation is most of the time underestimating the real value - // because maintenance cost is take into account but not shared between all the units - return token.rentedUnits - ? (token.netRentYearPerToken * token.totalUnits) / token.rentedUnits - : NaN } - return rentPerToken() * token.amount + + return APREstimation() || 0 } export const AssetCard = memo(AssetCardComponent) diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index f048918..9a83d0d 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -187,7 +187,7 @@ "rentedUnits": "Rented units", "propertyValue": "Property value", "rentStartDate": "Rent Start", - "fullyRentedEstimation": "Estimated annual rent if fully rented", + "fullyRentedEstimation": "Fully rented APR", "rentNotStarted": "Rent not started yet", "isRmmAvailable": "RMM", "rentStatus": { diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index 6521c57..e0aa856 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -187,7 +187,7 @@ "rentedUnits": "Logements loués", "propertyValue": "Valeur de la propriété", "rentStartDate": "Date du premier loyer", - "fullyRentedEstimation": "Estimation loyer annuel si loué à 100%", + "fullyRentedEstimation": "Rendement 100% loué", "rentNotStarted": "Le loyer n'a pas débuté", "isRmmAvailable": "RMM", "rentStatus": { From aafdb192f30c0e8683033ee7e4d8490c3be0233f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 9 Aug 2024 21:29:39 +0200 Subject: [PATCH 08/22] apply max APR method --- src/components/cards/AssetCard.tsx | 60 ++++++++++++------------------ 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index 23a4e6d..23f79be 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -167,12 +167,12 @@ const AssetCardComponent: FC = (props) => { } const fullyRentedRentEstimation = (token: UserRealtoken) => { - if (token.rentedUnits === 0 && token.annualPercentageYield !== 0) { + if (token.rentedUnits === token.totalUnits) { return token.annualPercentageYield } - if (token.rentedUnits !== 0 && token.annualPercentageYield !== 0) { - return (token.annualPercentageYield * token.totalUnits) / token.rentedUnits + if (token.rentedUnits === 0 && token.annualPercentageYield !== 0) { + return token.annualPercentageYield } const APREstimation = () => { @@ -183,43 +183,31 @@ const fullyRentedRentEstimation = (token: UserRealtoken) => { return propInfo }) - // Find last rent from history where property was fully rented - for (const h of history.reverse()) { - if ( - h.rentedUnits === token.totalUnits && - h.netRentYear && - h.tokenPrice - ) { - return (h.netRentYear / (token.totalTokens * h.tokenPrice)) * 100 - } - } - - // If no fully rented history, use last history - const lastHistory = history - .reverse() - .find( - (h) => - h.netRentYear && + const previousAPR = history + .map((h) => { + if ( h.rentedUnits && - h.tokenPrice && - token.rentedUnits !== 0, - ) - if ( - lastHistory && - lastHistory.netRentYear && - lastHistory.rentedUnits != 0 && - lastHistory.tokenPrice - ) - return ( - (token.totalUnits / token.rentedUnits) * - (lastHistory.netRentYear / - (token.totalTokens * lastHistory.tokenPrice)) * - 100 - ) + h.rentedUnits !== 0 && + h.netRentYear && + h.tokenPrice + ) { + return ( + ((h.netRentYear * token.totalUnits) / + (token.totalTokens * h.tokenPrice * h.rentedUnits)) * + 100 + ) + } + return 0 + }) + .filter((apr) => apr !== undefined) + + return Math.max(...previousAPR) + } else { + return 0 } } - return APREstimation() || 0 + return APREstimation() } export const AssetCard = memo(AssetCardComponent) From 7d79682b1c4b028a6ddec4d266fb302861c3a617 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 9 Aug 2024 21:37:56 +0200 Subject: [PATCH 09/22] rename variable and functions --- src/components/cards/AssetCard.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index 23f79be..4fcd666 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -48,8 +48,8 @@ const AssetCardComponent: FC = (props) => { const yearlyAmount = props.value.amount * props.value.netRentYearPerToken const totalInvestment = props.value.totalInvestment - const fullyRentedRentEstimationValue = - Math.floor(fullyRentedRentEstimation(props.value) * 100) / 100 + const fullyRentedAPR = + Math.floor(fullyRentedAPREstimation(props.value) * 100) / 100 return ( = (props) => {
{t('fullyRentedEstimation')}*
-
{fullyRentedRentEstimationValue} %
+
{fullyRentedAPR} %
@@ -166,7 +166,7 @@ const AssetCardComponent: FC = (props) => { ) } -const fullyRentedRentEstimation = (token: UserRealtoken) => { +const fullyRentedAPREstimation = (token: UserRealtoken) => { if (token.rentedUnits === token.totalUnits) { return token.annualPercentageYield } From 6462260fc09ca0f0caafac25c14f2fe553c7cb32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 15 Aug 2024 21:53:11 +0200 Subject: [PATCH 10/22] use hook --- src/components/cards/AssetCard.tsx | 52 +++------------------------ src/hooks/useFullyRentedAPR.ts | 58 ++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 47 deletions(-) create mode 100644 src/hooks/useFullyRentedAPR.ts diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index 4fcd666..f479b51 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -9,6 +9,7 @@ import { Badge, Card, Group } from '@mantine/core' import moment from 'moment' import { useCurrencyValue } from 'src/hooks/useCurrencyValue' +import { useFullyRentedAPR } from 'src/hooks/useFullyRentedAPR' import { selectUserRentCalculation } from 'src/store/features/settings/settingsSelector' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' import { RentCalculationState } from 'src/types/RentCalculation' @@ -48,8 +49,7 @@ const AssetCardComponent: FC = (props) => { const yearlyAmount = props.value.amount * props.value.netRentYearPerToken const totalInvestment = props.value.totalInvestment - const fullyRentedAPR = - Math.floor(fullyRentedAPREstimation(props.value) * 100) / 100 + const fullyRentedAPR = useFullyRentedAPR(props.value) return ( = (props) => {
{t('fullyRentedEstimation')}*
-
{fullyRentedAPR} %
+
+ {tNumbers('percent', { value: fullyRentedAPR })} +
@@ -166,48 +168,4 @@ const AssetCardComponent: FC = (props) => { ) } -const fullyRentedAPREstimation = (token: UserRealtoken) => { - if (token.rentedUnits === token.totalUnits) { - return token.annualPercentageYield - } - - if (token.rentedUnits === 0 && token.annualPercentageYield !== 0) { - return token.annualPercentageYield - } - - const APREstimation = () => { - if (token.history.length > 0) { - let propInfo = token.history[0].values - const history = token.history.map((h) => { - propInfo = { ...propInfo, ...h.values } - return propInfo - }) - - const previousAPR = history - .map((h) => { - if ( - h.rentedUnits && - h.rentedUnits !== 0 && - h.netRentYear && - h.tokenPrice - ) { - return ( - ((h.netRentYear * token.totalUnits) / - (token.totalTokens * h.tokenPrice * h.rentedUnits)) * - 100 - ) - } - return 0 - }) - .filter((apr) => apr !== undefined) - - return Math.max(...previousAPR) - } else { - return 0 - } - } - - return APREstimation() -} - export const AssetCard = memo(AssetCardComponent) diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts new file mode 100644 index 0000000..b36dab0 --- /dev/null +++ b/src/hooks/useFullyRentedAPR.ts @@ -0,0 +1,58 @@ +import { useEffect, useState } from 'react' + +import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' + +const fullyRentedAPREstimation = (token: UserRealtoken) => { + // Case of fully rented property + if (token.rentedUnits === token.totalUnits) { + return token.annualPercentageYield + } + + // Case of property with no rented unit but with APR (e.g. RMM or rent paid by inssurance) + if (token.rentedUnits === 0 && token.annualPercentageYield !== 0) { + return token.annualPercentageYield + } + + if (token.history.length > 0) { + let propInfo = token.history[0].values + const history = token.history.map((h) => { + propInfo = { ...propInfo, ...h.values } + return propInfo + }) + + const previousAPR = history + .map((h) => { + if ( + h.rentedUnits && + h.rentedUnits !== 0 && + h.netRentYear && + h.tokenPrice + ) { + return ( + ((h.netRentYear * token.totalUnits) / + (token.totalTokens * h.tokenPrice * h.rentedUnits)) * + 100 + ) + } + return 0 + }) + .filter((apr) => apr !== undefined) + + // Assuming the highest APR is the most accurate + return Math.max(...previousAPR, token.annualPercentageYield) + } + + return Math.max(token.annualPercentageYield, 0) +} + +export const useFullyRentedAPR = (token: UserRealtoken) => { + const [fullyRentedAPR, setFullyRentedAPR] = useState( + fullyRentedAPREstimation(token), + ) + + useEffect(() => { + setFullyRentedAPR(fullyRentedAPREstimation(token)) + }, [token]) + + return fullyRentedAPR +} From 86cfeb24829f4a661aa432d555bbd4973bf37ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 15 Aug 2024 22:11:05 +0200 Subject: [PATCH 11/22] add fallback --- src/components/cards/AssetCard.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/cards/AssetCard.tsx b/src/components/cards/AssetCard.tsx index f479b51..eb4f351 100644 --- a/src/components/cards/AssetCard.tsx +++ b/src/components/cards/AssetCard.tsx @@ -156,7 +156,9 @@ const AssetCardComponent: FC = (props) => {
{t('fullyRentedEstimation')}*
- {tNumbers('percent', { value: fullyRentedAPR })} + {fullyRentedAPR + ? tNumbers('percent', { value: fullyRentedAPR }) + : '-'}
From 3e0787abef5759e5ea552c03534abb90405ab7b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 15 Aug 2024 22:22:23 +0200 Subject: [PATCH 12/22] switch for a useMemo --- src/hooks/useFullyRentedAPR.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts index b36dab0..d4e08c3 100644 --- a/src/hooks/useFullyRentedAPR.ts +++ b/src/hooks/useFullyRentedAPR.ts @@ -1,4 +1,4 @@ -import { useEffect, useState } from 'react' +import { useMemo } from 'react' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' @@ -46,13 +46,7 @@ const fullyRentedAPREstimation = (token: UserRealtoken) => { } export const useFullyRentedAPR = (token: UserRealtoken) => { - const [fullyRentedAPR, setFullyRentedAPR] = useState( - fullyRentedAPREstimation(token), - ) - - useEffect(() => { - setFullyRentedAPR(fullyRentedAPREstimation(token)) - }, [token]) + const fullyRentedAPR = useMemo(() => fullyRentedAPREstimation(token), [token]) return fullyRentedAPR } From 175d3ff5ea766fadf3e040312eb5f98199a0dfed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 15 Aug 2024 22:55:19 +0200 Subject: [PATCH 13/22] feat: add real time fully rented APR --- src/hooks/useFullyRentedAPR.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts index d4e08c3..b7ff331 100644 --- a/src/hooks/useFullyRentedAPR.ts +++ b/src/hooks/useFullyRentedAPR.ts @@ -1,6 +1,11 @@ import { useMemo } from 'react' +import { useSelector } from 'react-redux' +import moment from 'moment' + +import { selectUserRentCalculation } from 'src/store/features/settings/settingsSelector' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' +import { RentCalculationState } from 'src/types/RentCalculation' const fullyRentedAPREstimation = (token: UserRealtoken) => { // Case of fully rented property @@ -46,7 +51,17 @@ const fullyRentedAPREstimation = (token: UserRealtoken) => { } export const useFullyRentedAPR = (token: UserRealtoken) => { - const fullyRentedAPR = useMemo(() => fullyRentedAPREstimation(token), [token]) + const rentCalculation = useSelector(selectUserRentCalculation) + + const fullyRentedAPR = useMemo(() => { + const realtimeDate = moment(new Date(rentCalculation.date)) + const rentStartDate = new Date(token.rentStartDate.date) + const isDisabled = + rentCalculation.state === RentCalculationState.Realtime && + rentStartDate > realtimeDate.toDate() + if (isDisabled) return 0 + return fullyRentedAPREstimation(token) + }, [token, rentCalculation]) return fullyRentedAPR } From d00acd306d246f6851874fbe84f612e1d6168b3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 15 Aug 2024 23:38:49 +0200 Subject: [PATCH 14/22] feat: add gloabl metric fully rented APR --- src/components/cards/main/RentsCard.tsx | 9 +++++ src/hooks/useFullyRentedAPR.ts | 44 +++++++++++++++++++++---- src/i18next/locales/en/common.json | 1 + src/i18next/locales/fr/common.json | 1 + 4 files changed, 49 insertions(+), 6 deletions(-) diff --git a/src/components/cards/main/RentsCard.tsx b/src/components/cards/main/RentsCard.tsx index 2f1f188..20df43e 100644 --- a/src/components/cards/main/RentsCard.tsx +++ b/src/components/cards/main/RentsCard.tsx @@ -4,7 +4,9 @@ import { useSelector } from 'react-redux' import { Box, Card, Title } from '@mantine/core' +import { useGeneralFullyRentedAPR } from 'src/hooks/useFullyRentedAPR' import { + selectOwnedRealtokens, selectOwnedRealtokensAPY, selectOwnedRealtokensRents, } from 'src/store/features/wallets/walletsSelector' @@ -16,6 +18,7 @@ export const RentsCard: FC = () => { const rents = useSelector(selectOwnedRealtokensRents) const apy = useSelector(selectOwnedRealtokensAPY) + const realtokens = useSelector(selectOwnedRealtokens) // In Dollars const dailyRents = rents.daily @@ -23,11 +26,17 @@ export const RentsCard: FC = () => { const monthlyRents = rents.monthly const yearlyRents = rents.yearly + const fullyRentedAPR = useGeneralFullyRentedAPR(realtokens) + return ( {t('title')} + diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts index b7ff331..15519b3 100644 --- a/src/hooks/useFullyRentedAPR.ts +++ b/src/hooks/useFullyRentedAPR.ts @@ -5,7 +5,10 @@ import moment from 'moment' import { selectUserRentCalculation } from 'src/store/features/settings/settingsSelector' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' -import { RentCalculationState } from 'src/types/RentCalculation' +import { + RentCalculation, + RentCalculationState, +} from 'src/types/RentCalculation' const fullyRentedAPREstimation = (token: UserRealtoken) => { // Case of fully rented property @@ -54,14 +57,43 @@ export const useFullyRentedAPR = (token: UserRealtoken) => { const rentCalculation = useSelector(selectUserRentCalculation) const fullyRentedAPR = useMemo(() => { - const realtimeDate = moment(new Date(rentCalculation.date)) - const rentStartDate = new Date(token.rentStartDate.date) - const isDisabled = - rentCalculation.state === RentCalculationState.Realtime && - rentStartDate > realtimeDate.toDate() + const isDisabled = APRDisabled(rentCalculation, token) if (isDisabled) return 0 return fullyRentedAPREstimation(token) }, [token, rentCalculation]) return fullyRentedAPR } + +export const useGeneralFullyRentedAPR = (tokens: UserRealtoken[]) => { + const rentCalculation = useSelector(selectUserRentCalculation) + // Fully rented APR average using valuation ponderation + const fullyRentedAPR = useMemo(() => { + const totalValue = tokens.reduce((acc, token) => { + const isDisabled = APRDisabled(rentCalculation, token) + if (isDisabled) return acc + return acc + token.value + }, 0) + const totalAPR = tokens.reduce((acc, token) => { + const isDisabled = APRDisabled(rentCalculation, token) + if (isDisabled) return acc + return acc + token.value * fullyRentedAPREstimation(token) + }, 0) + console.log({ totalValue, totalAPR, fullyRentedAPR: totalAPR / totalValue }) + return totalAPR / totalValue + }, [tokens, rentCalculation]) + + return fullyRentedAPR +} + +const APRDisabled = ( + rentCalculation: RentCalculation, + token: UserRealtoken, +) => { + const realtimeDate = moment(new Date(rentCalculation.date)) + const rentStartDate = new Date(token.rentStartDate.date) + const isDisabled = + rentCalculation.state === RentCalculationState.Realtime && + rentStartDate > realtimeDate.toDate() + return isDisabled +} diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index 9a83d0d..fe13057 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -81,6 +81,7 @@ "rentsCard": { "title": "Rents", "apr": "APR", + "fullyRentedAPR": "Fully rented APR *", "daily": "Daily", "weekly": "Weekly", "monthly": "Monthly", diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index e0aa856..211783c 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -81,6 +81,7 @@ "rentsCard": { "title": "Loyers", "apr": "Rendement annuel", + "fullyRentedAPR": "Rendement 100% loué *", "daily": "Journaliers", "weekly": "Hebdomadaires", "monthly": "Mensuels", From 8cded5da8c597ebe9446a2e1e8344054884b7f76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Thu, 15 Aug 2024 23:52:02 +0200 Subject: [PATCH 15/22] feat: add disclaimer --- src/components/assetsView/views/AssetGrid.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/assetsView/views/AssetGrid.tsx b/src/components/assetsView/views/AssetGrid.tsx index c794c38..edfbb81 100644 --- a/src/components/assetsView/views/AssetGrid.tsx +++ b/src/components/assetsView/views/AssetGrid.tsx @@ -2,7 +2,7 @@ import { FC, useEffect, useMemo, useState } from 'react' import { useRouter } from 'next/router' -import { Grid, Group, Pagination } from '@mantine/core' +import { Grid, Group, Pagination, Text } from '@mantine/core' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' @@ -56,6 +56,12 @@ export const AssetGrid: FC<{ realtokens: UserRealtoken[] }> = (props) => { onChange={onPageChange} /> + + * This is a beta estimation done by RealT community. Please report any + issues. Please note that is an indicative value and not a guarantee. + RealT community does not take any responsibility for the accuracy of + this information. + ) } From cdc615fdfabb7f0bbaa66b21a32513236556f255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 16 Aug 2024 00:11:42 +0200 Subject: [PATCH 16/22] feat: add disclaimer --- src/components/assetsView/views/AssetGrid.tsx | 8 ++------ .../commons/others/FullyRentedAPRDisclaimer.tsx | 14 ++++++++++++++ src/i18next/locales/en/common.json | 3 +++ src/i18next/locales/fr/common.json | 3 +++ 4 files changed, 22 insertions(+), 6 deletions(-) create mode 100644 src/components/commons/others/FullyRentedAPRDisclaimer.tsx diff --git a/src/components/assetsView/views/AssetGrid.tsx b/src/components/assetsView/views/AssetGrid.tsx index edfbb81..cf430f8 100644 --- a/src/components/assetsView/views/AssetGrid.tsx +++ b/src/components/assetsView/views/AssetGrid.tsx @@ -4,6 +4,7 @@ import { useRouter } from 'next/router' import { Grid, Group, Pagination, Text } from '@mantine/core' +import FullyRentedAPRDisclaimer from 'src/components/commons/others/FullyRentedAPRDisclaimer' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' import { AssetCard } from '../../cards' @@ -55,13 +56,8 @@ export const AssetGrid: FC<{ realtokens: UserRealtoken[] }> = (props) => { size={'sm'} onChange={onPageChange} /> + - - * This is a beta estimation done by RealT community. Please report any - issues. Please note that is an indicative value and not a guarantee. - RealT community does not take any responsibility for the accuracy of - this information. - ) } diff --git a/src/components/commons/others/FullyRentedAPRDisclaimer.tsx b/src/components/commons/others/FullyRentedAPRDisclaimer.tsx new file mode 100644 index 0000000..8a977cd --- /dev/null +++ b/src/components/commons/others/FullyRentedAPRDisclaimer.tsx @@ -0,0 +1,14 @@ +import { useTranslation } from 'react-i18next' + +import { Text } from '@mantine/core' + +const FullyRentedAPRDisclaimer = () => { + const { t } = useTranslation('common', { keyPrefix: 'disclaimer' }) + return ( + + *{t('fullyRentedAPR')} + + ) +} + +export default FullyRentedAPRDisclaimer diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index fe13057..ceb12ce 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -372,5 +372,8 @@ "initialTransfersLoader": { "title": "Initial data loading", "description": "Retrieving your transactions in progress. This loading can take some time depending on the number of transactions performed (10-20 seconds / 1000 transactions). On your next visits, only new transactions will be retrieved." + }, + "disclaimer":{ + "fullyRentedAPR": "This is a beta estimation done by RealT community. Please report any issues. Please note that is an indicative value and not a guarantee. RealT community does not take any responsibility for the accuracy of this information." } } diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index 211783c..88de786 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -374,5 +374,8 @@ "initialTransfersLoader": { "title": "Chargement initial des données", "description": "Récupération de vos transactions en cours. Ce chargement peut prendre un certain temps en fonction du nombre de transactions effecutées (10-20 secondes / 1000 transactions). Lors de vos prochaines visites, seul les nouvelles transactions seront récupérées." + }, + "disclaimer":{ + "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ne peut être tenu responsable en cas d'inexactitude des données." } } From 1ae5788c6f416cd3b5ecd823ad36cf3451661f26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 16 Aug 2024 00:13:03 +0200 Subject: [PATCH 17/22] feat: update disclaimer message --- src/i18next/locales/en/common.json | 2 +- src/i18next/locales/fr/common.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index ceb12ce..ee2690e 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -374,6 +374,6 @@ "description": "Retrieving your transactions in progress. This loading can take some time depending on the number of transactions performed (10-20 seconds / 1000 transactions). On your next visits, only new transactions will be retrieved." }, "disclaimer":{ - "fullyRentedAPR": "This is a beta estimation done by RealT community. Please report any issues. Please note that is an indicative value and not a guarantee. RealT community does not take any responsibility for the accuracy of this information." + "fullyRentedAPR": "This is a beta estimation done by RealT community. Please report any issues. Please note that is an indicative value and not a guarantee. RealT community or RealT does not take any responsibility for the accuracy of this information." } } diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index 88de786..deda98b 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -376,6 +376,6 @@ "description": "Récupération de vos transactions en cours. Ce chargement peut prendre un certain temps en fonction du nombre de transactions effecutées (10-20 secondes / 1000 transactions). Lors de vos prochaines visites, seul les nouvelles transactions seront récupérées." }, "disclaimer":{ - "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ne peut être tenu responsable en cas d'inexactitude des données." + "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT ou RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ne peut être tenu responsable en cas d'inexactitude des données." } } From 72abe3171ee53c4d88858006a720793db0eee0e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 16 Aug 2024 00:16:05 +0200 Subject: [PATCH 18/22] fix: disclaimer message --- src/i18next/locales/fr/common.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index deda98b..f5f81b8 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -376,6 +376,6 @@ "description": "Récupération de vos transactions en cours. Ce chargement peut prendre un certain temps en fonction du nombre de transactions effecutées (10-20 secondes / 1000 transactions). Lors de vos prochaines visites, seul les nouvelles transactions seront récupérées." }, "disclaimer":{ - "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT ou RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ne peut être tenu responsable en cas d'inexactitude des données." + "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ou RealT ne peut être tenu responsable en cas d'inexactitude des données." } } From 417c0381ff84f72bb69f14b03f41db9671e62e96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Fri, 16 Aug 2024 00:18:19 +0200 Subject: [PATCH 19/22] improve message --- src/i18next/locales/en/common.json | 2 +- src/i18next/locales/fr/common.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index ee2690e..0a0861b 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -374,6 +374,6 @@ "description": "Retrieving your transactions in progress. This loading can take some time depending on the number of transactions performed (10-20 seconds / 1000 transactions). On your next visits, only new transactions will be retrieved." }, "disclaimer":{ - "fullyRentedAPR": "This is a beta estimation done by RealT community. Please report any issues. Please note that is an indicative value and not a guarantee. RealT community or RealT does not take any responsibility for the accuracy of this information." + "fullyRentedAPR": "This is a beta estimation done by RealT community. Please report any issues. Please note that is an indicative value and not a guarantee. RealT community or RealT does not take any responsibility for user actions based on this value." } } diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index f5f81b8..dc9094a 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -376,6 +376,6 @@ "description": "Récupération de vos transactions en cours. Ce chargement peut prendre un certain temps en fonction du nombre de transactions effecutées (10-20 secondes / 1000 transactions). Lors de vos prochaines visites, seul les nouvelles transactions seront récupérées." }, "disclaimer":{ - "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ou RealT ne peut être tenu responsable en cas d'inexactitude des données." + "fullyRentedAPR": "Cette estimation est en phase bêta et a été développée par la communauté RealT. Nous vous invitons à signaler tout problème éventuel. Les informations fournies sont à titre indicatif uniquement. La communauté RealT ou RealT ne peut être tenu responsable en cas de décision prise à partir de données inexactites." } } From 94102b83b367a34ddb985f8a19acee2a8eebf6e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Sat, 17 Aug 2024 23:08:30 +0200 Subject: [PATCH 20/22] feat: add fully rented APR to asset grid --- src/components/assetsView/views/AssetTable.tsx | 13 +++++++++++++ src/i18next/locales/en/common.json | 1 + src/i18next/locales/fr/common.json | 1 + 3 files changed, 15 insertions(+) diff --git a/src/components/assetsView/views/AssetTable.tsx b/src/components/assetsView/views/AssetTable.tsx index 3e85df8..f125cc5 100644 --- a/src/components/assetsView/views/AssetTable.tsx +++ b/src/components/assetsView/views/AssetTable.tsx @@ -9,6 +9,7 @@ import { Anchor, ScrollArea, Table } from '@mantine/core' import moment from 'moment' import { useCurrencyValue } from 'src/hooks/useCurrencyValue' +import { useFullyRentedAPR } from 'src/hooks/useFullyRentedAPR' import { selectTransfersIsLoaded } from 'src/store/features/transfers/transfersSelector' import { RWARealtoken, @@ -62,6 +63,7 @@ const AssetTableHeader: FC = () => { ) : null} {t('ownedTokens')} {t('apr')} + {t('fullyRentedAPR')} {t('weeklyRents')} {t('yearlyRents')} {t('rentedUnits')} @@ -85,6 +87,10 @@ const AssetTableRow: FC<{ value: UserRealtoken }> = (props) => { const weeklyAmount = props.value.amount * props.value.netRentDayPerToken * 7 const yearlyAmount = props.value.amount * props.value.netRentYearPerToken const totalInvestment = props.value.totalInvestment + const isAProperty = props.value.hasOwnProperty('rentStatus') + const fullyRentedAPR = isAProperty + ? useFullyRentedAPR(props.value as UserRealtoken) + : null return ( @@ -121,6 +127,13 @@ const AssetTableRow: FC<{ value: UserRealtoken }> = (props) => { {t('percent', { value: props.value.annualPercentageYield })} + {isAProperty ? ( + + {t('percent', { value: fullyRentedAPR })} + + ) : ( + + )} {useCurrencyValue(weeklyAmount)} diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index 4c6fd71..53105be 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -215,6 +215,7 @@ "unitPriceCost": "Unit price cost", "unrealizedCapitalGain": "Capital gain", "apr": "Yield", + "fullyRentedAPR":"Fully rented APR *", "weeklyRents": "Weekly rents", "yearlyRents": "Yearly rents", "rentedUnits": "Rented units", diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index eb6998b..65e42cb 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -215,6 +215,7 @@ "tokenPrice": "Prix du token", "unitPriceCost": "Prix de revient", "apr": "Rendement annuel", + "fullyRentedAPR":"Rendement 100% loué *", "weeklyRents": "Loyer hebdo", "yearlyRents": "Loyer annuel", "rentedUnits": "Logements loués", From 791ef7716d48eeba8f406e96ad75cd3c5e1ae408 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Sat, 17 Aug 2024 23:09:56 +0200 Subject: [PATCH 21/22] refactor: remove logs --- src/components/assetsView/views/AssetGrid.tsx | 1 - src/hooks/useFullyRentedAPR.ts | 1 - src/pages/yamStatistics.tsx | 2 -- 3 files changed, 4 deletions(-) diff --git a/src/components/assetsView/views/AssetGrid.tsx b/src/components/assetsView/views/AssetGrid.tsx index 94964ea..930c9a6 100644 --- a/src/components/assetsView/views/AssetGrid.tsx +++ b/src/components/assetsView/views/AssetGrid.tsx @@ -33,7 +33,6 @@ export const AssetGrid: FC<{ realtokens: (UserRealtoken | RWARealtoken)[] }> = ( } const paginationOffers: (UserRealtoken | RWARealtoken)[] = useMemo(() => { - console.log({ realtokens: props.realtokens }) if (pageSize === Infinity) return props.realtokens const start = (page - 1) * pageSize const end = start + pageSize diff --git a/src/hooks/useFullyRentedAPR.ts b/src/hooks/useFullyRentedAPR.ts index 15519b3..08f166a 100644 --- a/src/hooks/useFullyRentedAPR.ts +++ b/src/hooks/useFullyRentedAPR.ts @@ -79,7 +79,6 @@ export const useGeneralFullyRentedAPR = (tokens: UserRealtoken[]) => { if (isDisabled) return acc return acc + token.value * fullyRentedAPREstimation(token) }, 0) - console.log({ totalValue, totalAPR, fullyRentedAPR: totalAPR / totalValue }) return totalAPR / totalValue }, [tokens, rentCalculation]) diff --git a/src/pages/yamStatistics.tsx b/src/pages/yamStatistics.tsx index e130f6b..86f7cd8 100644 --- a/src/pages/yamStatistics.tsx +++ b/src/pages/yamStatistics.tsx @@ -87,7 +87,6 @@ const YamStatisticsPage = () => { } const yamStatisticsPromise: Promise = useMemo(async () => { - console.log({ realtokens }) if (!realtokensWithYam.length) return Promise.resolve([]) const statsPromises = realtokensWithYam.map((realtoken) => GetYamStatistics({ realtoken }), @@ -101,7 +100,6 @@ const YamStatisticsPage = () => { yamStatisticsPromise.then((data) => { setYamStatistics(data) setIsLoading(false) - console.log({ data }) }) }, [yamStatisticsPromise]) From 86b991d0056c5fcf2287f21178abf4a1bd097729 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nandy=20B=C3=A2?= Date: Sat, 17 Aug 2024 23:48:45 +0200 Subject: [PATCH 22/22] feat: add fully rented APR to property details --- src/components/assetPage/assetPagePropertyTab.tsx | 7 +++++++ src/i18next/locales/en/common.json | 1 + src/i18next/locales/fr/common.json | 1 + src/pages/asset/[assetId].tsx | 2 ++ 4 files changed, 11 insertions(+) diff --git a/src/components/assetPage/assetPagePropertyTab.tsx b/src/components/assetPage/assetPagePropertyTab.tsx index 49f6dfb..b3f58a6 100644 --- a/src/components/assetPage/assetPagePropertyTab.tsx +++ b/src/components/assetPage/assetPagePropertyTab.tsx @@ -2,6 +2,7 @@ import { FC } from 'react' import { useTranslation } from 'react-i18next' import { useCurrencyValue } from 'src/hooks/useCurrencyValue' +import { useFullyRentedAPR } from 'src/hooks/useFullyRentedAPR' import { UserRealtoken } from 'src/store/features/wallets/walletsSelector' import { RealTokenRentalType } from 'src/types/RealToken' @@ -44,6 +45,8 @@ export const AssetPagePropertyTab: FC<{ const propertyStories = realtoken.propertyStories ? tNumbers('integer', { value: realtoken.propertyStories }) : '-' + const fullyRentedAPR = useFullyRentedAPR(realtoken) + const fullyRentedAPRValue = tNumbers('percent', { value: fullyRentedAPR }) return ( <> @@ -106,6 +109,10 @@ export const AssetPagePropertyTab: FC<{ label: t('annualYield'), value: annualYield, }, + { + label: t('fullyRentedAPR'), + value: fullyRentedAPRValue, + }, ]} /> diff --git a/src/i18next/locales/en/common.json b/src/i18next/locales/en/common.json index 53105be..f5facca 100644 --- a/src/i18next/locales/en/common.json +++ b/src/i18next/locales/en/common.json @@ -264,6 +264,7 @@ "grossRentMonth": "Gross monthly rent", "netRentMonth": "Net monthly rent", "annualYield": "Annual yield", + "fullyRentedAPR": "Fully rented APR *", "constructionYear": "Construction year", "propertyStories": "Number of stories", "propertyUnits": "Number of units", diff --git a/src/i18next/locales/fr/common.json b/src/i18next/locales/fr/common.json index 65e42cb..f5bdbfa 100644 --- a/src/i18next/locales/fr/common.json +++ b/src/i18next/locales/fr/common.json @@ -264,6 +264,7 @@ "grossRentMonth": "Loyer brut mensuel", "netRentMonth": "Loyer net mensuel", "annualYield": "Rendement annuel", + "fullyRentedAPR": "Rendement 100% loué *", "constructionYear": "Année de construction", "propertyStories": "Nombre d'étages", "propertyUnits": "Nombre de logements", diff --git a/src/pages/asset/[assetId].tsx b/src/pages/asset/[assetId].tsx index 2d2a1ad..9c93d54 100644 --- a/src/pages/asset/[assetId].tsx +++ b/src/pages/asset/[assetId].tsx @@ -14,6 +14,7 @@ import { AssetPageMainTab } from 'src/components/assetPage/assetPageMainTab' import { AssetPagePropertyTab } from 'src/components/assetPage/assetPagePropertyTab' import { AssetPageTransfersTab } from 'src/components/assetPage/assetPageTransfersTab' import { AssetPageYamStatisticsTab } from 'src/components/assetPage/assetPageYamStatisticsTab' +import FullyRentedAPRDisclaimer from 'src/components/commons/others/FullyRentedAPRDisclaimer' import { selectIsLoading } from 'src/store/features/settings/settingsSelector' import { selectTransfersIsLoaded } from 'src/store/features/transfers/transfersSelector' import { selectAllUserRealtokens } from 'src/store/features/wallets/walletsSelector' @@ -158,6 +159,7 @@ const AssetPage: NextPage = () => {
+ ) }