Skip to content

Commit 785e33f

Browse files
feat: handle all request status (#138)
1 parent c339015 commit 785e33f

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import { Types } from "@requestnetwork/request-client.js";
3232
import { onMount } from "svelte";
3333
import { formatUnits } from "viem";
34-
import { debounce, exportToPDF, formatAddress } from "../utils";
34+
import { capitalize, debounce, exportToPDF, formatAddress } from "../utils";
3535
import { getCurrencyFromManager } from "../utils/getCurrency";
3636
import { Drawer, InvoiceView } from "./dashboard";
3737
@@ -276,11 +276,13 @@
276276
};
277277
278278
const checkStatus = (request: any) => {
279-
switch (request?.balance?.balance >= request?.expectedAmount) {
279+
switch (request?.balance?.balance > 0) {
280280
case true:
281-
return "Paid";
281+
return request?.balance?.balance >= request?.expectedAmount
282+
? "Paid"
283+
: "Partially Paid";
282284
default:
283-
return "Created";
285+
return capitalize(request?.state);
284286
}
285287
};
286288
</script>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const capitalize = (str: string) => (str && str[0].toUpperCase() + str.slice(1)) || ""

packages/invoice-dashboard/src/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ export { debounce } from "./debounce";
22
export { formatAddress } from "./formatAddress";
33
export { exportToPDF } from "./generateInvoice";
44
export { publicClientToProvider, walletClientToSigner } from "./wallet-utils";
5+
export { capitalize } from "./capitalize";

0 commit comments

Comments
 (0)