feat(ui): add Send/Re-send button on invoices page and order block

This commit is contained in:
Gerhard Scheikl
2026-05-09 17:09:33 +02:00
parent 227c00b3a0
commit cc159f9b6b
2 changed files with 97 additions and 15 deletions
+17 -1
View File
@@ -234,13 +234,16 @@ function FilterChip({
function OrderRow({ order }: { order: RecentOrder }) {
const fetcher = useFetcher<{ ok: boolean; error?: string; invoiceNumber?: string }>();
const sendFetcher = useFetcher<{ ok: boolean; error?: string }>();
const isBusy = fetcher.state !== "idle";
const isSending = sendFetcher.state !== "idle";
const isCancelReissue = order.hasInvoice && order.invoiceSent;
const buttonLabel = !order.hasInvoice
? "Generate"
: order.invoiceSent
? "Cancel & reissue"
: "Regenerate";
const sendLabel = order.invoiceSent ? "Re-send" : "Send";
return (
<s-table-row>
@@ -271,6 +274,9 @@ function OrderRow({ order }: { order: RecentOrder }) {
{fetcher.data?.error ? (
<s-text tone="critical">{fetcher.data.error}</s-text>
) : null}
{sendFetcher.data?.error ? (
<s-text tone="critical">{sendFetcher.data.error}</s-text>
) : null}
</s-stack>
) : (
<s-text tone="neutral"></s-text>
@@ -289,13 +295,23 @@ function OrderRow({ order }: { order: RecentOrder }) {
) : null}
<s-button
type="submit"
disabled={isBusy}
disabled={isBusy || isSending}
variant={order.hasInvoice ? "secondary" : "primary"}
tone={isCancelReissue ? "critical" : "auto"}
>
{isBusy ? "Working…" : buttonLabel}
</s-button>
</fetcher.Form>
<sendFetcher.Form method="post" action={`/api/orders/${order.numericId}/invoice`}>
<input type="hidden" name="action" value="send" />
<s-button
type="submit"
disabled={isBusy || isSending}
variant={order.hasInvoice && !order.invoiceSent ? "primary" : "secondary"}
>
{isSending ? "Sending…" : sendLabel}
</s-button>
</sendFetcher.Form>
</s-stack>
</s-table-cell>
</s-table-row>