Skip to content

Commit 99d3461

Browse files
authored
fix: added payment check when invoice is paid (#83)
1 parent 020cbe5 commit 99d3461

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
export let requestNetwork: RequestNetwork | null | undefined;
3434
export let request: Types.IRequestDataWithEvents | undefined;
3535
export let currencyManager: any;
36+
export let isRequestPayed: boolean;
3637
3738
let network = request?.currencyInfo?.network || "mainnet";
3839
let currency = currencyManager.fromAddress(request?.currencyInfo?.value);
@@ -140,6 +141,7 @@
140141
isPaid = true;
141142
loading = false;
142143
statuses = [];
144+
isRequestPayed = true;
143145
} catch (err) {
144146
console.error("Something went wrong while paying : ", err);
145147
loading = false;

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
let loading = false;
4747
let searchQuery = "";
4848
let debouncedUpdate: any;
49+
let isRequestPayed = false;
4950
let currentTab = "All";
5051
let requests: Types.IRequestDataWithEvents[] | undefined = [];
5152
let activeRequest: Types.IRequestDataWithEvents | undefined;
@@ -67,6 +68,8 @@
6768
signer = wallet?.accounts[0]?.address;
6869
}
6970
71+
$: isRequestPayed, getOneRequest(activeRequest);
72+
7073
onMount(() => {
7174
currencyManager = initializeCurrencyManager(currencies);
7275
});
@@ -90,6 +93,28 @@
9093
}
9194
};
9295
96+
const getOneRequest = async (activeRequest: any) => {
97+
try {
98+
loading = true;
99+
100+
const _request = await requestNetwork?.fromRequestId(
101+
activeRequest?.requestId!
102+
);
103+
104+
requests = requests?.filter(
105+
(request) => request.requestId !== activeRequest.requestId
106+
);
107+
requests = [...requests, _request.getData()].sort(
108+
(a, b) => b.timestamp - a.timestamp
109+
);
110+
111+
loading = false;
112+
} catch (error) {
113+
loading = false;
114+
console.error("Failed to fetch request:", error);
115+
}
116+
};
117+
93118
$: {
94119
if (requests && loading) {
95120
loading = false;
@@ -471,6 +496,7 @@
471496
{#if activeRequest !== undefined}
472497
<InvoiceView
473498
{wallet}
499+
bind:isRequestPayed
474500
{requestNetwork}
475501
{currencyManager}
476502
config={activeConfig}

0 commit comments

Comments
 (0)