Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
export let requestNetwork: RequestNetwork | null | undefined;
export let request: Types.IRequestDataWithEvents | undefined;
export let currencyManager: any;
export let isRequestPayed: boolean;

let network = request?.currencyInfo?.network || "mainnet";
let currency = currencyManager.fromAddress(request?.currencyInfo?.value);
Expand Down Expand Up @@ -140,6 +141,7 @@
isPaid = true;
loading = false;
statuses = [];
isRequestPayed = true;
} catch (err) {
console.error("Something went wrong while paying : ", err);
loading = false;
Expand Down
26 changes: 26 additions & 0 deletions packages/invoice-dashboard/src/lib/view-requests.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
let loading = false;
let searchQuery = "";
let debouncedUpdate: any;
let isRequestPayed = false;
let currentTab = "All";
let requests: Types.IRequestDataWithEvents[] | undefined = [];
let activeRequest: Types.IRequestDataWithEvents | undefined;
Expand All @@ -67,6 +68,8 @@
signer = wallet?.accounts[0]?.address;
}

$: isRequestPayed, getOneRequest(activeRequest);

onMount(() => {
currencyManager = initializeCurrencyManager(currencies);
});
Expand All @@ -90,6 +93,28 @@
}
};

const getOneRequest = async (activeRequest: any) => {
try {
loading = true;

const _request = await requestNetwork?.fromRequestId(
activeRequest?.requestId!
);

requests = requests?.filter(
(request) => request.requestId !== activeRequest.requestId
);
requests = [...requests, _request.getData()].sort(
(a, b) => b.timestamp - a.timestamp
);

loading = false;
} catch (error) {
loading = false;
console.error("Failed to fetch request:", error);
}
};

$: {
if (requests && loading) {
loading = false;
Expand Down Expand Up @@ -471,6 +496,7 @@
{#if activeRequest !== undefined}
<InvoiceView
{wallet}
bind:isRequestPayed
{requestNetwork}
{currencyManager}
config={activeConfig}
Expand Down