Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy Production 06/19/2024 #237

Merged
merged 3 commits into from
Jun 19, 2024
Merged
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
9 changes: 8 additions & 1 deletion src/components/Summary/Summary.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
5 changes: 2 additions & 3 deletions src/components/Ticket/AcceptTicket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -29,9 +30,7 @@ const AcceptTicket: React.FC<IAcceptTicketProps> = ({ 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 (
<img
Expand Down
5 changes: 2 additions & 3 deletions src/components/Ticket/NFTRegistrationTicket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import AccordionDetails from '@mui/material/AccordionDetails';
import { ExpandMore as ExpandMoreIcon } from '@mui/icons-material';
import parse from 'html-react-parser';

import { getSenseImage } from '@utils/helpers/url';
import RouterLink from '@components/RouterLink/RouterLink';
import { INftRegistrationTicket, INftTicket } from '@utils/types/ITransactions';
import * as ROUTES from '@utils/constants/routes';
Expand Down Expand Up @@ -255,9 +256,7 @@ const NFTRegistrationTicket: React.FC<INFTRegistrationTicketProps> = ({
{ticket.nftId ? (
<Link to={`${ROUTES.NFT_DETAILS}?txid=${transactionHash}`}>
<img
src={
ticket?.image ? `data:image/jpeg;base64,${ticket.image}` : noImagePlaceholder
}
src={ticket?.image ? getSenseImage(ticket.image) : noImagePlaceholder}
alt={transactionHash}
className={`sense-img ${!ticket?.image ? 'placeholder' : ''}`}
/>
Expand Down
5 changes: 2 additions & 3 deletions src/components/Ticket/OfferTicket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -28,9 +29,7 @@ const OfferTicket: React.FC<IOfferTicketProps> = ({ 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 (
<img
Expand Down
5 changes: 2 additions & 3 deletions src/components/Ticket/TransferTicket.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 { ITransferTicket } from '@utils/types/ITransactions';
import * as ROUTES from '@utils/constants/routes';
Expand All @@ -25,9 +26,7 @@ const TransferTicket: React.FC<ITransferTicketProps> = ({ 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 (
<img
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Details/BlockDetails/Tickets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Link } from 'react-router-dom';
import { decode } from 'js-base64';
import parse from 'html-react-parser';

import { getSenseImage } from '@utils/helpers/url';
import RouterLink from '@components/RouterLink/RouterLink';
import * as ROUTES from '@utils/constants/routes';
import {
Expand Down Expand Up @@ -302,7 +303,7 @@ const TicketsList: React.FC<ITicketsList> = ({
<img
src={
sense.imageFileCdnUrl
? `data:image/jpeg;base64,${sense.imageFileCdnUrl}`
? getSenseImage(sense.imageFileCdnUrl)
: noImagePlaceholder
}
alt={sense.imageFileHash}
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Details/NftDetails/SubmittedImage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getSenseImage } from '@utils/helpers/url';
import noImagePlaceholder from '@assets/images/no-image-placeholder.svg';

import * as Styles from './NftDetails.styles';
Expand All @@ -10,7 +11,7 @@ interface ISubmittedImage {
const SubmittedImage: React.FC<ISubmittedImage> = ({ img, alt }) => {
return (
<Styles.SubmittedImageWrapper className={`${!img ? 'image-placeholder' : ''}`}>
<img src={img ? `data:image/jpeg;base64,${img}` : noImagePlaceholder} alt={alt || ''} />
<img src={img ? getSenseImage(img) : noImagePlaceholder} alt={alt || ''} />
</Styles.SubmittedImageWrapper>
);
};
Expand Down
3 changes: 2 additions & 1 deletion src/pages/Details/PastelIdDetails/TicketList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -160,7 +161,7 @@ const TicketsList: React.FC<ITicketsList> = ({
<img
src={
sense.imageFileCdnUrl
? `data:image/jpeg;base64,${sense.imageFileCdnUrl}`
? getSenseImage(sense.imageFileCdnUrl)
: noImagePlaceholder
}
alt={sense.imageFileHash}
Expand Down
5 changes: 3 additions & 2 deletions src/pages/Details/SenseDetails/SubmittedImage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState } from 'react';
import Box from '@mui/material/Box';

import { translateDropdown } from '@utils/helpers/i18n';
import { getSenseImage } from '@utils/helpers/url';

import imagePlaceholder from '@assets/images/no-image-placeholder.svg';
import * as Styles from './SenseDetails.styles';
Expand Down Expand Up @@ -31,7 +32,7 @@ const SubmittedImage: React.FC<ISubmittedImageProps> = ({ imageUrl, imageHash })
onClick={handleClickOpen}
title={translateDropdown('pages.senseDetails.viewFull')}
>
<img src={`data:image/jpeg;base64,${imageUrl}`} alt={imageHash} />
<img src={getSenseImage(imageUrl)} alt={imageHash} />
</button>
) : (
<Box className="image-placeholder-wrapper">
Expand All @@ -41,7 +42,7 @@ const SubmittedImage: React.FC<ISubmittedImageProps> = ({ imageUrl, imageHash })
</Box>
<Styles.Dialog onClose={handleClose} open={open}>
<Styles.FullImageWrapper>
<img src={`data:image/jpeg;base64,${imageUrl}`} alt={imageHash} />
<img src={getSenseImage(imageUrl)} alt={imageHash} />
</Styles.FullImageWrapper>
</Styles.Dialog>
</>
Expand Down
41 changes: 26 additions & 15 deletions src/pages/Tickets/Tickets.helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -343,11 +344,7 @@ export const transformSenseData = (sense: TicketsList[], usdPrice: number) =>
{dupeDetectionSystemVersion && imageFileCdnUrl ? (
<Link to={`${ROUTES.SENSE_DETAILS}?txid=${transactionHash}&hash=${imageHash}`}>
<img
src={
imageFileCdnUrl
? `data:image/jpeg;base64,${imageFileCdnUrl}`
: noImagePlaceholder
}
src={imageFileCdnUrl ? getSenseImage(imageFileCdnUrl) : noImagePlaceholder}
alt={imageHash}
className="sense-img"
/>
Expand Down Expand Up @@ -380,11 +377,7 @@ export const transformSenseData = (sense: TicketsList[], usdPrice: number) =>
{dupeDetectionSystemVersion && imageFileCdnUrl ? (
<Link to={`${ROUTES.SENSE_DETAILS}?txid=${transactionHash}&hash=${imageHash}`}>
<img
src={
imageFileCdnUrl
? `data:image/jpeg;base64,${imageFileCdnUrl}`
: noImagePlaceholder
}
src={imageFileCdnUrl ? getSenseImage(imageFileCdnUrl) : noImagePlaceholder}
alt={imageHash}
className="sense-img"
/>
Expand All @@ -411,11 +404,7 @@ export const transformSenseData = (sense: TicketsList[], usdPrice: number) =>
{dupeDetectionSystemVersion && imageFileCdnUrl ? (
<Link to={`${ROUTES.SENSE_DETAILS}?txid=${transactionHash}&hash=${imageHash}`}>
<img
src={
imageFileCdnUrl
? `data:image/jpeg;base64,${imageFileCdnUrl}`
: noImagePlaceholder
}
src={imageFileCdnUrl ? getSenseImage(imageFileCdnUrl) : noImagePlaceholder}
alt={imageHash}
className="sense-img"
/>
Expand Down Expand Up @@ -627,6 +616,17 @@ export const transformOfferAndTransferData = (data: TicketsList[]) =>
};

const getImage = () => {
if (ticketType === 'sense') {
return (
<Link to={getInfo().link}>
<img
src={image ? getSenseImage(image) : noImagePlaceholder}
alt={reTxId}
className="sense-img"
/>
</Link>
);
}
return (
<Link to={getInfo().link}>
<img
Expand Down Expand Up @@ -910,6 +910,17 @@ export const transformInferenceAPICreditPackData = (data: TicketsList[]) =>
};

const getImage = () => {
if (ticketType === 'sense') {
return (
<Link to={getInfo().link}>
<img
src={image ? getSenseImage(image) : noImagePlaceholder}
alt={reTxId}
className="sense-img"
/>
</Link>
);
}
return (
<Link to={getInfo().link}>
<img
Expand Down
3 changes: 2 additions & 1 deletion src/pages/TicketsType/TicketList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,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 {
Expand Down Expand Up @@ -200,7 +201,7 @@ const TicketsList: React.FC<ITicketsList> = ({
<img
src={
sense.imageFileCdnUrl
? `data:image/jpeg;base64,${sense.imageFileCdnUrl}`
? getSenseImage(sense.imageFileCdnUrl)
: noImagePlaceholder
}
alt={sense.imageFileHash}
Expand Down
6 changes: 6 additions & 0 deletions src/utils/helpers/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { getBaseURL } from '@utils/constants/statistics';

export const getParameterByName = (name: string, url = window.location.search) => {
const params = new URLSearchParams(url);
return params.get(name) || '';
};

export const getSenseImage = (imageUrl: string) => {
return `${getBaseURL()}/static/sense_images/${imageUrl}`;
};
Loading