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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### Changed

- Payments, Plan, payment setup and the admin overview, vendors and activity pages now use more of the shared `@merqo/ui` components (stat tiles, sections, cards, data tables). Payments shows one table at every width, with the Kit and Created columns hidden on phones. Behaviour, plan limits and copy are unchanged.
- Bookings, inquiries and their detail pages now use the shared Merqo section, card and empty-state components.

## [0.11.3] - 2026-12-02
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -409,3 +409,5 @@ The `/admin/activity` paging links and boundaries are pinned by `src/app/admin/a
The landing phone mockups use rem font sizes, so the dashboard text-size adjuster scales them like the rest of the page.

The bookings list, inquiries and their detail pages use the shared `@merqo/ui` `Section`, `ElevatedCard` and `EmptyState` (see `CHANGELOG.md`).

The payments table, payment setup, plan and admin pages use more shared `@merqo/ui` components (stat tiles, sections, cards, data tables); see `CHANGELOG.md`.
6 changes: 4 additions & 2 deletions src/app/admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ figure-tile helper used by the overview and vendors screens.
`securityStats()` in `@/lib/admin-data`), a recent cross-vendor activity
feed (rows link to `/admin/vendors?q=<vendor id>`, or `EmptyState` when empty). Page titles use the
shared `PageHeader`; statuses read Awaiting payment / Marked paid / Received.
- Overview figures use `@merqo/ui`'s shared `StatCard` (label/value plus optional
`caption` and a period-over-period `delta`/`deltaTooltip` pill, `deltaSize="xs"`).
- Overview figures use `@merqo/ui`'s `StatTile` with `card` (label/value plus optional
`caption` and a period-over-period `delta`/`deltaTooltip` pill). The recent-activity feed is
`recent-activity-table.tsx`, a `DataTable` in a Client Component whose vendor cell links to
`/admin/vendors?q=<vendor id>`; Kit and When hide on phones.
- `vendors/`

## Connectivity
Expand Down
2 changes: 2 additions & 0 deletions src/app/admin/activity/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ The action select uses `FILTER_SELECT_CLASS` (with a `sm:w-56` override); paging
Timestamps display through `Timestamp` (or `formatDate`/`formatDateTime`) from `@merqo/ui`, always in Asia/Singapore so server and client render identically (no hydration mismatch).

Paging for this page is covered by `activity-paging.dom.test.tsx` (boundary links, second-page rows, filters kept in links, past-the-end redirect) alongside `activity-page.dom.test.tsx`.

The Target link is a 44px tap target (`inline-flex min-h-11 items-center`).
2 changes: 1 addition & 1 deletion src/app/admin/activity/activity-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const columns: DataTableColumn<ActivityEntry>[] = [
e.target ? (
<Link
href={listHref("/admin/vendors", { q: e.target })}
className="underline-offset-4 hover:underline"
className="inline-flex min-h-11 items-center underline-offset-4 hover:underline"
>
{e.target}
</Link>
Expand Down
118 changes: 22 additions & 96 deletions src/app/admin/page.tsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,20 @@
import type { Metadata } from "next";
import Link from "next/link";
import { requireAdmin } from "@/lib/admin";
import {
platformTotals,
recentActivity,
securityStats,
} from "@/lib/admin-data";
import { Badge } from "@merqo/ui/primitives";

import {
EmptyState,
Money,
PageHeader,
StatCard,
Timestamp,
formatMoney,
} from "@merqo/ui";
import type { TxStatus } from "@/lib/types";
import { listHref } from "@/app/admin/list-params";
import { PageHeader, Section, StatTile, formatMoney } from "@merqo/ui";
import { pctChange } from "@/lib/utils";
import { RecentActivityTable } from "./recent-activity-table";

export const metadata: Metadata = {
title: "Admin overview",
};

export const revalidate = 0;

// API status values are unchanged; only the displayed wording differs.
const STATUS_LABELS: Record<TxStatus, string> = {
pending: "Awaiting payment",
claimed: "Marked paid",
confirmed: "Received",
};

export default async function AdminOverviewPage() {
await requireAdmin();

Expand All @@ -47,113 +29,57 @@ export default async function AdminOverviewPage() {
<PageHeader responsive title="Overview" className="mb-0" />

<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6">
<StatCard
deltaSize="xs"
label="Vendors"
value={String(totals.vendors)}
/>
<StatCard
deltaSize="xs"
label="Free plan"
value={String(totals.free_vendors)}
/>
<StatCard
deltaSize="xs"
label="Pro plan"
value={String(totals.pro_vendors)}
/>
<StatCard
deltaSize="xs"
<StatTile label="Vendors" value={String(totals.vendors)} card />
<StatTile label="Free plan" value={String(totals.free_vendors)} card />
<StatTile label="Pro plan" value={String(totals.pro_vendors)} card />
<StatTile
label="Transactions"
value={String(totals.transactions)}
card
/>
<StatCard
deltaSize="xs"
<StatTile
label="Confirmed · 7d"
value={String(totals.confirmed_7d)}
delta={pctChange(totals.confirmed_7d, totals.confirmed_prev_7d)}
deltaTooltip="vs. the prior 7 days"
card
/>
<StatCard
deltaSize="xs"
<StatTile
label="Confirmed volume · 30d"
value={formatMoney(totals.confirmed_volume_cents_30d)}
delta={pctChange(
totals.confirmed_volume_cents_30d,
totals.confirmed_volume_cents_prev_30d,
)}
deltaTooltip="vs. the prior 30 days"
card
/>
<StatCard
deltaSize="xs"
<StatTile
label="Refunds · 30d"
value={String(totals.refund_count_30d)}
caption={formatMoney(totals.refund_volume_cents_30d)}
card
/>
</div>

<section className="space-y-3">
<h2 className="text-sm font-medium text-muted-foreground">Security</h2>
<Section title="Security">
<div className="grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-6">
<StatCard
deltaSize="xs"
<StatTile
label="Failed sign-ins, last 24h"
value={String(security.failed_auth_24h)}
card
/>
<StatCard
deltaSize="xs"
<StatTile
label="Rate-limited kits · 24h"
value={String(security.rate_limited_kits_24h)}
card
/>
</div>
</section>
</Section>

<section className="space-y-3">
<h2 className="text-sm font-medium text-muted-foreground">
Recent activity across all vendors
</h2>
{activity.length > 0 ? (
<ul className="divide-y border-y">
{activity.map((tx) => (
<li key={tx.id}>
<Link
href={listHref("/admin/vendors", { q: tx.vendor_id })}
className="flex min-h-11 flex-wrap items-center justify-between gap-x-3 gap-y-1 py-2.5 text-sm hover:bg-muted/50"
>
<span className="flex min-w-0 items-center gap-2.5">
<span className="min-w-0 truncate font-medium">
{tx.email ?? "Not set"}
</span>
<span className="shrink-0 text-muted-foreground">
{tx.kit_slug}
</span>
<Badge
variant={
tx.status === "confirmed" ? "default" : "secondary"
}
>
{STATUS_LABELS[tx.status]}
</Badge>
</span>
<span className="flex shrink-0 items-center gap-3">
<Money cents={tx.amount_cents} />
<Timestamp
value={tx.created_at}
variant="datetime"
className="text-muted-foreground"
/>
</span>
</Link>
</li>
))}
</ul>
) : (
<EmptyState
title="No activity yet"
description="Payments from every vendor show up here as they happen."
/>
)}
</section>
<Section title="Recent activity across all vendors">
<RecentActivityTable rows={activity} />
</Section>
</main>
);
}
91 changes: 91 additions & 0 deletions src/app/admin/recent-activity-table.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
"use client";

import Link from "next/link";
import {
DataTable,
EmptyState,
Money,
Timestamp,
type DataTableColumn,
} from "@merqo/ui";
import { Badge } from "@merqo/ui/primitives";
import type { TxStatus } from "@/lib/types";
import { listHref } from "@/app/admin/list-params";

export type RecentActivityRow = {
id: string;
vendor_id: string;
email: string | null;
kit_slug: string;
amount_cents: number;
status: TxStatus;
created_at: string;
};

// API status values are unchanged; only the displayed wording differs.
const STATUS_LABELS: Record<TxStatus, string> = {
pending: "Awaiting payment",
claimed: "Marked paid",
confirmed: "Received",
};

// `columns` holds `cell` render callbacks, so `DataTable` has to be rendered
// from a Client Component rather than the server page.
const columns: DataTableColumn<RecentActivityRow>[] = [
{
header: "Vendor",
cell: (tx) => (
<Link
href={listHref("/admin/vendors", { q: tx.vendor_id })}
className="inline-flex min-h-11 items-center font-medium underline-offset-4 hover:underline"
>
{tx.email ?? "Not set"}
</Link>
),
},
{
header: "Kit",
className: "hidden sm:table-cell",
cell: (tx) => tx.kit_slug,
},
{
header: "Status",
cell: (tx) => (
<Badge variant={tx.status === "confirmed" ? "default" : "secondary"}>
{STATUS_LABELS[tx.status]}
</Badge>
),
},
{
header: "Amount",
align: "end",
cell: (tx) => <Money cents={tx.amount_cents} />,
},
{
header: "When",
className: "hidden sm:table-cell",
cell: (tx) => (
<Timestamp
value={tx.created_at}
variant="datetime"
className="text-muted-foreground"
/>
),
},
];

export function RecentActivityTable({ rows }: { rows: RecentActivityRow[] }) {
return (
<DataTable
rows={rows}
columns={columns}
getRowKey={(tx) => tx.id}
emptyState={
<EmptyState
title="No activity yet"
description="Payments from every vendor show up here as they happen."
/>
}
/>
);
}
2 changes: 2 additions & 0 deletions src/app/admin/vendors/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,5 @@ Buttons, inputs, dialogs, badges and the other shared primitives here are import
Paging and the failed-read card are the shared `UrlPager` and `ListError` from `@/components/list/`.

Timestamps display through `Timestamp` (or `formatDate`/`formatDateTime`) from `@merqo/ui`, always in Asia/Singapore so server and client render identically (no hydration mismatch).

The Transactions column is end-aligned through the column `align` option.
3 changes: 2 additions & 1 deletion src/app/admin/vendors/vendors-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ const columns: DataTableColumn<VendorRow>[] = [
{
header: "Transactions",
cell: (v) => v.transaction_count,
className: "text-right tabular-nums",
align: "end",
className: "tabular-nums",
},
{
header: "Joined",
Expand Down
1 change: 0 additions & 1 deletion src/app/dashboard/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,5 +105,4 @@ Gotchas:
- `DataTable` has no row-level link, so make one cell's link a 44px target (`inline-flex min-h-11 items-center`) and hide low-value columns on phones with a column `className` of `hidden sm:table-cell`.
- `SegmentedControl` link mode needs `LinkComponent={Link}` (from `next/link`) for client-side navigation, and `selected` on the active option sets `aria-current="page"`.
- `ElevatedCard` has no padding of its own; add `p-6` (or similar) on the card.
- `src/app/admin/page.tsx` still uses the deprecated `StatCard`; move it to `StatTile card` in slice 4.
- `@merqo/ui` has no bottom tab bar, More sheet or side rail export. Its `DashboardNav` only offers `mobileNav="menu" | "none"` (a burger menu), so the phone tab bar and desktop rail stay local in `src/components/nav`.
2 changes: 2 additions & 0 deletions src/app/dashboard/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,3 +112,5 @@ Buttons, inputs, dialogs, badges and the other shared primitives here are import
Inline save errors on the payment form use the shared `FormError`. The Stripe and HitPay link warnings in `pointer-presets.ts` contain no em dash.

The amber warning on a pointer URL uses the `warning` tone (`--warning` in `globals.css`), not a palette colour.

The sample QR preview sits in a shared `ElevatedCard`.
6 changes: 3 additions & 3 deletions src/app/dashboard/config/payment-config-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
removeUnsavedImages,
uploadPaykitImage,
} from "@/lib/image-upload-adapter";
import { FormError, resizeToWebp } from "@merqo/ui";
import { ElevatedCard, FormError, resizeToWebp } from "@merqo/ui";
import { buildPayNowPayload } from "@/lib/payments/paynow";
import { isHttpUrl } from "@/lib/schemas";
import { saveConfigAction, type SaveConfigState } from "./actions";
Expand Down Expand Up @@ -186,12 +186,12 @@ function PayNowFields({
)}

{previewPayload && (
<div className="rounded-xl border p-4">
<ElevatedCard className="p-4">
<p className="mb-2 text-xs font-semibold uppercase tracking-wider text-muted-foreground">
Preview ($1.00 sample QR)
</p>
<QRCode value={previewPayload} size={160} />
</div>
</ElevatedCard>
)}
</>
);
Expand Down
2 changes: 2 additions & 0 deletions src/app/dashboard/plan/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,5 @@ Page chrome here (PageHeader) comes from `@merqo/ui`; paykit keeps no local copy
The merqo base URL used by the page comes from `@merqo/ui/kit-api`.

Signed-out and stale-terms vendors come back here after sign-in or terms acceptance: the page passes its own path and query to `getVendorSession` as `returnTo`.

The current-plan panel is an `ElevatedCard` and "What paid plans add" is a shared `Section`.
Loading
Loading