Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -0,0 +1,214 @@
import { useRef } from "react";
import { useTranslation } from "react-i18next";
import { FeatherDatabase, FeatherTrash2 } from "@subframe/core";
import type { DemoDataSettingsVM } from "@hivegrid/view-models";
import ConfirmDialog, { type RefConfirmDialog } from "~/components/ui/modals/ConfirmDialog";
import { useLocaleFormatters } from "~/locale/format";
import { Alert } from "~/ui/components/Alert";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageIntro, PageShell } from "../shared/PageShell";
export type DemoDataSettingsActions = {
readonly onCreate: () => void | Promise<void>;
readonly onDelete: (provisioningId: string) => void | Promise<void>;
readonly onRetry?: () => void | Promise<void>;
};
export type DemoDataSettingsPageProps = {
readonly vm: DemoDataSettingsVM;
readonly actions: DemoDataSettingsActions;
readonly busy?: boolean;
/** Inside the Workspace hub (AK-SET-01) the hub owns the header — see PageIntro. */
readonly embedded?: boolean;
};
const TITLE_KEY = "onboarding.demoData.title";
const DESCRIPTION_KEY = "onboarding.demoData.description";
/** Page chrome shared by every VM state, so the headline bar does not flicker between loading and ready. */
function DemoDataShell({
titleKey = TITLE_KEY,
descriptionKey = DESCRIPTION_KEY,
headerActions,
embedded = false,
children,
}: {
titleKey?: string;
descriptionKey?: string;
headerActions?: React.ReactNode;
/** Inside the Workspace hub (AK-SET-01) the hub owns the header. */
embedded?: boolean;
children: React.ReactNode;
}) {
const { t } = useTranslation();
return (
<PageShell uiId="ui.onboarding.demoData.page">
{embedded ? null : (
<PageHeader
icon={<FeatherDatabase className={PAGE_HEADER_ICON_CLASS} />}
title={t(titleKey)}
subtitle={t(descriptionKey)}
actions={headerActions}
/>
)}
<PageBody>
{embedded ? (
// The header carried the destructive actions, so they have to be
// re-hosted rather than disappear with it.
<div className="mobile:flex-col mobile:items-start flex w-full items-start justify-between gap-4">
<PageIntro uiId="ui.onboarding.demoData.intro">{t(descriptionKey)}</PageIntro>
{headerActions ? <div className="flex items-center gap-2">{headerActions}</div> : null}
</div>
) : null}
{children}
</PageBody>
</PageShell>
);
}
export function DemoDataSettingsPage({ vm, actions, busy = false, embedded = false }: DemoDataSettingsPageProps) {
const { t } = useTranslation();
const formatters = useLocaleFormatters();
const confirmDialog = useRef<RefConfirmDialog>(null);
if (vm.status === "loading" || vm.status === "idle") {
return (
<DemoDataShell embedded={embedded}>
<Alert variant="neutral" title={t("onboarding.demoData.loading.title")} description={t("onboarding.demoData.loading.body")} />
</DemoDataShell>
);
}
if (vm.status === "error") {
return (
<DemoDataShell embedded={embedded}>
<EmptyState
outlined
variant="error"
title={t("onboarding.demoData.error.title")}
body={t(vm.error.messageKey)}
action={
actions.onRetry ? (
<Button variant="tertiary" onClick={() => void actions.onRetry?.()}>
{t("shared.retry")}
</Button>
) : undefined
}
/>
</DemoDataShell>
);
}
if (vm.status === "empty" || !vm.data) {
return (
<DemoDataShell embedded={embedded}>
<EmptyState outlined title={t("onboarding.demoData.unavailable.title")} body={t("onboarding.demoData.unavailable.body")} />
</DemoDataShell>
);
}
const data = vm.data;
const confirmDelete = () => {
if (!data.provisioningId) return;
confirmDialog.current?.show({
title: t("onboarding.demoData.deleteDialog.title"),
description: t("onboarding.demoData.deleteDialog.description", { count: data.totalCount }),
confirmText: t("onboarding.demoData.delete"),
cancelText: t("shared.cancel"),
destructive: true,
onConfirm: () => void actions.onDelete(data.provisioningId as string),
});
};
return (
<DemoDataShell
embedded={embedded}
titleKey={data.titleKey}
descriptionKey={data.descriptionKey}
headerActions={<BadgeFeedback farbe={data.hasDemoData ? "subtle-positive" : "subtle-neutral"}>{t(data.statusLabelKey)}</BadgeFeedback>}
>
<Alert
variant={data.canCreate ? "information" : "neutral"}
notDismissible
title={t(data.environmentNoticeKey)}
description={t(data.hasDemoData ? "onboarding.demoData.environment.cleanupHint" : "onboarding.demoData.environment.createHint")}
/>
{!data.hasDemoData ? (
<EmptyState
outlined
title={t("onboarding.demoData.empty.title")}
body={t("onboarding.demoData.empty.body")}
action={
data.canCreate ? (
<Button
loading={busy}
disabled={busy}
icon={<FeatherDatabase />}
onClick={() => void actions.onCreate()}
data-ui-id="ui.onboarding.demoData.create"
>
{t("onboarding.demoData.create")}
</Button>
) : undefined
}
/>
) : (
<Card data-ui-id="ui.onboarding.demoData.summary">
<div className="flex w-full flex-wrap items-start justify-between gap-4">
<div className="flex flex-col gap-1">
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("onboarding.demoData.contents.title")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{t("onboarding.demoData.contents.summary", { count: data.totalCount })}
</span>
</div>
<Button
variant="destructive"
loading={busy}
disabled={busy || !data.canDelete}
icon={<FeatherTrash2 />}
onClick={confirmDelete}
data-ui-id="ui.onboarding.demoData.delete"
data-testid="demo-delete-trigger"
>
{t("onboarding.demoData.delete")}
</Button>
</div>
<div className="mobile:grid-cols-1 grid w-full grid-cols-3 gap-3">
{data.entities.map((entity) => (
<div
key={entity.kind}
className="border-border-default bg-surface-neutral-primary flex items-center justify-between gap-3 rounded-md border border-solid px-4 py-3"
>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t(entity.labelKey)}</span>
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{formatters.number(entity.count)}</span>
</div>
))}
</div>
{data.createdAt || data.removableUntil ? (
<div className="border-border-default flex w-full flex-wrap gap-x-6 gap-y-1 border-t border-solid pt-4">
{data.createdAt ? (
<span className="text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-tertiary">
{t("onboarding.demoData.createdAt", { date: formatters.dateTime(data.createdAt) })}
</span>
) : null}
{data.removableUntil ? (
<span className="text-body-extra-small-regular-0 font-body-extra-small-regular-0 text-text-neutral-tertiary">
{t("onboarding.demoData.removableUntil", { date: formatters.date(data.removableUntil) })}
</span>
) : null}
</div>
) : null}
</Card>
)}
<ConfirmDialog ref={confirmDialog} destructive />
</DemoDataShell>
);
}
@@ -0,0 +1,190 @@
import { useTranslation } from "react-i18next";
import { FeatherArrowRight, FeatherCheck, FeatherCheckCircle, FeatherEye, FeatherListChecks } from "@subframe/core";
import type { FirstStepsChecklistVM } from "@hivegrid/view-models";
import { Alert } from "~/ui/components/Alert";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { IconWithBackground } from "~/ui/components/IconWithBackground";
import { Progress } from "~/ui/components/Progress";
export type FirstStepsChecklistActions = {
readonly onComplete: (sessionStepId: string) => void | Promise<void>;
readonly onDismiss: () => void | Promise<void>;
readonly onReopen?: () => void | Promise<void>;
readonly onOpen: (href: string) => void;
readonly onRetry?: () => void | Promise<void>;
};
export type FirstStepsChecklistPageProps = {
readonly vm: FirstStepsChecklistVM;
readonly actions: FirstStepsChecklistActions;
readonly busy?: boolean;
};
export function FirstStepsChecklistPage({ vm, actions, busy = false }: FirstStepsChecklistPageProps) {
const { t } = useTranslation();
if (vm.status === "loading" || vm.status === "idle") {
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.onboarding.firstSteps.page">
<Alert variant="neutral" title={t("onboarding.firstSteps.loading.title")} description={t("onboarding.firstSteps.loading.body")} />
</div>
);
}
if (vm.status === "error") {
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.onboarding.firstSteps.page">
<EmptyState
outlined
variant="error"
title={t("onboarding.firstSteps.error.title")}
body={t(vm.error.messageKey)}
action={
actions.onRetry ? (
<Button variant="tertiary" onClick={() => void actions.onRetry?.()}>
{t("shared.retry")}
</Button>
) : undefined
}
/>
</div>
);
}
if (vm.status === "empty" || !vm.data) {
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.onboarding.firstSteps.page">
<EmptyState outlined title={t("onboarding.firstSteps.empty.title")} body={t("onboarding.firstSteps.empty.body")} />
</div>
);
}
const data = vm.data;
if (data.dismissed) {
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.onboarding.firstSteps.page">
<div className="flex items-start gap-3">
<IconWithBackground variant="neutral" size="large" icon={<FeatherListChecks />} />
<div className="flex flex-col gap-0">
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("onboarding.firstSteps.title")}</h1>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("onboarding.firstSteps.description")}
</span>
</div>
</div>
<EmptyState
outlined
title={t("onboarding.firstSteps.dismissed.title")}
body={t("onboarding.firstSteps.dismissed.body")}
action={
actions.onReopen ? (
<Button
variant="secondary"
loading={busy}
disabled={busy}
icon={<FeatherEye />}
onClick={() => void actions.onReopen?.()}
data-ui-id="ui.onboarding.firstSteps.reopen"
>
{t("onboarding.firstSteps.dismissed.reopen")}
</Button>
) : undefined
}
/>
</div>
);
}
return (
<div className="flex w-full flex-col gap-6 p-6" data-ui-id="ui.onboarding.firstSteps.page">
<div className="flex w-full flex-wrap items-start justify-between gap-4">
<div className="flex items-start gap-3">
<IconWithBackground variant={data.isComplete ? "success" : "information"} size="large" icon={<FeatherListChecks />} />
<div className="flex flex-col gap-0">
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("onboarding.firstSteps.title")}</h1>
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("onboarding.firstSteps.description")}
</span>
</div>
</div>
<BadgeFeedback farbe={data.isComplete ? "subtle-positive" : "subtle-information"}>
{t("onboarding.firstSteps.progressBadge", { completed: data.completedCount, total: data.totalCount })}
</BadgeFeedback>
</div>
<Card variant={data.isComplete ? "positive" : "information"}>
<div className="flex w-full flex-col gap-3">
<div className="flex w-full items-center justify-between gap-3">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
{t(data.progressLabelKey, { completed: data.completedCount, total: data.totalCount })}
</span>
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary">{data.percentComplete}%</span>
</div>
<Progress
className="w-full"
value={data.percentComplete}
state={data.isComplete ? "success" : "uploading"}
hideLabel
aria-label={t("onboarding.firstSteps.progressAria", { percent: data.percentComplete })}
/>
</div>
</Card>
{data.isComplete ? (
<Alert variant="success" notDismissible title={t("onboarding.firstSteps.completeTitle")} description={t("onboarding.firstSteps.completeBody")} />
) : null}
<div className="flex w-full flex-col gap-3" data-ui-id="ui.onboarding.firstSteps.items">
{data.items.map((item) => (
<Card key={item.id} data-row-id={item.id}>
<div className="flex w-full flex-wrap items-center justify-between gap-4">
<div className="flex min-w-0 items-center gap-3">
<IconWithBackground variant={item.completed ? "success" : "neutral"} icon={item.completed ? <FeatherCheckCircle /> : <FeatherListChecks />} />
<div className="flex min-w-0 flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(item.titleKey)}</span>
<BadgeFeedback farbe={item.completed ? "subtle-positive" : "subtle-neutral"} size="small">
{t(item.statusLabelKey)}
</BadgeFeedback>
</div>
</div>
<div className="mobile:w-full mobile:flex-col mobile:items-stretch flex flex-wrap items-center gap-2">
<Button
className="mobile:w-full"
variant="tertiary"
iconRight={<FeatherArrowRight />}
onClick={() => actions.onOpen(item.href)}
data-ui-id={`ui.onboarding.firstSteps.open.${item.id}`}
>
{t("onboarding.firstSteps.open")}
</Button>
{item.canComplete ? (
<Button
className="mobile:w-full"
variant="secondary"
loading={busy}
disabled={busy}
icon={<FeatherCheck />}
onClick={() => void actions.onComplete(item.id)}
data-ui-id={`ui.onboarding.firstSteps.complete.${item.id}`}
>
{t("onboarding.firstSteps.complete")}
</Button>
) : null}
</div>
</div>
</Card>
))}
</div>
<div className="flex w-full justify-end">
<Button variant="ghost" disabled={busy} onClick={() => void actions.onDismiss()} data-ui-id="ui.onboarding.firstSteps.dismiss">
{t("onboarding.firstSteps.hide")}
</Button>
</div>
</div>
);
}
@@ -0,0 +1,53 @@
import { useTranslation } from "react-i18next";
import { FeatherArrowRight, FeatherCheckCircle, FeatherListChecks } from "@subframe/core";
import type { FirstStepsChecklistVM } from "@hivegrid/view-models";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { IconWithBackground } from "~/ui/components/IconWithBackground";
import { Progress } from "~/ui/components/Progress";
export type FirstStepsChecklistWidgetProps = {
readonly vm: FirstStepsChecklistVM;
readonly href: string;
readonly onOpen: (href: string) => void;
};
export function FirstStepsChecklistWidget({ vm, href, onOpen }: FirstStepsChecklistWidgetProps) {
const { t } = useTranslation();
if (vm.status !== "ready" || !vm.data || vm.data.dismissed) return null;
const data = vm.data;
return (
<Card variant={data.isComplete ? "positive" : "default"} data-ui-id="ui.onboarding.firstSteps.widget">
<div className="flex w-full flex-wrap items-start justify-between gap-4">
<div className="flex min-w-0 items-start gap-3">
<IconWithBackground variant={data.isComplete ? "success" : "information"} icon={data.isComplete ? <FeatherCheckCircle /> : <FeatherListChecks />} />
<div className="flex min-w-0 flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("onboarding.firstSteps.dashboardTitle")}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{t(data.progressLabelKey, { completed: data.completedCount, total: data.totalCount })}
</span>
</div>
</div>
<Button
className="mobile:w-full"
variant="tertiary"
size="small"
iconRight={<FeatherArrowRight />}
onClick={() => onOpen(href)}
data-ui-id="ui.onboarding.firstSteps.widget.open"
>
{t("onboarding.firstSteps.open")}
</Button>
</div>
<Progress
className="w-full"
value={data.percentComplete}
state={data.isComplete ? "success" : "uploading"}
hideLabel
aria-label={t("onboarding.firstSteps.progressAria", { percent: data.percentComplete })}
/>
</Card>
);
}
@@ -0,0 +1,103 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import React from "react";
import { fireEvent, render, screen } from "@testing-library/react";
import { beforeEach, describe, expect, it, vi } from "vitest";
import { toDemoDataSettingsVM, toFirstStepsChecklistVM } from "@hivegrid/view-models";
import { DemoDataSettingsPage } from "./DemoDataSettingsPage";
import { FirstStepsChecklistPage } from "./FirstStepsChecklistPage";
import { FirstStepsChecklistWidget } from "./FirstStepsChecklistWidget";
vi.mock("react-i18next", () => ({
useTranslation: () => ({
t: (key: string, values?: Record<string, unknown>) => (values ? `${key}:${Object.values(values).join("/")}` : key),
i18n: { language: "de" },
}),
}));
vi.mock("~/locale/format", () => ({
useLocaleFormatters: () => ({
number: (value: number) => String(value),
date: (value: string) => value,
dateTime: (value: string) => value,
}),
}));
const checklistVm = toFirstStepsChecklistVM({
id: "checklist_1",
status: "active",
dismissed: false,
items: [
{ id: "step_1", block: "profile", titleKey: "onboarding.firstSteps.profile", href: "/acme/settings/profile", completed: true },
{ id: "step_2", block: "contacts", titleKey: "onboarding.firstSteps.contacts", href: "/acme/contacts", completed: false },
],
});
describe("AK-P20 onboarding interim screens", () => {
beforeEach(() => vi.clearAllMocks());
it("renders the demo-data empty state and calls the injected create action", () => {
const onCreate = vi.fn();
const vm = toDemoDataSettingsVM({ demoDataUiEnabled: true, provisioning: null });
render(<DemoDataSettingsPage vm={vm} actions={{ onCreate, onDelete: vi.fn() }} />);
fireEvent.click(screen.getByRole("button", { name: "onboarding.demoData.create" }));
expect(onCreate).toHaveBeenCalledOnce();
expect(screen.getByText("onboarding.demoData.empty.title")).toBeInTheDocument();
});
it("renders tracked demo counts and opens a destructive confirmation", () => {
const vm = toDemoDataSettingsVM({
demoDataUiEnabled: false,
provisioning: { id: "demo_1", entitiesCreated: { kontakt: ["k1"], projekt: ["p1", "p2"], task: ["t1"] } },
});
render(<DemoDataSettingsPage vm={vm} actions={{ onCreate: vi.fn(), onDelete: vi.fn() }} />);
expect(screen.getByText("onboarding.demoData.contents.summary:4")).toBeInTheDocument();
fireEvent.click(screen.getByTestId("demo-delete-trigger"));
expect(screen.getByText("onboarding.demoData.deleteDialog.title")).toBeInTheDocument();
});
it("renders checklist progress and calls complete and dismiss actions", () => {
const onComplete = vi.fn();
const onDismiss = vi.fn();
const onOpen = vi.fn();
render(<FirstStepsChecklistPage vm={checklistVm} actions={{ onComplete, onDismiss, onOpen }} />);
fireEvent.click(screen.getAllByRole("button", { name: "onboarding.firstSteps.open" })[0]!);
fireEvent.click(screen.getByRole("button", { name: "onboarding.firstSteps.complete" }));
fireEvent.click(screen.getByRole("button", { name: "onboarding.firstSteps.hide" }));
expect(onOpen).toHaveBeenCalledWith("/acme/settings/profile");
expect(onComplete).toHaveBeenCalledWith("step_2");
expect(onDismiss).toHaveBeenCalledOnce();
});
it("offers a reopen action on the dismissed state", () => {
const onReopen = vi.fn();
const dismissedVm = toFirstStepsChecklistVM({
id: "checklist_1",
status: "dismissed",
dismissed: true,
items: [{ id: "step_1", block: "profile", titleKey: "onboarding.firstSteps.profile", href: "/acme/settings/profile", completed: true }],
});
render(<FirstStepsChecklistPage vm={dismissedVm} actions={{ onComplete: vi.fn(), onDismiss: vi.fn(), onReopen, onOpen: vi.fn() }} />);
expect(screen.getByText("onboarding.firstSteps.dismissed.title")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "onboarding.firstSteps.dismissed.reopen" }));
expect(onReopen).toHaveBeenCalledOnce();
});
it("reuses the same checklist VM in the dashboard widget", () => {
const onOpen = vi.fn();
render(<FirstStepsChecklistWidget vm={checklistVm} href="/acme/onboarding/checklist" onOpen={onOpen} />);
expect(screen.getByText("onboarding.firstSteps.dashboardTitle")).toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "onboarding.firstSteps.open" }));
expect(onOpen).toHaveBeenCalledWith("/acme/onboarding/checklist");
});
});
@@ -0,0 +1,45 @@
// @vitest-environment jsdom
import "@testing-library/jest-dom/vitest";
import { fireEvent, render, screen } from "@testing-library/react";
import { describe, expect, it, vi } from "vitest";
import { toFirstStepsChecklistVM, toWelcomeSetupVM } from "@hivegrid/view-models";
import { WelcomeSetupPage } from "./WelcomeSetupPage";
import { assertNoA11yViolations } from "~/utils/test/a11y";
vi.mock("~/components/brand/Logo", () => ({ default: ({ to }: { to?: string }) => (to ? <a href={to}>HiveGrid</a> : <span>HiveGrid</span>) }));
vi.mock("react-i18next", () => ({
useTranslation: () => ({
t: (key: string, values?: Record<string, unknown>) => (values ? `${key}:${Object.values(values).join("/")}` : key),
}),
}));
const checklist = toFirstStepsChecklistVM({
id: "session_1",
status: "active",
dismissed: false,
items: [
{ id: "profile", block: "profile", titleKey: "onboarding.firstSteps.profile", href: "/acme/settings/profile", completed: true },
{ id: "team", block: "team", titleKey: "onboarding.firstSteps.team", href: "/acme/settings/team/members/new", completed: false, canComplete: false },
{ id: "contacts", block: "contacts", titleKey: "onboarding.firstSteps.contacts", href: "/acme/contacts", completed: false },
],
});
const vm = toWelcomeSetupVM({ firstName: "Ada", workspaceName: "Acme", dashboardHref: "/acme/dashboard", checklist });
describe("WelcomeSetupPage", () => {
it("renders automatic setup progress and keeps navigation explicit", () => {
const onOpen = vi.fn();
const onDashboard = vi.fn();
const { container } = render(<WelcomeSetupPage vm={vm} homeHref="/acme/dashboard" actions={{ onOpen, onDashboard }} />);
expect(screen.getByRole("heading", { name: "onboarding.welcome.titleNamed:Ada" })).toBeInTheDocument();
expect(screen.getByText("onboarding.firstSteps.progressBadge:1/3")).toBeInTheDocument();
expect(screen.getByText("onboarding.firstSteps.completed")).toBeInTheDocument();
expect(screen.queryByRole("link", { name: "HiveGrid" })).not.toBeInTheDocument();
fireEvent.click(screen.getByRole("button", { name: "onboarding.welcome.tasks.team.action" }));
expect(onOpen).toHaveBeenCalledWith("/acme/settings/team/members/new");
fireEvent.click(screen.getByRole("button", { name: "onboarding.welcome.dashboardAction" }));
expect(onDashboard).toHaveBeenCalledWith("/acme/dashboard");
assertNoA11yViolations(container);
});
});
@@ -0,0 +1,231 @@
import { useTranslation } from "react-i18next";
import {
FeatherArrowRight,
FeatherBriefcase,
FeatherBuilding2,
FeatherCheckCircle,
FeatherContact,
FeatherCreditCard,
FeatherUser,
FeatherUsers,
} from "@subframe/core";
import type { FirstStepsChecklistItemVM, WelcomeSetupVM } from "@hivegrid/view-models";
import Logo from "~/components/brand/Logo";
import { Alert } from "~/ui/components/Alert";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { IconWithBackground } from "~/ui/components/IconWithBackground";
import { Progress } from "~/ui/components/Progress";
import { StepperHorizontal } from "~/ui/components/StepperHorizontal";
export type WelcomeSetupPageProps = {
readonly vm: WelcomeSetupVM;
readonly homeHref: string;
readonly actions: {
readonly onOpen: (href: string) => void;
readonly onDashboard: (href: string) => void;
readonly onRetry?: () => void;
};
};
const taskContent: Record<string, { descriptionKey: string; actionKey: string; icon: React.ReactNode }> = {
profile: {
descriptionKey: "onboarding.welcome.tasks.profile.description",
actionKey: "onboarding.welcome.tasks.profile.action",
icon: <FeatherUser />,
},
team: {
descriptionKey: "onboarding.welcome.tasks.team.description",
actionKey: "onboarding.welcome.tasks.team.action",
icon: <FeatherUsers />,
},
contacts: {
descriptionKey: "onboarding.welcome.tasks.contacts.description",
actionKey: "onboarding.welcome.tasks.contacts.action",
icon: <FeatherContact />,
},
projects: {
descriptionKey: "onboarding.welcome.tasks.projects.description",
actionKey: "onboarding.welcome.tasks.projects.action",
icon: <FeatherBriefcase />,
},
billing: {
descriptionKey: "onboarding.welcome.tasks.billing.description",
actionKey: "onboarding.welcome.tasks.billing.action",
icon: <FeatherCreditCard />,
},
};
function contentFor(item: FirstStepsChecklistItemVM) {
return taskContent[item.block] ?? {
descriptionKey: "onboarding.welcome.tasks.default.description",
actionKey: "onboarding.welcome.tasks.default.action",
icon: <FeatherCheckCircle />,
};
}
export function WelcomeSetupPage({ vm, homeHref, actions }: WelcomeSetupPageProps) {
const { t } = useTranslation();
if (vm.status === "loading" || vm.status === "idle") {
return (
<main className="flex min-h-screen items-center justify-center bg-surface-neutral-secondary p-6" data-ui-id="ui.onboarding.welcome.loading">
<Alert variant="neutral" title={t("onboarding.welcome.loading.title")} description={t("onboarding.welcome.loading.body")} />
</main>
);
}
if (vm.status === "error") {
return (
<main className="flex min-h-screen items-center justify-center bg-surface-neutral-secondary p-6" data-ui-id="ui.onboarding.welcome.error">
<EmptyState
outlined
variant="error"
title={
<span role="heading" aria-level={1}>
{t("onboarding.welcome.error.title")}
</span>
}
body={t(vm.error.messageKey)}
action={
actions.onRetry ? (
<Button variant="tertiary" onClick={actions.onRetry}>
{t("shared.retry")}
</Button>
) : undefined
}
/>
</main>
);
}
if (vm.status === "empty" || !vm.data) {
return (
<main className="flex min-h-screen items-center justify-center bg-surface-neutral-secondary p-6" data-ui-id="ui.onboarding.welcome.empty">
<EmptyState
outlined
title={
<span role="heading" aria-level={1}>
{t("onboarding.welcome.empty.title")}
</span>
}
body={t("onboarding.welcome.empty.body")}
action={<Button onClick={() => actions.onDashboard(homeHref)}>{t("onboarding.welcome.dashboardAction")}</Button>}
/>
</main>
);
}
const { checklist } = vm.data;
const greeting = vm.data.firstName ? t("onboarding.welcome.titleNamed", { firstName: vm.data.firstName }) : t("onboarding.welcome.title");
return (
<main className="min-h-screen bg-surface-neutral-secondary px-4 py-8 sm:px-6 sm:py-10" data-ui-id="ui.onboarding.welcome.page">
<div className="mx-auto flex w-full max-w-6xl flex-col gap-8">
<div className="flex justify-center">
<Logo size="h-12" />
</div>
<StepperHorizontal aria-label={t("onboarding.welcome.stepper.label")}>
<StepperHorizontal.Step variant="completed" firstStep stepNumber="1" label={t("onboarding.welcome.stepper.account")} />
<StepperHorizontal.Step variant="completed" stepNumber="2" label={t("onboarding.welcome.stepper.payment")} />
<StepperHorizontal.Step variant="active" lastStep stepNumber="3" label={t("onboarding.welcome.stepper.workspace")} />
</StepperHorizontal>
<div className="flex flex-col items-center gap-3 text-center">
<BadgeFeedback farbe="subtle-positive">{t("onboarding.welcome.activeBadge")}</BadgeFeedback>
<h1 className="text-heading-1 font-heading-1 text-text-neutral-primary">{greeting}</h1>
<p className="max-w-2xl text-body-large-0 font-body-large-0 text-text-neutral-secondary">
{t("onboarding.welcome.description", { workspaceName: vm.data.workspaceName })}
</p>
</div>
<div className="grid items-start gap-6 lg:grid-cols-[minmax(0,1fr)_320px]">
<Card size="large" className="gap-6" data-ui-id="ui.onboarding.welcome.checklist">
<div className="flex w-full flex-wrap items-start justify-between gap-4">
<div className="flex items-start gap-3">
<IconWithBackground variant={checklist.isComplete ? "success" : "information"} size="large" icon={<FeatherCheckCircle />} />
<div className="flex flex-col gap-1">
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("onboarding.welcome.setupTitle")}</h2>
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("onboarding.welcome.setupDescription")}
</p>
</div>
</div>
<BadgeFeedback farbe={checklist.isComplete ? "subtle-positive" : "subtle-information"}>
{t("onboarding.firstSteps.progressBadge", { completed: checklist.completedCount, total: checklist.totalCount })}
</BadgeFeedback>
</div>
<Progress
className="w-full"
value={checklist.percentComplete}
state={checklist.isComplete ? "success" : "uploading"}
hideLabel
aria-label={t("onboarding.firstSteps.progressAria", { percent: checklist.percentComplete })}
/>
<div className="flex w-full flex-col gap-3">
{checklist.items.map((item) => {
const content = contentFor(item);
const isNext = vm.data?.nextItem?.id === item.id;
return (
<div
key={item.id}
className="flex w-full flex-wrap items-center justify-between gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4"
data-row-id={item.id}
>
<div className="flex min-w-0 items-start gap-3">
<IconWithBackground variant={item.completed ? "success" : isNext ? "information" : "neutral"} icon={item.completed ? <FeatherCheckCircle /> : content.icon} />
<div className="flex min-w-0 flex-col gap-1">
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(item.titleKey)}</span>
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
{t(content.descriptionKey)}
</span>
</div>
</div>
{item.completed ? (
<BadgeFeedback farbe="subtle-positive" size="small">
{t("onboarding.firstSteps.completed")}
</BadgeFeedback>
) : (
<Button
className="mobile:w-full"
variant={isNext ? "primary" : "tertiary"}
size="small"
iconRight={<FeatherArrowRight />}
onClick={() => actions.onOpen(item.href)}
data-ui-id={`ui.onboarding.welcome.open.${item.block}`}
>
{t(content.actionKey)}
</Button>
)}
</div>
);
})}
</div>
</Card>
<div className="flex flex-col gap-4">
<Card variant="positive" size="large" data-ui-id="ui.onboarding.welcome.workspaceActive">
<IconWithBackground variant="success" size="large" icon={<FeatherBuilding2 />} />
<div className="flex flex-col gap-2">
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("onboarding.welcome.workspaceActive.title")}</h2>
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
{t("onboarding.welcome.workspaceActive.body", { workspaceName: vm.data.workspaceName })}
</p>
</div>
<Button className="w-full" variant="secondary" iconRight={<FeatherArrowRight />} onClick={() => actions.onDashboard(vm.data!.dashboardHref)}>
{t("onboarding.welcome.dashboardAction")}
</Button>
</Card>
<Alert notDismissible variant="information" title={t("onboarding.welcome.resume.title")} description={t("onboarding.welcome.resume.body")} />
</div>
</div>
</div>
</main>
);
}
@@ -0,0 +1,120 @@
import { toFirstStepsChecklistVM, toWelcomeSetupVM } from "@hivegrid/view-models";
import { createMemoryRouter, RouterProvider } from "react-router";
import { CheckoutSuccessPage } from "~/components/screens/billing/CheckoutSuccessPage";
import { WelcomeSetupPage } from "./WelcomeSetupPage";
const noOp = (): void => undefined;
export function Bill20CheckoutSuccessVisualFixture(): React.JSX.Element {
const router = createMemoryRouter(
[
{
path: "*",
element: (
<CheckoutSuccessPage
state="success"
activationKind="paid"
homeHref="/analytical-engines/dashboard"
workspaceName="Analytical Engines GmbH"
planTitle="Core"
formattedPrice="236,81 €"
interval="Monat"
nextInvoice="2. September 2026"
actions={{ onStartSetup: noOp, onOpenBilling: noOp, onRetry: noOp, onRestartCheckout: noOp }}
/>
),
},
],
{ initialEntries: ["/analytical-engines/subscribe/success"] }
);
return <RouterProvider router={router} />;
}
export function Bill20TrialSuccessVisualFixture(): React.JSX.Element {
const router = createMemoryRouter(
[
{
path: "*",
element: (
<CheckoutSuccessPage
state="success"
activationKind="trial"
homeHref="/analytical-engines/dashboard"
workspaceName="Analytical Engines GmbH"
planTitle="Core"
formattedPrice="236,81 €"
interval="Monat"
nextInvoice="16. August 2026"
actions={{ onStartSetup: noOp, onOpenBilling: noOp, onRetry: noOp, onRestartCheckout: noOp }}
/>
),
},
],
{ initialEntries: ["/analytical-engines/subscribe/trial-success"] }
);
return <RouterProvider router={router} />;
}
export function Bill20WelcomeSetupVisualFixture(): React.JSX.Element {
const checklist = toFirstStepsChecklistVM({
id: "session_bill_20",
status: "active",
dismissed: false,
items: [
{
id: "profile",
block: "profile",
titleKey: "onboarding.firstSteps.profile",
href: "/analytical-engines/settings/profile",
completed: true,
},
{
id: "team",
block: "team",
titleKey: "onboarding.firstSteps.team",
href: "/analytical-engines/settings/team/members/new",
completed: false,
canComplete: false,
},
{
id: "contacts",
block: "contacts",
titleKey: "onboarding.firstSteps.contacts",
href: "/analytical-engines/contacts",
completed: false,
},
{
id: "projects",
block: "projects",
titleKey: "onboarding.firstSteps.projects",
href: "/analytical-engines/projects",
completed: false,
},
{
id: "billing",
block: "billing",
titleKey: "onboarding.firstSteps.billing",
href: "/analytical-engines/settings/billing",
completed: true,
},
],
});
const vm = toWelcomeSetupVM({
firstName: "Ada",
workspaceName: "Analytical Engines GmbH",
dashboardHref: "/analytical-engines/dashboard",
checklist,
});
const router = createMemoryRouter(
[
{
path: "*",
element: <WelcomeSetupPage vm={vm} homeHref="/analytical-engines/dashboard" actions={{ onOpen: noOp, onDashboard: noOp }} />,
},
],
{ initialEntries: ["/analytical-engines/onboarding/welcome"] }
);
return <RouterProvider router={router} />;
}