Skip to content

Commit fc93a94

Browse files
committed
[Dashboard] Update PaymentLink type and handling
- Modified PaymentLink type to allow 'amount' to be optional. - Updated getPaymentLink function to handle undefined amounts correctly. - Adjusted PayPage and PayPageEmbed components to accommodate changes in amount handling, ensuring proper conversion and default values.
1 parent a544192 commit fc93a94

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

apps/dashboard/src/@/api/universal-bridge/links.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ type PaymentLink = {
1111
decimals: number;
1212
chainId: number;
1313
};
14-
amount: bigint;
14+
amount: bigint | undefined;
1515
purchaseData: unknown;
1616
};
1717

@@ -32,5 +32,12 @@ export async function getPaymentLink(props: {
3232
}
3333

3434
const { data } = await res.json();
35-
return data as PaymentLink;
35+
return {
36+
clientId: data.clientId,
37+
label: data.label,
38+
receiver: data.receiver,
39+
destinationToken: data.destinationToken,
40+
amount: data.amount ? BigInt(data.amount) : undefined,
41+
purchaseData: data.purchaseData,
42+
} as PaymentLink;
3643
}

apps/dashboard/src/app/pay/[id]/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ export default async function PayPage({
5959
paymentLinkId={id}
6060
chainId={Number(paymentLink.destinationToken.chainId)}
6161
recipientAddress={paymentLink.receiver}
62-
amount={BigInt(paymentLink.amount)}
62+
amount={paymentLink.amount ? BigInt(paymentLink.amount) : undefined}
6363
token={token}
6464
clientId={paymentLink.clientId}
6565
name={paymentLink.label}

apps/dashboard/src/app/pay/components/client/PayPageEmbed.client.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export function PayPageEmbed({
2020
chainId: number;
2121
recipientAddress: string;
2222
paymentLinkId?: string;
23-
amount: bigint;
23+
amount?: bigint;
2424
token: { name: string; symbol: string; address: string; decimals: number };
2525
name?: string;
2626
image?: string;
@@ -54,7 +54,7 @@ export function PayPageEmbed({
5454
paymentInfo: {
5555
chain,
5656
sellerAddress: recipientAddress,
57-
amount: toTokens(amount, token.decimals),
57+
amount: amount ? toTokens(amount, token.decimals) : "0.01",
5858
token: token.address === NATIVE_TOKEN_ADDRESS ? undefined : token,
5959
},
6060
onPurchaseSuccess: (result) => {

0 commit comments

Comments
 (0)