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
15 changes: 10 additions & 5 deletions src/app/dashboard/wallets/[id]/payment-links/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { use, useCallback, useEffect, useState } from "react";
import { use, useCallback, useEffect, useRef, useState } from "react";
import { useAuth } from "@/lib/useAuth";
import { useWallet } from "@/lib/useWallet";
import { PaymentLinkList } from "@/components/payment-links/PaymentLinkList";
Expand Down Expand Up @@ -51,12 +51,17 @@ export default function PaymentLinksPage({
const [pageIndex, setPageIndex] = useState(0);
const [nextCursor, setNextCursor] = useState<string | null>(null);

// Latest non-silent request id; a response that no longer matches it is stale and dropped.
const latestReq = useRef(0);

const load = useCallback(
(before: string | null, opts?: { silent?: boolean }) => {
if (!token) return;
const reqId = opts?.silent ? latestReq.current : ++latestReq.current;
if (!opts?.silent) setRefreshing(true);
listPaymentLinksPage(asAuthToken(token), asWalletId(id), { before })
return listPaymentLinksPage(asAuthToken(token), asWalletId(id), { before })
.then((page) => {
if (reqId !== latestReq.current) return;
setLinks(page.data);
setNextCursor(page.next_cursor);
setError(null);
Expand Down Expand Up @@ -148,14 +153,14 @@ export default function PaymentLinksPage({
</div>

<div className="grid grid-cols-2 gap-4 lg:grid-cols-4">
<Stat label="Total links" value={String(links.length)} />
<Stat label="Active links" value={String(activeCount)} />
<Stat label="Links on this page" value={String(links.length)} />
<Stat label="Active on this page" value={String(activeCount)} />
<Stat
label="Total collected (this page)"
value={`$${formatStroops(totalCollected)}`}
/>
<Stat
label="Avg. payment (this page)"
label="Avg. collected per paid link (this page)"
value={`$${formatStroops(avgPayment)}`}
/>
</div>
Expand Down
9 changes: 7 additions & 2 deletions src/app/dashboard/wallets/[id]/transactions/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { use, useCallback, useEffect, useMemo, useState } from "react";
import { use, useCallback, useEffect, useRef, useMemo, useState } from "react";
import { useAuth } from "@/lib/useAuth";
import { useWallet } from "@/lib/useWallet";
import {
Expand Down Expand Up @@ -43,12 +43,17 @@ export default function TransactionsPage({
const [pageIndex, setPageIndex] = useState(0);
const [nextCursor, setNextCursor] = useState<string | null>(null);

// Latest non-silent request id; a response that no longer matches it is stale and dropped.
const latestReq = useRef(0);

const load = useCallback(
(before: string | null, opts?: { silent?: boolean }) => {
if (!token) return;
const reqId = opts?.silent ? latestReq.current : ++latestReq.current;
if (!opts?.silent) setRefreshing(true);
listTransactionsPage(token, id, { before })
return listTransactionsPage(token, id, { before })
.then((page) => {
if (reqId !== latestReq.current) return;
setTxns(page.data);
setNextCursor(page.next_cursor);
setError(null);
Expand Down
4 changes: 2 additions & 2 deletions src/components/addresses/AddressSearchBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export function AddressSearchBox({ onChange }: { onChange: (query: string) => vo
type="search"
value={value}
onChange={(e) => setValue(e.target.value)}
placeholder="Search by customer reference"
aria-label="Search addresses by customer reference"
placeholder="Search loaded addresses by customer reference"
aria-label="Search loaded addresses by customer reference"
className="w-full max-w-sm rounded-xl border border-border bg-surface-raised px-4 py-2 text-sm text-foreground placeholder:text-muted/60 focus:border-burgundy-bright focus:outline-none"
/>
);
Expand Down
Loading