Skip to content

Commit

Permalink
feat: handle all request status (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigopavezi authored Sep 17, 2024
1 parent c339015 commit 785e33f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions packages/invoice-dashboard/src/lib/view-requests.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import { Types } from "@requestnetwork/request-client.js";
import { onMount } from "svelte";
import { formatUnits } from "viem";
import { debounce, exportToPDF, formatAddress } from "../utils";
import { capitalize, debounce, exportToPDF, formatAddress } from "../utils";
import { getCurrencyFromManager } from "../utils/getCurrency";
import { Drawer, InvoiceView } from "./dashboard";
Expand Down Expand Up @@ -276,11 +276,13 @@
};
const checkStatus = (request: any) => {
switch (request?.balance?.balance >= request?.expectedAmount) {
switch (request?.balance?.balance > 0) {
case true:
return "Paid";
return request?.balance?.balance >= request?.expectedAmount
? "Paid"
: "Partially Paid";
default:
return "Created";
return capitalize(request?.state);
}
};
</script>
Expand Down
1 change: 1 addition & 0 deletions packages/invoice-dashboard/src/utils/capitalize.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const capitalize = (str: string) => (str && str[0].toUpperCase() + str.slice(1)) || ""
1 change: 1 addition & 0 deletions packages/invoice-dashboard/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ export { debounce } from "./debounce";
export { formatAddress } from "./formatAddress";
export { exportToPDF } from "./generateInvoice";
export { publicClientToProvider, walletClientToSigner } from "./wallet-utils";
export { capitalize } from "./capitalize";

0 comments on commit 785e33f

Please sign in to comment.