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
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -399,11 +399,11 @@ If a screen still needs a capability the GRIDGO API does not expose, show an hon

## Navigation contract

**Single source:** `src/lib/nav.ts` → `ROLE_NAV_GROUPS` (rail sections) and flattened `ROLE_NAV` (items). Overview / Orders / Jobs stay top-level as plain rows; every labeled group (Work queue / Field & delivery / People & shops / Money / Marketing / Legal & privacy for ops; Work queue / Field & delivery / People & shops / Catalogue / Money / Marketing / Legal & privacy / System for admin; Shop / Money for suppliers) is a collapsible parent row — group `icon` + label + chevron — with its pages as indented sub-rows on a guide line. The group holding the current page opens itself; other groups remember the person's choice, and the whole-rail fold is remembered too (`src/components/shell/rail-state.ts`, localStorage). In the icon rail a group opens its pages in a flyout. Small muted section headings (sidebar-07) sit above runs of groups — each `NavGroup.section`; ops Desk / Work / Manage, admin Desk / Work / Manage / Platform, supplier Work / Business — and drop out on the icon rail. Count badges sit inline right after a label, never at the far edge: `NavItem.count` names the source, `src/lib/nav-counts.ts` owns sums, wording ("Orders, 3 need action" as the row's `aria-label`) and 99+, and `src/lib/live/useNavCounts.tsx` reads each source once per rail from an existing list endpoint (never a rail-only endpoint). Yellow only for orders waiting on Operations; other counts are monochrome. A folded group shows its filled total; an open group shows an outlined total only when two or more rows are counted; the icon rail puts the total on the group icon and per-page counts in the flyout. Screenshots: `docs/screenshots/sidebar/`.
**Single source:** `src/lib/nav.ts` → `ROLE_NAV_GROUPS` (rail sections) and flattened `ROLE_NAV` (items). Overview / Orders / Jobs stay top-level as plain rows; every labeled group (Work queue / Field & delivery / People & shops / Money / Marketing / Legal & privacy for ops; Work queue / Field & delivery / People & shops / Catalogue / Money / Marketing / Legal & privacy / System for admin; To do / Money / My shop for suppliers, with Messages a plain row between them, the phone app's four sections; a `railHidden` item stays routable and is linked from My shop instead of the rail) is a collapsible parent row — group `icon` + label + chevron — with its pages as indented sub-rows on a guide line. The group holding the current page opens itself; other groups remember the person's choice, and the whole-rail fold is remembered too (`src/components/shell/rail-state.ts`, localStorage). In the icon rail a group opens its pages in a flyout. Small muted section headings (sidebar-07) sit above runs of groups — each `NavGroup.section`; ops Desk / Work / Manage, admin Desk / Work / Manage / Platform, none for suppliers — and drop out on the icon rail. Count badges sit inline right after a label, never at the far edge: `NavItem.count` names the source, `src/lib/nav-counts.ts` owns sums, wording ("Orders, 3 need action" as the row's `aria-label`) and 99+, and `src/lib/live/useNavCounts.tsx` reads each source once per rail from an existing list endpoint (never a rail-only endpoint). Yellow only for orders waiting on Operations; other counts are monochrome. A folded group shows its filled total; an open group shows an outlined total only when two or more rows are counted; the icon rail puts the total on the group icon and per-page counts in the flyout. Screenshots: `docs/screenshots/sidebar/`.

| Role | Surface (hrefs) |
| ----------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
| supplier | `/supplier/dashboard`, `jobs`, `chat`, `shop`, `team`, `documents`, `services`, `catalogue`, `product-types`, `schedule`, `shop-hours`, `capacity`, `payouts`, `payout-account` |
| supplier | `/supplier/dashboard` (Today, the home), `jobs`, `schedule`, `performance`, `chat`, `payouts`, `payout-account`, `my-shop`, `catalogue`, `team`, `shop-hours`, `shop`, `documents` (off the rail, linked from My shop: `product-types`, `services`, `capacity`, `record`, `legal`, `privacy`, `report`). Shop Staff see Today and All jobs only |
| ops_admin | `/ops/overview`, `orders`, `quotes`, `sample-batches`, `finished-work`, `service-lines`, `listing-reviews`, `colour-price-checks`, `featured-prints`, `dispatch`, `riders`, `handoff-reminders`, `shop-hours`, `late-production`, `shop-performance`, `shop-changes`, `hub`, `escalations`, `schedule`, `payouts`, `supplier-invoices`, `refunds`, `cash`, `organizations`, `vouchers`, `promotions`, `home-promos`, `founding-testers`, `play-testers`, `early-access`, `claims`, `recovery`, `legal`, `acceptance-log`, `privacy-requests` (`/ops/settings` and `/ops/audit` stay as the "Super Admin only" screen, off the rail) |
| super_admin | `/admin/overview`, `orders`, `chat`, `order-chats`, `quotes`, `sample-batches`, `finished-work`, `colour-price-checks`, `shop-changes`, `issue-reports`, `survey-responses`, `riders`, `handoff-reminders`, `escalations`, `hub`, `zones`, `verification`, `roles`, `staff`, `organizations`, `founding-testers`, `play-testers`, `early-access`, `shop-hours`, `shop-performance`, `late-production`, `catalogue`, `listing-reviews`, `supplier-products`, `finance`, `pricing`, `supplier-invoices`, `refunds`, `cash`, `promotions`, `vouchers`, `home-promos`, `featured-prints`, `broadcast`, `legal`, `acceptance-log`, `privacy-requests`, `account-deletion`, `settings`, `audit`, `planning`, `season-windows`, `tracker`, `file-retention` |

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ vi.mock("@/lib/api/client", async () => {
return { ...actual, listJobs: listJobsMock, getSupplierReadiness: readinessMock };
});

import SupplierDashboardPage from "@/app/supplier/dashboard/page";
import SupplierDashboardPage from "@/app/supplier/performance/page";

beforeAll(() => {
// Recharts measures its container; jsdom reports zero and renders nothing.
Expand Down
80 changes: 80 additions & 0 deletions src/app/supplier/__tests__/today.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { describe, expect, it } from "vitest";

import type { Order } from "@/lib/api/types";
import { afterThat, dueToday, earnedToday, expressQueue, greeting } from "@/app/supplier/_lib/today";

const NOW = new Date(2026, 10, 22, 10, 0, 0);

function job(over: Partial<Order> & Pick<Order, "id" | "state">): Order {
return { title: "Job", ...over } as Order;
}

function expressJob(id: string, state: string, deadline: string, acceptance = "pending"): Order {
return job({
id,
state,
orderType: "express",
expressOrder: { printSettings: [] },
shopAcceptance: {
supplierId: "s",
assignedAt: deadline,
deadlineAt: deadline,
workingMinutes: 5,
status: acceptance as "pending",
},
});
}

describe("Today", () => {
it("puts Express offers first, then the counter, then the press, soonest clock first", () => {
const queue = expressQueue([
expressJob("working", "payment_authorized", "2026-11-22T02:00:00Z", "accepted"),
expressJob("offer_late", "supplier_assigned", "2026-11-22T02:05:00Z"),
expressJob("counter", "ready_for_dispatch", "2026-11-22T01:00:00Z", "accepted"),
expressJob("offer_soon", "supplier_assigned", "2026-11-22T02:01:00Z"),
job({ id: "regular", state: "production" }),
]);
expect(queue.map((order) => order.id)).toEqual(["offer_soon", "offer_late", "counter", "working"]);
});

it("leaves Express jobs out of After that", () => {
const rows = afterThat(
[expressJob("x", "supplier_assigned", "2026-11-22T02:00:00Z"), job({ id: "r", state: "supplier_assigned" })],
NOW,
);
expect(rows.some((row) => row.href.endsWith("/x"))).toBe(false);
expect(rows.some((row) => row.href.endsWith("/r"))).toBe(true);
});

it("lists only open work due today, earliest first", () => {
const due = dueToday(
[
job({ id: "late", state: "production", readyBy: new Date(2026, 10, 22, 16).toISOString() }),
job({ id: "soon", state: "production", readyBy: new Date(2026, 10, 22, 12).toISOString() }),
job({ id: "tomorrow", state: "production", readyBy: new Date(2026, 10, 23, 12).toISOString() }),
job({ id: "done", state: "completed", readyBy: new Date(2026, 10, 22, 12).toISOString() }),
],
NOW,
);
expect(due.map((order) => order.id)).toEqual(["soon", "late"]);
});

it("adds what today's finished work pays, counting Express", () => {
const today = new Date(2026, 10, 22, 9).toISOString();
expect(
earnedToday(
[
{ ...expressJob("e", "completed", today, "accepted"), readyAt: today, supplierPriceMinor: 12_000 },
job({ id: "r", state: "completed", readyAt: today, supplierPriceMinor: 30_000 }),
job({ id: "y", state: "completed", readyAt: new Date(2026, 10, 21).toISOString(), supplierPriceMinor: 99 }),
],
NOW,
),
).toEqual({ minor: 42_000, jobs: 2, express: 1 });
});

it("greets by the clock with the first name", () => {
expect(greeting(NOW, "Ana Reyes")).toBe("Magandang umaga, Ana!");
expect(greeting(new Date(2026, 10, 22, 19), null)).toBe("Magandang gabi!");
});
});
41 changes: 6 additions & 35 deletions src/app/supplier/_components/SupplierLegalGate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { Button } from "@/components/ui/button";
import { SkeletonCards } from "@/components/ui/loading";
import { ApiError } from "@/lib/api/client";
import { useShopAccess } from "@/lib/auth/shop-access";
import { supplierWebDeviceId } from "@/lib/device-id";
import { acceptSupplierLegal, getSupplierLegalPending } from "@/lib/api/supplier-self";
import {
LEGAL_VERSION_CHANGED,
Expand All @@ -30,6 +31,8 @@ import {
type GateValue = {
status: "unknown" | "clear" | "blocked" | "unavailable" | "unsupported";
pending: LegalVersion[];
/** Updated documents that need no signature: read on My shop, never a banner on every page. */
notices: LegalVersion[];
checking: boolean;
refresh: () => void;
error: string | null;
Expand All @@ -45,21 +48,8 @@ export function useSupplierLegal(): GateValue {
return value;
}

const INSTALLATION_KEY = "gridgo.supplier.web.installationId";

function webContext(): { app: string; device: string } {
let device = "supplier-web";
try {
const stored = window.localStorage.getItem(INSTALLATION_KEY);
if (stored) device = stored;
else {
device = `supplier-web-${crypto.randomUUID()}`;
window.localStorage.setItem(INSTALLATION_KEY, device);
}
} catch {
device = "supplier-web";
}
return { app: "gridgo-web/supplier", device };
return { app: "gridgo-web/supplier", device: supplierWebDeviceId() };
}

/**
Expand All @@ -70,6 +60,7 @@ function webContext(): { app: string; device: string } {
const STAFF_GATE: GateValue = {
status: "clear",
pending: [],
notices: [],
checking: false,
refresh: () => undefined,
error: null,
Expand Down Expand Up @@ -214,7 +205,7 @@ function LegalSession({
(status === "unknown" || status === "blocked" || status === "unavailable");
return (
<Gate.Provider
value={{ status, pending, error, accepting, accept, checking, refresh }}
value={{ status, pending, notices, error, accepting, accept, checking, refresh }}
>
{error && !accepting ? (
<div className="flex flex-col items-start gap-2" role="alert">
Expand All @@ -233,26 +224,6 @@ function LegalSession({
</Link>
</div>
) : null}
{notices.length ? (
<section aria-label="Document updates" className="mb-4 flex flex-col gap-2">
<h2 className="text-body text-text-primary m-0">Document updates</h2>
{notices.map((doc) => (
<div key={doc.id}>
<Link
href={`/supplier/legal/${encodeURIComponent(doc.id)}`}
className="text-body text-text-primary underline"
>
{doc.title}
</Link>
{doc.changeSummary ? (
<p className="text-caption text-text-secondary m-0">
{doc.changeSummary}
</p>
) : null}
</div>
))}
</section>
) : null}
{waiting ? (
status !== "unavailable" ? (
<SkeletonCards count={2} lines={2} label="Checking terms" />
Expand Down
16 changes: 10 additions & 6 deletions src/app/supplier/_components/__tests__/SupplierLegalGate.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,21 +106,25 @@ it("rechecks on focus and removes work when new consent becomes required", async
await waitFor(() => expect(m.replace).toHaveBeenCalled());
expect(screen.queryByText("Ordinary work")).not.toBeInTheDocument();
});
it("shows editorial notices without requiring another checkbox", async () => {
it("hands editorial notices to My shop instead of a banner on every page", async () => {
m.pending.mockResolvedValue({
...clear,
notices: [{ ...doc, id: "editorial", title: "Updated privacy notice" }],
});
function Notices() {
const { notices } = useSupplierLegal();
return <p>Notices: {notices.map((notice) => notice.title).join(", ")}</p>;
}
render(
<SupplierLegalGate>
<div>Ordinary work</div>
<Notices />
</SupplierLegalGate>,
);
await screen.findByText("Ordinary work");
expect(screen.getByRole("link", { name: "Updated privacy notice" })).toHaveAttribute(
"href",
"/supplier/legal/editorial",
);
await screen.findByText("Notices: Updated privacy notice");
expect(screen.getByText("Ordinary work")).toBeVisible();
// No banner and no link drawn above the work (gridgoph/gridgo-web#327).
expect(screen.queryByRole("link", { name: "Updated privacy notice" })).not.toBeInTheDocument();
expect(screen.queryByRole("checkbox")).not.toBeInTheDocument();
});
it("keeps the legal and privacy pages available during a pending check", async () => {
Expand Down
Loading
Loading