From 393cd541282f9e7daa746c6dd222cdea16f239f9 Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Wed, 12 Jun 2024 15:26:49 +0700 Subject: [PATCH 1/2] update image path for sense --- src/components/Ticket/AcceptTicket.tsx | 5 +-- .../Ticket/NFTRegistrationTicket.tsx | 5 +-- src/components/Ticket/OfferTicket.tsx | 5 +-- src/components/Ticket/TransferTicket.tsx | 5 +-- src/pages/Details/BlockDetails/Tickets.tsx | 3 +- .../Details/NftDetails/SubmittedImage.tsx | 3 +- .../Details/PastelIdDetails/TicketList.tsx | 3 +- .../Details/SenseDetails/SubmittedImage.tsx | 5 ++- src/pages/Tickets/Tickets.helpers.tsx | 41 ++++++++++++------- src/pages/TicketsType/TicketList.tsx | 3 +- src/utils/helpers/url.ts | 6 +++ 11 files changed, 51 insertions(+), 33 deletions(-) diff --git a/src/components/Ticket/AcceptTicket.tsx b/src/components/Ticket/AcceptTicket.tsx index b5eca720..b730cf2a 100644 --- a/src/components/Ticket/AcceptTicket.tsx +++ b/src/components/Ticket/AcceptTicket.tsx @@ -2,6 +2,7 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import parse from 'html-react-parser'; +import { getSenseImage } from '@utils/helpers/url'; import RouterLink, { ExternalLink } from '@components/RouterLink/RouterLink'; import { formatNumber } from '@utils/helpers/formatNumbers/formatNumbers'; import { IAcceptTicket } from '@utils/types/ITransactions'; @@ -29,9 +30,7 @@ const AcceptTicket: React.FC = ({ ticket, variant }) => { let image = noImagePlaceholder; if (ticket.image) { image = - ticket.otherData.offerType === 'nft-offer' - ? ticket.image - : `data:image/jpeg;base64,${ticket.image}`; + ticket.otherData.offerType === 'nft-offer' ? ticket.image : getSenseImage(ticket.image); } return ( = ({ {ticket.nftId ? ( {transactionHash} diff --git a/src/components/Ticket/OfferTicket.tsx b/src/components/Ticket/OfferTicket.tsx index 205098b3..d89e7619 100644 --- a/src/components/Ticket/OfferTicket.tsx +++ b/src/components/Ticket/OfferTicket.tsx @@ -2,6 +2,7 @@ import Grid from '@mui/material/Grid'; import Box from '@mui/material/Box'; import parse from 'html-react-parser'; +import { getSenseImage } from '@utils/helpers/url'; import RouterLink, { ExternalLink } from '@components/RouterLink/RouterLink'; import { formatNumber } from '@utils/helpers/formatNumbers/formatNumbers'; import { IOfferTicket } from '@utils/types/ITransactions'; @@ -28,9 +29,7 @@ const OfferTicket: React.FC = ({ ticket, variant }) => { let image = noImagePlaceholder; if (ticket.image) { image = - ticket.otherData.offerType === 'nft-offer' - ? ticket.image - : `data:image/jpeg;base64,${ticket.image}`; + ticket.otherData.offerType === 'nft-offer' ? ticket.image : getSenseImage(ticket.image); } return ( = ({ ticket, variant }) => let image = noImagePlaceholder; if (ticket.image) { image = - ticket.otherData.offerType === 'nft-offer' - ? ticket.image - : `data:image/jpeg;base64,${ticket.image}`; + ticket.otherData.offerType === 'nft-offer' ? ticket.image : getSenseImage(ticket.image); } return ( = ({ {sense.imageFileHash} = ({ img, alt }) => { return ( - {alt + {alt ); }; diff --git a/src/pages/Details/PastelIdDetails/TicketList.tsx b/src/pages/Details/PastelIdDetails/TicketList.tsx index 718a8246..6944eaa3 100644 --- a/src/pages/Details/PastelIdDetails/TicketList.tsx +++ b/src/pages/Details/PastelIdDetails/TicketList.tsx @@ -5,6 +5,7 @@ import { decode } from 'js-base64'; import parse from 'html-react-parser'; import { SelectChangeEvent } from '@mui/material/Select'; +import { getSenseImage } from '@utils/helpers/url'; import RouterLink from '@components/RouterLink/RouterLink'; import * as ROUTES from '@utils/constants/routes'; import { @@ -160,7 +161,7 @@ const TicketsList: React.FC = ({ {sense.imageFileHash} = ({ imageUrl, imageHash }) onClick={handleClickOpen} title={translateDropdown('pages.senseDetails.viewFull')} > - {imageHash} + {imageHash} ) : ( @@ -41,7 +42,7 @@ const SubmittedImage: React.FC = ({ imageUrl, imageHash }) - {imageHash} + {imageHash} diff --git a/src/pages/Tickets/Tickets.helpers.tsx b/src/pages/Tickets/Tickets.helpers.tsx index cb9ef349..6e1433ce 100644 --- a/src/pages/Tickets/Tickets.helpers.tsx +++ b/src/pages/Tickets/Tickets.helpers.tsx @@ -9,6 +9,7 @@ import { Link } from 'react-router-dom'; import parse from 'html-react-parser'; import { decode } from 'js-base64'; +import { getSenseImage } from '@utils/helpers/url'; import CopyButton from '@components/CopyButton/CopyButton'; import RouterLink from '@components/RouterLink/RouterLink'; import * as ROUTES from '@utils/constants/routes'; @@ -343,11 +344,7 @@ export const transformSenseData = (sense: TicketsList[], usdPrice: number) => {dupeDetectionSystemVersion && imageFileCdnUrl ? ( {imageHash} @@ -380,11 +377,7 @@ export const transformSenseData = (sense: TicketsList[], usdPrice: number) => {dupeDetectionSystemVersion && imageFileCdnUrl ? ( {imageHash} @@ -411,11 +404,7 @@ export const transformSenseData = (sense: TicketsList[], usdPrice: number) => {dupeDetectionSystemVersion && imageFileCdnUrl ? ( {imageHash} @@ -627,6 +616,17 @@ export const transformOfferAndTransferData = (data: TicketsList[]) => }; const getImage = () => { + if (ticketType === 'sense') { + return ( + + {reTxId} + + ); + } return ( }; const getImage = () => { + if (ticketType === 'sense') { + return ( + + {reTxId} + + ); + } return ( = ({ {sense.imageFileHash} { const params = new URLSearchParams(url); return params.get(name) || ''; }; + +export const getSenseImage = (imageUrl: string) => { + return `${getBaseURL()}/static/sense_images/${imageUrl}`; +}; From adb25a4f4c8b0daf00f6ba083199a74ffb97cfcc Mon Sep 17 00:00:00 2001 From: Tuan Nguyen Date: Fri, 14 Jun 2024 16:58:44 +0700 Subject: [PATCH 2/2] Added minimum percent for the 24h change in dashboard. --- src/components/Summary/Summary.helpers.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Summary/Summary.helpers.ts b/src/components/Summary/Summary.helpers.ts index 822df02b..309a82f8 100644 --- a/src/components/Summary/Summary.helpers.ts +++ b/src/components/Summary/Summary.helpers.ts @@ -109,7 +109,14 @@ export const calculateDifference = ( difference = ((firstValue - secondValue) / targetValue) * 100; } - return difference.toFixed(2); + let value = difference.toFixed(2); + if (Number(difference) > 0 && Number(difference) < 0.01) { + value = '0.01'; + } else if (Number(difference) < 0 && Number(difference) > -0.01) { + value = '-0.01'; + } + + return value; }; export const getRouteForChart = (key: string) => {