From 0d505a336eaa4ee7e88c9e5bc5c4d193c05a9dba Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Tue, 31 Aug 2021 17:20:20 +0100 Subject: [PATCH 1/5] chore(vBump): hotfix v1.4.1 fix(notifier): makes safer expiration date calc (cherry picked from commit c95a872566d0253606e074cb6fedf9386ebafc69) --- package-lock.json | 2 +- package.json | 2 +- src/components/molecules/ExpirationDate.tsx | 8 ++++---- src/components/organisms/notifier/buy/CheckoutPayment.tsx | 2 +- src/components/organisms/notifier/buy/CheckoutStepper.tsx | 7 ++++--- .../pages/notifier/buy/NotifierOfferCheckoutPage.tsx | 2 +- .../pages/notifier/myoffers/mapActiveContracts.tsx | 8 ++------ .../pages/notifier/mypurchase/NotifierMyPurchasePage.tsx | 2 +- 8 files changed, 15 insertions(+), 18 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9b212f830..9c165f687 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rif-marketplace-ui", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index b20d7ae44..a509097d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rif-marketplace-ui", - "version": "1.4.0", + "version": "1.4.1", "description": "RIF Marketplace provides a digital catalogue with a wide range of decentralised services.", "keywords": [ "RIF", diff --git a/src/components/molecules/ExpirationDate.tsx b/src/components/molecules/ExpirationDate.tsx index 5f7923673..1a4f5a200 100644 --- a/src/components/molecules/ExpirationDate.tsx +++ b/src/components/molecules/ExpirationDate.tsx @@ -1,4 +1,4 @@ -import Typography from '@material-ui/core/Typography' +import Typography, { TypographyProps } from '@material-ui/core/Typography' import React, { FC } from 'react' import { getShortDateString } from 'utils/dateUtils' import { @@ -35,10 +35,10 @@ type Props = { className?: string date: Date type: SubscriptionExpirationType -} +} & TypographyProps const ExpirationDate: FC = ({ - className = '', date, type, + className = '', date, type, ...typoProps }) => { const classes = useStyles() @@ -51,7 +51,7 @@ const ExpirationDate: FC = ({ className={`${classes[type]} ${className}`} > - + {getShortDateString(date)} diff --git a/src/components/organisms/notifier/buy/CheckoutPayment.tsx b/src/components/organisms/notifier/buy/CheckoutPayment.tsx index feab880f5..f677c42ad 100644 --- a/src/components/organisms/notifier/buy/CheckoutPayment.tsx +++ b/src/components/organisms/notifier/buy/CheckoutPayment.tsx @@ -61,7 +61,7 @@ const CheckoutPayment: FC = ({ web3 as Web3, account as string, selectedTokenSymbol, ) setHasEnoughFunds(Big(balance).gte(cryptoPrice)) - } catch (error) { + } catch (error: any) { reportError({ error, id: 'get-balance', diff --git a/src/components/organisms/notifier/buy/CheckoutStepper.tsx b/src/components/organisms/notifier/buy/CheckoutStepper.tsx index aa63cba28..b9a9a88d1 100644 --- a/src/components/organisms/notifier/buy/CheckoutStepper.tsx +++ b/src/components/organisms/notifier/buy/CheckoutStepper.tsx @@ -19,9 +19,10 @@ type Props = { } const getExpirationDate = (daysLeft: number): Date => { - const retDate = new Date() - retDate.setDate(retDate.getDate() + daysLeft) - return retDate + const expirationDate = new Date() + expirationDate.setUTCHours(0, 0, 0, 0) + expirationDate.setUTCDate(expirationDate.getDate() + daysLeft) + return new Date(expirationDate) } const CheckoutStepper: FC = ( diff --git a/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx b/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx index 9e7666cd9..038326423 100644 --- a/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx +++ b/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx @@ -122,7 +122,7 @@ const NotifierOfferCheckoutPage: FC = () => { }, }) } - } catch (error) { + } catch (error: any) { const { customMessage } = error reportError({ error, diff --git a/src/components/pages/notifier/myoffers/mapActiveContracts.tsx b/src/components/pages/notifier/myoffers/mapActiveContracts.tsx index 22e7aeaca..f75aff64b 100644 --- a/src/components/pages/notifier/myoffers/mapActiveContracts.tsx +++ b/src/components/pages/notifier/myoffers/mapActiveContracts.tsx @@ -6,12 +6,12 @@ import MarketplaceAddressCell from 'components/molecules/MarketplaceAddressCell' import NotificationsBalance from 'components/molecules/notifier/NotificationsBalance' import { Item, MarketCryptoRecord } from 'models/Market' import { NotifierOfferItem, NotifierSubscriptionItem } from 'models/marketItems/NotifierItem' -import { getShortDateString } from 'utils/dateUtils' import { BaseFiat } from 'models/Fiat' import { getFiatPrice } from 'utils/priceUtils' import RoundBtn from 'components/atoms/RoundBtn' import { ConfirmationData, SubscriptionWithdrawData } from 'context/Confirmations/interfaces' import { Spinner } from '@rsksmart/rif-ui' +import ExpirationDate from 'components/molecules/ExpirationDate' export const activeContractHeaders = { customer: 'Customer', @@ -76,11 +76,7 @@ const mapActiveContracts = ( { id, customer: , - expDate: ( - - {getShortDateString(expirationDate)} - - ), + expDate: , notifBalance: { }, }) } - } catch (error) { + } catch (error: any) { const { customMessage } = error reportError({ error, From 62625b7abba25a3326410d882505189dddd1d97c Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Fri, 3 Sep 2021 09:41:58 +0100 Subject: [PATCH 2/5] feat: removes staging --- .github/workflows/backport.yml | 2 +- .github/workflows/staging.yml | 60 ---------------------------------- 2 files changed, 1 insertion(+), 61 deletions(-) delete mode 100644 .github/workflows/staging.yml diff --git a/.github/workflows/backport.yml b/.github/workflows/backport.yml index 90d897391..c6b592cf4 100644 --- a/.github/workflows/backport.yml +++ b/.github/workflows/backport.yml @@ -15,5 +15,5 @@ jobs: - name: backport uses: rsksmart/rif-marketplace-backport@v1 with: - branches: develop,staging,testnet,mainnet + branches: develop,testnet,mainnet github_token: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/staging.yml b/.github/workflows/staging.yml deleted file mode 100644 index 0f25c35c2..000000000 --- a/.github/workflows/staging.yml +++ /dev/null @@ -1,60 +0,0 @@ -name: RIF Marketplace UI deploy - -on: - push: - branches: - - staging - -jobs: - deploy-staging: - name: RIF Marketplace UI - Staging - runs-on: ubuntu-latest - environment: staging - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Setup Node 14 - uses: actions/setup-node@v1 - with: - node-version: '14' - - - uses: actions/cache@v2 - id: cache - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - restore-keys: | - ${{ runner.os }}-node- - - - name: Install dependencies - run: | - npm ci - - - name: Build site - env: - REACT_APP_CACHE_ADDR: ${{ secrets.STAGING_REACT_APP_CACHE_ADDR }} - REACT_APP_UPLOAD_ADDR: ${{ secrets.STAGING_REACT_APP_UPLOAD_ADDR }} - REACT_APP_LOG_LEVEL: error - REACT_APP_NETWORK: rskstaging - REACT_APP_REQUIRED_NETWORK_ID: 31 - REACT_APP_REQUIRED_NETWORK_NAME: RSK Staging - run: | - npm run build:prod - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - aws-access-key-id: ${{ secrets.STAGING_AWS_ACCESS_KEY_ID }} - aws-secret-access-key: ${{ secrets.STAGING_AWS_SECRET_ACCESS_KEY }} - aws-region: ${{ secrets.STAGING_AWS_REGION }} - - - name: Deploy site to S3 - run: | - aws s3 sync --delete --only-show-errors build/ ${{ secrets.STAGING_S3_BUCKET }} - - - name: Invalidate CloudFront cache - run: | - aws cloudfront create-invalidation --distribution-id ${{ secrets.STAGING_CLOUDFRONT_DISTRIBUTION }} --paths "/*" - From 569fc01eaef3c36f6f529f2b305dc721418a692e Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Fri, 3 Sep 2021 11:36:12 +0100 Subject: [PATCH 3/5] fix(hotfix): v1.4.2 - removes breaking typing of errors (cherry picked from commit db46ca14b6079023abe99d03a9190c63a711cd7e) --- package-lock.json | 4 ++-- package.json | 4 ++-- src/components/organisms/notifier/buy/CheckoutPayment.tsx | 2 +- .../pages/notifier/buy/NotifierOfferCheckoutPage.tsx | 2 +- .../pages/notifier/mypurchase/NotifierMyPurchasePage.tsx | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/package-lock.json b/package-lock.json index 9c165f687..76cba2a7b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rif-marketplace-ui", - "version": "1.4.1", + "version": "1.4.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -19719,4 +19719,4 @@ "integrity": "sha1-AI4G2AlDIMNy28L47XagymyKxBk=" } } -} +} \ No newline at end of file diff --git a/package.json b/package.json index a509097d4..3d897ffd6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rif-marketplace-ui", - "version": "1.4.1", + "version": "1.4.2", "description": "RIF Marketplace provides a digital catalogue with a wide range of decentralised services.", "keywords": [ "RIF", @@ -107,4 +107,4 @@ "\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "/__mocks__/fileMock.ts" } } -} +} \ No newline at end of file diff --git a/src/components/organisms/notifier/buy/CheckoutPayment.tsx b/src/components/organisms/notifier/buy/CheckoutPayment.tsx index f677c42ad..feab880f5 100644 --- a/src/components/organisms/notifier/buy/CheckoutPayment.tsx +++ b/src/components/organisms/notifier/buy/CheckoutPayment.tsx @@ -61,7 +61,7 @@ const CheckoutPayment: FC = ({ web3 as Web3, account as string, selectedTokenSymbol, ) setHasEnoughFunds(Big(balance).gte(cryptoPrice)) - } catch (error: any) { + } catch (error) { reportError({ error, id: 'get-balance', diff --git a/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx b/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx index 038326423..9e7666cd9 100644 --- a/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx +++ b/src/components/pages/notifier/buy/NotifierOfferCheckoutPage.tsx @@ -122,7 +122,7 @@ const NotifierOfferCheckoutPage: FC = () => { }, }) } - } catch (error: any) { + } catch (error) { const { customMessage } = error reportError({ error, diff --git a/src/components/pages/notifier/mypurchase/NotifierMyPurchasePage.tsx b/src/components/pages/notifier/mypurchase/NotifierMyPurchasePage.tsx index ac27413c4..2f35ea2c3 100644 --- a/src/components/pages/notifier/mypurchase/NotifierMyPurchasePage.tsx +++ b/src/components/pages/notifier/mypurchase/NotifierMyPurchasePage.tsx @@ -225,7 +225,7 @@ const NotifierMyPurchasePage: FC = () => { }, }) } - } catch (error: any) { + } catch (error) { const { customMessage } = error reportError({ error, From 3f22d69e66b7644b267315901ee363dc685175ac Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Mon, 6 Sep 2021 14:33:20 +0100 Subject: [PATCH 4/5] fix(storage): fixes visual defects + buggy mapping --- package-lock.json | 2 +- package.json | 2 +- src/components/molecules/RifAddress.tsx | 9 +- src/components/molecules/index.ts | 2 +- .../organisms/rns/sell/MyDomains.tsx | 4 +- .../organisms/rns/sell/MyOffers.tsx | 4 +- .../organisms/rns/sell/SoldDomains.tsx | 6 +- .../storage/agreements/DetailsModal.tsx | 13 +- .../organisms/storage/agreements/utils.tsx | 235 +++++++++--------- .../pages/notifier/buy/NotifierOffersPage.tsx | 4 +- .../pages/rns/buy/DomainOffersPage.tsx | 6 +- .../pages/storage/buy/StorageOffersPage.tsx | 4 +- 12 files changed, 155 insertions(+), 136 deletions(-) diff --git a/package-lock.json b/package-lock.json index 76cba2a7b..1d33fd1e8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "rif-marketplace-ui", - "version": "1.4.2", + "version": "1.4.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 3d897ffd6..38feb79a8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rif-marketplace-ui", - "version": "1.4.2", + "version": "1.4.3", "description": "RIF Marketplace provides a digital catalogue with a wide range of decentralised services.", "keywords": [ "RIF", diff --git a/src/components/molecules/RifAddress.tsx b/src/components/molecules/RifAddress.tsx index 2cd881fd4..0992f423b 100644 --- a/src/components/molecules/RifAddress.tsx +++ b/src/components/molecules/RifAddress.tsx @@ -1,15 +1,18 @@ import Typography, { TypographyProps } from '@material-ui/core/Typography' -import { CopyTextTooltip } from '@rsksmart/rif-ui' +import { CopyTextTooltip, shortenString } from '@rsksmart/rif-ui' import React, { FC } from 'react' import { shortChecksumAddress } from 'utils/stringUtils' export interface RifAddressProps extends TypographyProps { pretext?: string value: string + disableChecksum?: boolean } -const RifAddress: FC = ({ pretext, value, ...rest }) => { - const address = shortChecksumAddress(value) +const RifAddress: FC = ({ + pretext, value, disableChecksum, ...rest +}) => { + const address = disableChecksum ? shortenString(value) : shortChecksumAddress(value) const displayElement = ( diff --git a/src/components/molecules/index.ts b/src/components/molecules/index.ts index b434449c2..b3a1f1bb2 100644 --- a/src/components/molecules/index.ts +++ b/src/components/molecules/index.ts @@ -9,7 +9,7 @@ export { CombinedPriceCell, IconedItem, ReturnButton, - RifAddress as AddressItem, + RifAddress, JobDoneBox, SelectRowButton, } diff --git a/src/components/organisms/rns/sell/MyDomains.tsx b/src/components/organisms/rns/sell/MyDomains.tsx index e65881e00..3bb97fa8f 100644 --- a/src/components/organisms/rns/sell/MyDomains.tsx +++ b/src/components/organisms/rns/sell/MyDomains.tsx @@ -1,4 +1,4 @@ -import { AddressItem, SelectRowButton } from 'components/molecules' +import { RifAddress, SelectRowButton } from 'components/molecules' import DomainFilters from 'components/organisms/filters/DomainFilters' import MarketPageTemplate from 'components/templates/MarketPageTemplate' import { RnsDomain } from 'models/marketItems/DomainItem' @@ -70,7 +70,7 @@ const MyDomains: FC = () => { maxLength={30} /> ) - : + : const isProcessingConfs = pendingConfs.some( ({ contractActionData }) => ( diff --git a/src/components/organisms/rns/sell/MyOffers.tsx b/src/components/organisms/rns/sell/MyOffers.tsx index ad031758e..81095e0f4 100644 --- a/src/components/organisms/rns/sell/MyOffers.tsx +++ b/src/components/organisms/rns/sell/MyOffers.tsx @@ -1,6 +1,6 @@ import IconButton from '@material-ui/core/IconButton' import ClearIcon from '@material-ui/icons/Clear' -import { AddressItem, CombinedPriceCell, SelectRowButton } from 'components/molecules' +import { RifAddress, CombinedPriceCell, SelectRowButton } from 'components/molecules' import DomainFilters from 'components/organisms/filters/DomainFilters' import MarketPageTemplate from 'components/templates/MarketPageTemplate' import { RnsDomain } from 'models/marketItems/DomainItem' @@ -76,7 +76,7 @@ const MyOffers: FC = () => { maxLength={30} /> ) - : + : const isProcessingConfs = pendingConfs.some( ({ contractActionData }) => ( diff --git a/src/components/organisms/rns/sell/SoldDomains.tsx b/src/components/organisms/rns/sell/SoldDomains.tsx index afeb7c727..d6ff33ba2 100644 --- a/src/components/organisms/rns/sell/SoldDomains.tsx +++ b/src/components/organisms/rns/sell/SoldDomains.tsx @@ -1,4 +1,4 @@ -import { AddressItem, CombinedPriceCell } from 'components/molecules' +import { RifAddress, CombinedPriceCell } from 'components/molecules' import DomainFilters from 'components/organisms/filters/DomainFilters' import MarketPageTemplate from 'components/templates/MarketPageTemplate' import { RnsSoldDomain } from 'models/marketItems/DomainItem' @@ -52,12 +52,12 @@ const SoldDomains: FC<{}> = () => { const pseudoResolvedName = name && `${name}.rsk` const displayDomainName = domainName || pseudoResolvedName ? - : + : const displayItem = { id, domainName: displayDomainName, - buyer: , + buyer: , currency: displayName, sellingPrice: ({ }, })) -const DetailsModal: FC = ({ modalProps, itemDetails, actions }) => { +const DetailsModal: FC = ({ + modalProps, itemDetails, actions, +}) => { const modalCardStyleClasses = useModalStyles() return ( = ({ modalProps, itemDetails, actions {itemDetails?.title} - {itemDetails ? Object.keys(itemDetails) @@ -68,6 +72,7 @@ const DetailsModal: FC = ({ modalProps, itemDetails, actions container direction="row" spacing={6} + wrap="nowrap" xs={12} > = ({ modalProps, itemDetails, actions {itemDetails[key]} )) : ''} - + diff --git a/src/components/organisms/storage/agreements/utils.tsx b/src/components/organisms/storage/agreements/utils.tsx index 2d3156a78..5219ac82a 100644 --- a/src/components/organisms/storage/agreements/utils.tsx +++ b/src/components/organisms/storage/agreements/utils.tsx @@ -1,6 +1,6 @@ import { Spinner } from '@rsksmart/rif-ui' import ItemWUnit from 'components/atoms/ItemWUnit' -import { AddressItem, CombinedPriceCell, SelectRowButton } from 'components/molecules' +import { RifAddress, CombinedPriceCell, SelectRowButton } from 'components/molecules' import { MarketplaceItem } from 'components/templates/marketplace/Marketplace' import { AgreementUpdateData, ConfirmationData } from 'context/Confirmations/interfaces' import { BaseFiat } from 'models/Fiat' @@ -33,19 +33,17 @@ export type AgreementCustomerView = AgreementView & { const getCoreItemFields = ( agreement: Agreement, - crypto: MarketCryptoRecord, + { rate, displayName }: TokenXR, currentFiat: BaseFiat, ): AgreementView => { const { monthlyFee, renewalDate, - paymentToken, size, subscriptionPeriod, id, dataReference, } = agreement - const currency: TokenXR = crypto[paymentToken.symbol] const sizeValue = ( ) - const idValue = + const idValue = return { - HASH: , + HASH: , title: idValue, 'PRICE/GB': feeValue, AMOUNT: sizeValue, 'RENEWAL DATE': renewalDate ? getShortDateString(renewalDate) : 'Expired', 'SUBSCRIPTION PERIOD': subscriptionPeriod, - CURRENCY: currency.displayName, + CURRENCY: displayName, SYSTEM: 'IPFS', } } export const getCustomerViewFrom = ( agreement: Agreement, - crypto: MarketCryptoRecord, + currency: TokenXR, currentFiat: BaseFiat, ): AgreementCustomerView => { - const agreementInfo = getCoreItemFields(agreement, crypto, currentFiat) + const agreementInfo = getCoreItemFields(agreement, currency, currentFiat) const { - provider, paymentToken, withdrawableFunds, + provider, withdrawableFunds, } = agreement - const currency: TokenXR = crypto[paymentToken.symbol] - const providerValue = + const providerValue = const withdrawableFundsValue = ( void, withdrawAndRenewConfs: ConfirmationData[], -): MarketplaceItem[] => agreements.map((agreement: Agreement) => { - const { - id, expiresInSeconds, isActive, - } = agreement - const customerView = getCustomerViewFrom(agreement, crypto, currentFiat) - - const isProcessingConfs = withdrawAndRenewConfs.some( - ({ contractActionData }) => ( - (contractActionData as AgreementUpdateData).agreementId === id - ), - ) +): MarketplaceItem[] => agreements + .filter(({ paymentToken: { symbol } }) => crypto[symbol]) + .map((agreement: Agreement) => { + const { + id, expiresInSeconds, isActive, paymentToken: { symbol }, + } = agreement + const customerView = getCustomerViewFrom( + agreement, + crypto[symbol], + currentFiat, + ) - return { - ...customerView, - id, - provider: customerView.PROVIDER, - contentSize: customerView.AMOUNT, - renewalDate: customerView['RENEWAL DATE'], - subscriptionPeriod: customerView['SUBSCRIPTION PERIOD'], - monthlyFee: customerView['PRICE/GB'], - withdrawableFunds: customerView['WITHDRAWABLE FUNDS'], - renew: isProcessingConfs - ? - : ( - { - onItemRenew(event, agreement) - }} - > - Renew - - ), - view: isProcessingConfs - ? <> - : ( - onItemSelect( - event, customerView, agreement, - )} - > - View - + const isProcessingConfs = withdrawAndRenewConfs.some( + ({ contractActionData }) => ( + (contractActionData as AgreementUpdateData).agreementId === id ), - } -}) + ) + + return { + ...customerView, + id, + provider: customerView.PROVIDER, + contentSize: customerView.AMOUNT, + renewalDate: customerView['RENEWAL DATE'], + subscriptionPeriod: customerView['SUBSCRIPTION PERIOD'], + monthlyFee: customerView['PRICE/GB'], + withdrawableFunds: customerView['WITHDRAWABLE FUNDS'], + renew: isProcessingConfs + ? + : ( + { + onItemRenew(event, agreement) + }} + > + Renew + + ), + view: isProcessingConfs + ? <> + : ( + onItemSelect( + event, customerView, agreement, + )} + > + View + + ), + } + }) export const getProviderViewFrom = ( agreement: Agreement, - crypto: MarketCryptoRecord, + currency: TokenXR, currentFiat: BaseFiat, ): AgreementProviderView => { - const agreementInfo = getCoreItemFields(agreement, crypto, currentFiat) const { - consumer, paymentToken, toBePayedOut, + consumer, toBePayedOut, } = agreement - const currency: TokenXR = crypto[paymentToken.symbol] - const consumerValue = + const consumerValue = const toBePayedOutValue = ( ) + const agreementInfo = getCoreItemFields(agreement, currency, currentFiat) + return { ...agreementInfo, CONSUMER: consumerValue, @@ -201,51 +204,59 @@ export const createProviderItemFields = ( agreement: Agreement, ) => void, payoutConfirmations: ConfirmationData[], -): MarketplaceItem[] => agreements.map((agreement: Agreement) => { - const providerView = getProviderViewFrom(agreement, crypto, currentFiat) - const { - id, - } = agreement - - const isProcessingPayoutConfs = payoutConfirmations.some( - ({ contractActionData }) => ( - (contractActionData as AgreementUpdateData).agreementId === id - ), - ) +): MarketplaceItem[] => agreements + .filter(({ paymentToken: { symbol } }) => crypto[symbol]) + .map((agreement: Agreement) => { + const { + id, + paymentToken: { symbol }, + } = agreement - return { - ...providerView, - id, - customer: providerView.CONSUMER, - contentSize: providerView.AMOUNT, - renewalDate: providerView['RENEWAL DATE'], - subscriptionPeriod: providerView['SUBSCRIPTION PERIOD'], - monthlyFee: providerView['PRICE/GB'], - toBePayedOut: providerView['AVAILABLE FUNDS'], - withdraw: isProcessingPayoutConfs - ? - : ( - { - onItemWithdraw(event, agreement) - }} - disabled={Number(agreement.toBePayedOut) <= 0} - > - Withdraw - - ), - view: isProcessingPayoutConfs - ? <> - : ( - onItemSelect( - event, providerView, agreement, - )} - > - View - + const isProcessingPayoutConfs = payoutConfirmations.some( + ({ contractActionData }) => ( + (contractActionData as AgreementUpdateData).agreementId === id ), - } -}) + ) + + const providerView = getProviderViewFrom( + agreement, + crypto[symbol], + currentFiat, + ) + + return { + ...providerView, + id, + customer: providerView.CONSUMER, + contentSize: providerView.AMOUNT, + renewalDate: providerView['RENEWAL DATE'], + subscriptionPeriod: providerView['SUBSCRIPTION PERIOD'], + monthlyFee: providerView['PRICE/GB'], + toBePayedOut: providerView['AVAILABLE FUNDS'], + withdraw: isProcessingPayoutConfs + ? + : ( + { + onItemWithdraw(event, agreement) + }} + disabled={Number(agreement.toBePayedOut) <= 0} + > + Withdraw + + ), + view: isProcessingPayoutConfs + ? <> + : ( + onItemSelect( + event, providerView, agreement, + )} + > + View + + ), + } + }) diff --git a/src/components/pages/notifier/buy/NotifierOffersPage.tsx b/src/components/pages/notifier/buy/NotifierOffersPage.tsx index 72f35685a..cab6abd7e 100644 --- a/src/components/pages/notifier/buy/NotifierOffersPage.tsx +++ b/src/components/pages/notifier/buy/NotifierOffersPage.tsx @@ -4,7 +4,7 @@ import { Spinner, Web3Store } from '@rsksmart/rif-ui' import { SubscriptionPlanDTO } from 'api/rif-notifier-service/models/subscriptionPlan' import SubscriptionPlans from 'api/rif-notifier-service/subscriptionPlans' import ItemWUnit from 'components/atoms/ItemWUnit' -import { AddressItem, SelectRowButton } from 'components/molecules' +import { RifAddress, SelectRowButton } from 'components/molecules' import { SelectRowButtonProps } from 'components/molecules/SelectRowButton' import NotifierOffersFilters from 'components/organisms/filters/notifier/OffersFilters' import NotifierPlansDraw from 'components/organisms/notifier/NotifierPlansDraw' @@ -187,7 +187,7 @@ const NotifierOffersPage: FC = () => { const commonProperties = { id: provider, - provider: , + provider: , action1: account === provider ? 'Your offer' : (buttonSelect), } diff --git a/src/components/pages/rns/buy/DomainOffersPage.tsx b/src/components/pages/rns/buy/DomainOffersPage.tsx index 00d9019c4..8f08e7bc1 100644 --- a/src/components/pages/rns/buy/DomainOffersPage.tsx +++ b/src/components/pages/rns/buy/DomainOffersPage.tsx @@ -1,7 +1,7 @@ import { Web3Store, ShortenTextTooltip, Spinner } from '@rsksmart/rif-ui' import React, { FC, useContext } from 'react' import { useHistory } from 'react-router-dom' -import { AddressItem, CombinedPriceCell, SelectRowButton } from 'components/molecules' +import { RifAddress, CombinedPriceCell, SelectRowButton } from 'components/molecules' import RifPaging from 'components/molecules/RifPaging' import DomainOfferFilters from 'components/organisms/filters/DomainOffersFilters' import MarketPageTemplate from 'components/templates/MarketPageTemplate' @@ -158,7 +158,7 @@ const DomainOffersPage: FC = () => { maxLength={30} /> ) - : + : const isProcessingConfs = pendingConfs.some( ({ contractActionData }) => ( @@ -183,7 +183,7 @@ const DomainOffersPage: FC = () => { const displayItem = { id, domainName: displayDomainName, - ownerAddress: , + ownerAddress: , expirationDate: expirationDate.toLocaleDateString(), combinedPrice: { return { id, - provider: , + provider: , system, availableSize: , subscriptionOptions: Array.from(new Set( From e4b1b645b438f941a0ab7753d200678aa920a479 Mon Sep 17 00:00:00 2001 From: Juraj Piar Date: Tue, 14 Sep 2021 15:49:00 +0100 Subject: [PATCH 5/5] fix(notifier): makes exp date calc safer (cherry picked from commit b4fea5ad22dc24a4e10208884641ea0ce402dbfc) --- .../organisms/notifier/buy/CheckoutStepper.tsx | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/components/organisms/notifier/buy/CheckoutStepper.tsx b/src/components/organisms/notifier/buy/CheckoutStepper.tsx index b9a9a88d1..df76a4ae4 100644 --- a/src/components/organisms/notifier/buy/CheckoutStepper.tsx +++ b/src/components/organisms/notifier/buy/CheckoutStepper.tsx @@ -19,9 +19,13 @@ type Props = { } const getExpirationDate = (daysLeft: number): Date => { - const expirationDate = new Date() - expirationDate.setUTCHours(0, 0, 0, 0) - expirationDate.setUTCDate(expirationDate.getDate() + daysLeft) + const now = new Date() + const expirationDate = new Date(Date.UTC( + now.getFullYear(), + now.getMonth(), + now.getDate(), + )) + expirationDate.setUTCDate(expirationDate.getUTCDate() + daysLeft) return new Date(expirationDate) }