#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere
TypeScript dockerhacktoberfestjavapdfpdf-converterpdf-editorpdf-manipulationpdf-mergerpdf-ocrpdf-toolspdf-web-appspdfmergerself-hosted
Portal: Procurement surface — layout rework + stateful mock backend (#6785)
Reece Browneb38c849726b7
diff --git a/frontend/portal/public/locales/en-US/translation.toml b/frontend/portal/public/locales/en-US/translation.tomlindex 4e90ab71f1..fb85a21a27 100644--- a/frontend/portal/public/locales/en-US/translation.toml+++ b/frontend/portal/public/locales/en-US/translation.toml@@ -28,6 +28,7 @@ components = "Components"infrastructure = "Infrastructure"usage = "Usage & Billing"docs = "Developer Docs"+procurement = "Procurement"settings = "Settings"[shell.header]@@ -1806,3 +1807,75 @@ body = "Your Stirling account session has expired. Sign in again to view billingloadWallet = "Couldn't load wallet"openStripePortal = "Couldn't open Stripe portal"walletUnavailable = "Wallet unavailable: {{status}} {{statusText}}"++[procurement]+title = "Procurement"+subtitle = "Get your team evaluated, contracted, and onboarded. Every document in one place."+enterpriseBadge = "Enterprise"++[procurement.journey]+eyebrow = "Your rollout"+title = "From trial to live, one guided path"+subtitle = "Your solutions engineer is on every step. One next action at a time; the full checklist is below."+engineerLabel = "Your solutions engineer"+trialTitle = "Enterprise trial"+daysLeft_one = "{{count}} day left"+daysLeft_other = "{{count}} days left"+live = "You're live on Stirling Enterprise"+nextStep = "Next step: {{action}}"++[procurement.docs]+title = "Documents"+subtitle = "Everything you need at each step of the journey, surfaced as the deal moves through it."+here = "You're here"+done = "Done"+count_one = "{{count}} doc"+count_other = "{{count}} docs"+supportingTitle = "Supporting your evaluation"+supportingSubtitle = "SOC 2, security reviews, tax forms and more, ready when your security or procurement team asks. Some carry a one-time fee."+show = "Show"+hide = "Hide"+optional = "Optional"+paidAddon = "Paid add-on"+upcoming = "Upcoming"++[procurement.status]+available = "Available"+action = "Action needed"+pending = "Pending"+request = "On request"+complete = "Complete"++[procurement.action]+download = "Download"+sign = "Review & sign"+pay = "Pay now"+upload = "Upload"+request = "Request"++[procurement.modal]+cancel = "Cancel"+chooseFile = "Choose file"+noFile = "No file selected"+signTitle = "Review and sign your agreement"+signBody = "Opens the Stirling Enterprise Agreement for e-signature: one signature covers the MSA, order form, EULA and DPA. We countersign automatically and you advance to payment."+signCta = "Open for signature"+payTitle = "Confirm payment"+payBody = "Pay your committed contract by card or bank transfer through Stripe. Your workspace provisions as soon as payment clears."+payCta = "Continue to Stripe"+uploadTitle = "Upload your purchase order"+uploadBody = "Send us your PO and we invoice against it on your terms. Drag in the PDF or pick a file below."+uploadCta = "Upload purchase order"+requestTitle = "Request this document"+requestBodyPaid = "This is a paid add-on. Confirm and your solutions engineer will scope it and send the paperwork."+requestBodyFree = "We generate this on demand. Confirm and your solutions engineer will send it across shortly."+requestCta = "Request"+downloadTitle = "Download"+downloadBody = "Your download will begin shortly."+downloadCta = "Download"++[procurement.locked]+eyebrow = "Enterprise only"+title = "The procurement track opens with Enterprise"+description = "Trial keys, committed-volume quotes, the one-signature agreement, payment, and your document ledger all live here once you start an enterprise evaluation."+talkToSales = "Talk to sales"diff --git a/frontend/portal/src/ViewRouter.tsx b/frontend/portal/src/ViewRouter.tsxindex f56aa08bff..3ad54cd1bb 100644--- a/frontend/portal/src/ViewRouter.tsx+++ b/frontend/portal/src/ViewRouter.tsx@@ -11,6 +11,7 @@ import { EditorAdmin } from "@portal/views/EditorAdmin";import { Infrastructure } from "@portal/views/Infrastructure";import { Usage } from "@portal/views/Usage";import { DeveloperDocs } from "@portal/views/DeveloperDocs";+import { Procurement } from "@portal/views/Procurement";import { VIEW_PATHS } from "@portal/contexts/ViewContext";export function ViewRouter() {@@ -27,6 +28,7 @@ export function ViewRouter() {<Route path={VIEW_PATHS.editor} element={<EditorAdmin />} /><Route path={VIEW_PATHS.infrastructure} element={<Infrastructure />} /><Route path={VIEW_PATHS.usage} element={<Usage />} />+ <Route path={VIEW_PATHS.procurement} element={<Procurement />} /><Route path={VIEW_PATHS.docs} element={<DeveloperDocs />} />{/* Account-link is now a Settings panel; redirect legacy bookmarks home. */}<Route path="/account-link" element={<Navigate to="/" replace />} />diff --git a/frontend/portal/src/api/procurement.ts b/frontend/portal/src/api/procurement.tsnew file mode 100644index 0000000000..3a2b9fe0f2--- /dev/null+++ b/frontend/portal/src/api/procurement.ts@@ -0,0 +1,94 @@+import { apiClient } from "@portal/api/http";+import type { Tier } from "@portal/contexts/TierContext";+import type {+ DealStage,+ DocAction,+ ProcurementResponse,+} from "@portal/mocks/procurement";++export type {+ Deal,+ DealStage,+ DocAction,+ DocStatus,+ JourneyStep,+ LedgerDoc,+ LedgerGroup,+ ProcurementResponse,+ QuoteInfo,+ SolutionsEngineer,+ SupportingCategory,+ SupportingGroup,+ TrialInfo,+} from "@portal/mocks/procurement";+export { JOURNEY } from "@portal/mocks/procurement";++/** GET /v1/procurement?tier=…, the deal, journey, ledger and supporting pool. */+export async function fetchProcurement(+ tier: Tier,+): Promise<ProcurementResponse> {+ return apiClient.local.json<ProcurementResponse>(+ `/v1/procurement?tier=${encodeURIComponent(tier)}`,+ );+}++/*+ * Commercial actions. Each mutates the deal server-side and returns the updated+ * ProcurementResponse, the new canonical state, which the view applies so the+ * journey progresses. The MSW layer answers these today; a real backend honours+ * the same contracts unchanged.+ */++/** Advance the deal to the next stage (the journey's primary CTA). */+export async function advanceStage(+ fromStage: DealStage,+): Promise<ProcurementResponse> {+ return apiClient.local.json<ProcurementResponse>("/v1/procurement/advance", {+ method: "POST",+ body: { fromStage },+ });+}++/** Sign the Stirling Enterprise Agreement (MSA + order form + EULA + DPA). */+export async function signAgreement(+ docId: string,+): Promise<ProcurementResponse> {+ // A real backend opens an e-signature envelope and completes on callback;+ // here it completes immediately and advances the deal.+ return apiClient.local.json<ProcurementResponse>("/v1/procurement/sign", {+ method: "POST",+ body: { docId },+ });+}++/** Pay the contract online (card / bank transfer via Stripe). */+export async function payOnline(): Promise<ProcurementResponse> {+ return apiClient.local.json<ProcurementResponse>("/v1/procurement/pay", {+ method: "POST",+ });+}++/** Upload a purchase order to invoice against (an alternate payment path). */+export async function uploadPurchaseOrder(+ file: File,+): Promise<ProcurementResponse> {+ // A real backend takes the PO as multipart; the mock only needs the name.+ return apiClient.local.json<ProcurementResponse>(+ "/v1/procurement/purchase-order",+ {+ method: "POST",+ body: { fileName: file.name },+ },+ );+}++/** Request a document that is generated on demand (some carry a one-off fee). */+export async function requestDocument(+ docId: string,+ action: DocAction,+): Promise<ProcurementResponse> {+ return apiClient.local.json<ProcurementResponse>(+ `/v1/procurement/documents/${encodeURIComponent(docId)}/request`,+ { method: "POST", body: { action } },+ );+}diff --git a/frontend/portal/src/components/Sidebar.tsx b/frontend/portal/src/components/Sidebar.tsxindex a94c780e9d..ecfa0e7900 100644--- a/frontend/portal/src/components/Sidebar.tsx+++ b/frontend/portal/src/components/Sidebar.tsx@@ -22,6 +22,7 @@ import {UsageIcon,LinkIcon,DocsIcon,+ ProcurementIcon,SettingsIcon,ChevronDownIcon,} from "@portal/components/icons";@@ -135,8 +136,16 @@ export function Sidebar() {const { activeView, setActiveView } = useView();const { theme } = useTheme();const { openSettings } = useUI();+ const { tier } = useTier();const { t } = useTranslation();+ // Procurement is the enterprise buyer's commercial journey — surfaced only to+ // enterprise tenants (it has no free/pro equivalent).+ const platformGroup: NavEntry[] =+ tier === "enterprise"+ ? [{ id: "procurement", icon: <ProcurementIcon /> }, ...GROUP_PLATFORM]+ : GROUP_PLATFORM;+function renderGroup(entries: NavEntry[]) {return entries.map((entry) => (<NavItem@@ -218,7 +227,7 @@ export function Sidebar() {</div><div className="portal-sidebar__divider" aria-hidden /><div className="portal-sidebar__group">- {renderGroup(GROUP_PLATFORM)}+ {renderGroup(platformGroup)}</div></nav>diff --git a/frontend/portal/src/components/icons.tsx b/frontend/portal/src/components/icons.tsxindex 84d66c9cb3..51a8f0693c 100644--- a/frontend/portal/src/components/icons.tsx+++ b/frontend/portal/src/components/icons.tsx@@ -244,6 +244,16 @@ export function AgentBuilderIcon(props: IconProps) {);}+export function ProcurementIcon(props: IconProps) {+ return (+ <Svg {...props}>+ <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z" />+ <polyline points="14 2 14 8 20 8" />+ <path d="m9 15 2 2 4-4" />+ </Svg>+ );+}+export function LinkIcon(props: IconProps) {return (<Svg {...props}>diff --git a/frontend/portal/src/components/procurement/ActionModal.stories.tsx b/frontend/portal/src/components/procurement/ActionModal.stories.tsxnew file mode 100644index 0000000000..ea767202d1--- /dev/null+++ b/frontend/portal/src/components/procurement/ActionModal.stories.tsx@@ -0,0 +1,51 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { ActionModal } from "@portal/components/procurement/ActionModal";+import type { LedgerDoc } from "@portal/api/procurement";+import "@portal/views/Procurement.css";++const meta: Meta<typeof ActionModal> = {+ title: "Portal/Procurement/ActionModal",+ component: ActionModal,+ parameters: { layout: "fullscreen" },+ args: { onClose: () => {}, onDone: () => {} },+};+export default meta;+type Story = StoryObj<typeof ActionModal>;++const sign: LedgerDoc = {+ id: "d1",+ name: "Stirling Enterprise Agreement",+ sub: "One signature: MSA + order form + EULA + DPA.",+ status: "action",+ action: "sign",+};++const pay: LedgerDoc = {+ id: "d2",+ name: "Pay online",+ sub: "Card or bank transfer via Stripe.",+ status: "pending",+ action: "pay",+};++const upload: LedgerDoc = {+ id: "d3",+ name: "Purchase order",+ sub: "Upload it and we invoice against it.",+ status: "request",+ action: "upload",+};++const requestPaid: LedgerDoc = {+ id: "d4",+ name: "Custom security review",+ sub: "Dedicated session with our security team.",+ status: "request",+ action: "request",+ fee: 5_000,+};++export const Sign: Story = { args: { doc: sign } };+export const Pay: Story = { args: { doc: pay } };+export const UploadPO: Story = { args: { doc: upload } };+export const RequestPaid: Story = { args: { doc: requestPaid } };diff --git a/frontend/portal/src/components/procurement/ActionModal.tsx b/frontend/portal/src/components/procurement/ActionModal.tsxnew file mode 100644index 0000000000..0026a93684--- /dev/null+++ b/frontend/portal/src/components/procurement/ActionModal.tsx@@ -0,0 +1,166 @@+import { useRef, useState } from "react";+import { useTranslation } from "react-i18next";+import type { TFunction } from "i18next";+import { Button, Modal } from "@shared/components";+import type { LedgerDoc, ProcurementResponse } from "@portal/api/procurement";+import {+ payOnline,+ requestDocument,+ signAgreement,+ uploadPurchaseOrder,+} from "@portal/api/procurement";+import { USD } from "@portal/components/procurement/format";++interface ActionCopy {+ title: string;+ subtitle: string;+ body: string;+ cta: string;+}++/** Per-action confirmation copy, with the fee folded into the CTA when present. */+function actionCopy(doc: LedgerDoc, t: TFunction): ActionCopy {+ const fee = doc.fee !== undefined ? ` · ${USD.format(doc.fee)}` : "";+ switch (doc.action) {+ case "sign":+ return {+ title: t("procurement.modal.signTitle"),+ subtitle: doc.name,+ body: t("procurement.modal.signBody"),+ cta: t("procurement.modal.signCta"),+ };+ case "pay":+ return {+ title: t("procurement.modal.payTitle"),+ subtitle: doc.name,+ body: t("procurement.modal.payBody"),+ cta: t("procurement.modal.payCta"),+ };+ case "upload":+ return {+ title: t("procurement.modal.uploadTitle"),+ subtitle: doc.name,+ body: t("procurement.modal.uploadBody"),+ cta: t("procurement.modal.uploadCta"),+ };+ case "request":+ return {+ title: t("procurement.modal.requestTitle"),+ subtitle: doc.name,+ body: doc.fee+ ? t("procurement.modal.requestBodyPaid")+ : t("procurement.modal.requestBodyFree"),+ cta: `${t("procurement.modal.requestCta")}${fee}`,+ };+ default:+ return {+ title: t("procurement.modal.downloadTitle"),+ subtitle: doc.name,+ body: t("procurement.modal.downloadBody"),+ cta: t("procurement.modal.downloadCta"),+ };+ }+}++/**+ * Confirmation modal for a document's gating action. Owns its in-flight state;+ * on success it hands the updated deal back to the caller via `onDone` so the+ * journey re-renders. Downloads are client-side and just close the modal.+ */+export function ActionModal({+ doc,+ onClose,+ onDone,+}: {+ doc: LedgerDoc | null;+ onClose: () => void;+ onDone: (next: ProcurementResponse) => void;+}) {+ const { t } = useTranslation();+ const [submitting, setSubmitting] = useState(false);+ const fileRef = useRef<HTMLInputElement>(null);+ const [file, setFile] = useState<File | null>(null);++ if (!doc) return null;+ const copy = actionCopy(doc, t);+ const needsFile = doc.action === "upload";++ async function submit() {+ if (!doc) return;+ setSubmitting(true);+ try {+ let next: ProcurementResponse | null = null;+ switch (doc.action) {+ case "sign":+ next = await signAgreement(doc.id);+ break;+ case "pay":+ next = await payOnline();+ break;+ case "upload":+ if (file) next = await uploadPurchaseOrder(file);+ break;+ case "request":+ next = await requestDocument(doc.id, doc.action);+ break;+ default:+ // download is client-side; no state change.+ break;+ }+ setFile(null);+ if (next) onDone(next);+ else onClose();+ } finally {+ setSubmitting(false);+ }+ }++ return (+ <Modal+ open+ onClose={onClose}+ width="md"+ title={copy.title}+ subtitle={copy.subtitle}+ footer={+ <div className="portal-proc__modal-actions">+ <Button variant="ghost" onClick={onClose}>+ {t("procurement.modal.cancel")}+ </Button>+ <Button+ variant="gradient"+ accent="purple"+ loading={submitting}+ disabled={needsFile && !file}+ onClick={submit}+ >+ {copy.cta}+ </Button>+ </div>+ }+ >+ <p className="portal-proc__modal-body">{copy.body}</p>+ {needsFile && (+ <div className="portal-proc__upload">+ <input+ ref={fileRef}+ type="file"+ accept=".pdf,.doc,.docx"+ className="portal-proc__upload-input"+ onChange={(e) => setFile(e.target.files?.[0] ?? null)}+ />+ <Button+ variant="outline"+ size="sm"+ onClick={() => fileRef.current?.click()}+ >+ {t("procurement.modal.chooseFile")}+ </Button>+ <span className="portal-proc__upload-name">+ {file ? file.name : t("procurement.modal.noFile")}+ </span>+ </div>+ )}+ </Modal>+ );+}diff --git a/frontend/portal/src/components/procurement/DealJourney.stories.tsx b/frontend/portal/src/components/procurement/DealJourney.stories.tsxnew file mode 100644index 0000000000..a59386dc3a--- /dev/null+++ b/frontend/portal/src/components/procurement/DealJourney.stories.tsx@@ -0,0 +1,30 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { DealJourney } from "@portal/components/procurement/DealJourney";+import { buildProcurement } from "@portal/mocks/procurement";+import type { Deal } from "@portal/api/procurement";+import "@portal/views/Procurement.css";++const data = buildProcurement("enterprise");+const deal = data.deal as Deal;++const meta: Meta<typeof DealJourney> = {+ title: "Portal/Procurement/DealJourney",+ component: DealJourney,+ parameters: { layout: "padded" },+ args: { deal, journey: data.journey, onAdvance: () => {} },+};+export default meta;+type Story = StoryObj<typeof DealJourney>;++// Mid-journey at the Agreement stage, the seeded deal state.+export const Default: Story = {};++// Evaluating: the trial strip shows runway + key; next step builds the quote.+export const AtTrial: Story = {+ args: { deal: { ...deal, currentStage: "trial" } },+};++// Terminal stage, provisioning, no further CTA.+export const Live: Story = {+ args: { deal: { ...deal, currentStage: "active" } },+};diff --git a/frontend/portal/src/components/procurement/DealJourney.tsx b/frontend/portal/src/components/procurement/DealJourney.tsxnew file mode 100644index 0000000000..837b9034a9--- /dev/null+++ b/frontend/portal/src/components/procurement/DealJourney.tsx@@ -0,0 +1,97 @@+import { useTranslation } from "react-i18next";+import { Button, Card } from "@shared/components";+import type { Deal, DealStage, JourneyStep } from "@portal/api/procurement";+import { StageStepper } from "@portal/components/procurement/StageStepper";++/**+ * The deal's commercial journey in one card: who's guiding it (the solutions+ * engineer), where it sits (the stage stepper), trial runway while evaluating,+ * and the single next action that advances the deal. Mirrors "one next action+ * at a time"; the full per-stage checklist lives in the Documents card.+ */+export function DealJourney({+ deal,+ journey,+ onAdvance,+ advancing = false,+}: {+ deal: Deal;+ journey: JourneyStep[];+ onAdvance: (stage: DealStage) => void;+ advancing?: boolean;+}) {+ const { t } = useTranslation();+ const { engineer, trial, currentStage } = deal;+ const currentStep = journey.find((s) => s.stage === currentStage);+ const isTerminal =+ journey.length > 0 && journey[journey.length - 1].stage === currentStage;++ return (+ <Card padding="none" className="portal-proc__journey">+ <div className="portal-proc__journey-head">+ <div>+ <span className="portal-proc__eyebrow">+ {t("procurement.journey.eyebrow")}+ </span>+ <h2 className="portal-proc__journey-title">+ {t("procurement.journey.title")}+ </h2>+ <p className="portal-proc__journey-sub">+ {t("procurement.journey.subtitle")}+ </p>+ </div>+ <div className="portal-proc__se">+ <span className="portal-proc__eyebrow">+ {t("procurement.journey.engineerLabel")}+ </span>+ <span className="portal-proc__se-name">{engineer.name}</span>+ <a+ className="portal-proc__se-email"+ href={`mailto:${engineer.email}`}+ >+ {engineer.email}+ </a>+ </div>+ </div>++ <div className="portal-proc__journey-stepper">+ <StageStepper journey={journey} currentStage={currentStage} />+ </div>++ {currentStage === "trial" && (+ <div className="portal-proc__trial">+ <span className="portal-proc__trial-title">+ {t("procurement.journey.trialTitle")}+ </span>+ <span className="portal-proc__trial-dim">+ {t("procurement.journey.daysLeft", { count: trial.daysLeft })}+ </span>+ <span className="portal-proc__trial-key">{trial.key}</span>+ </div>+ )}++ <div className="portal-proc__next">+ <div className="portal-proc__next-label">+ <span className="portal-proc__next-dot" data-live={isTerminal} />+ <span>+ {isTerminal+ ? t("procurement.journey.live")+ : t("procurement.journey.nextStep", {+ action: currentStep?.gatingAction ?? "",+ })}+ </span>+ </div>+ {!isTerminal && currentStep && (+ <Button+ variant="gradient"+ accent="purple"+ loading={advancing}+ onClick={() => onAdvance(currentStage)}+ >+ {currentStep.gatingAction}+ </Button>+ )}+ </div>+ </Card>+ );+}diff --git a/frontend/portal/src/components/procurement/DocRow.stories.tsx b/frontend/portal/src/components/procurement/DocRow.stories.tsxnew file mode 100644index 0000000000..695b8c6941--- /dev/null+++ b/frontend/portal/src/components/procurement/DocRow.stories.tsx@@ -0,0 +1,62 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { DocRow } from "@portal/components/procurement/DocRow";+import type { LedgerDoc } from "@portal/api/procurement";+import "@portal/views/Procurement.css";++const meta: Meta<typeof DocRow> = {+ title: "Portal/Procurement/DocRow",+ component: DocRow,+ parameters: { layout: "padded" },+ args: { onAction: () => {} },+};+export default meta;+type Story = StoryObj<typeof DocRow>;++const sign: LedgerDoc = {+ id: "d1",+ name: "Stirling Enterprise Agreement",+ sub: "One signature: MSA + order form + EULA + DPA.",+ status: "action",+ action: "sign",+};++const download: LedgerDoc = {+ id: "d2",+ name: "SOC 2 Type II report",+ sub: "Independent audit of our security controls.",+ status: "available",+ action: "download",+};++const paidAddon: LedgerDoc = {+ id: "d3",+ name: "Onboarding & training",+ sub: "Guided rollout and live training for your team.",+ status: "request",+ action: "request",+ optional: true,+ fee: 7_500,+};++const done: LedgerDoc = {+ id: "d4",+ name: "Formal quote",+ sub: "Committed-volume pricing, term and line items.",+ status: "complete",+ action: "download",+};++// Deal-advancing action, filled purple CTA.+export const SignAction: Story = { args: { doc: sign } };++// Quiet outline action for a ready download.+export const Download: Story = { args: { doc: download } };++// Optional paid add-on, chips flag it and the fee folds into the CTA.+export const PaidAddon: Story = { args: { doc: paidAddon } };++// Completed paperwork keeps a record but offers no further action.+export const Complete: Story = { args: { doc: done } };++// A row in a future, not-yet-reached stage, dimmed, marked "Upcoming", inert.+export const Locked: Story = { args: { doc: sign, locked: true } };diff --git a/frontend/portal/src/components/procurement/DocRow.tsx b/frontend/portal/src/components/procurement/DocRow.tsxnew file mode 100644index 0000000000..1655c3744e--- /dev/null+++ b/frontend/portal/src/components/procurement/DocRow.tsx@@ -0,0 +1,89 @@+import { useTranslation } from "react-i18next";+import { Button, Chip, StatusBadge } from "@shared/components";+import type { LedgerDoc } from "@portal/api/procurement";+import {+ ACTION_LABEL_KEY,+ STATUS_LABEL_KEY,+ STATUS_TONE,+ USD,+} from "@portal/components/procurement/format";++/** Maps a document's action to the button accent + variant. */+function buttonStyle(doc: LedgerDoc): {+ variant: "gradient" | "outline";+ accent: "purple" | "blue";+} {+ // The agreement signature and online payment are the deal-advancing actions;+ // give them the filled accent CTA. Everything else is a quieter outline.+ if (doc.action === "sign" || doc.action === "pay") {+ return { variant: "gradient", accent: "purple" };+ }+ return { variant: "outline", accent: "blue" };+}++/**+ * A single document in the ledger or supporting pool: name + sub-line on the+ * left, status badge and action button on the right. Optional/fee-bearing docs+ * carry a chip so the buyer sees a paid add-on before clicking. `locked` is for+ * rows in a future, not-yet-reached stage: dimmed, marked "Upcoming", inert.+ */+export function DocRow({+ doc,+ onAction,+ locked = false,+}: {+ doc: LedgerDoc;+ onAction: (doc: LedgerDoc) => void;+ locked?: boolean;+}) {+ const { t } = useTranslation();+ const { variant, accent } = buttonStyle(doc);+ // Locked (future-stage), in-progress (pending) and completed paperwork all+ // offer no action; only "available", "action" and "request" docs do.+ const actionable =+ !locked && doc.status !== "complete" && doc.status !== "pending";+ const label = t(ACTION_LABEL_KEY[doc.action]);+ const actionLabel =+ doc.fee !== undefined ? `${label} · ${USD.format(doc.fee)}` : label;++ return (+ <div className="portal-proc__doc" data-locked={locked || undefined}>+ <div className="portal-proc__doc-text">+ <div className="portal-proc__doc-name-row">+ <span className="portal-proc__doc-name">{doc.name}</span>+ {doc.optional && (+ <Chip tone="neutral" size="sm">+ {t("procurement.docs.optional")}+ </Chip>+ )}+ {doc.fee !== undefined && (+ <Chip tone="amber" size="sm">+ {t("procurement.docs.paidAddon")}+ </Chip>+ )}+ </div>+ <p className="portal-proc__doc-sub">{doc.sub}</p>+ </div>+ <div className="portal-proc__doc-actions">+ <StatusBadge+ tone={locked ? "neutral" : STATUS_TONE[doc.status]}+ size="sm"+ >+ {locked+ ? t("procurement.docs.upcoming")+ : t(STATUS_LABEL_KEY[doc.status])}+ </StatusBadge>+ {actionable && (+ <Button+ variant={variant}+ accent={accent}+ size="sm"+ onClick={() => onAction(doc)}+ >+ {actionLabel}+ </Button>+ )}+ </div>+ </div>+ );+}diff --git a/frontend/portal/src/components/procurement/DocumentLedger.stories.tsx b/frontend/portal/src/components/procurement/DocumentLedger.stories.tsxnew file mode 100644index 0000000000..5de6692999--- /dev/null+++ b/frontend/portal/src/components/procurement/DocumentLedger.stories.tsx@@ -0,0 +1,30 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { DocumentLedger } from "@portal/components/procurement/DocumentLedger";+import { buildProcurement } from "@portal/mocks/procurement";+import "@portal/views/Procurement.css";++const data = buildProcurement("enterprise");++const meta: Meta<typeof DocumentLedger> = {+ title: "Portal/Procurement/DocumentLedger",+ component: DocumentLedger,+ parameters: { layout: "padded" },+ args: {+ groups: data.ledger,+ supporting: data.supporting,+ journey: data.journey,+ currentStage: data.deal?.currentStage ?? "trial",+ onAction: () => {},+ },+};+export default meta;+type Story = StoryObj<typeof DocumentLedger>;++// Mid-journey: the Agreement stage is open, earlier stages read as done, later+// stages are locked previews, and the supporting pool sits collapsed below.+export const Default: Story = {};++// Day one: only the Trial stage has been reached; everything ahead is locked.+export const AtTrial: Story = {+ args: { currentStage: "trial" },+};diff --git a/frontend/portal/src/components/procurement/DocumentLedger.tsx b/frontend/portal/src/components/procurement/DocumentLedger.tsxnew file mode 100644index 0000000000..5ef9bbc30f--- /dev/null+++ b/frontend/portal/src/components/procurement/DocumentLedger.tsx@@ -0,0 +1,158 @@+import { useEffect, useState } from "react";+import { useTranslation } from "react-i18next";+import { Card, Chip, Collapsible } from "@shared/components";+import type {+ DealStage,+ JourneyStep,+ LedgerDoc,+ LedgerGroup,+ SupportingGroup,+} from "@portal/api/procurement";+import { DocRow } from "@portal/components/procurement/DocRow";++/**+ * The "Documents" card: every artifact the deal needs, as a stage accordion+ * that mirrors the journey. Only the current stage is open by default; earlier+ * stages read as done, later stages are locked previews. A collapsed-by-default+ * "Supporting your evaluation" pool holds the stage-agnostic paperwork.+ */+export function DocumentLedger({+ groups,+ supporting,+ journey,+ currentStage,+ onAction,+}: {+ groups: LedgerGroup[];+ supporting: SupportingGroup[];+ journey: JourneyStep[];+ currentStage: DealStage;+ onAction: (doc: LedgerDoc) => void;+}) {+ const { t } = useTranslation();+ const order = journey.map((s) => s.stage);+ const curIdx = order.indexOf(currentStage);+ // Follow the deal: the stage you're in opens first; any other stage can be+ // peeked. null collapses them all. Advancing moves the open section along.+ const [openStage, setOpenStage] = useState<DealStage | null>(currentStage);+ const [supportingOpen, setSupportingOpen] = useState(false);+ useEffect(() => setOpenStage(currentStage), [currentStage]);++ return (+ <Card padding="none" className="portal-proc__docs">+ <div className="portal-proc__docs-head">+ <h2 className="portal-proc__docs-title">+ {t("procurement.docs.title")}+ </h2>+ <p className="portal-proc__docs-sub">+ {t("procurement.docs.subtitle")}+ </p>+ </div>++ <div className="portal-proc__docs-body">+ {groups.map((group) => {+ const idx = order.indexOf(group.stage);+ const done = idx < curIdx;+ const cur = group.stage === currentStage;+ const locked = idx > curIdx;+ const blurb = journey.find((s) => s.stage === group.stage)?.blurb;+ const open = openStage === group.stage;+ const count = group.docs.length;++ return (+ <Collapsible+ key={group.stage}+ open={open}+ onToggle={() => setOpenStage(open ? null : group.stage)}+ header={+ <>+ <span+ className="portal-proc__stage-dot"+ data-state={done ? "done" : cur ? "current" : "upcoming"}+ aria-hidden+ />+ <span+ className="portal-proc__stage-label"+ data-current={cur || undefined}+ >+ {group.label}+ </span>+ {blurb && (+ <span className="portal-proc__stage-hint">· {blurb}</span>+ )}+ {cur && (+ <Chip tone="purple" size="sm">+ {t("procurement.docs.here")}+ </Chip>+ )}+ {done && (+ <Chip tone="green" size="sm">+ {t("procurement.docs.done")}+ </Chip>+ )}+ </>+ }+ aside={+ <span className="portal-proc__stage-count">+ {t("procurement.docs.count", { count })}+ </span>+ }+ >+ <div className="portal-proc__doc-list">+ {group.docs.map((doc) => (+ <DocRow+ key={doc.id}+ doc={doc}+ onAction={onAction}+ locked={locked}+ />+ ))}+ </div>+ </Collapsible>+ );+ })}++ {supporting.length > 0 && (+ <Collapsible+ className="portal-proc__supporting-acc"+ open={supportingOpen}+ onToggle={() => setSupportingOpen((o) => !o)}+ header={+ <span className="portal-proc__supporting-head">+ <span className="portal-proc__stage-label">+ {t("procurement.docs.supportingTitle")}+ </span>+ <span className="portal-proc__supporting-sub">+ {t("procurement.docs.supportingSubtitle")}+ </span>+ </span>+ }+ aside={+ <span className="portal-proc__acc-toggle-label">+ {supportingOpen+ ? t("procurement.docs.hide")+ : t("procurement.docs.show")}+ </span>+ }+ >+ <div className="portal-proc__supporting-groups">+ {supporting.map((group) => (+ <div+ key={group.category}+ className="portal-proc__supporting-group"+ >+ <div className="portal-proc__group-label">{group.label}</div>+ <div className="portal-proc__doc-list portal-proc__doc-list--boxed">+ {group.docs.map((doc) => (+ <DocRow key={doc.id} doc={doc} onAction={onAction} />+ ))}+ </div>+ </div>+ ))}+ </div>+ </Collapsible>+ )}+ </div>+ </Card>+ );+}diff --git a/frontend/portal/src/components/procurement/LockedState.stories.tsx b/frontend/portal/src/components/procurement/LockedState.stories.tsxnew file mode 100644index 0000000000..e88c810801--- /dev/null+++ b/frontend/portal/src/components/procurement/LockedState.stories.tsx@@ -0,0 +1,18 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { LockedState } from "@portal/components/procurement/LockedState";+import { JOURNEY } from "@portal/mocks/procurement";+import "@portal/views/Procurement.css";++const meta: Meta<typeof LockedState> = {+ title: "Portal/Procurement/LockedState",+ component: LockedState,+ parameters: { layout: "padded" },+ args: { onTalkToSales: () => {} },+};+export default meta;+type Story = StoryObj<typeof LockedState>;++// Shown to free/pro buyers, the journey preview behind the upgrade prompt.+export const Default: Story = {+ args: { journey: JOURNEY },+};diff --git a/frontend/portal/src/components/procurement/LockedState.tsx b/frontend/portal/src/components/procurement/LockedState.tsxnew file mode 100644index 0000000000..72a5e8b129--- /dev/null+++ b/frontend/portal/src/components/procurement/LockedState.tsx@@ -0,0 +1,36 @@+import { useTranslation } from "react-i18next";+import { Button, Card, EmptyState } from "@shared/components";+import type { JourneyStep } from "@portal/api/procurement";+import { StageStepper } from "@portal/components/procurement/StageStepper";++/**+ * Enterprise-only gate for free/pro buyers. Shows the journey as a greyed+ * preview behind an upgrade prompt so the buyer understands what the+ * commercial track looks like before they talk to sales.+ */+export function LockedState({+ journey,+ onTalkToSales,+}: {+ journey: JourneyStep[];+ onTalkToSales: () => void;+}) {+ const { t } = useTranslation();+ return (+ <div className="portal-proc__locked">+ <EmptyState+ eyebrow={t("procurement.locked.eyebrow")}+ title={t("procurement.locked.title")}+ description={t("procurement.locked.description")}+ actions={+ <Button variant="gradient" accent="purple" onClick={onTalkToSales}>+ {t("procurement.locked.talkToSales")}+ </Button>+ }+ />+ <Card padding="loose" className="portal-proc__journey-stepper">+ <StageStepper journey={journey} currentStage="trial" locked />+ </Card>+ </div>+ );+}diff --git a/frontend/portal/src/components/procurement/StageStepper.stories.tsx b/frontend/portal/src/components/procurement/StageStepper.stories.tsxnew file mode 100644index 0000000000..a27b0b90aa--- /dev/null+++ b/frontend/portal/src/components/procurement/StageStepper.stories.tsx@@ -0,0 +1,20 @@+import type { Meta, StoryObj } from "@storybook/react-vite";+import { StageStepper } from "@portal/components/procurement/StageStepper";+import { JOURNEY } from "@portal/mocks/procurement";+import "@portal/views/Procurement.css";++const meta: Meta<typeof StageStepper> = {+ title: "Portal/Procurement/StageStepper",+ component: StageStepper,+ parameters: { layout: "padded" },+ args: { journey: JOURNEY },+};+export default meta;+type Story = StoryObj<typeof StageStepper>;++export const AtAgreement: Story = { args: { currentStage: "security" } };++export const AtTrial: Story = { args: { currentStage: "trial" } };++// Greyed preview for the free/pro upgrade gate, no stage is current.+export const Locked: Story = { args: { currentStage: "trial", locked: true } };diff --git a/frontend/portal/src/components/procurement/StageStepper.tsx b/frontend/portal/src/components/procurement/StageStepper.tsxnew file mode 100644index 0000000000..1981078459--- /dev/null+++ b/frontend/portal/src/components/procurement/StageStepper.tsx@@ -0,0 +1,50 @@+import { Fragment } from "react";+import type { DealStage, JourneyStep } from "@portal/api/procurement";++/** Status of a step relative to the deal's current stage. */+type StepState = "complete" | "current" | "upcoming";++/**+ * The five-stage commercial journey as a horizontal band of labelled dots with+ * connectors between them. Purely presentational, the gating action lives in+ * the journey card's next-step row, not on the dots. `locked` greys the whole+ * band for the free/pro upgrade preview, where no stage is current.+ */+export function StageStepper({+ journey,+ currentStage,+ locked = false,+}: {+ journey: JourneyStep[];+ currentStage: DealStage;+ locked?: boolean;+}) {+ const order = journey.map((s) => s.stage);+ const curIdx = locked ? -1 : order.indexOf(currentStage);++ return (+ <div+ className={`portal-proc__steps${locked ? " portal-proc__steps--locked" : ""}`}+ >+ {journey.map((step, i) => {+ const state: StepState =+ i < curIdx ? "complete" : i === curIdx ? "current" : "upcoming";+ return (+ <Fragment key={step.stage}>+ {i > 0 && (+ <span+ className="portal-proc__step-line"+ data-filled={i <= curIdx}+ aria-hidden+ />+ )}+ <div className={`portal-proc__step portal-proc__step--${state}`}>+ <span className="portal-proc__step-dot" aria-hidden />+ <span className="portal-proc__step-label">{step.label}</span>+ </div>+ </Fragment>+ );+ })}+ </div>+ );+}diff --git a/frontend/portal/src/components/procurement/format.ts b/frontend/portal/src/components/procurement/format.tsnew file mode 100644index 0000000000..c40d7921aa--- /dev/null+++ b/frontend/portal/src/components/procurement/format.ts@@ -0,0 +1,37 @@+/** Shared formatting + status/action mappings for the Procurement surface. */++import type { StatusTone } from "@shared/components";+import type { DocAction, DocStatus } from "@portal/api/procurement";++export const USD = new Intl.NumberFormat(undefined, {+ style: "currency",+ currency: "USD",+ maximumFractionDigits: 0,+});++/** Document status → badge tone. Action items lean amber to pull the eye. */+export const STATUS_TONE: Record<DocStatus, StatusTone> = {+ available: "success",+ action: "warning",+ pending: "info",+ request: "neutral",+ complete: "neutral",+};++/** Document status → translation key for the short badge label. */+export const STATUS_LABEL_KEY: Record<DocStatus, string> = {+ available: "procurement.status.available",+ action: "procurement.status.action",+ pending: "procurement.status.pending",+ request: "procurement.status.request",+ complete: "procurement.status.complete",+};++/** Action → translation key for the button label (the fee, when present, is appended by the caller). */+export const ACTION_LABEL_KEY: Record<DocAction, string> = {+ download: "procurement.action.download",+ sign: "procurement.action.sign",+ pay: "procurement.action.pay",+ upload: "procurement.action.upload",+ request: "procurement.action.request",+};diff --git a/frontend/portal/src/contexts/ViewContext.tsx b/frontend/portal/src/contexts/ViewContext.tsxindex a8eff0fee4..01c3de9b54 100644--- a/frontend/portal/src/contexts/ViewContext.tsx+++ b/frontend/portal/src/contexts/ViewContext.tsx@@ -14,6 +14,7 @@ export type ViewId =| "infrastructure"| "usage"| "docs"+ | "procurement"| "settings";export const VIEW_LABELS: Record<ViewId, string> = {@@ -29,6 +30,7 @@ export const VIEW_LABELS: Record<ViewId, string> = {infrastructure: "Infrastructure",usage: "Usage & Billing",docs: "Developer Docs",+ procurement: "Procurement",settings: "Settings",};@@ -45,6 +47,7 @@ export const VIEW_PATHS: Record<ViewId, string> = {infrastructure: "/infrastructure",usage: "/usage",docs: "/docs",+ procurement: "/procurement",settings: "/settings",};diff --git a/frontend/portal/src/mocks/handlers/index.ts b/frontend/portal/src/mocks/handlers/index.tsindex 130d1a7b35..8c9d1cad91 100644--- a/frontend/portal/src/mocks/handlers/index.ts+++ b/frontend/portal/src/mocks/handlers/index.ts@@ -7,6 +7,7 @@ import { searchHandlers } from "@portal/mocks/handlers/search";import { pipelinesHandlers } from "@portal/mocks/handlers/pipelines";import { sourcesHandlers } from "@portal/mocks/handlers/sources";import { infrastructureHandlers } from "@portal/mocks/handlers/infrastructure";+import { procurementHandlers } from "@portal/mocks/handlers/procurement";import { docsHandlers } from "@portal/mocks/handlers/docs";import { settingsHandlers } from "@portal/mocks/handlers/settings";import { usersHandlers } from "@portal/mocks/handlers/users";@@ -28,6 +29,7 @@ export const handlers = [...sourcesHandlers,...infrastructureHandlers,...docsHandlers,+ ...procurementHandlers,...settingsHandlers,...usersHandlers,...agentsHandlers,@@ -39,3 +41,4 @@ export const handlers = [];export { resetNotificationsStore } from "@portal/mocks/handlers/notifications";+export { resetProcurementStore } from "@portal/mocks/handlers/procurement";diff --git a/frontend/portal/src/mocks/handlers/procurement.ts b/frontend/portal/src/mocks/handlers/procurement.tsnew file mode 100644index 0000000000..e0e6f497c2--- /dev/null+++ b/frontend/portal/src/mocks/handlers/procurement.ts@@ -0,0 +1,90 @@+import { http, HttpResponse, delay } from "msw";+import type { Tier } from "@portal/contexts/TierContext";+import {+ JOURNEY,+ buildProcurement,+ seedEnterpriseDeal,+ type DealStage,+ type ProcurementResponse,+} from "@portal/mocks/procurement";+import {+ advanceDeal,+ payDeal,+ requestDoc,+ signDoc,+ uploadPurchaseOrder,+} from "@portal/mocks/procurementMachine";++/**+ * Stateful mock of the commercial backend. The write endpoints drive the+ * procurement state machine over one in-memory enterprise deal, so the journey+ * genuinely progresses within a session, advancing a stage flips the gating+ * paperwork, unlocks the next stage's documents, and the GET reflects every+ * prior write. Swapping in the real backend is just deleting these handlers;+ * the api/ contracts and the state-machine semantics stay.+ */+let store = seedEnterpriseDeal();++/** Reseed the deal to its starting (mid-journey) state, used by tests + replay. */+export function resetProcurementStore() {+ store = seedEnterpriseDeal();+}++function snapshot(): ProcurementResponse {+ return {+ tier: "enterprise",+ unlocked: true,+ deal: store.deal,+ journey: JOURNEY,+ ledger: store.ledger,+ supporting: store.supporting,+ };+}++export const procurementHandlers = [+ http.get("/v1/procurement", async ({ request }) => {+ await delay(120);+ const tier = (new URL(request.url).searchParams.get("tier") ??+ "pro") as Tier;+ // Only the enterprise tenant has a live deal; others get the locked payload.+ if (tier !== "enterprise") return HttpResponse.json(buildProcurement(tier));+ return HttpResponse.json(snapshot());+ }),++ // POST /v1/procurement/advance, the journey's primary "next step".+ http.post("/v1/procurement/advance", async ({ request }) => {+ await delay(140);+ const { fromStage } = (await request.json()) as { fromStage: DealStage };+ advanceDeal(store, fromStage);+ return HttpResponse.json(snapshot());+ }),++ // POST /v1/procurement/sign, e-sign the agreement, then advance.+ http.post("/v1/procurement/sign", async ({ request }) => {+ await delay(160);+ const { docId } = (await request.json()) as { docId: string };+ signDoc(store, docId);+ return HttpResponse.json(snapshot());+ }),++ // POST /v1/procurement/pay, confirm online payment, then advance.+ http.post("/v1/procurement/pay", async () => {+ await delay(160);+ payDeal(store);+ return HttpResponse.json(snapshot());+ }),++ // POST /v1/procurement/purchase-order, upload a PO (an alternate pay path).+ http.post("/v1/procurement/purchase-order", async () => {+ await delay(160);+ uploadPurchaseOrder(store);+ return HttpResponse.json(snapshot());+ }),++ // POST /v1/procurement/documents/:docId/request, queue an on-demand doc.+ http.post("/v1/procurement/documents/:docId/request", async ({ params }) => {+ await delay(140);+ requestDoc(store, String(params.docId));+ return HttpResponse.json(snapshot());+ }),+];diff --git a/frontend/portal/src/mocks/procurement.ts b/frontend/portal/src/mocks/procurement.tsnew file mode 100644index 0000000000..4faeefa491--- /dev/null+++ b/frontend/portal/src/mocks/procurement.ts@@ -0,0 +1,480 @@+/**+ * Procurement fixtures and the types api/procurement.ts shares with them.+ * api/procurement.ts imports the types; the MSW handlers in+ * mocks/handlers/procurement.ts serve this fixture data over the intercepted+ * httpJson() calls. Components never reach into this module directly.+ *+ * Procurement models the enterprise commercial journey, trial → quote →+ * agreement → payment → implementation, plus the paperwork ledger that rides+ * alongside it. The journey is enterprise-only; free/pro tiers receive a+ * minimal locked payload the view renders as an upgrade prompt.+ *+ * Once a real commercial backend exists the MSW handlers stop being registered+ * and these fixtures can be deleted (or kept as test seeds).+ */++import type { Tier } from "@portal/contexts/TierContext";++/* ──────────────────────────────────────────────────────────────────────── */+/* Journey stages */+/* ──────────────────────────────────────────────────────────────────────── */++/**+ * The five-stage enterprise journey. The id is the contract value the backend+ * advances; the labels below are the buyer-facing stage names (Agreement and+ * Payment read more plainly than the internal `security` / `procurement`).+ */+export type DealStage =+ | "trial"+ | "quote"+ | "security"+ | "procurement"+ | "active";++export interface JourneyStep {+ stage: DealStage;+ /** Buyer-facing stage name. */+ label: string;+ /** One-line description of what happens at this stage. */+ blurb: string;+ /**+ * Label for the single action that advances this stage. The current stage+ * surfaces its gating action; `active` is terminal (provisioning).+ */+ gatingAction: string;+}++/** Ordered journey definition, the stepper renders this verbatim. */+export const JOURNEY: JourneyStep[] = [+ {+ stage: "trial",+ label: "Trial",+ blurb: "Evaluate Stirling against your documents and workflows.",+ gatingAction: "Build your quote",+ },+ {+ stage: "quote",+ label: "Quote",+ blurb: "Review committed-volume pricing and contract term.",+ gatingAction: "Accept your quote",+ },+ {+ stage: "security",+ label: "Agreement",+ blurb: "One signature covers MSA, order form, EULA and DPA.",+ gatingAction: "Review and sign your agreement",+ },+ {+ stage: "procurement",+ label: "Payment",+ blurb: "Pay by card, bank transfer, or against a purchase order.",+ gatingAction: "Confirm payment",+ },+ {+ stage: "active",+ label: "Implementation",+ blurb: "Provision your workspace and run the go-live playbook.",+ gatingAction: "Provisioning your workspace",+ },+];++/* ──────────────────────────────────────────────────────────────────────── */+/* Deal header */+/* ──────────────────────────────────────────────────────────────────────── */++export interface SolutionsEngineer {+ name: string;+ title: string;+ email: string;+}++export interface TrialInfo {+ /** License key seeded for the evaluation. */+ key: string;+ /** ISO date the trial began. */+ startedOn: string;+ /** ISO date the trial expires. */+ endsOn: string;+ /** Whole days remaining (derived in the fixture for a stable demo number). */+ daysLeft: number;+ extensionsUsed: number;+ maxExtensions: number;+}++export interface QuoteInfo {+ number: string;+ /** Annual contract value, in USD. */+ amount: number;+ /** Contract term, e.g. "12 months". */+ term: string;+ /** ISO date the quote expires. */+ validUntil: string;+}++export interface Deal {+ company: string;+ currentStage: DealStage;+ engineer: SolutionsEngineer;+ trial: TrialInfo;+ quote: QuoteInfo;+}++/* ──────────────────────────────────────────────────────────────────────── */+/* Document ledger + supporting pool */+/* ──────────────────────────────────────────────────────────────────────── */++/**+ * Lifecycle of a single document.+ * available: ready to grab now (download/sign/pay/upload as the action says)+ * action: waiting on the buyer to act (the gating paperwork of a stage)+ * pending: issued, awaiting the other side / a system step+ * request: not generated yet; the buyer asks for it (some carry a fee)+ * complete: done, kept for the record+ */+export type DocStatus =+ | "available"+ | "action"+ | "pending"+ | "request"+ | "complete";++/** What pressing the document's button does. */+export type DocAction = "download" | "sign" | "pay" | "upload" | "request";++export interface LedgerDoc {+ id: string;+ name: string;+ /** Sub-line describing what the document is / what it covers. */+ sub: string;+ status: DocStatus;+ action: DocAction;+ /** Buyer-skippable paperwork (e.g. paid onboarding). */+ optional?: boolean;+ /** One-off fee in USD when the document/service is a paid add-on. */+ fee?: number;+}++/** Document ledger grouped by the journey stage the paperwork belongs to. */+export interface LedgerGroup {+ stage: DealStage;+ /** Buyer-facing stage name (matches JourneyStep.label). */+ label: string;+ docs: LedgerDoc[];+}++/** Categories the stage-agnostic supporting pool is grouped under. */+export type SupportingCategory =+ | "security"+ | "legal"+ | "corporate"+ | "procurement";++export interface SupportingGroup {+ category: SupportingCategory;+ label: string;+ docs: LedgerDoc[];+}++/* ──────────────────────────────────────────────────────────────────────── */+/* Full procurement payload */+/* ──────────────────────────────────────────────────────────────────────── */++export interface ProcurementResponse {+ tier: Tier;+ /** True only for enterprise, gates the whole journey + ledger. */+ unlocked: boolean;+ /** Present only when unlocked. */+ deal: Deal | null;+ journey: JourneyStep[];+ ledger: LedgerGroup[];+ supporting: SupportingGroup[];+}++/* ──────────────────────────────────────────────────────────────────────── */+/* Fixtures */+/* ──────────────────────────────────────────────────────────────────────── */++const ENTERPRISE_DEAL: Deal = {+ company: "Northwind Logistics",+ // The buyer has accepted the quote and is at the agreement signature, the+ // mid-journey state shows the most surface area (completed + active + ahead).+ currentStage: "security",+ engineer: {+ name: "Priya Raman",+ title: "Senior Solutions Engineer",+ email: "[email protected]",+ },+ trial: {+ key: "TRIAL-NWND-7F3A-2C9E",+ startedOn: daysFromNow(-23),+ endsOn: daysFromNow(7),+ daysLeft: 7,+ extensionsUsed: 1,+ maxExtensions: 2,+ },+ quote: {+ number: "Q-2026-0488",+ amount: 84_000,+ term: "12 months",+ validUntil: daysFromNow(14),+ },+};++/** Document ledger for the live enterprise deal, grouped by stage. */+const ENTERPRISE_LEDGER: LedgerGroup[] = [+ {+ stage: "trial",+ label: "Trial",+ docs: [+ {+ id: "doc-trial-quickstart",+ name: "Trial quick-start guide",+ sub: "Stand up the evaluation environment in under an hour.",+ status: "available",+ action: "download",+ },+ {+ id: "doc-trial-handout",+ name: "Evaluator handout",+ sub: "Share Stirling's capabilities with your evaluation team.",+ status: "available",+ action: "download",+ },+ ],+ },+ {+ stage: "quote",+ label: "Quote",+ docs: [+ {+ id: "doc-quote-formal",+ name: "Formal quote",+ sub: "Committed-volume pricing, term and line items, Q-2026-0488.",+ status: "complete",+ action: "download",+ },+ ],+ },+ {+ stage: "security",+ label: "Agreement",+ docs: [+ {+ id: "doc-agreement-enterprise",+ name: "Stirling Enterprise Agreement",+ sub: "One signature: MSA + order form + EULA + DPA.",+ status: "action",+ action: "sign",+ },+ ],+ },+ {+ stage: "procurement",+ label: "Payment",+ docs: [+ {+ id: "doc-pay-online",+ name: "Pay online",+ sub: "Card or bank transfer via Stripe.",+ status: "pending",+ action: "pay",+ },+ {+ id: "doc-pay-wire",+ name: "Bank transfer instructions",+ sub: "Wire details, plus RIB for EU buyers.",+ status: "pending",+ action: "download",+ },+ {+ id: "doc-pay-po",+ name: "Purchase order",+ sub: "Upload it and we invoice against it.",+ status: "request",+ action: "upload",+ },+ ],+ },+ {+ stage: "active",+ label: "Implementation",+ docs: [+ {+ id: "doc-active-playbook",+ name: "Go-live playbook",+ sub: "Cut-over steps, rollback plan, and success checks.",+ status: "pending",+ action: "download",+ },+ {+ id: "doc-active-admin",+ name: "Administrator setup guide",+ sub: "SSO, regions, audit export and seat provisioning.",+ status: "pending",+ action: "download",+ },+ {+ id: "doc-active-onboarding",+ name: "Onboarding & training",+ sub: "Guided rollout and live training for your team.",+ status: "request",+ action: "request",+ optional: true,+ fee: 7_500,+ },+ ],+ },+];++/** Stage-agnostic supporting documents, grouped by category. */+const ENTERPRISE_SUPPORTING: SupportingGroup[] = [+ {+ category: "security",+ label: "Security",+ docs: [+ {+ id: "sup-soc2",+ name: "SOC 2 Type II report",+ sub: "Independent audit of our security controls.",+ status: "available",+ action: "download",+ },+ {+ id: "sup-caiq",+ name: "Security questionnaire (CAIQ)",+ sub: "Pre-filled Consensus Assessments Initiative Questionnaire.",+ status: "available",+ action: "download",+ },+ {+ id: "sup-pentest",+ name: "Penetration test summary",+ sub: "Latest third-party penetration test results.",+ status: "available",+ action: "download",+ },+ {+ id: "sup-custom-review",+ name: "Custom security review",+ sub: "Dedicated session with our security team for your assessment.",+ status: "request",+ action: "request",+ fee: 5_000,+ },+ ],+ },+ {+ category: "legal",+ label: "Legal",+ docs: [+ {+ id: "sup-baa",+ name: "Business Associate Agreement (HIPAA)",+ sub: "Required when processing protected health information.",+ status: "request",+ action: "request",+ fee: 2_500,+ },+ ],+ },+ {+ category: "corporate",+ label: "Corporate",+ docs: [+ {+ id: "sup-w9",+ name: "IRS Form W-9",+ sub: "Our taxpayer identification for your records.",+ status: "available",+ action: "download",+ },+ {+ id: "sup-incorporation",+ name: "Certificate of Incorporation",+ sub: "Proof of our legal entity registration.",+ status: "available",+ action: "download",+ },+ {+ id: "sup-insurance",+ name: "Certificate of Insurance",+ sub: "Liability and cyber insurance coverage evidence.",+ status: "available",+ action: "download",+ },+ ],+ },+ {+ category: "procurement",+ label: "Procurement",+ docs: [+ {+ id: "sup-vendor-onboarding",+ name: "Vendor onboarding form",+ sub: "We fill out your procurement-portal forms for you.",+ status: "request",+ action: "request",+ fee: 1_500,+ },+ ],+ },+];++/** Structured deep clone of plain fixture data (no functions / class instances). */+function clone<T>(value: T): T {+ return JSON.parse(JSON.stringify(value)) as T;+}++/**+ * A fresh, mutable copy of the live enterprise deal, deal header, stage ledger+ * and supporting pool. The MSW layer seeds its in-memory store from this so the+ * write handlers can advance the journey within a session without mutating the+ * shared fixtures. The journey definition (JOURNEY) is immutable and shared.+ */+export function seedEnterpriseDeal(): {+ deal: Deal;+ ledger: LedgerGroup[];+ supporting: SupportingGroup[];+} {+ return {+ deal: clone(ENTERPRISE_DEAL),+ ledger: clone(ENTERPRISE_LEDGER),+ supporting: clone(ENTERPRISE_SUPPORTING),+ };+}++/**+ * Builds the procurement payload for a tier. Enterprise gets the full live+ * deal; free/pro get a minimal locked payload the view renders as an+ * "enterprise-only" upgrade state.+ */+export function buildProcurement(tier: Tier): ProcurementResponse {+ if (tier !== "enterprise") {+ // Locked tiers still receive the journey definition so the view can render+ // a greyed preview of the steps behind the upgrade prompt.+ return {+ tier,+ unlocked: false,+ deal: null,+ journey: JOURNEY,+ ledger: [],+ supporting: [],+ };+ }++ return {+ tier,+ unlocked: true,+ deal: ENTERPRISE_DEAL,+ journey: JOURNEY,+ ledger: ENTERPRISE_LEDGER,+ supporting: ENTERPRISE_SUPPORTING,+ };+}++/** ISO date (YYYY-MM-DD) `n` days from today; negative for the past. */+function daysFromNow(n: number): string {+ const d = new Date();+ d.setDate(d.getDate() + n);+ return d.toISOString().slice(0, 10);+}diff --git a/frontend/portal/src/mocks/procurementMachine.test.ts b/frontend/portal/src/mocks/procurementMachine.test.tsnew file mode 100644index 0000000000..6bf913b89c--- /dev/null+++ b/frontend/portal/src/mocks/procurementMachine.test.ts@@ -0,0 +1,86 @@+import { beforeEach, describe, expect, it } from "vitest";+import { seedEnterpriseDeal } from "@portal/mocks/procurement";+import {+ advanceDeal,+ payDeal,+ requestDoc,+ signDoc,+ uploadPurchaseOrder,+ type ProcurementStore,+} from "@portal/mocks/procurementMachine";++let store: ProcurementStore;+beforeEach(() => {+ store = seedEnterpriseDeal();+});++function status(s: ProcurementStore, id: string): string | undefined {+ return [+ ...s.ledger.flatMap((g) => g.docs),+ ...s.supporting.flatMap((g) => g.docs),+ ].find((d) => d.id === id)?.status;+}++describe("seed", () => {+ it("starts mid-journey at the agreement, awaiting signature", () => {+ expect(store.deal.currentStage).toBe("security");+ expect(status(store, "doc-agreement-enterprise")).toBe("action");+ });++ it("is an independent copy each call (writes never touch the fixture)", () => {+ advanceDeal(store, "security");+ const fresh = seedEnterpriseDeal();+ expect(fresh.deal.currentStage).toBe("security");+ });+});++describe("advanceDeal", () => {+ it("completes the stage's gating doc and unlocks the next stage", () => {+ advanceDeal(store, "security");+ expect(store.deal.currentStage).toBe("procurement");+ expect(status(store, "doc-agreement-enterprise")).toBe("complete");+ // Payment paperwork becomes actionable / downloadable on entry.+ expect(status(store, "doc-pay-online")).toBe("action");+ expect(status(store, "doc-pay-wire")).toBe("available");+ });++ it("ignores a stale stage so a double-click can't skip ahead", () => {+ advanceDeal(store, "security"); // → procurement+ advanceDeal(store, "security"); // stale, no-op+ expect(store.deal.currentStage).toBe("procurement");+ });++ it("is a no-op at the terminal stage", () => {+ advanceDeal(store, "security"); // → procurement+ advanceDeal(store, "procurement"); // → active+ expect(store.deal.currentStage).toBe("active");+ advanceDeal(store, "active"); // terminal+ expect(store.deal.currentStage).toBe("active");+ });+});++describe("document actions", () => {+ it("signing completes the agreement and advances the deal", () => {+ signDoc(store, "doc-agreement-enterprise");+ expect(status(store, "doc-agreement-enterprise")).toBe("complete");+ expect(store.deal.currentStage).toBe("procurement");+ });++ it("paying clears payment and advances to implementation", () => {+ advanceDeal(store, "security"); // → procurement+ payDeal(store);+ expect(store.deal.currentStage).toBe("active");+ expect(status(store, "doc-pay-online")).toBe("complete");+ });++ it("uploading a PO is an alternate payment path that also advances", () => {+ advanceDeal(store, "security"); // → procurement+ uploadPurchaseOrder(store);+ expect(store.deal.currentStage).toBe("active");+ });++ it("requesting an on-demand document moves it to pending", () => {+ requestDoc(store, "sup-custom-review");+ expect(status(store, "sup-custom-review")).toBe("pending");+ });+});diff --git a/frontend/portal/src/mocks/procurementMachine.ts b/frontend/portal/src/mocks/procurementMachine.tsnew file mode 100644index 0000000000..275b511b51--- /dev/null+++ b/frontend/portal/src/mocks/procurementMachine.ts@@ -0,0 +1,114 @@+/**+ * The procurement deal's state machine, the exact server-side semantics the+ * mock backend enforces, as pure functions over a {@link ProcurementStore}.+ *+ * Kept separate from the MSW handler (which just owns one in-memory store and+ * wires these to endpoints) so the rules are unit-testable without a network,+ * and so a real backend has a precise spec to mirror. Every function mutates+ * the store in place, there's a single instance per session.+ */++import {+ JOURNEY,+ type Deal,+ type DealStage,+ type DocAction,+ type DocStatus,+ type LedgerDoc,+ type LedgerGroup,+ type SupportingGroup,+} from "@portal/mocks/procurement";++export interface ProcurementStore {+ deal: Deal;+ ledger: LedgerGroup[];+ supporting: SupportingGroup[];+}++/** Document actions that gate a stage, completing them moves the deal forward. */+const GATING: DocAction[] = ["sign", "pay", "upload"];++function nextStage(stage: DealStage): DealStage | null {+ const i = JOURNEY.findIndex((s) => s.stage === stage);+ return i >= 0 && i < JOURNEY.length - 1 ? JOURNEY[i + 1].stage : null;+}++function allDocs(store: ProcurementStore): LedgerDoc[] {+ return [+ ...store.ledger.flatMap((g) => g.docs),+ ...store.supporting.flatMap((g) => g.docs),+ ];+}++function setDocStatus(store: ProcurementStore, id: string, status: DocStatus) {+ const doc = allDocs(store).find((d) => d.id === id);+ if (doc) doc.status = status;+}++function stageOfDoc(+ store: ProcurementStore,+ id: string,+): DealStage | undefined {+ return store.ledger.find((g) => g.docs.some((d) => d.id === id))?.stage;+}++/**+ * Advance the deal one stage. Completing a stage marks its outstanding gating+ * docs done; entering the next stage promotes that stage's paperwork from+ * "pending" to actionable (gating → action needed, downloads → available).+ * No-ops on a stale `from` so a double-click can't skip a stage.+ */+export function advanceDeal(store: ProcurementStore, from: DealStage) {+ if (store.deal.currentStage !== from) return;+ const to = nextStage(from);+ if (!to) return;++ store.ledger+ .find((g) => g.stage === from)+ ?.docs.forEach((d) => {+ if (d.status === "action") d.status = "complete";+ });++ store.deal.currentStage = to;++ store.ledger+ .find((g) => g.stage === to)+ ?.docs.forEach((d) => {+ if (d.status !== "pending") return;+ if (GATING.includes(d.action)) d.status = "action";+ else if (d.action === "download") d.status = "available";+ });+}++/** Complete the current stage's doc matching an action, then advance past it. */+function completeAndAdvance(store: ProcurementStore, action: DocAction) {+ const stage = store.deal.currentStage;+ store.ledger+ .find((g) => g.stage === stage)+ ?.docs.forEach((d) => {+ if (d.action === action) d.status = "complete";+ });+ advanceDeal(store, stage);+}++/** Sign the agreement: complete the doc and advance out of its stage. */+export function signDoc(store: ProcurementStore, docId: string) {+ setDocStatus(store, docId, "complete");+ const stage = stageOfDoc(store, docId);+ if (stage && stage === store.deal.currentStage) advanceDeal(store, stage);+}++/** Confirm online payment, then advance to implementation. */+export function payDeal(store: ProcurementStore) {+ completeAndAdvance(store, "pay");+}++/** Upload a purchase order (an alternate payment path), then advance. */+export function uploadPurchaseOrder(store: ProcurementStore) {+ completeAndAdvance(store, "upload");+}++/** Queue an on-demand document, it moves to "pending" until generated. */+export function requestDoc(store: ProcurementStore, docId: string) {+ setDocStatus(store, docId, "pending");+}diff --git a/frontend/portal/src/views/Procurement.css b/frontend/portal/src/views/Procurement.cssnew file mode 100644index 0000000000..90da816a53--- /dev/null+++ b/frontend/portal/src/views/Procurement.css@@ -0,0 +1,453 @@+.portal-proc {+ display: flex;+ flex-direction: column;+ gap: 1.25rem;+ padding: 1.5rem;+ max-width: 84rem;+ margin: 0 auto;+}++/* Page header */+.portal-proc__header {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: 1rem;+}++.portal-proc__title {+ margin: 0;+ font-size: 1.375rem;+ font-weight: 600;+ color: var(--color-text-1);+}++.portal-proc__subtitle {+ margin: 0.25rem 0 0;+ font-size: 0.8125rem;+ color: var(--color-text-4);+}++/* Eyebrow label shared by the journey header + SE block */+.portal-proc__eyebrow {+ display: block;+ font-size: 0.6875rem;+ font-weight: 600;+ text-transform: uppercase;+ letter-spacing: 0.05em;+ color: var(--color-text-5);+ margin-bottom: 0.25rem;+}++/* ── Journey card ─────────────────────────────────────────────────────── */+/* Stacked, border-divided sections: header / stepper / trial / next step. */+.portal-proc__journey-head {+ display: flex;+ align-items: flex-start;+ justify-content: space-between;+ gap: 1rem;+ padding: 1.25rem 1.5rem;+ border-bottom: 1px solid var(--color-border-light);+ flex-wrap: wrap;+}++.portal-proc__journey-title {+ margin: 0;+ font-size: 1.0625rem;+ font-weight: 700;+ color: var(--color-text-1);+}++.portal-proc__journey-sub {+ margin: 0.25rem 0 0;+ max-width: 36rem;+ font-size: 0.8125rem;+ line-height: 1.5;+ color: var(--color-text-4);+}++.portal-proc__se {+ display: flex;+ flex-direction: column;+ text-align: right;+ flex-shrink: 0;+}++.portal-proc__se .portal-proc__eyebrow {+ margin-bottom: 0.25rem;+}++.portal-proc__se-name {+ font-size: 0.8125rem;+ font-weight: 600;+ color: var(--color-text-1);+}++.portal-proc__se-email {+ font-size: 0.75rem;+ color: var(--color-blue);+ text-decoration: none;+}++.portal-proc__se-email:hover {+ text-decoration: underline;+}++/* Stepper band */+.portal-proc__journey-stepper {+ padding: 1.125rem 1.5rem;+ border-bottom: 1px solid var(--color-border-light);+}++.portal-proc__steps {+ display: flex;+ align-items: flex-start;+}++.portal-proc__steps--locked {+ opacity: 0.55;+ filter: grayscale(0.4);+ pointer-events: none;+}++.portal-proc__step {+ display: flex;+ flex-direction: column;+ align-items: center;+ gap: 0.4rem;+ min-width: 4rem;+}++.portal-proc__step-dot {+ width: 0.875rem;+ height: 0.875rem;+ border-radius: 50%;+ background: var(--color-border-input);+}++.portal-proc__step--complete .portal-proc__step-dot {+ background: var(--color-green);+}++.portal-proc__step--current .portal-proc__step-dot {+ background: var(--color-purple);+ box-shadow: 0 0 0 4px var(--color-purple-light);+}++.portal-proc__step-label {+ font-size: 0.6875rem;+ font-weight: 500;+ text-align: center;+ white-space: nowrap;+ color: var(--color-text-5);+}++.portal-proc__step--complete .portal-proc__step-label {+ color: var(--color-text-4);+}++.portal-proc__step--current .portal-proc__step-label {+ font-weight: 700;+ color: var(--color-text-1);+}++/* Connector aligns with the 0.875rem dots: (14px − 2px) / 2 = 6px down */+.portal-proc__step-line {+ flex: 1;+ height: 2px;+ margin: 0.375rem 0.375rem 0;+ background: var(--color-border-light);+}++.portal-proc__step-line[data-filled="true"] {+ background: var(--color-green);+}++/* Trial status strip (shown while evaluating) */+.portal-proc__trial {+ display: flex;+ align-items: center;+ gap: 0.625rem;+ flex-wrap: wrap;+ padding: 0.75rem 1.5rem;+ border-bottom: 1px solid var(--color-border-light);+ background: var(--color-bg-code);+}++.portal-proc__trial-title {+ font-size: 0.8125rem;+ font-weight: 600;+ color: var(--color-text-1);+}++.portal-proc__trial-dim {+ font-size: 0.78125rem;+ color: var(--color-text-5);+}++.portal-proc__trial-key {+ font-family:+ ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;+ font-size: 0.6875rem;+ color: var(--color-text-4);+ background: var(--color-surface);+ border: 1px solid var(--color-border-input);+ border-radius: 0.375rem;+ padding: 0.1875rem 0.5rem;+}++/* Next-step row: one primary action at a time */+.portal-proc__next {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 1rem;+ flex-wrap: wrap;+ padding: 1rem 1.5rem;+}++.portal-proc__next-label {+ display: flex;+ align-items: center;+ gap: 0.625rem;+ font-size: 0.84375rem;+ font-weight: 600;+ color: var(--color-text-1);+}++.portal-proc__next-dot {+ width: 0.5rem;+ height: 0.5rem;+ border-radius: 50%;+ background: var(--color-amber);+ flex-shrink: 0;+}++.portal-proc__next-dot[data-live="true"] {+ background: var(--color-green);+}++/* ── Documents card ───────────────────────────────────────────────────── */+.portal-proc__docs-head {+ padding: 1.125rem 1.5rem;+ border-bottom: 1px solid var(--color-border-light);+}++.portal-proc__docs-title {+ margin: 0;+ font-size: 0.9375rem;+ font-weight: 700;+ color: var(--color-text-1);+}++.portal-proc__docs-sub {+ margin: 0.25rem 0 0;+ font-size: 0.78125rem;+ color: var(--color-text-5);+}++.portal-proc__docs-body {+ padding: 0.375rem 1.5rem 1.125rem;+}++/* Accordion spacing — the disclosure chrome itself lives in shared Collapsible+ (.sui-collapsible); here we only space the stacked sections. */+.portal-proc__docs-body .sui-collapsible {+ margin-top: 0.875rem;+}++/* Stage header bits */+.portal-proc__stage-dot {+ width: 0.4375rem;+ height: 0.4375rem;+ border-radius: 50%;+ flex-shrink: 0;+}++.portal-proc__stage-dot[data-state="done"] {+ background: var(--color-green);+}++.portal-proc__stage-dot[data-state="current"] {+ background: var(--color-purple);+}++.portal-proc__stage-dot[data-state="upcoming"] {+ background: var(--color-border-input);+}++.portal-proc__stage-label {+ font-size: 0.75rem;+ font-weight: 700;+ letter-spacing: 0.03em;+ text-transform: uppercase;+ color: var(--color-text-4);+}++.portal-proc__stage-label[data-current] {+ color: var(--color-text-1);+}++.portal-proc__stage-hint {+ font-size: 0.71875rem;+ color: var(--color-text-5);+}++.portal-proc__stage-count {+ font-size: 0.6875rem;+ color: var(--color-text-5);+}++/* Document lists inside the accordion */+.portal-proc__doc-list {+ border-top: 1px solid var(--color-border-light);+}++.portal-proc__doc-list--boxed {+ border: 1px solid var(--color-border-light);+ border-radius: 0.5rem;+ overflow: hidden;+}++/* Supporting section — extra separation from the stage accordion above it.+ Scoped to match the general .sui-collapsible spacing rule's specificity. */+.portal-proc__docs-body .portal-proc__supporting-acc {+ margin-top: 1.5rem;+}++.portal-proc__supporting-head {+ display: flex;+ flex-direction: column;+ gap: 0.125rem;+ min-width: 0;+}++.portal-proc__supporting-sub {+ font-size: 0.71875rem;+ font-weight: 400;+ line-height: 1.45;+ color: var(--color-text-5);+}++.portal-proc__acc-toggle-label {+ font-size: 0.75rem;+ font-weight: 600;+ color: var(--color-blue);+}++.portal-proc__supporting-groups {+ display: flex;+ flex-direction: column;+ gap: 1rem;+ border-top: 1px solid var(--color-border-light);+ padding: 0.875rem;+}++.portal-proc__group-label {+ font-size: 0.6875rem;+ font-weight: 700;+ text-transform: uppercase;+ letter-spacing: 0.05em;+ color: var(--color-text-5);+ margin-bottom: 0.5rem;+}++/* ── Document rows (ledger + supporting) ──────────────────────────────── */+.portal-proc__doc {+ display: flex;+ align-items: center;+ justify-content: space-between;+ gap: 1rem;+ padding: 0.75rem 0.875rem;+ border-bottom: 1px solid var(--color-border-light);+}++.portal-proc__doc:last-child {+ border-bottom: none;+}++.portal-proc__doc[data-locked] {+ opacity: 0.6;+}++.portal-proc__doc-text {+ min-width: 0;+}++.portal-proc__doc-name-row {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ flex-wrap: wrap;+}++.portal-proc__doc-name {+ font-size: 0.84375rem;+ font-weight: 600;+ color: var(--color-text-1);+}++.portal-proc__doc-sub {+ margin: 0.0625rem 0 0;+ font-size: 0.71875rem;+ line-height: 1.4;+ color: var(--color-text-5);+}++.portal-proc__doc-actions {+ display: flex;+ align-items: center;+ gap: 0.75rem;+ flex-shrink: 0;+}++/* ── Locked state ─────────────────────────────────────────────────────── */+.portal-proc__locked {+ display: flex;+ flex-direction: column;+ gap: 1.25rem;+}++/* ── Action modal ─────────────────────────────────────────────────────── */+.portal-proc__modal-body {+ margin: 0 0 1rem;+ font-size: 0.875rem;+ line-height: 1.55;+ color: var(--color-text-2);+}++.portal-proc__modal-actions {+ display: flex;+ align-items: center;+ justify-content: flex-end;+ gap: 0.625rem;+}++.portal-proc__upload {+ display: flex;+ align-items: center;+ gap: 0.75rem;+}++.portal-proc__upload-input {+ display: none;+}++.portal-proc__upload-name {+ font-size: 0.75rem;+ color: var(--color-text-4);+}++@media (max-width: 48rem) {+ .portal-proc__journey-head {+ flex-direction: column;+ }++ .portal-proc__se {+ text-align: left;+ }++ .portal-proc__steps {+ overflow-x: auto;+ }+}diff --git a/frontend/portal/src/views/Procurement.tsx b/frontend/portal/src/views/Procurement.tsxnew file mode 100644index 0000000000..f41bbe52d4--- /dev/null+++ b/frontend/portal/src/views/Procurement.tsx@@ -0,0 +1,107 @@+import { useEffect, useState } from "react";+import { useTranslation } from "react-i18next";+import { Card, Skeleton, StatusBadge } from "@shared/components";+import { useTier } from "@portal/contexts/TierContext";+import { useAsync } from "@portal/hooks/useAsync";+import {+ advanceStage,+ fetchProcurement,+ type DealStage,+ type LedgerDoc,+ type ProcurementResponse,+} from "@portal/api/procurement";+import { DealJourney } from "@portal/components/procurement/DealJourney";+import { DocumentLedger } from "@portal/components/procurement/DocumentLedger";+import { ActionModal } from "@portal/components/procurement/ActionModal";+import { LockedState } from "@portal/components/procurement/LockedState";+import "@portal/views/Procurement.css";++/**+ * Procurement: the enterprise commercial journey (trial to live) plus the+ * document ledger. Enterprise-only: free/pro buyers see a locked upgrade state.+ */+export function Procurement() {+ const { t } = useTranslation();+ const { tier } = useTier();+ const [activeDoc, setActiveDoc] = useState<LedgerDoc | null>(null);+ const [advancing, setAdvancing] = useState(false);++ const state = useAsync<ProcurementResponse>(+ () => fetchProcurement(tier),+ [tier],+ );++ // Write actions return the new canonical state; we hold it here so the+ // journey reflects every action immediately. Cleared when the tier (and so+ // the deal) changes, falling back to whatever the GET loaded.+ const [applied, setApplied] = useState<ProcurementResponse | null>(null);+ useEffect(() => setApplied(null), [tier]);+ const data = applied ?? (state.loading ? null : state.data);++ async function onAdvance(stage: DealStage) {+ setAdvancing(true);+ try {+ setApplied(await advanceStage(stage));+ } finally {+ setAdvancing(false);+ }+ }++ return (+ <div className="portal-proc">+ <header className="portal-proc__header">+ <div>+ <h1 className="portal-proc__title">{t("procurement.title")}</h1>+ <p className="portal-proc__subtitle">{t("procurement.subtitle")}</p>+ </div>+ <StatusBadge tone="purple" size="md">+ {t("procurement.enterpriseBadge")}+ </StatusBadge>+ </header>++ {state.loading && (+ <Card padding="loose">+ <Skeleton width="12rem" height="1.25rem" />+ <Skeleton height="8rem" />+ </Card>+ )}++ {data && !data.unlocked && (+ <LockedState+ journey={data.journey}+ onTalkToSales={() => {+ // TODO(backend): POST /v1/procurement/sales-contact, for now this+ // is the sidebar's upgrade path; hand off to the account team.+ }}+ />+ )}++ {data && data.unlocked && data.deal && (+ <>+ <DealJourney+ deal={data.deal}+ journey={data.journey}+ onAdvance={onAdvance}+ advancing={advancing}+ />+ <DocumentLedger+ groups={data.ledger}+ supporting={data.supporting}+ journey={data.journey}+ currentStage={data.deal.currentStage}+ onAction={setActiveDoc}+ />+ </>+ )}++ <ActionModal+ doc={activeDoc}+ onClose={() => setActiveDoc(null)}+ onDone={(next) => {+ setApplied(next);+ setActiveDoc(null);+ }}+ />+ </div>+ );+}diff --git a/frontend/shared/components/Collapsible.css b/frontend/shared/components/Collapsible.cssnew file mode 100644index 0000000000..95b53886a5--- /dev/null+++ b/frontend/shared/components/Collapsible.css@@ -0,0 +1,63 @@+.sui-collapsible {+ border: 1px solid var(--color-border-light);+ border-radius: 0.5625rem;+ overflow: hidden;+}++.sui-collapsible__head {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ width: 100%;+ padding: 0.75rem 0.875rem;+ background: var(--color-surface);+ border: none;+ cursor: pointer;+ text-align: left;+ transition: background-color 0.15s ease;+}++.sui-collapsible__head:hover {+ background: var(--color-bg-hover);+}++.sui-collapsible__head-main {+ display: flex;+ align-items: center;+ gap: 0.5rem;+ flex: 1;+ min-width: 0;+ flex-wrap: wrap;+}++.sui-collapsible__head-end {+ display: inline-flex;+ align-items: center;+ gap: 0.625rem;+ margin-left: auto;+ flex-shrink: 0;+}++.sui-collapsible__chevron {+ color: var(--color-text-5);+ transition: transform 0.2s ease;+}++.sui-collapsible__chevron[data-open="true"] {+ transform: rotate(180deg);+}++/* Grid-rows disclosure: 0fr → 1fr, no magic max-height */+.sui-collapsible__body {+ display: grid;+ grid-template-rows: 0fr;+ transition: grid-template-rows 0.25s cubic-bezier(0.4, 0, 0.2, 1);+}++.sui-collapsible__body[data-open="true"] {+ grid-template-rows: 1fr;+}++.sui-collapsible__body-inner {+ overflow: hidden;+}diff --git a/frontend/shared/components/Collapsible.stories.tsx b/frontend/shared/components/Collapsible.stories.tsxnew file mode 100644index 0000000000..79e71cbe51--- /dev/null+++ b/frontend/shared/components/Collapsible.stories.tsx@@ -0,0 +1,63 @@+import { useState } from "react";+import type { Meta, StoryObj } from "@storybook/react-vite";+import { Collapsible } from "@shared/components/Collapsible";++const meta: Meta<typeof Collapsible> = {+ title: "Components/Collapsible",+ component: Collapsible,+ parameters: { layout: "padded" },+};+export default meta;+type Story = StoryObj<typeof Collapsible>;++// open/onToggle are a controlled pair, so the stories own the state.+export const Default: Story = {+ render: () => {+ const [open, setOpen] = useState(false);+ return (+ <div style={{ maxWidth: "40rem" }}>+ <Collapsible+ open={open}+ onToggle={() => setOpen((o) => !o)}+ header={<strong>Section title</strong>}+ aside={<span style={{ fontSize: "0.75rem" }}>3 items</span>}+ >+ <div style={{ padding: "0.875rem", borderTop: "1px solid #eee" }}>+ Body content revealed when the section is open.+ </div>+ </Collapsible>+ </div>+ );+ },+};++// Stacked instances form an accordion; each section toggles independently.+export const Accordion: Story = {+ render: () => {+ const [open, setOpen] = useState<number | null>(0);+ const sections = ["Trial", "Quote", "Agreement"];+ return (+ <div+ style={{+ maxWidth: "40rem",+ display: "flex",+ flexDirection: "column",+ gap: "0.75rem",+ }}+ >+ {sections.map((label, i) => (+ <Collapsible+ key={label}+ open={open === i}+ onToggle={() => setOpen(open === i ? null : i)}+ header={<strong>{label}</strong>}+ >+ <div style={{ padding: "0.875rem", borderTop: "1px solid #eee" }}>+ {label} details.+ </div>+ </Collapsible>+ ))}+ </div>+ );+ },+};diff --git a/frontend/shared/components/Collapsible.tsx b/frontend/shared/components/Collapsible.tsxnew file mode 100644index 0000000000..d4768e9d1e--- /dev/null+++ b/frontend/shared/components/Collapsible.tsx@@ -0,0 +1,65 @@+import type { ReactNode } from "react";+import "@shared/components/Collapsible.css";++export interface CollapsibleProps {+ /** Whether the section is expanded. Controlled — pair with `onToggle`. */+ open: boolean;+ onToggle: () => void;+ /** Header content (left/main side); the chevron is appended automatically. */+ header: ReactNode;+ /** Right-aligned header content shown before the chevron (a count, a label). */+ aside?: ReactNode;+ children: ReactNode;+ className?: string;+}++/**+ * A single bordered disclosure section: an always-visible header that toggles,+ * and a body that animates open/closed via a grid-rows transition (no magic+ * max-height). Stack several to build an accordion. Header content is fully+ * caller-supplied, so it suits both terse and rich (icon + chips + count) rows.+ */+export function Collapsible({+ open,+ onToggle,+ header,+ aside,+ children,+ className,+}: CollapsibleProps) {+ return (+ <div+ className={["sui-collapsible", className ?? ""].filter(Boolean).join(" ")}+ >+ <button+ type="button"+ className="sui-collapsible__head"+ onClick={onToggle}+ aria-expanded={open}+ >+ <span className="sui-collapsible__head-main">{header}</span>+ <span className="sui-collapsible__head-end">+ {aside}+ <svg+ className="sui-collapsible__chevron"+ data-open={open}+ viewBox="0 0 24 24"+ width={16}+ height={16}+ fill="none"+ stroke="currentColor"+ strokeWidth={2}+ strokeLinecap="round"+ strokeLinejoin="round"+ aria-hidden+ >+ <polyline points="6 9 12 15 18 9" />+ </svg>+ </span>+ </button>+ <div className="sui-collapsible__body" data-open={open}>+ <div className="sui-collapsible__body-inner">{children}</div>+ </div>+ </div>+ );+}diff --git a/frontend/shared/components/index.ts b/frontend/shared/components/index.tsindex fd2846a7cc..0416614d97 100644--- a/frontend/shared/components/index.ts+++ b/frontend/shared/components/index.ts@@ -28,6 +28,7 @@ export * from "@shared/components/Banner";export * from "@shared/components/Toast";// Compound+export * from "@shared/components/Collapsible";export * from "@shared/components/Tabs";export * from "@shared/components/Dropdown";export * from "@shared/components/Drawer";