Skip to content
This repository has been archived by the owner on Aug 9, 2022. It is now read-only.

chore(backport): fix(notifier): makes exp date calc safer #979

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/backport.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
60 changes: 0 additions & 60 deletions .github/workflows/staging.yml

This file was deleted.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rif-marketplace-ui",
"version": "1.4.0",
"version": "1.4.3",
"description": "RIF Marketplace provides a digital catalogue with a wide range of decentralised services.",
"keywords": [
"RIF",
Expand Down Expand Up @@ -107,4 +107,4 @@
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/__mocks__/fileMock.ts"
}
}
}
}
8 changes: 4 additions & 4 deletions src/components/molecules/ExpirationDate.tsx
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down Expand Up @@ -35,10 +35,10 @@ type Props = {
className?: string
date: Date
type: SubscriptionExpirationType
}
} & TypographyProps

const ExpirationDate: FC<Props> = ({
className = '', date, type,
className = '', date, type, ...typoProps
}) => {
const classes = useStyles()

Expand All @@ -51,7 +51,7 @@ const ExpirationDate: FC<Props> = ({
className={`${classes[type]} ${className}`}
>
<Grid item>
<Typography variant="body2">
<Typography variant="body2" {...typoProps}>
{getShortDateString(date)}
</Typography>
</Grid>
Expand Down
9 changes: 6 additions & 3 deletions src/components/molecules/RifAddress.tsx
Original file line number Diff line number Diff line change
@@ -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<RifAddressProps> = ({ pretext, value, ...rest }) => {
const address = shortChecksumAddress(value)
const RifAddress: FC<RifAddressProps> = ({
pretext, value, disableChecksum, ...rest
}) => {
const address = disableChecksum ? shortenString(value) : shortChecksumAddress(value)

const displayElement = (
<Typography {...rest}>
Expand Down
2 changes: 1 addition & 1 deletion src/components/molecules/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export {
CombinedPriceCell,
IconedItem,
ReturnButton,
RifAddress as AddressItem,
RifAddress,
JobDoneBox,
SelectRowButton,
}
11 changes: 8 additions & 3 deletions src/components/organisms/notifier/buy/CheckoutStepper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ type Props = {
}

const getExpirationDate = (daysLeft: number): Date => {
const retDate = new Date()
retDate.setDate(retDate.getDate() + daysLeft)
return retDate
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)
}

const CheckoutStepper: FC<Props> = (
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/rns/sell/MyDomains.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -70,7 +70,7 @@ const MyDomains: FC = () => {
maxLength={30}
/>
)
: <AddressItem pretext="Unknown RNS:" value={tokenId} />
: <RifAddress pretext="Unknown RNS:" value={tokenId} />

const isProcessingConfs = pendingConfs.some(
({ contractActionData }) => (
Expand Down
4 changes: 2 additions & 2 deletions src/components/organisms/rns/sell/MyOffers.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -76,7 +76,7 @@ const MyOffers: FC = () => {
maxLength={30}
/>
)
: <AddressItem pretext="Unknown RNS:" value={tokenId} />
: <RifAddress pretext="Unknown RNS:" value={tokenId} />

const isProcessingConfs = pendingConfs.some(
({ contractActionData }) => (
Expand Down
6 changes: 3 additions & 3 deletions src/components/organisms/rns/sell/SoldDomains.tsx
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -52,12 +52,12 @@ const SoldDomains: FC<{}> = () => {
const pseudoResolvedName = name && `${name}.rsk`
const displayDomainName = domainName || pseudoResolvedName
? <ShortenTextTooltip value={domainName || pseudoResolvedName as string} maxLength={30} />
: <AddressItem pretext="Unknown RNS:" value={tokenId} />
: <RifAddress pretext="Unknown RNS:" value={tokenId} />

const displayItem = {
id,
domainName: displayDomainName,
buyer: <AddressItem value={buyer} />,
buyer: <RifAddress value={buyer} />,
currency: displayName,
sellingPrice: <CombinedPriceCell
price={price.toString()}
Expand Down
13 changes: 9 additions & 4 deletions src/components/organisms/storage/agreements/DetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from '@rsksmart/rif-ui'
/* eslint-disable-next-line import/no-unresolved */
import { ModalProps } from '@rsksmart/rif-ui/dist/components/atoms/modal/Modal'
import GridColumn from 'components/atoms/GridColumn'
import GridItem from 'components/atoms/GridItem'
import RifCard from 'components/organisms/RifCard'
import { AgreementCustomerView, AgreementProviderView } from 'components/organisms/storage/agreements/utils'
Expand Down Expand Up @@ -35,7 +34,9 @@ const useModalStyles = makeStyles((theme: Theme) => ({
},
}))

const DetailsModal: FC<DetailsModalProps> = ({ modalProps, itemDetails, actions }) => {
const DetailsModal: FC<DetailsModalProps> = ({
modalProps, itemDetails, actions,
}) => {
const modalCardStyleClasses = useModalStyles()
return (
<Modal
Expand All @@ -55,8 +56,11 @@ const DetailsModal: FC<DetailsModalProps> = ({ modalProps, itemDetails, actions
<ModalHeader className={modalCardStyleClasses.modalWidth}>
<ModalTitle>{itemDetails?.title}</ModalTitle>
</ModalHeader>
<GridColumn
<Grid
container
spacing={2}
wrap="nowrap"
direction="column"
className={modalCardStyleClasses.itemDetails}
>
{itemDetails ? Object.keys(itemDetails)
Expand All @@ -68,6 +72,7 @@ const DetailsModal: FC<DetailsModalProps> = ({ modalProps, itemDetails, actions
container
direction="row"
spacing={6}
wrap="nowrap"
xs={12}
>
<GridItem
Expand All @@ -84,7 +89,7 @@ const DetailsModal: FC<DetailsModalProps> = ({ modalProps, itemDetails, actions
<GridItem xs={6}>{itemDetails[key]}</GridItem>
</Grid>
)) : ''}
</GridColumn>
</Grid>
</RifCard>
</ModalBody>
</>
Expand Down
Loading