diff --git a/src/components/Request/Components/ReferenceAndAttachment.tsx b/src/components/Request/Components/ReferenceAndAttachment.tsx new file mode 100644 index 000000000..5696fb0c2 --- /dev/null +++ b/src/components/Request/Components/ReferenceAndAttachment.tsx @@ -0,0 +1,34 @@ +import Icon from '@/components/Global/Icon' + +export const ReferenceAndAttachment = ({ + reference, + attachmentUrl, +}: { + reference?: string | null + attachmentUrl?: string | null +}) => { + if (!reference && !attachmentUrl) return null + return ( + <> +
+ {reference && ( + + )} + {attachmentUrl && ( + + + Download attachment + + )} +
+
+ + ) +} diff --git a/src/components/Request/Pay/Views/GeneralViews/AlreadyPaid.view.tsx b/src/components/Request/Pay/Views/GeneralViews/AlreadyPaid.view.tsx index 962d1c93b..fdc339f54 100644 --- a/src/components/Request/Pay/Views/GeneralViews/AlreadyPaid.view.tsx +++ b/src/components/Request/Pay/Views/GeneralViews/AlreadyPaid.view.tsx @@ -5,24 +5,29 @@ import * as consts from '@/constants' import * as _consts from '../../Pay.consts' import * as utils from '@/utils' import Link from 'next/link' +import { ReferenceAndAttachment } from '@/components/Request/Components/ReferenceAndAttachment' export const AlreadyPaidLinkView = ({ requestLinkData }: { requestLinkData: _consts.IRequestLinkData | undefined }) => { - - const chainName = consts.supportedPeanutChains && consts.supportedPeanutChains.find((chain) => chain.chainId == requestLinkData?.chainId)?.name + const chainName = + consts.supportedPeanutChains && + consts.supportedPeanutChains.find((chain) => chain.chainId == requestLinkData?.chainId)?.name const tokenSymbolAvailable: boolean = !!requestLinkData?.tokenSymbol const tokenAmountAvailable: boolean = !!requestLinkData?.tokenAmount const chainAvailable: boolean = !!requestLinkData?.chainId const recipientAddressAvailable: boolean = !!requestLinkData?.recipientAddress - const dataAvailable: boolean = tokenSymbolAvailable || tokenAmountAvailable || chainAvailable || recipientAddressAvailable - + const dataAvailable: boolean = + tokenSymbolAvailable || tokenAmountAvailable || chainAvailable || recipientAddressAvailable + return (
+ {dataAvailable && (
- + {tokenSymbolAvailable && (
@@ -50,8 +55,10 @@ export const AlreadyPaidLinkView = ({ requestLinkData }: { requestLinkData: _con
detail.chainId === requestLinkData?.chainId)?.icon - .url + src={ + consts.supportedPeanutChains.find( + (detail) => detail.chainId === requestLinkData?.chainId + )?.icon.url } className="h-6 w-6" /> diff --git a/src/components/Request/Pay/Views/Initial.view.tsx b/src/components/Request/Pay/Views/Initial.view.tsx index 3d06d7d11..b7e51126c 100644 --- a/src/components/Request/Pay/Views/Initial.view.tsx +++ b/src/components/Request/Pay/Views/Initial.view.tsx @@ -22,6 +22,7 @@ import { peanut, interfaces } from '@squirrel-labs/peanut-sdk' import TokenSelector from '@/components/Global/TokenSelector/TokenSelector' import { switchNetwork as switchNetworkUtil } from '@/utils/general.utils' import { type ITokenPriceData } from '@/interfaces' +import { ReferenceAndAttachment } from '@/components/Request/Components/ReferenceAndAttachment' const ERR_NO_ROUTE = 'No route found to pay in this chain and token' @@ -321,30 +322,10 @@ export const InitialView = ({ return (
- {(requestLinkData.reference || requestLinkData.attachmentUrl) && ( - <> -
- {requestLinkData.reference && ( - - )} - {requestLinkData.attachmentUrl && ( - - - Download attachment - - )} -
-
- - )} - +