Skip to content

Commit 04da746

Browse files
committed
fix: updated logic for pay now button
1 parent 022f883 commit 04da746

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

packages/invoice-dashboard/src/lib/dashboard/invoice-view.svelte

+13-2
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@
100100
101101
let isSigningTransaction = false;
102102
103+
let initialPaymentCheck = false;
104+
105+
let showPaymentButton = true;
106+
103107
const generateDetailParagraphs = (info: any) => {
104108
const fullName = [info?.firstName, info?.lastName]
105109
.filter(Boolean)
@@ -154,6 +158,12 @@
154158
$: {
155159
if (request?.requestId !== previousRequestId) {
156160
previousRequestId = request?.requestId;
161+
initialPaymentCheck =
162+
request?.state === "paid" ||
163+
request?.state === "overpaid" ||
164+
status === "paid" ||
165+
status === "overpaid" ||
166+
request?.balance?.balance >= request?.expectedAmount;
157167
checkInvoice();
158168
}
159169
}
@@ -345,6 +355,7 @@
345355
isPaid = true;
346356
status = checkStatus(requestData);
347357
isRequestPayed = true;
358+
showPaymentButton = false; // Hide the button after successful payment
348359
} catch (err) {
349360
console.error("Something went wrong while paying : ", err);
350361
@@ -857,7 +868,7 @@
857868
{/each}
858869
{/if}
859870
</div>
860-
{#if !isPaid && !isPayee}
871+
{#if !isPayee && !initialPaymentCheck}
861872
<div class="status-container">
862873
<div class="statuses">
863874
{#if statuses?.length > 0}
@@ -920,7 +931,7 @@
920931
</div>
921932
{/if}
922933
<div class="invoice-view-actions">
923-
{#if !isPayee && !unsupportedNetwork && !isPaid && !isRequestPayed && !isSigningTransaction && !unknownCurrency}
934+
{#if showPaymentButton && !isPayee && !unsupportedNetwork && !isSigningTransaction && !unknownCurrency && !initialPaymentCheck}
924935
{#if !hasEnoughBalance && correctChain}
925936
<div class="balance-warning">
926937
Insufficient funds: {Number(userBalance).toFixed(4)}

0 commit comments

Comments
 (0)