Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`AK-P20 interim visual baseline > renders representative ready states for all five real ~/ui screens 1`] = `"<main data-ui-id="ui.akP20.interim.visualBaseline"><div class="flex w-full flex-col items-start bg-surface-neutral-primary" data-ui-id="ui.billing.subscriptionOverview.page"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">billing:subscriptionOverview.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">billing:subscriptionOverview.description</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="button" data-ui-id="ui.billing.subscriptionOverview.contact"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">billing:subscriptionOverview.contact</span></button></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4 items-start"><div class="group/3a65613d flex w-full flex-col items-start gap-2 rounded-md px-4 py-5 relative border border-solid border-border-positive-subtle bg-surface-feedback-subtle-positive"><div class="flex w-full items-start gap-3"><span class="text-heading-0 font-heading-0 text-icon-feedback-information hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-heading-0 font-heading-0 text-icon-feedback-positive inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-heading-0 font-heading-0 text-icon-feedback-warning icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-heading-0 font-heading-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-heading-0 font-heading-0 text-icon-neutral-secondary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div class="flex grow shrink-0 basis-0 flex-col items-start gap-2"><span class="w-full whitespace-pre-wrap text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-positive">settings.subscription.banner.trial.title</span><span class="w-full whitespace-pre-wrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">settings.subscription.banner.trial.description:2</span></div></div><div class="hidden items-start justify-center absolute top-3 right-3"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-secondary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div><div class="mobile:grid-cols-1 grid w-full grid-cols-4 gap-4"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">billing:subscriptionOverview.summary.plan</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span classLine truncated
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`AK-P21 interim visual baseline > renders representative ready states for all five privacy ~/ui screens 1`] = `"<main data-ui-id="ui.akP21.interim.visualBaseline"><div class="flex w-full flex-col items-start bg-surface-neutral-primary" data-ui-id="ui.settings.privacy.page"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">settings.privacy.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">settings.privacy.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4 items-start"><div class="group/3a65613d flex w-full flex-col items-start gap-2 rounded-md px-4 py-5 relative border border-solid border-border-warning-subtle bg-surface-feedback-subtle-warning"><div class="flex w-full items-start gap-3"><span class="text-heading-0 font-heading-0 text-icon-feedback-information hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-heading-0 font-heading-0 text-icon-feedback-positive icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-heading-0 font-heading-0 text-icon-feedback-warning inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-heading-0 font-heading-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-heading-0 font-heading-0 text-icon-neutral-secondary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div class="flex grow shrink-0 basis-0 flex-col items-start gap-2"><span class="w-full whitespace-pre-wrap text-body-default-medium-0 font-body-default-medium-0 text-text-feedback-warning">settings.privacy.hub.tenantDeletionBanner.title:20</span><span class="w-full whitespace-pre-wrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">settings.privacy.hub.tenantDeletionBanner.description:2026-08-01T12:00:00.000Z</span></div></div><div class="hidden items-start justify-center absolute top-3 right-3"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-secondary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm" data-ui-id="ui.settings.privacy.selfExport"><div class="flex w-full flex-col items-start gap-4"><div class="flex w-full flex-col items-start"><span class="text-body-large font-body-large text-text-neutral-primary">settings.privacy.export.title</span><span class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">settings.privacy.export.description</span></div><form method="post" data-ui-id="ui.settings.privacy.export.form" class="flex w-full flex-col items-start gap-2"><input type="hidden" value="export" name="intent"><input type="hidden" value="test-csrf" name="csrf"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="submit"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">settings.privacy.export.submit</span></button><span classLine truncated
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, Link } from "react-router";
|
||||
import { FeatherAlertTriangle, FeatherArrowRight, FeatherCreditCard, FeatherLockKeyhole, FeatherRefreshCw, FeatherUsers } from "@subframe/core";
|
||||
import type { AdminBillingRow, AdminBillingStatus, AdminBillingVM } from "@hivegrid/view-models";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { NumberInput } from "~/ui/components/NumberInput";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { planCodeLabel } from "./adminEnumLabels";
|
||||
|
||||
export type AdminBillingPageProps = {
|
||||
vm: AdminBillingVM;
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
feedback?: { success?: string; error?: string };
|
||||
};
|
||||
|
||||
/** D-ADMIN S05: Lago/Mollie and entitlement administration interim screen. */
|
||||
export function AdminBillingPage({ vm, csrf, submitting, feedback }: AdminBillingPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const ready = vm.status === "ready" ? vm.data : null;
|
||||
return (
|
||||
<div data-ui-id="ui.admin.billing.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.billing.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.billing.description")}</p>
|
||||
</div>
|
||||
</header>
|
||||
{feedback?.success ? <BannerAlert type="success" fillContainer>{feedback.success}</BannerAlert> : null}
|
||||
{feedback?.error ? <BannerAlert type="error" fillContainer>{feedback.error}</BannerAlert> : null}
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
{vm.status === "empty" ? (
|
||||
<EmptyState outlined title={t("admin.billing.empty.headline")} body={t("admin.billing.empty.body")} />
|
||||
) : vm.status === "error" ? (
|
||||
<EmptyState variant="error" outlined title={t("admin.billing.title")} body={t(vm.error.messageKey)} />
|
||||
) : ready ? (
|
||||
<>
|
||||
<BillingSummary summary={ready.summary} />
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
{ready.rows.map((row) => <BillingTenantCard key={row.tenantId} row={row} csrf={csrf} submitting={submitting} />)}
|
||||
</div>
|
||||
</>
|
||||
) : <EmptyState outlined title={t("admin.billing.empty.headline")} body={t("admin.billing.empty.body")} />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BillingSummary({ summary }: { summary: NonNullable<AdminBillingVM["data"]>["summary"] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="grid w-full grid-cols-5 gap-4 mobile:grid-cols-1">
|
||||
<StatsCard label={t("admin.billing.summary.attention.title")} value={summary.attentionCount} trend={summary.attentionCount ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherAlertTriangle />} />
|
||||
<StatsCard label={t("admin.billing.summary.readOnlyTitle")} value={summary.readOnlyCount} trend={summary.readOnlyCount ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherLockKeyhole />} />
|
||||
<StatsCard label={t("admin.billing.summary.providers.title")} value={summary.missingProviderCount} trend={summary.missingProviderCount ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherRefreshCw />} />
|
||||
<StatsCard label={t("admin.billing.summary.enterprise.title")} value={summary.enterpriseCount + summary.customCount} trend="neutral" percentage="" comparisonText="" icon={<FeatherCreditCard />} />
|
||||
<StatsCard label={t("admin.billing.summary.seats.title")} value={summary.totalSeats} trend="neutral" percentage="" comparisonText="" icon={<FeatherUsers />} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BillingTenantCard({ row, csrf, submitting }: { row: AdminBillingRow; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4 mobile:flex-col">
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<Link to={adminPath(`accounts/${row.tenantId}`, { mode: "host-aware" })} className="text-body-large-0 font-body-large-0 text-text-neutral-primary hover:underline">{row.tenantName}</Link>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">/{row.tenantSlug}</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
<BadgeFeedback farbe={statusTone(row.status)} size="small">{t(row.statusLabelKey)}</BadgeFeedback>
|
||||
<BadgeFeedback farbe={row.planKind === "unassigned" ? "subtle-warning" : "subtle-information"} size="small">{t(row.planKindLabelKey)}</BadgeFeedback>
|
||||
{row.readOnly ? <BadgeFeedback farbe="subtle-negative" size="small">{t("admin.billing.summary.readOnly")}</BadgeFeedback> : null}
|
||||
<BadgeFeedback farbe={row.hasLagoReference ? "subtle-positive" : "subtle-warning"} size="small">{t("admin.billing.providers.lago")}</BadgeFeedback>
|
||||
<BadgeFeedback farbe={row.hasMollieReference ? "subtle-positive" : "subtle-warning"} size="small">{t("admin.billing.providers.mollie")}</BadgeFeedback>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full grid-cols-4 gap-4 mobile:grid-cols-1">
|
||||
{/* `/accounts` renders the same plan as "Business"; this view printed the raw `business` (audit I18N-02). */}
|
||||
<Value label={t("admin.billing.fields.planCode")} value={planCodeLabel(row.planCode)} />
|
||||
<Value label={t("admin.billing.fields.seats")} value={row.seatQuantity} />
|
||||
<Value label={t("admin.billing.fields.readOnlyReason")} value={t(row.readOnlyReasonKey)} />
|
||||
<Value label={t("admin.billing.fields.lastInvoice")} value={row.lastInvoiceExternalId} />
|
||||
</div>
|
||||
|
||||
<Card variant="warning">
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-warning">{t("admin.billing.overrideNotice")}</span>
|
||||
{/* NumberInput is a fixed 192px-wide component — the seats column must match or the stepper gets overlapped. */}
|
||||
<Form method="post" className="grid w-full grid-cols-[minmax(160px,1fr)_192px_minmax(240px,2fr)_auto] items-end gap-4 mobile:grid-cols-1">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="set-plan-seats" />
|
||||
<input type="hidden" name="tenantId" value={row.tenantId} />
|
||||
<TextInput showLabel label={t("admin.billing.fields.planCode")} fillContainer><TextInput.Input name="planCode" defaultValue={row.planCode ?? ""} placeholder={t("admin.billing.placeholders.planCode")} required /></TextInput>
|
||||
<NumberInput showLabel label={t("admin.billing.fields.seats")}><NumberInput.Input name="seatQuantity" min={1} defaultValue={row.seatQuantity ?? 1} required /></NumberInput>
|
||||
<TextInput showLabel label={t("admin.billing.fields.reason")} fillContainer><TextInput.Input name="reason" placeholder={t("admin.billing.placeholders.reason")} required /></TextInput>
|
||||
<Button type="submit" loading={submitting}>{t("admin.billing.actions.saveOverride")}</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
<div className="flex w-full items-center justify-between gap-4 mobile:flex-col mobile:items-start">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{(["lago", "mollie"] as const).map((provider) => (
|
||||
<Form key={provider} method="post">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="request-sync" />
|
||||
<input type="hidden" name="tenantId" value={row.tenantId} />
|
||||
<input type="hidden" name="provider" value={provider} />
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting} icon={<FeatherRefreshCw />}>
|
||||
{t("admin.billing.actions.requestProviderSync", { provider: t(`admin.billing.providers.${provider}`) })}
|
||||
</Button>
|
||||
</Form>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Link to={adminPath(`audit?tenantId=${row.tenantId}`, { mode: "host-aware" })}><Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>{t("admin.billing.links.audit")}</Button></Link>
|
||||
<Link to={adminPath(`accounts/users?tenantId=${row.tenantId}`, { mode: "host-aware" })}><Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>{t("admin.billing.links.users")}</Button></Link>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function Value({ label, value }: { label: string; value: string | number | null }): React.JSX.Element {
|
||||
return <div className="flex flex-col items-start gap-1"><span className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 uppercase text-text-neutral-tertiary">{label}</span><span className="break-all text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary">{value || "-"}</span></div>;
|
||||
}
|
||||
|
||||
function statusTone(status: AdminBillingStatus): "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-information" {
|
||||
if (status === "active") return "subtle-positive";
|
||||
if (status === "cancelled") return "subtle-negative";
|
||||
if (status === "past_due" || status === "frozen") return "subtle-warning";
|
||||
return "subtle-information";
|
||||
}
|
||||
+153
@@ -0,0 +1,153 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
import {
|
||||
FeatherAlertTriangle,
|
||||
FeatherCheckCircle,
|
||||
FeatherHelpCircle,
|
||||
FeatherCreditCard,
|
||||
FeatherExternalLink,
|
||||
FeatherHeartPulse,
|
||||
FeatherRadioTower,
|
||||
FeatherRocket,
|
||||
FeatherServer,
|
||||
} from "@subframe/core";
|
||||
import type { OperatorHealthData, OperatorHealthStatus, OperatorHealthSubsystem, OperatorHealthTone, OperatorHealthVM } from "@hivegrid/view-models";
|
||||
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 { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
|
||||
/** D-ADMIN S07: app-chrome-free platform health interim screen. */
|
||||
export function AdminHealthPage({ vm }: { vm: OperatorHealthVM }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const ready = vm.status === "ready" ? vm.data : null;
|
||||
return (
|
||||
<div data-ui-id="ui.admin.health.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.health.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.health.description")}</p>
|
||||
</div>
|
||||
{ready ? <BadgeFeedback farbe={statusTone(ready.overallStatus)}>{t(ready.overallLabelKey)}</BadgeFeedback> : null}
|
||||
</header>
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
{vm.status === "error" ? (
|
||||
<EmptyState variant="error" outlined title={t("admin.health.error.headline")} body={t(vm.error.messageKey)} />
|
||||
) : vm.status === "empty" ? (
|
||||
<EmptyState outlined title={t("admin.health.empty.headline")} body={t("admin.health.empty.body")} />
|
||||
) : ready ? <HealthData data={ready} /> : <EmptyState outlined title={t("admin.health.empty.headline")} body={t("admin.health.empty.body")} />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function HealthData({ data }: { data: OperatorHealthData }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<>
|
||||
<Card variant="neutral">
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.health.deployLine", { environment: data.deploy.environment, release: data.deploy.release, branch: data.deploy.branch })}
|
||||
</span>
|
||||
</Card>
|
||||
<div className="grid w-full grid-cols-4 gap-4 mobile:grid-cols-1">
|
||||
<StatsCard label={t("admin.health.summary.ok")} value={data.summary.ok} trend="positive" percentage="" comparisonText="" icon={<FeatherCheckCircle />} />
|
||||
<StatsCard label={t("admin.health.summary.warning")} value={data.summary.warning} trend={data.summary.warning ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherAlertTriangle />} />
|
||||
<StatsCard label={t("admin.health.summary.critical")} value={data.summary.critical} trend={data.summary.critical ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherAlertTriangle />} />
|
||||
<StatsCard label={t("admin.health.summary.unknown")} value={data.summary.unknown} trend="neutral" percentage="" comparisonText="" icon={<FeatherHelpCircle />} />
|
||||
</div>
|
||||
<AttentionPanel data={data} />
|
||||
<div className="grid w-full grid-cols-3 gap-4 mobile:grid-cols-1">
|
||||
{data.subsystems.map((subsystem) => <SubsystemCard key={subsystem.id} subsystem={subsystem} />)}
|
||||
</div>
|
||||
<BillingErrors errors={data.billingErrors} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function AttentionPanel({ data }: { data: OperatorHealthData }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.health.attention.title")}</span>
|
||||
{data.attention.length === 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.health.attention.empty")}</span>
|
||||
) : data.attention.map((row) => (
|
||||
<div key={row.id} className="flex w-full items-center justify-between gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-3">
|
||||
<div className="flex items-center gap-3">
|
||||
<BadgeFeedback farbe={tone(row.tone)} size="small">{row.count}</BadgeFeedback>
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(row.labelKey)}</span>
|
||||
</div>
|
||||
<Link to={row.href}><Button variant="tertiary" size="small" iconRight={<FeatherExternalLink />}>{t("admin.health.actions.openDetail")}</Button></Link>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function SubsystemCard({ subsystem }: { subsystem: OperatorHealthSubsystem }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<span className="text-heading- font-heading- text-icon-neutral-tertiary">{subsystemIcon(subsystem.id)}</span>
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t(subsystem.labelKey)}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t(subsystem.detailKey)}</span>
|
||||
</div>
|
||||
</div>
|
||||
<BadgeFeedback farbe={statusTone(subsystem.status)} size="small">{t(subsystem.statusLabelKey)}</BadgeFeedback>
|
||||
</div>
|
||||
<Link to={subsystem.href}><Button variant="tertiary" size="small" iconRight={<FeatherExternalLink />}>{t("admin.health.actions.openDetail")}</Button></Link>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function BillingErrors({ errors }: { errors: OperatorHealthData["billingErrors"] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<Card>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.health.billingErrors.title")}</span>
|
||||
{errors.length === 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.health.billingErrors.empty")}</span>
|
||||
) : (
|
||||
<Table header={<Table.HeaderRow><Table.HeaderCell>{t("shared.type")}</Table.HeaderCell><Table.HeaderCell>{t("shared.error")}</Table.HeaderCell><Table.HeaderCell>{t("shared.createdAt")}</Table.HeaderCell></Table.HeaderRow>}>
|
||||
{errors.map((error) => (
|
||||
<Table.Row key={error.id}>
|
||||
<Table.Cell><span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{error.eventType}</span></Table.Cell>
|
||||
<Table.Cell><span className="break-all text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-negative">{error.error || t("shared.notSet")}</span></Table.Cell>
|
||||
<Table.Cell><span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{formatters.dateTime(new Date(error.createdAt))}</span></Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function subsystemIcon(id: OperatorHealthSubsystem["id"]): React.JSX.Element {
|
||||
if (id === "system") return <FeatherServer />;
|
||||
if (id === "deploy") return <FeatherRocket />;
|
||||
if (id === "queues") return <FeatherRadioTower />;
|
||||
if (id === "webhooks") return <FeatherHeartPulse />;
|
||||
return <FeatherCreditCard />;
|
||||
}
|
||||
|
||||
function statusTone(status: OperatorHealthStatus): "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral" {
|
||||
if (status === "ok") return "subtle-positive";
|
||||
if (status === "warning") return "subtle-warning";
|
||||
if (status === "critical") return "subtle-negative";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
function tone(value: OperatorHealthTone): "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-neutral" {
|
||||
if (value === "success") return "subtle-positive";
|
||||
if (value === "warning") return "subtle-warning";
|
||||
if (value === "danger") return "subtle-negative";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
+360
@@ -0,0 +1,360 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, useNavigate } from "react-router";
|
||||
import {
|
||||
FeatherAlertTriangle,
|
||||
FeatherCheckCircle,
|
||||
FeatherClock,
|
||||
FeatherFileText,
|
||||
FeatherPauseCircle,
|
||||
FeatherPlayCircle,
|
||||
FeatherRefreshCw,
|
||||
FeatherRotateCcw,
|
||||
} from "@subframe/core";
|
||||
import type { QueueMonitorVM, QueueMonitorRow } from "@hivegrid/view-models";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
|
||||
type FailedJob = {
|
||||
/** BullMQ wire id — retry and detail requests must send this value. */
|
||||
id: string;
|
||||
/** Human-readable id for operator text; see `fromBullMqJobId`. */
|
||||
displayId: string;
|
||||
name: string;
|
||||
failedReason: string | null;
|
||||
attemptsMade: number;
|
||||
timestamp: number | null;
|
||||
};
|
||||
|
||||
type FailedQueue = { queueName: string; jobs: readonly FailedJob[] };
|
||||
|
||||
export type JobDetailView = {
|
||||
queueName: string;
|
||||
job: {
|
||||
id: string;
|
||||
displayId: string;
|
||||
name: string;
|
||||
failedReason: string | null;
|
||||
stacktrace: readonly string[];
|
||||
attemptsMade: number;
|
||||
timestamp: number | null;
|
||||
processedOn: number | null;
|
||||
finishedOn: number | null;
|
||||
};
|
||||
};
|
||||
|
||||
const PRODUCT_PROVIDER_OUTBOX_QUEUE = "outbox.billing-product-provider";
|
||||
|
||||
export type AdminJobsPageProps = {
|
||||
vm: QueueMonitorVM;
|
||||
failedJobs: FailedQueue[];
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
canManagePortalDomainKillSwitch: boolean;
|
||||
feedback?: { success?: string; error?: string };
|
||||
jobDetail?: JobDetailView | null;
|
||||
};
|
||||
|
||||
/** D-ADMIN S08: app-chrome-free queue monitor interim screen. */
|
||||
export function AdminJobsPage({ vm, failedJobs, csrf, submitting, canManagePortalDomainKillSwitch, feedback, jobDetail }: AdminJobsPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const ready = vm.status === "ready" ? vm.data : null;
|
||||
|
||||
return (
|
||||
<div data-ui-id="ui.admin.jobs.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.jobs.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.jobs.description")}</p>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{feedback?.success ? <BannerAlert type="success" fillContainer>{feedback.success}</BannerAlert> : null}
|
||||
{feedback?.error ? <BannerAlert type="error" fillContainer>{feedback.error}</BannerAlert> : null}
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
{vm.status === "error" ? (
|
||||
<EmptyState
|
||||
variant="error"
|
||||
outlined
|
||||
title={t("admin.jobs.errors.queueUnavailableTitle")}
|
||||
body={t(vm.error.messageKey)}
|
||||
/>
|
||||
) : vm.status === "empty" || !ready ? (
|
||||
<EmptyState outlined title={t("admin.queues.empty.headline")} body={t("admin.queues.empty.body")} />
|
||||
) : (
|
||||
<>
|
||||
<QueueSummary vm={ready} />
|
||||
<div className="grid w-full grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
{ready.rows.map((row) => (
|
||||
<QueueCard
|
||||
key={row.queueName}
|
||||
row={row}
|
||||
failedJobs={failedJobs.find((item) => item.queueName === row.queueName)?.jobs ?? []}
|
||||
csrf={csrf}
|
||||
submitting={submitting}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{canManagePortalDomainKillSwitch ? <PortalDomainKillSwitch csrf={csrf} submitting={submitting} /> : null}
|
||||
</div>
|
||||
{jobDetail ? <JobDetailDialog detail={jobDetail} /> : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function JobDetailDialog({ detail }: { detail: JobDetailView }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const navigate = useNavigate();
|
||||
const close = () => navigate(".", { replace: true });
|
||||
const timelineEntries: Array<{ labelKey: string; value: number | null }> = [
|
||||
{ labelKey: "admin.jobs.detail.enqueuedAt", value: detail.job.timestamp },
|
||||
{ labelKey: "admin.jobs.detail.processedAt", value: detail.job.processedOn },
|
||||
{ labelKey: "admin.jobs.detail.finishedAt", value: detail.job.finishedOn },
|
||||
];
|
||||
return (
|
||||
<Dialog open onOpenChange={(open) => (open ? undefined : close())}>
|
||||
<Dialog.Content className="w-[720px] max-w-[95vw] p-8">
|
||||
<div className="flex w-full flex-col gap-6">
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<span className="text-heading-3 font-heading-3 text-text-neutral-primary">{detail.job.name}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.jobs.detail.meta", { queue: detail.queueName, id: detail.job.displayId, attempts: detail.job.attemptsMade })}
|
||||
</span>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" onClick={close}>{t("shared.close")}</Button>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full grid-cols-3 gap-4 mobile:grid-cols-1">
|
||||
{timelineEntries.map((entry) => (
|
||||
<div key={entry.labelKey} className="flex flex-col items-start gap-1">
|
||||
<span className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 uppercase text-text-neutral-tertiary">{t(entry.labelKey)}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary">
|
||||
{entry.value ? formatters.dateTime(new Date(entry.value)) : t("shared.notSet")}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">{t("admin.jobs.detail.failedReason")}</span>
|
||||
<span className="break-all text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-negative">
|
||||
{detail.job.failedReason || t("shared.notSet")}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">{t("admin.jobs.detail.stacktrace")}</span>
|
||||
{detail.job.stacktrace.length === 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.jobs.detail.noStacktrace")}</span>
|
||||
) : (
|
||||
<div className="max-h-[320px] w-full overflow-auto rounded-md border border-solid border-border-default bg-surface-neutral-secondary p-4">
|
||||
{detail.job.stacktrace.map((frame, index) => (
|
||||
<pre key={index} className="whitespace-pre-wrap break-all font-mono text-xs text-text-neutral-primary">{frame}</pre>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function PortalDomainKillSwitch({ csrf, submitting }: { csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">
|
||||
{t("admin.jobs.portalDomainKillSwitch.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.jobs.portalDomainKillSwitch.description")}
|
||||
</p>
|
||||
</div>
|
||||
<BannerAlert type="warning" fillContainer>
|
||||
{t("admin.jobs.portalDomainKillSwitch.warning")}
|
||||
</BannerAlert>
|
||||
<Form method="post" className="flex w-full max-w-[640px] flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<TextInput showLabel fillContainer label={t("admin.jobs.portalDomainKillSwitch.tenantIdLabel")}>
|
||||
<TextInput.Input name="tenantId" required autoComplete="off" />
|
||||
</TextInput>
|
||||
<TextArea showLabel label={t("admin.jobs.portalDomainKillSwitch.reasonLabel")}>
|
||||
<TextArea.Input name="reason" required minLength={5} />
|
||||
</TextArea>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Button
|
||||
type="submit"
|
||||
name="action"
|
||||
value="portal-domain-kill-enable"
|
||||
variant="destructive"
|
||||
loading={submitting}
|
||||
>
|
||||
{t("admin.jobs.portalDomainKillSwitch.enable")}
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
name="action"
|
||||
value="portal-domain-kill-disable"
|
||||
variant="tertiary"
|
||||
loading={submitting}
|
||||
>
|
||||
{t("admin.jobs.portalDomainKillSwitch.disable")}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function QueueSummary({ vm }: { vm: NonNullable<QueueMonitorVM["data"]> }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const waiting = vm.rows.reduce((sum, row) => sum + row.waiting + row.delayed, 0);
|
||||
const active = vm.rows.reduce((sum, row) => sum + row.active, 0);
|
||||
return (
|
||||
<div className="grid w-full grid-cols-4 gap-4 mobile:grid-cols-1">
|
||||
<StatsCard trend={vm.overallSignal === "ok" ? "positive" : "negative"} label={t("admin.jobs.summary.health")} value={t(vm.overallLabelKey)} percentage="" comparisonText="" icon={<FeatherCheckCircle />} />
|
||||
<StatsCard trend={vm.failedTotal > 0 ? "negative" : "positive"} label={t("admin.jobs.summary.failed")} value={vm.failedTotal} percentage="" comparisonText="" icon={<FeatherAlertTriangle />} />
|
||||
<StatsCard trend="neutral" label={t("admin.jobs.summary.inFlight")} value={active} percentage="" comparisonText="" icon={<FeatherRefreshCw />} />
|
||||
<StatsCard trend={waiting > 0 ? "negative" : "positive"} label={t("admin.jobs.summary.backlog")} value={waiting} percentage="" comparisonText="" icon={<FeatherClock />} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function QueueCard({ row, failedJobs, csrf, submitting }: { row: QueueMonitorRow; failedJobs: readonly FailedJob[]; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4 mobile:flex-col">
|
||||
<div className="flex min-w-0 flex-col items-start gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={queueTone(row.healthSignal)} size="small">{t(row.healthLabelKey)}</BadgeFeedback>
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">{t(row.groupLabelKey)}</BadgeFeedback>
|
||||
</div>
|
||||
<span className="break-all text-body-large-0 font-body-large-0 text-text-neutral-primary">{row.queueName}</span>
|
||||
</div>
|
||||
<Form method="post">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="queueName" value={row.queueName} />
|
||||
<input type="hidden" name="action" value={row.paused ? "resume" : "pause"} />
|
||||
<Button
|
||||
type="submit"
|
||||
variant="secondary"
|
||||
size="small"
|
||||
loading={submitting}
|
||||
icon={row.paused ? <FeatherPlayCircle /> : <FeatherPauseCircle />}
|
||||
>
|
||||
{row.paused ? t("admin.jobs.actions.resume") : t("admin.jobs.actions.pause")}
|
||||
</Button>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.jobs.metrics.active")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.jobs.metrics.waiting")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.jobs.metrics.delayed")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.jobs.metrics.failed")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.jobs.metrics.completed")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
<Table.Row>
|
||||
{[row.active, row.waiting, row.delayed, row.failed, row.completed].map((value, index) => (
|
||||
<Table.Cell key={index}><span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">{value}</span></Table.Cell>
|
||||
))}
|
||||
</Table.Row>
|
||||
</Table>
|
||||
|
||||
<FailedJobs queueName={row.queueName} jobs={failedJobs} csrf={csrf} submitting={submitting} />
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function FailedJobs({ queueName, jobs, csrf, submitting }: { queueName: string; jobs: readonly FailedJob[]; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const navigate = useNavigate();
|
||||
const requiresGenerationAwareReplay = queueName === PRODUCT_PROVIDER_OUTBOX_QUEUE;
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-3 border-t border-solid border-border-default pt-4">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">{t("admin.jobs.failedJobs.title")}</span>
|
||||
{requiresGenerationAwareReplay && jobs.length > 0 ? (
|
||||
<BannerAlert type="warning" fillContainer>
|
||||
{t("admin.jobs.failedJobs.generationAwareReplay")}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{jobs.length === 0 ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.jobs.failedJobs.empty")}</span>
|
||||
) : (
|
||||
jobs.map((job) => (
|
||||
<div key={job.id} className="flex w-full items-start justify-between gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 mobile:flex-col">
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<span className="break-all text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{job.name}</span>
|
||||
<span className="break-all text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-negative">{job.failedReason || t("shared.notSet")}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.jobs.failedJobs.meta", { id: job.displayId, attempts: job.attemptsMade, timestamp: job.timestamp ? formatters.dateTime(new Date(job.timestamp)) : t("shared.notSet") })}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex shrink-0 flex-wrap items-center gap-2">
|
||||
{/*
|
||||
A `<button>` inside an `<a>` is invalid markup, and it made the
|
||||
first click land on the button while only the second one reached
|
||||
the link (admin audit 2026-07-26, P0-10). The control opens a
|
||||
dialog on the same page, so a button that navigates is both valid
|
||||
and the more accurate semantics.
|
||||
|
||||
The query carries the BullMQ wire id, not `displayId`: the wire
|
||||
form is what the queue can look up, and percent-encoding it once
|
||||
is correct even though the result contains `%253A`. Decoding the
|
||||
display form back would be ambiguous for keys that legitimately
|
||||
contain a percent sign.
|
||||
*/}
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
size="small"
|
||||
icon={<FeatherFileText />}
|
||||
onClick={() => navigate(`?detailQueue=${encodeURIComponent(queueName)}&detailJob=${encodeURIComponent(job.id)}`, { preventScrollReset: true })}
|
||||
>
|
||||
{t("admin.jobs.actions.detail")}
|
||||
</Button>
|
||||
{requiresGenerationAwareReplay ? null : (
|
||||
<Form method="post">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="queueName" value={queueName} />
|
||||
<input type="hidden" name="jobId" value={job.id} />
|
||||
<input type="hidden" name="action" value="retry-job" />
|
||||
<Button type="submit" size="small" loading={submitting} icon={<FeatherRotateCcw />}>{t("admin.jobs.actions.retry")}</Button>
|
||||
</Form>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function queueTone(signal: QueueMonitorRow["healthSignal"]): "subtle-positive" | "subtle-warning" | "subtle-negative" {
|
||||
if (signal === "ok") return "subtle-positive";
|
||||
if (signal === "paused") return "subtle-warning";
|
||||
return "subtle-negative";
|
||||
}
|
||||
+94
@@ -0,0 +1,94 @@
|
||||
import type { KwpContractAdminVM, KwpContractDiffVM } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
|
||||
function diffLines(diff: KwpContractDiffVM | null): string {
|
||||
if (!diff) return "";
|
||||
return [
|
||||
...diff.added.map((path) => `+ ${path}`),
|
||||
...diff.removed.map((path) => `− ${path}`),
|
||||
...diff.changed.map((path) => `~ ${path}`),
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
export function AdminKwpContractsPage({
|
||||
vm,
|
||||
}: {
|
||||
readonly vm: KwpContractAdminVM;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const ready = vm.status === "ready" ? vm.data : null;
|
||||
return (
|
||||
<div data-ui-id="ui.admin.kwp-contracts.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.kwpContracts.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.kwpContracts.description")}
|
||||
</p>
|
||||
</div>
|
||||
{ready ? <BadgeFeedback farbe="subtle-negative">{ready.alarmCount}</BadgeFeedback> : null}
|
||||
</header>
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
{vm.status === "error" ? (
|
||||
<EmptyState variant="error" outlined title={t("admin.kwpContracts.error.title")} body={t(vm.error.messageKey)} />
|
||||
) : vm.status === "empty" ? (
|
||||
<EmptyState outlined title={t("admin.kwpContracts.empty.title")} body={t("admin.kwpContracts.empty.body")} />
|
||||
) : ready ? (
|
||||
<Card>
|
||||
<Table
|
||||
header={(
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.kwpContracts.fields.tenant")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.kwpContracts.fields.reason")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.kwpContracts.fields.diff")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.kwpContracts.fields.checkedAt")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
)}
|
||||
>
|
||||
{ready.alarms.map((alarm) => (
|
||||
<Table.Row key={alarm.id}>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-col items-start">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{alarm.tenantName}</span>
|
||||
<span className="text-caption font-caption text-text-neutral-tertiary">{alarm.connectionId}</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<BadgeFeedback farbe="subtle-negative">{alarm.reasonCode ?? t("shared.unknown")}</BadgeFeedback>
|
||||
<span className="text-caption font-caption text-text-neutral-tertiary">
|
||||
{t("admin.kwpContracts.revision", {
|
||||
adapter: alarm.adapterRevision,
|
||||
capability: alarm.capabilityRevision,
|
||||
})}
|
||||
</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="whitespace-pre-wrap break-all text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{diffLines(alarm.diff) || t("admin.kwpContracts.noDiff")}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{alarm.lastCheckedAt || alarm.pausedAt
|
||||
? formatters.dateTime(new Date(alarm.lastCheckedAt ?? alarm.pausedAt!))
|
||||
: t("shared.notSet")}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</Card>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import type { ReactNode } from "react";
|
||||
|
||||
export type AdminPageHeaderProps = {
|
||||
title: ReactNode;
|
||||
description?: ReactNode;
|
||||
actions?: ReactNode;
|
||||
};
|
||||
|
||||
/**
|
||||
* AK-P19 — shared AD-28 interim page header for the platform-admin pages,
|
||||
* matching the /health and /jobs screens: full-bleed bar with title,
|
||||
* description and an optional action slot.
|
||||
*/
|
||||
export function AdminPageHeader({ title, description, actions }: AdminPageHeaderProps): React.JSX.Element {
|
||||
return (
|
||||
<header
|
||||
data-ui-id="ui.admin.pageHeader"
|
||||
className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-wrap items-start gap-4 border-b border-solid px-6 py-5"
|
||||
>
|
||||
<div className="flex min-w-0 shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary truncate">{title}</h1>
|
||||
{description ? <p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{description}</p> : null}
|
||||
</div>
|
||||
{actions ? <div className="flex flex-wrap items-center gap-2">{actions}</div> : null}
|
||||
</header>
|
||||
);
|
||||
}
|
||||
+111
@@ -0,0 +1,111 @@
|
||||
import type {
|
||||
AdminDashboardVM,
|
||||
AdminDashboardWidgetVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import { FeatherArrowRight } from "@subframe/core";
|
||||
import { Link } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
|
||||
export function AdminPersonalizedDashboard({
|
||||
vm,
|
||||
}: {
|
||||
vm: AdminDashboardVM;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<section
|
||||
className="space-y-4"
|
||||
aria-labelledby="personalized-dashboard-title"
|
||||
data-ui-id="ui.admin.personalizedDashboard"
|
||||
>
|
||||
<div className="flex flex-wrap items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2
|
||||
id="personalized-dashboard-title"
|
||||
className="text-body-large-0 font-body-large-0 text-text-neutral-primary"
|
||||
>
|
||||
{t("admin.dashboard.personalized.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.dashboard.personalized.description")}
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
className="flex flex-wrap gap-2"
|
||||
aria-label={t("admin.dashboard.personalized.activeRoles")}
|
||||
>
|
||||
{vm.roles.map((role) => (
|
||||
<BadgeFeedback key={role} farbe="subtle-neutral" size="small">
|
||||
{t(`admin.sales.adminRoles.roleNames.${role}`)}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{vm.widgets.length === 0 ? (
|
||||
<Card variant="neutral">
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.dashboard.personalized.empty")}
|
||||
</p>
|
||||
</Card>
|
||||
) : (
|
||||
<div className="grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
{vm.widgets.map((widget) => (
|
||||
<PersonalizedWidget key={widget.id} widget={widget} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function PersonalizedWidget({ widget }: { widget: AdminDashboardWidgetVM }) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const translatedValue = i18n.exists(widget.value)
|
||||
? t(widget.value)
|
||||
: widget.value;
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<h3 className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t(widget.titleKey)}
|
||||
</h3>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-secondary">
|
||||
{t(widget.descriptionKey)}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback
|
||||
farbe={dashboardWidgetBadgeTone(widget.tone)}
|
||||
size="small"
|
||||
>
|
||||
{t(`admin.dashboard.personalized.tones.${widget.tone}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<p className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{translatedValue}
|
||||
</p>
|
||||
<Link to={widget.href}>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
iconRight={<FeatherArrowRight />}
|
||||
>
|
||||
{t("admin.dashboard.personalized.open")}
|
||||
</Button>
|
||||
</Link>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function dashboardWidgetBadgeTone(
|
||||
tone: AdminDashboardWidgetVM["tone"]
|
||||
): "subtle-positive" | "subtle-negative" | "subtle-warning" | "subtle-neutral" {
|
||||
if (tone === "positive") return "subtle-positive";
|
||||
if (tone === "critical") return "subtle-negative";
|
||||
if (tone === "warning") return "subtle-warning";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
+96
@@ -0,0 +1,96 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
import { FeatherAlertTriangle, FeatherArrowRight, FeatherInbox, FeatherMessageSquare, FeatherUserCheck } from "@subframe/core";
|
||||
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 { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { supportPriorityLabelKey, supportSourceLabel, supportStatusLabelKey, translateOrHumanize } from "./adminEnumLabels";
|
||||
|
||||
export type AdminSupportInboxVM = {
|
||||
summary: { ticketsTotal: number; feedbackTotal: number; openTickets: number; assignedTickets: number; urgentTickets: number };
|
||||
recentTickets: readonly { id: string; subject: string; status: string; priority: string; source: string; createdAt: string; tenantName: string | null; userEmail: string | null }[];
|
||||
recentFeedback: readonly { id: string; message: string; createdAt: string; tenantName: string | null; userEmail: string | null }[];
|
||||
};
|
||||
|
||||
/** D-ADMIN S09: support inbox overview backed by feedback and support-ticket data. */
|
||||
export function AdminSupportInboxPage({ vm }: { vm: AdminSupportInboxVM }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.support.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.supportInbox.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.supportInbox.tickets.description")}</p>
|
||||
</div>
|
||||
</header>
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
<div className="grid w-full grid-cols-5 gap-4 mobile:grid-cols-1">
|
||||
<StatsCard label={t("admin.supportInbox.metrics.tickets")} value={formatters.number(vm.summary.ticketsTotal)} trend="neutral" percentage="" comparisonText="" icon={<FeatherInbox />} />
|
||||
<StatsCard label={t("admin.supportInbox.metrics.openTickets")} value={formatters.number(vm.summary.openTickets)} trend={vm.summary.openTickets ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherMessageSquare />} />
|
||||
<StatsCard label={t("admin.supportInbox.metrics.urgentTickets")} value={formatters.number(vm.summary.urgentTickets)} trend={vm.summary.urgentTickets ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherAlertTriangle />} />
|
||||
<StatsCard label={t("admin.supportInbox.metrics.assignedTickets")} value={formatters.number(vm.summary.assignedTickets)} trend="neutral" percentage="" comparisonText="" icon={<FeatherUserCheck />} />
|
||||
<StatsCard label={t("admin.supportInbox.metrics.feedback")} value={formatters.number(vm.summary.feedbackTotal)} trend="neutral" percentage="" comparisonText="" icon={<FeatherMessageSquare />} />
|
||||
</div>
|
||||
|
||||
<div className="grid w-full grid-cols-[minmax(0,1.2fr)_minmax(320px,0.8fr)] gap-4 mobile:grid-cols-1">
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.supportInbox.tickets.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.supportInbox.tickets.description")}</span>
|
||||
</div>
|
||||
<Link to={adminPath("support/tickets", { mode: "host-aware" })}><Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>{t("shared.viewAll")}</Button></Link>
|
||||
</div>
|
||||
{vm.recentTickets.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.supportInbox.tickets.empty")} body={t("admin.supportInbox.tickets.description")} />
|
||||
) : (
|
||||
<Table header={<Table.HeaderRow><Table.HeaderCell>{t("shared.subject")}</Table.HeaderCell><Table.HeaderCell>{t("shared.status")}</Table.HeaderCell><Table.HeaderCell>{t("shared.priority")}</Table.HeaderCell><Table.HeaderCell>{t("shared.createdAt")}</Table.HeaderCell></Table.HeaderRow>}>
|
||||
{vm.recentTickets.map((ticket) => (
|
||||
<Table.Row key={ticket.id}>
|
||||
<Table.Cell><div className="flex min-w-0 flex-col items-start"><Link to={adminPath(`support/${ticket.id}`, { mode: "host-aware" })} className="max-w-80 truncate text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary hover:underline">{ticket.subject}</Link><span className="max-w-80 truncate text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{[ticket.tenantName, ticket.userEmail, supportSourceLabel(ticket.source)].filter(Boolean).join(" · ")}</span></div></Table.Cell>
|
||||
{/* Same labels as the ticket detail; the raw enum used to leak here (P0 audit I18N-02). */}
|
||||
<Table.Cell><BadgeFeedback farbe={statusTone(ticket.status)} size="small">{translateOrHumanize(t, supportStatusLabelKey(ticket.status), ticket.status)}</BadgeFeedback></Table.Cell>
|
||||
<Table.Cell><BadgeFeedback farbe={priorityTone(ticket.priority)} size="small">{translateOrHumanize(t, supportPriorityLabelKey(ticket.priority), ticket.priority)}</BadgeFeedback></Table.Cell>
|
||||
<Table.Cell><span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{formatters.dateTime(ticket.createdAt)}</span></Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col items-start"><span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.supportInbox.feedback.title")}</span><span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.supportInbox.feedback.description")}</span></div>
|
||||
<Link to={adminPath("support/feedback", { mode: "host-aware" })}><Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>{t("shared.viewAll")}</Button></Link>
|
||||
</div>
|
||||
{vm.recentFeedback.length === 0 ? <EmptyState outlined title={t("admin.supportInbox.feedback.empty")} body={t("admin.supportInbox.feedback.description")} /> : vm.recentFeedback.map((feedback) => (
|
||||
<div key={feedback.id} className="flex w-full flex-col items-start gap-1 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-3">
|
||||
<span className="line-clamp-2 text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-primary">{feedback.message}</span>
|
||||
<span className="max-w-full truncate text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{[feedback.tenantName, feedback.userEmail].filter(Boolean).join(" · ") || t("shared.notSet")}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{formatters.dateTime(feedback.createdAt)}</span>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function statusTone(status: string): "subtle-positive" | "subtle-warning" | "subtle-neutral" {
|
||||
if (status === "closed" || status === "resolved") return "subtle-positive";
|
||||
if (status === "open") return "subtle-warning";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
function priorityTone(priority: string): "subtle-negative" | "subtle-warning" | "subtle-neutral" {
|
||||
if (priority === "urgent" || priority === "high") return "subtle-negative";
|
||||
if (priority === "normal") return "subtle-neutral";
|
||||
return "subtle-warning";
|
||||
}
|
||||
+242
@@ -0,0 +1,242 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { fileTypeLabelKey } from "~/utils/files/fileTypeLabel";
|
||||
import { Form, Link } from "react-router";
|
||||
import { FeatherArrowLeft, FeatherDownload, FeatherLock, FeatherMessageSquare, FeatherSend, FeatherUserCheck } from "@subframe/core";
|
||||
import type { SupportConversationMessage, SupportConversationVM } from "@hivegrid/view-models";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
export type AdminSupportTicketMeta = {
|
||||
tenantName: string | null;
|
||||
userEmail: string | null;
|
||||
fromEmail: string | null;
|
||||
source: string;
|
||||
createdAtIso: string;
|
||||
status: string;
|
||||
priority: string;
|
||||
assignedToUserId: string | null;
|
||||
};
|
||||
|
||||
export type AdminSupportAssigneeOption = {
|
||||
id: string;
|
||||
email: string;
|
||||
};
|
||||
|
||||
/** AK-P21 — feedback attachment metadata shown to the operator. */
|
||||
export type AdminSupportTicketAttachmentVM = {
|
||||
id: string;
|
||||
displayName: string;
|
||||
mimeType: string;
|
||||
sizeBytes: number;
|
||||
scanStatus: string;
|
||||
/** Operator download URL; null while the scanner has not cleared the file. */
|
||||
downloadHref: string | null;
|
||||
};
|
||||
|
||||
export type AdminSupportTicketPageProps = {
|
||||
vm: SupportConversationVM;
|
||||
meta: AdminSupportTicketMeta;
|
||||
assignees: readonly AdminSupportAssigneeOption[];
|
||||
statuses: readonly string[];
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
feedback?: { success?: string; error?: string };
|
||||
attachments?: readonly AdminSupportTicketAttachmentVM[];
|
||||
};
|
||||
|
||||
/** AK-P19 DoD #6 — AD-28 interim screen: support-ticket conversation with reply, internal note, status and assignment. */
|
||||
export function AdminSupportTicketPage({
|
||||
vm,
|
||||
meta,
|
||||
assignees,
|
||||
statuses,
|
||||
csrf,
|
||||
submitting,
|
||||
feedback,
|
||||
attachments = [],
|
||||
}: AdminSupportTicketPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const ready = vm.status === "ready" ? vm.data : null;
|
||||
|
||||
return (
|
||||
<div data-ui-id="ui.admin.support.ticket.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start gap-1">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{ready?.subject ?? t("admin.support.detail.title")}</h1>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{ready ? <BadgeFeedback farbe={statusTone(meta.status)} size="small">{t(ready.statusLabelKey)}</BadgeFeedback> : null}
|
||||
{ready ? <BadgeFeedback farbe={priorityTone(meta.priority)} size="small">{t(ready.priorityLabelKey)}</BadgeFeedback> : null}
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{[meta.tenantName, meta.userEmail ?? meta.fromEmail, meta.source, formatters.dateTime(new Date(meta.createdAtIso))].filter(Boolean).join(" · ")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<Link to={adminPath("support", { mode: "host-aware" })}>
|
||||
<Button variant="tertiary" icon={<FeatherArrowLeft />}>{t("shared.back")}</Button>
|
||||
</Link>
|
||||
</header>
|
||||
{feedback?.success ? <BannerAlert type="success" fillContainer>{feedback.success}</BannerAlert> : null}
|
||||
{feedback?.error ? <BannerAlert type="error" fillContainer>{feedback.error}</BannerAlert> : null}
|
||||
|
||||
<div className="grid w-full grid-cols-[minmax(0,1.4fr)_minmax(280px,0.6fr)] gap-4 px-6 py-6 mobile:grid-cols-1 mobile:px-4">
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.support.detail.conversation")}</h2>
|
||||
{!ready || ready.messages.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.support.detail.emptyThread.headline")} body={t("admin.support.detail.emptyThread.body")} />
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
{ready.messages.map((message) => (
|
||||
<ThreadMessage key={message.id} message={message} />
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-4 border-t border-solid border-border-default pt-4">
|
||||
<Form method="post" className="flex w-full flex-col items-start gap-3">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<TextArea showLabel className="w-full" label={t("admin.support.detail.replyLabel")}>
|
||||
<TextArea.Input name="body" required placeholder={t("admin.support.detail.replyPlaceholder")} />
|
||||
</TextArea>
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<Button type="submit" name="action" value="reply" loading={submitting} icon={<FeatherSend />}>
|
||||
{t("admin.support.detail.sendReply")}
|
||||
</Button>
|
||||
<Button type="submit" name="action" value="internal-note" variant="secondary" loading={submitting} icon={<FeatherLock />}>
|
||||
{t("admin.support.detail.addInternalNote")}
|
||||
</Button>
|
||||
</div>
|
||||
</Form>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
{attachments.length > 0 ? (
|
||||
<Card data-ui-id="ui.admin.support.ticket.attachments">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.support.detail.attachments.title")}</h2>
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
{attachments.map((attachment) => (
|
||||
<div key={attachment.id} className="flex w-full flex-col items-start gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{attachment.displayName}</span>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={attachment.scanStatus === "clean" ? "subtle-positive" : attachment.scanStatus === "infected" ? "subtle-negative" : "subtle-warning"} size="small">
|
||||
{t(`admin.support.detail.attachments.scan.${attachment.scanStatus}`)}
|
||||
</BadgeFeedback>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
<span title={attachment.mimeType}>{t(fileTypeLabelKey(attachment.mimeType))}</span>
|
||||
{` · ${Math.max(1, Math.round(attachment.sizeBytes / 1024))} KB`}
|
||||
</span>
|
||||
</div>
|
||||
{attachment.downloadHref ? (
|
||||
<a href={attachment.downloadHref} rel="noreferrer" data-ui-id="ui.admin.support.ticket.attachment.download">
|
||||
<Button variant="tertiary" size="small" icon={<FeatherDownload />}>
|
||||
{t("admin.support.detail.attachments.download")}
|
||||
</Button>
|
||||
</a>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.support.detail.attachments.viewHint")}
|
||||
</span>
|
||||
</Card>
|
||||
) : null}
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.support.detail.statusTitle")}</h2>
|
||||
<Form method="post" className="flex w-full flex-col items-start gap-3">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="set-status" />
|
||||
<Select name="status" defaultValue={meta.status} placeholder={t("admin.support.detail.statusTitle")}>
|
||||
{statuses.map((status) => (
|
||||
<Select.Item key={status} value={status}>{t(`admin.support.status.${status}`)}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting} icon={<FeatherMessageSquare />}>
|
||||
{t("shared.save")}
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.support.detail.assigneeTitle")}</h2>
|
||||
<Form method="post" className="flex w-full flex-col items-start gap-3">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="assign" />
|
||||
<Select name="assigneeUserId" defaultValue={meta.assignedToUserId ?? "unassigned"} placeholder={t("admin.support.detail.assigneeTitle")}>
|
||||
<Select.Item value="unassigned">{t("admin.support.detail.unassigned")}</Select.Item>
|
||||
{assignees.map((assignee) => (
|
||||
<Select.Item key={assignee.id} value={assignee.id}>{assignee.email}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting} icon={<FeatherUserCheck />}>
|
||||
{t("shared.save")}
|
||||
</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
{ready ? (
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.support.detail.countsTitle")}</h2>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe="subtle-positive" size="small">{t("admin.support.detail.replies", { count: ready.replyCount })}</BadgeFeedback>
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">{t("admin.support.detail.internalNotes", { count: ready.internalNoteCount })}</BadgeFeedback>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function ThreadMessage({ message }: { message: SupportConversationMessage }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const authorLabel = message.authorLabel.startsWith("admin.") ? t(message.authorLabel) : message.authorLabel;
|
||||
return (
|
||||
<div
|
||||
className={
|
||||
message.kind === "internalNote"
|
||||
? "flex w-full flex-col items-start gap-1 rounded-md border border-dashed border-border-default bg-surface-neutral-secondary px-4 py-3"
|
||||
: "flex w-full flex-col items-start gap-1 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-3"
|
||||
}
|
||||
>
|
||||
<div className="flex w-full flex-wrap items-center justify-between gap-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={kindTone(message.kind)} size="small">{t(message.kindLabelKey)}</BadgeFeedback>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{authorLabel}</span>
|
||||
</div>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatters.dateTime(new Date(message.createdAtIso))}
|
||||
</span>
|
||||
</div>
|
||||
<span className="whitespace-pre-wrap text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary">{message.body}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function kindTone(kind: SupportConversationMessage["kind"]): "subtle-positive" | "subtle-warning" | "subtle-information" {
|
||||
if (kind === "reply") return "subtle-positive";
|
||||
if (kind === "internalNote") return "subtle-warning";
|
||||
return "subtle-information";
|
||||
}
|
||||
|
||||
function statusTone(status: string): "subtle-positive" | "subtle-warning" | "subtle-neutral" {
|
||||
if (status === "closed" || status === "answered") return "subtle-positive";
|
||||
if (status === "open") return "subtle-warning";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
|
||||
function priorityTone(priority: string): "subtle-negative" | "subtle-warning" | "subtle-neutral" {
|
||||
if (priority === "urgent" || priority === "high") return "subtle-negative";
|
||||
if (priority === "normal") return "subtle-neutral";
|
||||
return "subtle-warning";
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form, Link } from "react-router";
|
||||
import { FeatherArrowLeft, FeatherBuilding } from "@subframe/core";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { NumberInput } from "~/ui/components/NumberInput";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import UrlUtils from "~/utils/app/UrlUtils";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
export type AdminTenantCreatePageProps = {
|
||||
reservationRequestKey: string;
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
feedback?: { success?: string; error?: string };
|
||||
};
|
||||
|
||||
/**
|
||||
* AK-P19 DoD #3 — AD-28 interim screen for the dedicated manual tenant
|
||||
* creation route (`/admin/accounts/new`): base data + owner invitation +
|
||||
* plan/seats and trial, all behind a mandatory reason.
|
||||
*/
|
||||
export function AdminTenantCreatePage({ reservationRequestKey, csrf, submitting, feedback }: AdminTenantCreatePageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [name, setName] = useState("");
|
||||
const [slug, setSlug] = useState("");
|
||||
useEffect(() => {
|
||||
setSlug(UrlUtils.slugify(name));
|
||||
}, [name]);
|
||||
|
||||
return (
|
||||
<div data-ui-id="ui.admin.accounts.create.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.accounts.create.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("admin.accounts.create.pageDescription")}</p>
|
||||
</div>
|
||||
<Link to={adminPath("accounts", { mode: "host-aware" })}>
|
||||
<Button variant="tertiary" icon={<FeatherArrowLeft />}>{t("shared.back")}</Button>
|
||||
</Link>
|
||||
</header>
|
||||
{feedback?.success ? <BannerAlert type="success" fillContainer>{feedback.success}</BannerAlert> : null}
|
||||
{feedback?.error ? <BannerAlert type="error" fillContainer>{feedback.error}</BannerAlert> : null}
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
<Form method="post" className="flex w-full max-w-[720px] flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="reservationRequestKey" value={reservationRequestKey} readOnly />
|
||||
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.accounts.create.sections.base")}</h2>
|
||||
<div className="grid w-full grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput showLabel fillContainer label={t("shared.name")}>
|
||||
<TextInput.Input name="name" required value={name} onChange={(event) => setName(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput showLabel fillContainer label={t("shared.slug")}>
|
||||
<TextInput.Input name="slug" required value={slug} onChange={(event) => setSlug(event.target.value)} onBlur={() => setSlug(UrlUtils.slugify(slug))} />
|
||||
</TextInput>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.accounts.create.sections.owner")}</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("admin.accounts.create.ownerInvitationDescription")}</p>
|
||||
<div className="grid w-full grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput showLabel fillContainer label={t("models.user.email")}>
|
||||
<TextInput.Input name="ownerEmail" type="email" required />
|
||||
</TextInput>
|
||||
<div className="grid grid-cols-2 gap-4">
|
||||
<TextInput showLabel fillContainer label={t("models.user.firstName")}>
|
||||
<TextInput.Input name="ownerFirstName" required />
|
||||
</TextInput>
|
||||
<TextInput showLabel fillContainer label={t("models.user.lastName")}>
|
||||
<TextInput.Input name="ownerLastName" required />
|
||||
</TextInput>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.accounts.create.sections.subscription")}</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("admin.accounts.create.subscriptionDescription")}</p>
|
||||
{/* NumberInput is a fixed 192px-wide component — the columns must match or the steppers get overlapped. */}
|
||||
<div className="grid w-full grid-cols-[minmax(0,1fr)_192px_192px] items-end gap-4 mobile:grid-cols-1">
|
||||
<TextInput showLabel fillContainer label={t("admin.billing.fields.planCode")}>
|
||||
<TextInput.Input name="planCode" placeholder={t("admin.billing.placeholders.planCode")} />
|
||||
</TextInput>
|
||||
<NumberInput showLabel label={t("admin.billing.fields.seats")}>
|
||||
<NumberInput.Input name="seatQuantity" min={1} defaultValue={1} />
|
||||
</NumberInput>
|
||||
<NumberInput showLabel label={t("admin.accounts.create.trialDaysLabel")}>
|
||||
<NumberInput.Input name="trialDays" min={0} max={365} defaultValue={0} />
|
||||
</NumberInput>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.tenantOps.reasonLabel")}</h2>
|
||||
<TextInput showLabel fillContainer label={t("admin.tenantOps.reasonLabel")}>
|
||||
<TextInput.Input name="reason" required minLength={5} placeholder={t("admin.tenantOps.reasonPlaceholder")} />
|
||||
</TextInput>
|
||||
</Card>
|
||||
|
||||
<Button type="submit" loading={submitting} icon={<FeatherBuilding />}>{t("admin.accounts.create.submit")}</Button>
|
||||
</Form>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+228
@@ -0,0 +1,228 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Form } from "react-router";
|
||||
import { FeatherCalendarPlus, FeatherPin, FeatherPlug, FeatherStickyNote, FeatherTrash2 } from "@subframe/core";
|
||||
import type { AdminConnectorListVM, AdminConnectorRow, AdminTenantNoteListVM } from "@hivegrid/view-models";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { NumberInput } from "~/ui/components/NumberInput";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { subscriptionStatusLabelKey, translateOrHumanize } from "./adminEnumLabels";
|
||||
|
||||
export type AdminTenantTrialInfo = {
|
||||
status: string | null;
|
||||
trialEndsAtIso: string | null;
|
||||
};
|
||||
|
||||
export type AdminTenantOperationsPanelProps = {
|
||||
connectors: AdminConnectorListVM;
|
||||
notes: AdminTenantNoteListVM;
|
||||
trial: AdminTenantTrialInfo;
|
||||
noteCategories: readonly string[];
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
feedback?: { success?: string; error?: string };
|
||||
};
|
||||
|
||||
/**
|
||||
* AK-P19 DoD #3 — AD-28 interim panel on the admin tenant detail: trial
|
||||
* extension, subscription feature connectors (Abo-Baukasten) and operator
|
||||
* notes. VMs in, action forms out — no data fetching in here.
|
||||
*/
|
||||
export function AdminTenantOperationsPanel({ connectors, notes, trial, noteCategories, csrf, submitting, feedback }: AdminTenantOperationsPanelProps): React.JSX.Element {
|
||||
return (
|
||||
<div data-ui-id="ui.admin.tenantOps.panel" className="flex w-full flex-col items-start gap-4">
|
||||
{feedback?.success ? <BannerAlert type="success" fillContainer>{feedback.success}</BannerAlert> : null}
|
||||
{feedback?.error ? <BannerAlert type="error" fillContainer>{feedback.error}</BannerAlert> : null}
|
||||
<TrialCard trial={trial} csrf={csrf} submitting={submitting} />
|
||||
<ConnectorsCard connectors={connectors} csrf={csrf} submitting={submitting} />
|
||||
<NotesCard notes={notes} noteCategories={noteCategories} csrf={csrf} submitting={submitting} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TrialCard({ trial, csrf, submitting }: { trial: AdminTenantTrialInfo; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full flex-col items-start gap-1">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.tenantOps.trial.title")}</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.tenantOps.trial.description")}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={trial.status === "trial" ? "subtle-information" : "subtle-neutral"} size="small">
|
||||
{/* Printed the raw `trial` next to a translated "Aktiv" (audit I18N-02). */}
|
||||
{trial.status ? translateOrHumanize(t, subscriptionStatusLabelKey(trial.status), trial.status) : t("admin.tenantOps.trial.noSubscription")}
|
||||
</BadgeFeedback>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{trial.trialEndsAtIso
|
||||
? t("admin.tenantOps.trial.endsAt", { date: formatters.dateTime(new Date(trial.trialEndsAtIso)) })
|
||||
: t("admin.tenantOps.trial.noTrial")}
|
||||
</span>
|
||||
</div>
|
||||
{/* NumberInput is a fixed 192px-wide component — the column must match or the stepper gets overlapped. */}
|
||||
<Form method="post" className="grid w-full grid-cols-[192px_minmax(240px,1fr)_auto] items-end gap-4 mobile:grid-cols-1">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="trial-extend" />
|
||||
<NumberInput showLabel label={t("admin.tenantOps.trial.daysLabel")}>
|
||||
<NumberInput.Input name="days" min={1} max={365} defaultValue={14} required />
|
||||
</NumberInput>
|
||||
<TextInput showLabel fillContainer label={t("admin.tenantOps.reasonLabel")}>
|
||||
<TextInput.Input name="reason" required minLength={5} placeholder={t("admin.tenantOps.reasonPlaceholder")} />
|
||||
</TextInput>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherCalendarPlus />}>{t("admin.tenantOps.trial.extend")}</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function ConnectorsCard({ connectors, csrf, submitting }: { connectors: AdminConnectorListVM; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const ready = connectors.status === "ready" ? connectors.data : null;
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.connectors.title")}</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.connectors.description")}</p>
|
||||
</div>
|
||||
{ready ? (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe="subtle-positive" size="small">{t("admin.connectors.enabledCount", { count: ready.enabledCount })}</BadgeFeedback>
|
||||
<BadgeFeedback farbe={ready.overriddenCount ? "subtle-warning" : "subtle-neutral"} size="small">
|
||||
{t("admin.connectors.overriddenCount", { count: ready.overriddenCount })}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
{connectors.status === "empty" || !ready ? (
|
||||
<EmptyState outlined title={t("admin.connectors.empty.headline")} body={t("admin.connectors.empty.body")} />
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.connectors.columns.feature")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.connectors.columns.effective")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.connectors.columns.override")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{ready.rows.map((row) => (
|
||||
<ConnectorRow key={row.featureKey} row={row} csrf={csrf} submitting={submitting} />
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function ConnectorRow({ row, csrf, submitting }: { row: AdminConnectorRow; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t, i18n } = useTranslation();
|
||||
const label = i18n.exists(row.labelKey) ? t(row.labelKey) : row.featureKey;
|
||||
return (
|
||||
<Table.Row>
|
||||
<Table.Cell>
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{label}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(row.baseEnabled ? "admin.connectors.baseEnabled" : "admin.connectors.baseDisabled")}
|
||||
</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={row.effectiveEnabled ? "subtle-positive" : "subtle-negative"} size="small">
|
||||
{t(row.effectiveEnabled ? "admin.connectors.state.on" : "admin.connectors.state.off")}
|
||||
</BadgeFeedback>
|
||||
{row.overridden ? <BadgeFeedback farbe="subtle-warning" size="small"><FeatherPlug /> {t("admin.connectors.state.overridden")}</BadgeFeedback> : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{row.toggleable ? (
|
||||
<Form method="post" className="flex flex-wrap items-center gap-2">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="connector-set" />
|
||||
<input type="hidden" name="featureKey" value={row.featureKey} />
|
||||
<Select name="state" defaultValue={row.overrideState} placeholder={t("admin.connectors.columns.override")}>
|
||||
<Select.Item value="inherit">{t("admin.connectors.override.inherit")}</Select.Item>
|
||||
<Select.Item value="enabled">{t("admin.connectors.override.enabled")}</Select.Item>
|
||||
<Select.Item value="disabled">{t("admin.connectors.override.disabled")}</Select.Item>
|
||||
</Select>
|
||||
<TextInput>
|
||||
<TextInput.Input name="reason" required minLength={5} placeholder={t("admin.tenantOps.reasonPlaceholder")} />
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting}>{t("shared.save")}</Button>
|
||||
</Form>
|
||||
) : (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.connectors.notToggleable")}</span>
|
||||
)}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
);
|
||||
}
|
||||
|
||||
function NotesCard({ notes, noteCategories, csrf, submitting }: { notes: AdminTenantNoteListVM; noteCategories: readonly string[]; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const ready = notes.status === "ready" ? notes.data : null;
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full flex-col items-start gap-1">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.tenantNotes.title")}</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.tenantNotes.description")}</p>
|
||||
</div>
|
||||
|
||||
<Form method="post" className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="note-create" />
|
||||
<TextArea showLabel className="w-full" label={t("admin.tenantNotes.bodyLabel")}>
|
||||
<TextArea.Input name="noteText" required placeholder={t("admin.tenantNotes.bodyPlaceholder")} />
|
||||
</TextArea>
|
||||
<div className="flex w-full flex-wrap items-end gap-4">
|
||||
<Select name="category" defaultValue="general" placeholder={t("admin.tenantNotes.categoryLabel")}>
|
||||
{noteCategories.map((category) => (
|
||||
<Select.Item key={category} value={category}>{t(`admin.tenantNotes.category.${category}`)}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Checkbox name="pinned" value="true" label={t("admin.tenantNotes.pinnedLabel")} />
|
||||
<Button type="submit" loading={submitting} icon={<FeatherStickyNote />}>{t("admin.tenantNotes.create")}</Button>
|
||||
</div>
|
||||
</Form>
|
||||
|
||||
{notes.status === "empty" || !ready ? (
|
||||
<EmptyState outlined title={t("admin.tenantNotes.empty.headline")} body={t("admin.tenantNotes.empty.body")} />
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
{ready.rows.map((note) => (
|
||||
<div key={note.id} className="flex w-full items-start justify-between gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-3 mobile:flex-col">
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">{t(note.categoryLabelKey)}</BadgeFeedback>
|
||||
{note.pinned ? <BadgeFeedback farbe="subtle-information" size="small"><FeatherPin /> {t("admin.tenantNotes.pinnedLabel")}</BadgeFeedback> : null}
|
||||
</div>
|
||||
<span className="whitespace-pre-wrap text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary">{note.bodyMarkdown}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{note.authorLabel.startsWith("admin.") ? t(note.authorLabel) : note.authorLabel} · {formatters.dateTime(new Date(note.createdAtIso))}
|
||||
</span>
|
||||
</div>
|
||||
<Form method="post">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="note-delete" />
|
||||
<input type="hidden" name="noteId" value={note.id} />
|
||||
<Button type="submit" variant="destructive" size="small" loading={submitting} icon={<FeatherTrash2 />}>{t("shared.delete")}</Button>
|
||||
</Form>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`AK-P19 interim visual baseline > renders billing, queue, health and support ready states from ~/ui 1`] = `"<main data-ui-id="ui.akP19.interim.visualBaseline"><div data-ui-id="ui.admin.billing.page" class="flex w-full flex-col items-start bg-surface-neutral-primary"><header class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start"><h1 class="text-subtitle font-subtitle text-text-neutral-primary">admin.billing.title</h1><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.billing.description</p></div></header><div class="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4"><div class="grid w-full grid-cols-5 gap-4 mobile:grid-cols-1"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.billing.summary.attention.title</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">0</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-body-large-0 font-body-large-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.billing.summary.readOnlyTitle</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">0</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-body-large-0 font-body-large-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.billing.summary.providers.title</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">0</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-body-large-0 font-body-large-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col Line truncated
|
||||
|
||||
exports[`AK-P19 interim visual baseline > renders tenant operations, tenant creation and support-ticket detail ready states from ~/ui 1`] = `"<main data-ui-id="ui.akP19.interim.visualBaseline.restwork"><div data-ui-id="ui.admin.tenantOps.panel" class="flex w-full flex-col items-start gap-4"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full flex-col items-start gap-1"><h2 class="text-body-large-0 font-body-large-0 text-text-neutral-primary">admin.tenantOps.trial.title</h2><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.tenantOps.trial.description</p></div><div class="flex flex-wrap items-center gap-2"><div class="group/896531e4 flex items-center gap-2 rounded-round px-2.5 h-5 py-0.5 bg-surface-feedback-subtle-information"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-information"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">admin.billing.status.trial</span></div><span class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">admin.tenantOps.trial.endsAt</span></div><form method="post" action="/accounts/tenant-1" class="grid w-full grid-cols-[192px_minmax(240px,1fr)_auto] items-end gap-4 mobile:grid-cols-1" data-discover="true"><input type="hidden" value="csrf" name="csrf"><input type="hidden" value="trial-extend" name="action"><div class="group/06ebc0c5 flex w-full min-w-[192px] max-w-[192px] cursor-pointer flex-col items-start gap-4 group/numberinput h-auto"><div class="flex-col items-start gap-3 flex"><span id="_r_1_" class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.tenantOps.trial.daysLabel</span></div><div class="flex w-full rounded-sm border border-solid border-border-strong bg-surface-neutral-primary items-stretch group-hover/06ebc0c5:bg-surface-neutral-secondary group-hover/06ebc0c5:border-brand-brand-border-solid-hover group-focus-within/06ebc0c5:bg-surface-neutral-secondary group-focus-within/06ebc0c5:shadow-focus h-9 grow-0 shrink-0 basis-auto"><div class="flex grow shrink-0 basis-0 flex-col items-start justify-center self-stretch"><input class="h-full w-full px-3 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none [-moz-appearance:textfield]" min="1" max="365" required="" aria-labelledby="_r_1_" type="number" value="14" name="days"></div><div class="flex w-9 flex-none flex-col self-stretch overflow-hidden rounded-r-md border-l border-solid border-border-default items-stretch justify-center"><div class="group/de954ebd flex h-full w-9 cursor-pointer items-center justify-center overflow-hidden border-b border-solid border-white-0 px-3 pt-0.5 hover:bg-surface-feedback-subtle-neutral-hover active:bg-surface-feedback-subtle-neutral-active focus-within:border-b focus-within:border-x-0 focus-within:border-t-0 focus-within:border-solid focus-within:border-surface-feedback-solid-information focus-within:bg-surface-feedback-subtle-neutral-hover rounded-none" aria-hidden="true"><span class="text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-icon-neutral-secondary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex h-px w-full flex-none flex-col items-center gap-2 bg-border-default"></div><div class="group/de954ebd flex h-full w-9 cursor-pointer items-center justify-center overflow-hidden border-b border-solid border-white-0 px-3 hover:bg-surface-feedback-subtle-neutral-hover active:bg-surface-feedback-subtle-neutral-active focus-within:bg-surface-feedback-subtle-neutral-hover pt-0 pb-0.5 focus-within:border-t focus-within:border-x-0 focus-within:border-b-0 focus-within:border-solid focus-within:border-surface-feedback-solid-information rounded-none" aria-hidden="true"><span class="text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-icon-neutral-secondary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><label class="group/be48ca43 flex h-full w-full min-w-[192px] cursor-pointer flex-col items-start justify-center gap-4 max-w-none"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.tenantOps.reasonLabel</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutralLine truncated
|
||||
+43
@@ -0,0 +1,43 @@
|
||||
import { buildAdminDashboardVM } from "@hivegrid/view-models";
|
||||
import { createInstance } from "i18next";
|
||||
import { I18nextProvider, initReactI18next } from "react-i18next";
|
||||
import { MemoryRouter } from "react-router";
|
||||
|
||||
import deTranslations from "../../../../public/locales/de/translations.json";
|
||||
import { AdminPersonalizedDashboard } from "./AdminPersonalizedDashboard";
|
||||
|
||||
const visualI18n = createInstance();
|
||||
void visualI18n.use(initReactI18next).init({
|
||||
lng: "de",
|
||||
fallbackLng: "de",
|
||||
defaultNS: "translation",
|
||||
resources: { de: { translation: deTranslations } },
|
||||
interpolation: { escapeValue: false },
|
||||
initImmediate: false,
|
||||
});
|
||||
|
||||
export function createPersonalizedDashboardVisualVM() {
|
||||
return buildAdminDashboardVM({
|
||||
roles: ["sales", "engineering"],
|
||||
widgets: [
|
||||
{ id: "sales_own_pipeline", value: "128.000 €", href: "/sales/deals" },
|
||||
{ id: "sales_today", value: "6", href: "/sales/tasks/today", tone: "warning" },
|
||||
{ id: "sales_appointments", value: "4", href: "/sales/bookings" },
|
||||
{ id: "sales_followups", value: "9", href: "/sales/tasks/today" },
|
||||
{ id: "engineering_health", value: "OK", href: "/system", tone: "positive" },
|
||||
{ id: "engineering_queues", value: "0", href: "/system/jobs", tone: "positive" },
|
||||
{ id: "engineering_errors", value: "2", href: "/events", tone: "critical" },
|
||||
{ id: "engineering_deploy", value: "a12bc34", href: "/system/deploys" },
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
export function AdminPersonalizedDashboardVisualFixture(): React.JSX.Element {
|
||||
return (
|
||||
<MemoryRouter>
|
||||
<I18nextProvider i18n={visualI18n}>
|
||||
<AdminPersonalizedDashboard vm={createPersonalizedDashboardVisualVM()} />
|
||||
</I18nextProvider>
|
||||
</MemoryRouter>
|
||||
);
|
||||
}
|
||||
+84
@@ -0,0 +1,84 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
humanizeIdentifier,
|
||||
planCodeLabel,
|
||||
providerLabel,
|
||||
supportPriorityLabelKey,
|
||||
supportSourceLabel,
|
||||
supportStatusLabelKey,
|
||||
} from "./adminEnumLabels";
|
||||
|
||||
describe("supportStatusLabelKey", () => {
|
||||
it("resolves the same keys the ticket detail already used", () => {
|
||||
// The inbox printed `open` while the detail printed "Offen".
|
||||
expect(supportStatusLabelKey("open")).toBe("admin.support.status.open");
|
||||
expect(supportStatusLabelKey("closed")).toBe("admin.support.status.closed");
|
||||
});
|
||||
|
||||
it("returns null for unknown values instead of inventing a key", () => {
|
||||
expect(supportStatusLabelKey("escalated")).toBeNull();
|
||||
expect(supportStatusLabelKey("")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportPriorityLabelKey", () => {
|
||||
it("resolves known priorities", () => {
|
||||
expect(supportPriorityLabelKey("normal")).toBe("admin.support.priority.normal");
|
||||
expect(supportPriorityLabelKey("urgent")).toBe("admin.support.priority.urgent");
|
||||
});
|
||||
|
||||
it("returns null for unknown priorities", () => {
|
||||
expect(supportPriorityLabelKey("blocker")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("humanizeIdentifier", () => {
|
||||
it("makes stored identifiers readable", () => {
|
||||
expect(humanizeIdentifier("business")).toBe("Business");
|
||||
expect(humanizeIdentifier("past_due")).toBe("Past due");
|
||||
expect(humanizeIdentifier("admin-sales")).toBe("Admin sales");
|
||||
expect(humanizeIdentifier("BUSINESS")).toBe("Business");
|
||||
});
|
||||
|
||||
it("keeps an unusable value rather than returning something empty", () => {
|
||||
expect(humanizeIdentifier("")).toBe("");
|
||||
expect(humanizeIdentifier(" ")).toBe(" ");
|
||||
});
|
||||
});
|
||||
|
||||
describe("supportSourceLabel", () => {
|
||||
it("no longer shows the raw intake channel", () => {
|
||||
expect(supportSourceLabel("seed")).toBe("Seed");
|
||||
expect(supportSourceLabel("email")).toBe("Email");
|
||||
expect(supportSourceLabel("inline")).toBe("Inline");
|
||||
});
|
||||
});
|
||||
|
||||
describe("planCodeLabel", () => {
|
||||
it("matches how /accounts already renders the plan", () => {
|
||||
expect(planCodeLabel("business")).toBe("Business");
|
||||
expect(planCodeLabel("starter")).toBe("Starter");
|
||||
expect(planCodeLabel("pro")).toBe("Pro");
|
||||
});
|
||||
|
||||
it("returns null for an unset plan so the caller can render a dash", () => {
|
||||
expect(planCodeLabel(null)).toBeNull();
|
||||
expect(planCodeLabel(undefined)).toBeNull();
|
||||
expect(planCodeLabel(" ")).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("providerLabel", () => {
|
||||
it("preserves brand casing", () => {
|
||||
expect(providerLabel("hubspot")).toBe("HubSpot");
|
||||
expect(providerLabel("mailchimp")).toBe("Mailchimp");
|
||||
expect(providerLabel("slack")).toBe("Slack");
|
||||
expect(providerLabel("kwp")).toBe("KWP");
|
||||
expect(providerLabel("pandadoc")).toBe("PandaDoc");
|
||||
});
|
||||
|
||||
it("humanizes providers that are not in the brand list", () => {
|
||||
expect(providerLabel("custom_webhook")).toBe("Custom webhook");
|
||||
});
|
||||
});
|
||||
+109
@@ -0,0 +1,109 @@
|
||||
/**
|
||||
* Display labels for admin values that are stored as identifiers.
|
||||
*
|
||||
* The admin audit from 2026-07-26 found the same value rendered two ways
|
||||
* depending on the screen: `/support` listed `open` / `normal` / `seed` while the
|
||||
* ticket detail showed "Offen" / "Normal", and `/accounts/billing` printed
|
||||
* `business` where `/accounts` printed "Business". These helpers are the single
|
||||
* place that decides how such a value reads, so a list and a detail view can no
|
||||
* longer drift apart.
|
||||
*
|
||||
* Two kinds of values are handled differently:
|
||||
*
|
||||
* - Closed sets (ticket status, priority) resolve to an i18n key.
|
||||
* - Open sets (operator-defined plan codes, provider keys) are identifiers we
|
||||
* cannot translate exhaustively, so they are humanized instead — never shown
|
||||
* raw and never invented as a missing translation key.
|
||||
*/
|
||||
|
||||
/** Ticket statuses that have a translation under `admin.support.status.*`. */
|
||||
export const SUPPORT_TICKET_STATUSES = ["open", "pending", "answered", "closed"] as const;
|
||||
|
||||
/** Ticket priorities that have a translation under `admin.support.priority.*`. */
|
||||
export const SUPPORT_TICKET_PRIORITIES = ["low", "normal", "high", "urgent"] as const;
|
||||
|
||||
/** Subscription states that have a translation under `admin.billing.status.*`. */
|
||||
export const SUBSCRIPTION_STATUSES = ["trial", "active", "past_due", "cancelled", "frozen"] as const;
|
||||
|
||||
/**
|
||||
* Provider keys whose casing is a brand name rather than a word, so title-casing
|
||||
* would spell them wrong ("Hubspot" instead of "HubSpot").
|
||||
*/
|
||||
const BRAND_NAMES: Readonly<Record<string, string>> = {
|
||||
aircall: "Aircall",
|
||||
brevo: "Brevo",
|
||||
discord: "Discord",
|
||||
github: "GitHub",
|
||||
gitlab: "GitLab",
|
||||
hubspot: "HubSpot",
|
||||
kwp: "KWP",
|
||||
lago: "Lago",
|
||||
mailchimp: "Mailchimp",
|
||||
mailjet: "Mailjet",
|
||||
meilisearch: "Meilisearch",
|
||||
mollie: "Mollie",
|
||||
pandadoc: "PandaDoc",
|
||||
sendgrid: "SendGrid",
|
||||
slack: "Slack",
|
||||
webhook: "Webhook",
|
||||
};
|
||||
|
||||
/**
|
||||
* Turns a stored identifier into readable text: `past_due` → "Past due",
|
||||
* `admin-sales` → "Admin sales", `business` → "Business". Only the first word is
|
||||
* capitalized, because German sentence case reads better than Title Case for
|
||||
* multi-word values.
|
||||
*/
|
||||
export function humanizeIdentifier(value: string): string {
|
||||
const words = value
|
||||
.trim()
|
||||
.split(/[\s_.-]+/u)
|
||||
.filter(Boolean);
|
||||
if (words.length === 0) return value;
|
||||
const [first, ...rest] = words;
|
||||
return [first.charAt(0).toUpperCase() + first.slice(1).toLowerCase(), ...rest.map((word) => word.toLowerCase())].join(" ");
|
||||
}
|
||||
|
||||
/** i18n key for a ticket status, or `null` when the value is not a known status. */
|
||||
export function supportStatusLabelKey(status: string): string | null {
|
||||
return (SUPPORT_TICKET_STATUSES as readonly string[]).includes(status) ? `admin.support.status.${status}` : null;
|
||||
}
|
||||
|
||||
/** i18n key for a ticket priority, or `null` when the value is unknown. */
|
||||
export function supportPriorityLabelKey(priority: string): string | null {
|
||||
return (SUPPORT_TICKET_PRIORITIES as readonly string[]).includes(priority) ? `admin.support.priority.${priority}` : null;
|
||||
}
|
||||
|
||||
/** i18n key for a subscription state, or `null` when the value is unknown. */
|
||||
export function subscriptionStatusLabelKey(status: string): string | null {
|
||||
return (SUBSCRIPTION_STATUSES as readonly string[]).includes(status) ? `admin.billing.status.${status}` : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticket intake channel. The set grows with every new intake path (`email`,
|
||||
* `inline`, seeded demo data), so it is humanized rather than translated.
|
||||
*/
|
||||
export function supportSourceLabel(source: string): string {
|
||||
return humanizeIdentifier(source);
|
||||
}
|
||||
|
||||
/** Operator-defined subscription plan code, e.g. `business` → "Business". */
|
||||
export function planCodeLabel(planCode: string | null | undefined): string | null {
|
||||
if (!planCode?.trim()) return null;
|
||||
return humanizeIdentifier(planCode);
|
||||
}
|
||||
|
||||
/** Integration or provider key, with brand casing preserved. */
|
||||
export function providerLabel(provider: string): string {
|
||||
const normalized = provider.trim().toLowerCase();
|
||||
return BRAND_NAMES[normalized] ?? humanizeIdentifier(provider);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders a closed-set value through i18n and falls back to a humanized form for
|
||||
* values the catalog does not know yet. Keeps an unexpected value readable
|
||||
* instead of showing either a raw enum or a missing translation key.
|
||||
*/
|
||||
export function translateOrHumanize(translate: (key: string) => string, labelKey: string | null, rawValue: string): string {
|
||||
return labelKey ? translate(labelKey) : humanizeIdentifier(rawValue);
|
||||
}
|
||||
+206
@@ -0,0 +1,206 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { createMemoryRouter, RouterProvider } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
ADMIN_TENANT_NOTE_CATEGORIES,
|
||||
buildAdminBillingVM,
|
||||
buildAdminConnectorListVM,
|
||||
buildAdminTenantNoteListVM,
|
||||
buildOperatorHealthVM,
|
||||
buildQueueMonitorVM,
|
||||
buildSupportConversationVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import { AdminBillingPage } from "./AdminBillingPage";
|
||||
import { AdminHealthPage } from "./AdminHealthPage";
|
||||
import { AdminJobsPage } from "./AdminJobsPage";
|
||||
import { AdminSupportInboxPage } from "./AdminSupportInboxPage";
|
||||
import { AdminSupportTicketPage } from "./AdminSupportTicketPage";
|
||||
import { AdminTenantCreatePage } from "./AdminTenantCreatePage";
|
||||
import { AdminTenantOperationsPanel } from "./AdminTenantOperationsPanel";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de", exists: () => false } }),
|
||||
}));
|
||||
|
||||
// Radix Select measures itself; jsdom has no ResizeObserver.
|
||||
class ResizeObserverStub {
|
||||
observe(): void {}
|
||||
unobserve(): void {}
|
||||
disconnect(): void {}
|
||||
}
|
||||
globalThis.ResizeObserver = globalThis.ResizeObserver ?? (ResizeObserverStub as unknown as typeof ResizeObserver);
|
||||
|
||||
vi.mock("~/locale/format", () => ({
|
||||
// toISOString keeps the baseline timezone-independent (CI runs in UTC, dev machines in CEST).
|
||||
useLocaleFormatters: () => ({ number: (value: number) => String(value), dateTime: (value: string | Date) => new Date(value).toISOString() }),
|
||||
}));
|
||||
|
||||
describe("AK-P19 interim visual baseline", () => {
|
||||
it("renders billing, queue, health and support ready states from ~/ui", () => {
|
||||
const billing = buildAdminBillingVM({
|
||||
rows: [
|
||||
{
|
||||
tenantId: "tenant-1",
|
||||
tenantName: "Musterbetrieb GmbH",
|
||||
tenantSlug: "musterbetrieb",
|
||||
status: "active",
|
||||
readOnly: false,
|
||||
planCode: "starter",
|
||||
seatQuantity: 5,
|
||||
lagoCustomerId: "lago-1",
|
||||
mollieCustomerId: "mollie-1",
|
||||
lastInvoiceExternalId: "invoice-1",
|
||||
lastPaymentExternalId: "payment-1",
|
||||
currentPeriodStart: "2026-07-01",
|
||||
currentPeriodEnd: "2026-08-01",
|
||||
pastDueSince: null,
|
||||
frozenAt: null,
|
||||
cancelledAt: null,
|
||||
entitlementCount: 4,
|
||||
},
|
||||
],
|
||||
});
|
||||
const queues = buildQueueMonitorVM({
|
||||
queues: [{ queueName: "notifications", group: "notification", active: 1, waiting: 2, delayed: 0, failed: 0, completed: 40, paused: false }],
|
||||
});
|
||||
const health = buildOperatorHealthVM({
|
||||
subsystems: [{ id: "queues", status: "ok", href: "/system/jobs" }],
|
||||
deploy: { environment: "staging", release: "abc123", revision: "1", branch: "main" },
|
||||
signals: { failedJobsTotal: 0, pausedQueues: 0, webhookFailures: 0, billingErrors: 0 },
|
||||
links: { jobs: "/system/jobs", webhooks: "/system/webhooks", billing: "/system/billing" },
|
||||
billingErrors: [],
|
||||
});
|
||||
|
||||
const router = createMemoryRouter(
|
||||
[
|
||||
{
|
||||
path: "*",
|
||||
element: (
|
||||
<main data-ui-id="ui.akP19.interim.visualBaseline">
|
||||
<AdminBillingPage vm={billing} csrf="csrf" submitting={false} />
|
||||
<AdminJobsPage vm={queues} failedJobs={[]} csrf="csrf" submitting={false} canManagePortalDomainKillSwitch />
|
||||
<AdminHealthPage vm={health} />
|
||||
<AdminSupportInboxPage
|
||||
vm={{
|
||||
summary: { ticketsTotal: 1, feedbackTotal: 1, openTickets: 1, assignedTickets: 1, urgentTickets: 0 },
|
||||
recentTickets: [
|
||||
{
|
||||
id: "ticket-1",
|
||||
subject: "Frage zum Abo",
|
||||
status: "open",
|
||||
priority: "normal",
|
||||
source: "in_app_feedback_widget",
|
||||
createdAt: "2026-07-12",
|
||||
tenantName: "Musterbetrieb GmbH",
|
||||
userEmail: "admin@example.test",
|
||||
},
|
||||
],
|
||||
recentFeedback: [
|
||||
{ id: "feedback-1", message: "Bitte prüfen", createdAt: "2026-07-12", tenantName: "Musterbetrieb GmbH", userEmail: "admin@example.test" },
|
||||
],
|
||||
}}
|
||||
/>
|
||||
</main>
|
||||
),
|
||||
},
|
||||
],
|
||||
{ initialEntries: ["/system/billing"] }
|
||||
);
|
||||
const { container } = render(<RouterProvider router={router} />);
|
||||
|
||||
expect(container.querySelectorAll("[data-ui-id$='.page']")).toHaveLength(4);
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders tenant operations, tenant creation and support-ticket detail ready states from ~/ui", () => {
|
||||
const connectors = buildAdminConnectorListVM({
|
||||
rows: [
|
||||
{ featureKey: "projects", toggleable: true, baseEnabled: true, overrideState: null },
|
||||
{ featureKey: "telephony", toggleable: true, baseEnabled: false, overrideState: "enabled" },
|
||||
{ featureKey: "dashboard", toggleable: false, baseEnabled: true, overrideState: null },
|
||||
],
|
||||
});
|
||||
const notes = buildAdminTenantNoteListVM({
|
||||
rows: [
|
||||
{
|
||||
id: "note-1",
|
||||
createdAtIso: "2026-07-12T10:00:00.000Z",
|
||||
category: "billing",
|
||||
pinned: true,
|
||||
noteText: "Rechnung geht an die Zentrale.",
|
||||
authorEmail: "op@example.test",
|
||||
authorId: "admin-1",
|
||||
},
|
||||
],
|
||||
});
|
||||
const conversation = buildSupportConversationVM({
|
||||
ticketId: "ticket-1",
|
||||
subject: "Frage zum Abo",
|
||||
status: "open",
|
||||
priority: "high",
|
||||
messages: [
|
||||
{ id: "m-0", createdAtIso: "2026-07-12T09:00:00.000Z", internalNote: false, authorEmail: null, authorId: null, body: "Wie stelle ich um?" },
|
||||
{
|
||||
id: "m-1",
|
||||
createdAtIso: "2026-07-12T10:00:00.000Z",
|
||||
internalNote: true,
|
||||
authorEmail: "op@example.test",
|
||||
authorId: "admin-1",
|
||||
body: "Intern: prüfen.",
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const router = createMemoryRouter(
|
||||
[
|
||||
{
|
||||
path: "*",
|
||||
element: (
|
||||
<main data-ui-id="ui.akP19.interim.visualBaseline.restwork">
|
||||
<AdminTenantOperationsPanel
|
||||
connectors={connectors}
|
||||
notes={notes}
|
||||
trial={{ status: "trial", trialEndsAtIso: "2026-08-01T00:00:00.000Z" }}
|
||||
noteCategories={ADMIN_TENANT_NOTE_CATEGORIES}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
/>
|
||||
<AdminTenantCreatePage
|
||||
reservationRequestKey="3f2504e0-4f89-41d3-9a0c-0305e82c3301"
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
/>
|
||||
<AdminSupportTicketPage
|
||||
vm={conversation}
|
||||
meta={{
|
||||
tenantName: "Musterbetrieb GmbH",
|
||||
userEmail: "kunde@example.test",
|
||||
fromEmail: null,
|
||||
source: "in_app_feedback_widget",
|
||||
createdAtIso: "2026-07-12T09:00:00.000Z",
|
||||
status: "open",
|
||||
priority: "high",
|
||||
assignedToUserId: null,
|
||||
}}
|
||||
assignees={[{ id: "admin-1", email: "op@example.test" }]}
|
||||
statuses={["open", "pending", "answered", "closed"]}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
/>
|
||||
</main>
|
||||
),
|
||||
},
|
||||
],
|
||||
{ initialEntries: ["/accounts/tenant-1"] }
|
||||
);
|
||||
const { container } = render(<RouterProvider router={router} />);
|
||||
|
||||
expect(container.querySelectorAll("[data-ui-id$='.page']")).toHaveLength(2);
|
||||
expect(container.querySelectorAll("[data-ui-id='ui.admin.tenantOps.panel']")).toHaveLength(1);
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+622
@@ -0,0 +1,622 @@
|
||||
import { FeatherArchive, FeatherArrowLeft, FeatherRotateCcw, FeatherSave, FeatherSend } from "@subframe/core";
|
||||
import type { AdminLeadDetailVM } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadDetailPageProps = {
|
||||
readonly vm: AdminLeadDetailVM;
|
||||
readonly csrf: string;
|
||||
readonly submitting: boolean;
|
||||
readonly feedback?: { readonly success?: string; readonly error?: string };
|
||||
readonly actions: {
|
||||
readonly onBack: () => void;
|
||||
readonly onSubmit: PlatformLeadFormAction;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S03: platform lead detail and attributable activity timeline. */
|
||||
export function AdminPlatformLeadDetailPage({ vm, csrf, submitting, feedback, actions }: AdminPlatformLeadDetailPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.detail" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start gap-3 border-b border-solid px-6 py-5">
|
||||
<Breadcrumbs>
|
||||
<Link to={adminPath("leads", { mode: "host-aware" })}>
|
||||
<Breadcrumbs.Item>{t("admin.platformLeads.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{vm.displayName || t("shared.notSet")}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="mobile:flex-col flex w-full items-start gap-4">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{vm.displayName || t("shared.notSet")}</h1>
|
||||
<BadgeFeedback farbe={vm.statusTone}>{t(vm.statusLabelKey)}</BadgeFeedback>
|
||||
{vm.archivedAt ? <BadgeFeedback farbe="subtle-neutral">{t("admin.platformLeads.archive.archived")}</BadgeFeedback> : null}
|
||||
</div>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.platformLeads.detailDescription")}</p>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" icon={<FeatherArrowLeft />} onClick={actions.onBack}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{feedback?.success ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{feedback.success}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{feedback?.error ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{feedback.error}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{vm.duplicateHintOfLeadId ? (
|
||||
<BannerAlert type="warning" fillContainer>
|
||||
<span className="font-body-default-semibold-0">{t("admin.platformLeads.detail.duplicateHint")}</span>
|
||||
<span>{t("admin.platformLeads.detail.duplicateHintBody")}</span>
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{vm.archivedAt ? (
|
||||
<BannerAlert type="information" fillContainer>
|
||||
{t("admin.platformLeads.detail.archived")}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-[minmax(0,1fr)_minmax(320px,0.7fr)] gap-4">
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.contact")} />
|
||||
<DefinitionGrid
|
||||
rows={[
|
||||
[t("admin.platformLeads.fields.firstName"), vm.firstName],
|
||||
[t("admin.platformLeads.fields.lastName"), vm.lastName],
|
||||
[t("admin.platformLeads.fields.company"), vm.company],
|
||||
[t("admin.platformLeads.fields.email"), vm.email],
|
||||
[t("admin.platformLeads.fields.phone"), vm.phone],
|
||||
[t("admin.platformLeads.fields.source"), vm.sourceDisplayName],
|
||||
[t("admin.platformLeads.fields.externalId"), vm.externalId],
|
||||
[t("admin.platformLeads.fields.capturedAt"), formatters.dateTime(vm.capturedAt)],
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.qualification.title")} />
|
||||
<DefinitionGrid
|
||||
rows={[
|
||||
[
|
||||
t("admin.platformLeads.qualification.score"),
|
||||
vm.qualification ? String(vm.qualification.score) : null,
|
||||
],
|
||||
[
|
||||
t("admin.platformLeads.qualification.band"),
|
||||
vm.qualification
|
||||
? t(`admin.platformLeads.qualification.bands.${vm.qualification.scoreBand}`)
|
||||
: null,
|
||||
],
|
||||
[
|
||||
t("admin.platformLeads.qualification.enrichmentStatus"),
|
||||
vm.qualification
|
||||
? t(
|
||||
`admin.platformLeads.qualification.enrichment.${vm.qualification.enrichmentStatus}`
|
||||
)
|
||||
: null,
|
||||
],
|
||||
[
|
||||
t("admin.platformLeads.qualification.provider"),
|
||||
vm.qualification?.enrichmentProvider ?? null,
|
||||
],
|
||||
]}
|
||||
/>
|
||||
{vm.enrichmentRows.length > 0 ? (
|
||||
<div className="border-border-default grid w-full grid-cols-2 gap-3 border-t border-solid pt-4">
|
||||
{vm.enrichmentRows.map((row) => (
|
||||
<div key={row.key} className="flex min-w-0 flex-col items-start gap-1">
|
||||
<span className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">
|
||||
{t(`admin.platformLeads.qualification.fields.${row.key}`, {
|
||||
defaultValue: row.key,
|
||||
})}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary break-words">
|
||||
{row.value}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.message")} />
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary whitespace-pre-wrap">
|
||||
{vm.message || t("shared.notSet")}
|
||||
</p>
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.attribution")} />
|
||||
<DefinitionGrid
|
||||
rows={[
|
||||
[t("admin.platformLeads.fields.utmSource"), vm.attribution.utmSource],
|
||||
[t("admin.platformLeads.fields.utmMedium"), vm.attribution.utmMedium],
|
||||
[t("admin.platformLeads.fields.utmCampaign"), vm.attribution.utmCampaign],
|
||||
[t("admin.platformLeads.fields.utmTerm"), vm.attribution.utmTerm],
|
||||
[t("admin.platformLeads.fields.utmContent"), vm.attribution.utmContent],
|
||||
[t("admin.platformLeads.fields.referrer"), vm.attribution.referrer],
|
||||
[t("admin.platformLeads.fields.landingPage"), vm.attribution.landingPage],
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.qualification.actionsTitle")} />
|
||||
{vm.permissions.canWrite ? (
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<div className="flex w-full flex-wrap gap-2">
|
||||
<QuickLeadAction
|
||||
csrf={csrf}
|
||||
intent="score"
|
||||
reason={t("admin.platformLeads.qualification.reasons.score")}
|
||||
label={t("admin.platformLeads.qualification.actions.score")}
|
||||
submitting={submitting}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
{vm.permissions.canAssign ? (
|
||||
<QuickLeadAction
|
||||
csrf={csrf}
|
||||
intent="auto-assign"
|
||||
reason={t("admin.platformLeads.qualification.reasons.assign")}
|
||||
label={t("admin.platformLeads.qualification.actions.assign")}
|
||||
submitting={submitting}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
) : null}
|
||||
<QuickLeadAction
|
||||
csrf={csrf}
|
||||
intent="detect-duplicates"
|
||||
reason={t("admin.platformLeads.qualification.reasons.duplicates")}
|
||||
label={t("admin.platformLeads.qualification.actions.duplicates")}
|
||||
submitting={submitting}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form
|
||||
onSubmit={platformLeadFormHandler(actions.onSubmit)}
|
||||
className="flex w-full flex-col items-start gap-3"
|
||||
>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="enrich" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.qualification.reasons.enrich")}
|
||||
/>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.provider")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input
|
||||
name="provider"
|
||||
required
|
||||
defaultValue={vm.qualification?.enrichmentProvider ?? "provider-webhook"}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.company")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="companyName" defaultValue={vm.company ?? ""} />
|
||||
</TextInput>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-3">
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.domain")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="domain" />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.region")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="region" />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.countryCode")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="countryCode" maxLength={2} />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.industry")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="industry" />
|
||||
</TextInput>
|
||||
</div>
|
||||
<Button type="submit" variant="secondary" loading={submitting}>
|
||||
{t("admin.platformLeads.qualification.actions.enrich")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.platformLeads.qualification.actionsTitle")}
|
||||
body={t("admin.platformLeads.errors.noWritePermission")}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.duplicates.title")} />
|
||||
{vm.duplicates.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.platformLeads.duplicates.empty")}
|
||||
body={t("admin.platformLeads.duplicates.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
{vm.duplicates.map((candidate) => (
|
||||
<div
|
||||
key={candidate.id}
|
||||
className="border-border-default flex w-full flex-col items-start gap-3 rounded-md border border-solid p-3"
|
||||
>
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<Link
|
||||
className="text-body-default-medium-0 font-body-default-medium-0 text-text-brand-primary"
|
||||
to={adminPath(`leads/${candidate.candidateLeadId}`, {
|
||||
mode: "host-aware",
|
||||
})}
|
||||
>
|
||||
{candidate.candidateLeadId}
|
||||
</Link>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{candidate.matchKeys.join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-warning">
|
||||
{candidate.confidencePercent} %
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
{vm.permissions.canMerge ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="merge" />
|
||||
<input type="hidden" name="candidateId" value={candidate.id} />
|
||||
<input
|
||||
type="hidden"
|
||||
name="survivorLeadId"
|
||||
value={candidate.primaryLeadId}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
name="mergedLeadId"
|
||||
value={candidate.duplicateLeadId}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.duplicates.reasons.merge")}
|
||||
/>
|
||||
<Button type="submit" size="small" loading={submitting}>
|
||||
{t("admin.platformLeads.duplicates.actions.merge")}
|
||||
</Button>
|
||||
</form>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input
|
||||
type="hidden"
|
||||
name="intent"
|
||||
value="dismiss-duplicate"
|
||||
/>
|
||||
<input type="hidden" name="candidateId" value={candidate.id} />
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.duplicates.reasons.dismiss")}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
size="small"
|
||||
variant="tertiary"
|
||||
loading={submitting}
|
||||
>
|
||||
{t("admin.platformLeads.duplicates.actions.dismiss")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
{vm.status === "qualified" && !vm.converted && vm.permissions.canWrite ? (
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.conversion.title")} />
|
||||
<form
|
||||
onSubmit={platformLeadFormHandler(actions.onSubmit)}
|
||||
className="flex w-full flex-col items-start gap-3"
|
||||
>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="convert" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.conversion.reason")}
|
||||
/>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.company")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="companyName" required defaultValue={vm.company ?? ""} />
|
||||
</TextInput>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-3">
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.firstName")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="firstName" required defaultValue={vm.firstName ?? ""} />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.lastName")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="lastName" required defaultValue={vm.lastName ?? ""} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.conversion.dealTitle")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input
|
||||
name="dealTitle"
|
||||
required
|
||||
defaultValue={t("admin.platformLeads.conversion.defaultDealTitle", {
|
||||
name: vm.company || vm.displayName,
|
||||
})}
|
||||
/>
|
||||
</TextInput>
|
||||
<Select
|
||||
name="ownerAdminUserId"
|
||||
defaultValue={vm.assignedToAdminUserId ?? vm.assigneeOptions[0]?.id}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
>
|
||||
{vm.assigneeOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.conversion.amount")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="amountCents" type="number" min={0} />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.conversion.nextStep")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="nextStep" />
|
||||
</TextInput>
|
||||
<Button type="submit" loading={submitting}>
|
||||
{t("admin.platformLeads.conversion.action")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{vm.converted ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{t("admin.platformLeads.conversion.complete")}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.processing")} />
|
||||
{vm.permissions.canWrite ? (
|
||||
<>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="status" />
|
||||
<Select
|
||||
name="status"
|
||||
defaultValue={vm.status}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.status")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.status")}
|
||||
highContrastText
|
||||
>
|
||||
{(["new", "contacted", "qualified", "disqualified"] as const).map((status) => (
|
||||
<Select.Item key={status} value={status}>
|
||||
{t(`admin.platformLeads.status.${status}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.reason")} fillContainer>
|
||||
<TextInput.Input name="reason" required minLength={5} />
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary" loading={submitting} icon={<FeatherSave />}>
|
||||
{t("admin.platformLeads.actions.save")}
|
||||
</Button>
|
||||
</form>
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="assign" />
|
||||
<Select
|
||||
name="assignedToAdminUserId"
|
||||
defaultValue={vm.assignedToAdminUserId ?? "unassigned"}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{vm.assigneeOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.reason")} fillContainer>
|
||||
<TextInput.Input name="reason" required minLength={5} />
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary" loading={submitting} icon={<FeatherSave />}>
|
||||
{t("admin.platformLeads.actions.save")}
|
||||
</Button>
|
||||
</form>
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="note" />
|
||||
<TextArea showLabel label={t("admin.platformLeads.fields.note")} className="max-w-none">
|
||||
<TextArea.Input name="note" required maxLength={8000} />
|
||||
</TextArea>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherSend />}>
|
||||
{t("admin.platformLeads.actions.addNote")}
|
||||
</Button>
|
||||
</form>
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value={vm.archivedAt ? "restore" : "archive"} />
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.reason")} fillContainer>
|
||||
<TextInput.Input name="reason" required minLength={5} />
|
||||
</TextInput>
|
||||
<Button
|
||||
type="submit"
|
||||
variant={vm.archivedAt ? "secondary" : "destructive"}
|
||||
loading={submitting}
|
||||
icon={vm.archivedAt ? <FeatherRotateCcw /> : <FeatherArchive />}
|
||||
>
|
||||
{t(vm.archivedAt ? "admin.platformLeads.actions.restore" : "admin.platformLeads.actions.archive")}
|
||||
</Button>
|
||||
</form>
|
||||
</>
|
||||
) : (
|
||||
<EmptyState outlined title={t("admin.platformLeads.detail.processing")} body={t("admin.platformLeads.errors.noWritePermission")} />
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.activity")} />
|
||||
{vm.activities.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.empty.activities")} body={t("admin.platformLeads.detailDescription")} />
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
{vm.activities.map((activity) => (
|
||||
<div
|
||||
key={activity.id}
|
||||
className="border-border-default bg-surface-neutral-primary mobile:flex-col flex w-full items-start justify-between gap-4 rounded-md border border-solid px-4 py-4"
|
||||
>
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(activity.labelKey)}</span>
|
||||
{activity.note ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary whitespace-pre-wrap">
|
||||
{activity.note}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{activity.actorLabel || t("admin.platformLeads.activity.system")}
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatters.dateTime(activity.createdAt)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionTitle({ title }: { title: string }): React.JSX.Element {
|
||||
return <span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{title}</span>;
|
||||
}
|
||||
|
||||
function DefinitionGrid({ rows }: { rows: readonly (readonly [string, string | null])[] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<dl className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
{rows.map(([label, value]) => (
|
||||
<div key={label} className="flex min-w-0 flex-col items-start gap-1">
|
||||
<dt className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">{label}</dt>
|
||||
<dd className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary max-w-full break-words">
|
||||
{value || t("shared.notSet")}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
|
||||
function QuickLeadAction({
|
||||
csrf,
|
||||
intent,
|
||||
reason,
|
||||
label,
|
||||
submitting,
|
||||
onSubmit,
|
||||
}: {
|
||||
readonly csrf: string;
|
||||
readonly intent: "score" | "auto-assign" | "detect-duplicates";
|
||||
readonly reason: string;
|
||||
readonly label: string;
|
||||
readonly submitting: boolean;
|
||||
readonly onSubmit: PlatformLeadFormAction;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value={intent} />
|
||||
<input type="hidden" name="reason" value={reason} />
|
||||
<Button type="submit" size="small" variant="secondary" loading={submitting}>
|
||||
{label}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import { FeatherArrowLeft, FeatherPlus } from "@subframe/core";
|
||||
import type { AdminLeadOption } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadNewPageProps = {
|
||||
readonly sourceOptions: readonly AdminLeadOption[];
|
||||
readonly assigneeOptions: readonly AdminLeadOption[];
|
||||
readonly csrf: string;
|
||||
readonly submitting: boolean;
|
||||
readonly error?: string;
|
||||
readonly actions: {
|
||||
readonly onBack: () => void;
|
||||
readonly onCreate: PlatformLeadFormAction;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S02: manual lead intake through the shared domain service. */
|
||||
export function AdminPlatformLeadNewPage({
|
||||
sourceOptions,
|
||||
assigneeOptions,
|
||||
csrf,
|
||||
submitting,
|
||||
error,
|
||||
actions,
|
||||
}: AdminPlatformLeadNewPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.new" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start gap-3 border-b border-solid px-6 py-5">
|
||||
<Breadcrumbs>
|
||||
<Link to={adminPath("leads", { mode: "host-aware" })}>
|
||||
<Breadcrumbs.Item>{t("admin.platformLeads.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{t("admin.platformLeads.actions.new")}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="flex w-full items-start gap-4">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.platformLeads.newTitle")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.platformLeads.newDescription")}</p>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" icon={<FeatherArrowLeft />} onClick={actions.onBack}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mobile:px-4 flex w-full max-w-[960px] flex-col items-start gap-6 px-6 py-6">
|
||||
{error ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{error}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
<Card>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onCreate)} className="flex w-full flex-col items-start gap-6">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
<Select
|
||||
name="sourceId"
|
||||
required
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.source")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.source")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.fields.source")}
|
||||
>
|
||||
{sourceOptions.map((source) => (
|
||||
<Select.Item key={source.id} value={source.id}>
|
||||
{source.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="assignedToAdminUserId"
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.unassigned")}
|
||||
>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{assigneeOptions.map((assignee) => (
|
||||
<Select.Item key={assignee.id} value={assignee.id}>
|
||||
{assignee.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.firstName")} fillContainer>
|
||||
<TextInput.Input name="firstName" autoComplete="given-name" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.lastName")} fillContainer>
|
||||
<TextInput.Input name="lastName" autoComplete="family-name" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.email")} fillContainer>
|
||||
<TextInput.Input name="email" type="email" autoComplete="email" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.phone")} fillContainer>
|
||||
<TextInput.Input name="phone" type="tel" autoComplete="tel" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.company")} fillContainer>
|
||||
<TextInput.Input name="company" autoComplete="organization" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.sourceDetail")} fillContainer>
|
||||
<TextInput.Input name="sourceDetail" />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextArea showLabel label={t("admin.platformLeads.fields.message")} className="max-w-none">
|
||||
<TextArea.Input name="message" />
|
||||
</TextArea>
|
||||
<div className="flex w-full justify-end gap-2">
|
||||
<Button type="button" variant="ghost" onClick={actions.onBack}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherPlus />}>
|
||||
{t("admin.platformLeads.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
import { FeatherArrowLeft, FeatherKey, FeatherPlus, FeatherRefreshCw, FeatherSave, FeatherSlash } from "@subframe/core";
|
||||
import type { AdminLeadOption, AdminLeadSourcesVM } from "@hivegrid/view-models";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadSourcesPageProps = {
|
||||
readonly vm: AdminLeadSourcesVM;
|
||||
readonly csrf: string;
|
||||
readonly submitting: boolean;
|
||||
readonly feedback?: { readonly success?: string; readonly error?: string };
|
||||
readonly actions: {
|
||||
readonly onBack: () => void;
|
||||
readonly onSubmit: PlatformLeadFormAction;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S04: source routing and one-time credential administration. */
|
||||
export function AdminPlatformLeadSourcesPage({ vm, csrf, submitting, feedback, actions }: AdminPlatformLeadSourcesPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.sources" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start gap-3 border-b border-solid px-6 py-5">
|
||||
<Breadcrumbs>
|
||||
<Link to={adminPath("leads", { mode: "host-aware" })}>
|
||||
<Breadcrumbs.Item>{t("admin.platformLeads.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{t("admin.platformLeads.sources.title")}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="flex w-full items-start gap-4">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.platformLeads.sources.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.platformLeads.sources.description")}</p>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" icon={<FeatherArrowLeft />} onClick={actions.onBack}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{feedback?.success ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{feedback.success}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{feedback?.error ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{feedback.error}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{vm.revealedCredential ? (
|
||||
<BannerAlert type="warning" fillContainer>
|
||||
<span className="font-body-default-semibold-0">{t("admin.platformLeads.sources.revealedTitle")}</span>
|
||||
<span>{t("admin.platformLeads.sources.revealedBody")}</span>
|
||||
<TextInput fillContainer>
|
||||
<TextInput.Input value={vm.revealedCredential.plaintext} readOnly aria-label={t("admin.platformLeads.fields.sourceKey")} />
|
||||
</TextInput>
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
{vm.canAdmin ? (
|
||||
<Card>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.platformLeads.actions.createSource")}</span>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="mobile:grid-cols-1 grid w-full grid-cols-4 items-end gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="create-source" />
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.sourceKey")} fillContainer>
|
||||
<TextInput.Input name="key" required pattern="[a-z0-9]+(?:-[a-z0-9]+)*" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.sourceName")} fillContainer>
|
||||
<TextInput.Input name="displayName" required />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.rateLimit")} fillContainer>
|
||||
<TextInput.Input name="rateLimitPerMinute" type="number" min={1} max={10000} defaultValue="60" required />
|
||||
</TextInput>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherPlus />}>
|
||||
{t("admin.platformLeads.actions.createSource")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{vm.rows.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.empty.sourcesTitle")} body={t("admin.platformLeads.empty.sourcesBody")} />
|
||||
) : (
|
||||
vm.rows.map((source) => (
|
||||
<SourceCard
|
||||
key={source.id}
|
||||
source={source}
|
||||
assignees={vm.assigneeOptions}
|
||||
csrf={csrf}
|
||||
submitting={submitting}
|
||||
canAdmin={vm.canAdmin}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SourceCard({
|
||||
source,
|
||||
assignees,
|
||||
csrf,
|
||||
submitting,
|
||||
canAdmin,
|
||||
onSubmit,
|
||||
}: {
|
||||
source: AdminLeadSourcesVM["rows"][number];
|
||||
assignees: readonly AdminLeadOption[];
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
canAdmin: boolean;
|
||||
onSubmit: PlatformLeadFormAction;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<Card>
|
||||
<div className="mobile:flex-col flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{source.displayName}</span>
|
||||
<BadgeFeedback farbe={source.enabled ? "subtle-positive" : "subtle-neutral"}>
|
||||
{t(source.enabled ? "admin.platformLeads.sources.enabled" : "admin.platformLeads.sources.disabled")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<span className="font-monospace-body text-body-small-regular-0 text-text-neutral-tertiary">{source.key}</span>
|
||||
</div>
|
||||
{canAdmin ? (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="set-enabled" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="enabled" value={source.enabled ? "false" : "true"} />
|
||||
<input type="hidden" name="reason" value={source.enabled ? "Platform lead source disabled" : "Platform lead source enabled"} />
|
||||
<Button type="submit" variant={source.enabled ? "destructive" : "secondary"} loading={submitting} icon={<FeatherSlash />}>
|
||||
{t(source.enabled ? "admin.platformLeads.actions.disable" : "admin.platformLeads.actions.enable")}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-3 gap-4">
|
||||
<Metric label={t("admin.platformLeads.sources.leadCount")} value={String(source.leadCount)} />
|
||||
<Metric label={t("admin.platformLeads.sources.activeCredentials")} value={String(source.activeCredentialCount)} />
|
||||
<Metric label={t("admin.platformLeads.fields.rateLimit")} value={String(source.rateLimitPerMinute)} />
|
||||
</div>
|
||||
{canAdmin ? (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="update-routing" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source routing updated" />
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-3 gap-4">
|
||||
<Select
|
||||
name="defaultAssigneeAdminUserId"
|
||||
defaultValue={source.defaultAssigneeAdminUserId ?? "unassigned"}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{assignees.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.rateLimit")} fillContainer>
|
||||
<TextInput.Input name="rateLimitPerMinute" type="number" min={1} max={10000} defaultValue={String(source.rateLimitPerMinute)} required />
|
||||
</TextInput>
|
||||
<RecipientCheckboxes options={assignees} initial={source.notifyAdminUserIds} />
|
||||
</div>
|
||||
<Button type="submit" variant="secondary" loading={submitting} icon={<FeatherSave />}>
|
||||
{t("admin.platformLeads.actions.updateRouting")}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">
|
||||
{t("admin.platformLeads.sources.credentials")}
|
||||
</span>
|
||||
{canAdmin ? (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="create-credential" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source credential created" />
|
||||
<Button type="submit" size="small" loading={submitting} icon={<FeatherKey />}>
|
||||
{t("admin.platformLeads.actions.createCredential")}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
</div>
|
||||
{source.credentials.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.sources.credentials")} body={t("admin.platformLeads.empty.sourcesBody")} />
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.sources.prefix")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.sources.expiresAt")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.sources.lastUsedAt")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("shared.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell />
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{source.credentials.map((credential) => (
|
||||
<Table.Row key={credential.id}>
|
||||
<Table.Cell>{credential.keyPrefix}</Table.Cell>
|
||||
<Table.Cell>{credential.expiresAt ? formatters.dateTime(credential.expiresAt) : t("shared.notSet")}</Table.Cell>
|
||||
<Table.Cell>{credential.lastUsedAt ? formatters.dateTime(credential.lastUsedAt) : t("admin.platformLeads.sources.neverUsed")}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={credential.revokedAt ? "subtle-negative" : "subtle-positive"} size="small">
|
||||
{credential.revokedAt ? t("admin.platformLeads.sources.revokedAt") : t("admin.platformLeads.sources.enabled")}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{canAdmin && !credential.revokedAt ? (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="rotate-credential" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="credentialId" value={credential.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source credential rotated" />
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting} icon={<FeatherRefreshCw />}>
|
||||
{t("admin.platformLeads.actions.rotateCredential")}
|
||||
</Button>
|
||||
</form>
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="revoke-credential" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="credentialId" value={credential.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source credential revoked" />
|
||||
<Button type="submit" variant="destructive" size="small" loading={submitting}>
|
||||
{t("admin.platformLeads.actions.revokeCredential")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function RecipientCheckboxes({ options, initial }: { options: readonly AdminLeadOption[]; initial: readonly string[] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [selected, setSelected] = useState<readonly string[]>(initial);
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">{t("admin.platformLeads.fields.notifyUsers")}</span>
|
||||
{selected.map((id) => (
|
||||
<input key={id} type="hidden" name="notifyAdminUserIds" value={id} />
|
||||
))}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{options.map((option) => (
|
||||
<Checkbox
|
||||
key={option.id}
|
||||
checked={selected.includes(option.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
setSelected((current) => (checked ? [...new Set([...current, option.id])] : current.filter((id) => id !== option.id)))
|
||||
}
|
||||
label={option.label}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Metric({ label, value }: { label: string; value: string }): React.JSX.Element {
|
||||
return (
|
||||
<div className="border-border-default bg-surface-neutral-primary flex flex-col items-start gap-1 rounded-md border border-solid px-4 py-3">
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{label}</span>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{value}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FeatherArchive, FeatherCheckCircle, FeatherInbox, FeatherPlus, FeatherSettings, FeatherUserX } from "@subframe/core";
|
||||
import type { AdminLeadListVM, AdminLeadStatus } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { LIVE_FILTER_DEBOUNCE_MS } from "~/hooks/use-live-filter";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadsPageProps = {
|
||||
readonly vm: AdminLeadListVM;
|
||||
readonly loading?: boolean;
|
||||
readonly actions: {
|
||||
readonly onApplyFilters: PlatformLeadFormAction;
|
||||
readonly onFirstPage: () => void;
|
||||
readonly onNew: () => void;
|
||||
readonly onNextPage: (cursor: string) => void;
|
||||
readonly onReset: () => void;
|
||||
readonly onSources: () => void;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S01: app-chrome-free platform lead inbox interim screen. */
|
||||
export function AdminPlatformLeadsPage({ vm, loading = false, actions }: AdminPlatformLeadsPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
|
||||
// Live filter on the uncontrolled form: selects resubmit immediately (next
|
||||
// tick, so the hidden native select carries the fresh value), the search
|
||||
// input debounced.
|
||||
const filterFormRef = useRef<HTMLFormElement | null>(null);
|
||||
const filterDebounceRef = useRef<number | null>(null);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (filterDebounceRef.current) window.clearTimeout(filterDebounceRef.current);
|
||||
};
|
||||
}, []);
|
||||
function scheduleFilterSubmit(delayMs: number): void {
|
||||
if (filterDebounceRef.current) window.clearTimeout(filterDebounceRef.current);
|
||||
filterDebounceRef.current = window.setTimeout(() => filterFormRef.current?.requestSubmit(), delayMs);
|
||||
}
|
||||
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.list" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full items-start gap-4 border-b border-solid px-6 py-5">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.platformLeads.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("admin.platformLeads.description")}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{vm.permissions.canAdminSources ? (
|
||||
<Button type="button" variant="tertiary" icon={<FeatherSettings />} onClick={actions.onSources}>
|
||||
{t("admin.platformLeads.actions.sources")}
|
||||
</Button>
|
||||
) : null}
|
||||
{vm.permissions.canCreate ? (
|
||||
<Button type="button" icon={<FeatherPlus />} onClick={actions.onNew}>
|
||||
{t("admin.platformLeads.actions.new")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{loading ? (
|
||||
<BannerAlert type="information" fillContainer>
|
||||
<span aria-live="polite">{t("admin.platformLeads.loading")}</span>
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-5 gap-4">
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.total")}
|
||||
value={vm.summary.total}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherInbox />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.new")}
|
||||
value={vm.summary.newCount}
|
||||
trend={vm.summary.newCount ? "negative" : "positive"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherInbox />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.qualified")}
|
||||
value={vm.summary.qualifiedCount}
|
||||
trend="positive"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherCheckCircle />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.unassigned")}
|
||||
value={vm.summary.unassignedCount}
|
||||
trend={vm.summary.unassignedCount ? "negative" : "positive"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherUserX />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.archived")}
|
||||
value={vm.summary.archivedCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherArchive />}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<form ref={filterFormRef} onSubmit={platformLeadFormHandler(actions.onApplyFilters)} className="flex w-full flex-wrap items-end gap-4">
|
||||
<TextInput type="search" showLabel label={t("admin.platformLeads.fields.search")}>
|
||||
<TextInput.Input
|
||||
name="q"
|
||||
type="search"
|
||||
defaultValue={vm.filters.query}
|
||||
placeholder={t("admin.platformLeads.fields.searchPlaceholder")}
|
||||
onChange={() => scheduleFilterSubmit(LIVE_FILTER_DEBOUNCE_MS)}
|
||||
/>
|
||||
</TextInput>
|
||||
<Select
|
||||
name="status"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.status}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.status")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.status")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.all")}
|
||||
variant="filled"
|
||||
>
|
||||
<Select.Item value="all">{t("admin.platformLeads.filters.all")}</Select.Item>
|
||||
{(["new", "contacted", "qualified", "disqualified"] as const).map((status) => (
|
||||
<Select.Item key={status} value={status}>
|
||||
{t(`admin.platformLeads.status.${status}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="sourceId"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.sourceId}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.source")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.source")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.all")}
|
||||
variant="filled"
|
||||
>
|
||||
<Select.Item value="all">{t("admin.platformLeads.filters.all")}</Select.Item>
|
||||
{vm.sourceOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="assignee"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.assignedToAdminUserId}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.all")}
|
||||
variant="filled"
|
||||
>
|
||||
<Select.Item value="all">{t("admin.platformLeads.filters.all")}</Select.Item>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{vm.assigneeOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="archive"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.archive}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.archive")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.archive")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.archive.active")}
|
||||
variant="filled"
|
||||
>
|
||||
{(["active", "archived", "all"] as const).map((archive) => (
|
||||
<Select.Item key={archive} value={archive}>
|
||||
{t(`admin.platformLeads.archive.${archive}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button type="button" variant="ghost" onClick={actions.onReset}>
|
||||
{t("admin.platformLeads.actions.reset")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
{vm.rows.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.empty.title")} body={t("admin.platformLeads.empty.body")} />
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.lead")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.source")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.assignee")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.capturedAt")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{vm.rows.map((lead) => (
|
||||
<Table.Row key={lead.id}>
|
||||
<Table.Cell>
|
||||
<Link className="flex min-w-0 flex-col items-start" to={adminPath(`leads/${lead.id}`, { mode: "host-aware" })}>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary max-w-80 truncate">
|
||||
{lead.displayName || t("shared.notSet")}
|
||||
</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary max-w-80 truncate">
|
||||
{[lead.company, lead.contactLine].filter(Boolean).join(" · ") || t("shared.notSet")}
|
||||
</span>
|
||||
</Link>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{lead.sourceDisplayName}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={lead.statusTone} size="small">
|
||||
{t(lead.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{lead.archivedAt ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("admin.platformLeads.archive.archived")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
{lead.duplicateHintOfLeadId ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("admin.platformLeads.detail.duplicateHint")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{lead.assigneeLabel || t("admin.platformLeads.filters.unassigned")}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatters.dateTime(lead.capturedAt)}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
{vm.pagination.hasPrevious || vm.pagination.nextCursor ? (
|
||||
<nav className="flex w-full items-center justify-end gap-2" aria-label={t("admin.platformLeads.pagination.label")}>
|
||||
{vm.pagination.hasPrevious ? (
|
||||
<Button type="button" variant="ghost" onClick={actions.onFirstPage}>
|
||||
{t("admin.platformLeads.pagination.first")}
|
||||
</Button>
|
||||
) : null}
|
||||
{vm.pagination.nextCursor ? (
|
||||
<Button type="button" variant="secondary" onClick={() => actions.onNextPage(vm.pagination.nextCursor!)}>
|
||||
{t("admin.platformLeads.pagination.next")}
|
||||
</Button>
|
||||
) : null}
|
||||
</nav>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function isAdminLeadStatus(value: string): value is AdminLeadStatus {
|
||||
return ["new", "contacted", "qualified", "disqualified"].includes(value);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`R-LEADS interim visual baseline > renders list, manual intake, detail and source administration from VM props 1`] = `"<main data-ui-id="ui.admin.platformLeads.interim.visualBaseline"><div data-ui-id="ui.admin.platformLeads.list" class="bg-surface-neutral-primary flex w-full flex-col items-start"><header class="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full items-start gap-4 border-b border-solid px-6 py-5"><div class="flex shrink-0 grow basis-0 flex-col items-start"><h1 class="text-subtitle font-subtitle text-text-neutral-primary">admin.platformLeads.title</h1><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">admin.platformLeads.description</p></div><div class="flex flex-wrap items-center justify-end gap-2"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.platformLeads.actions.sources</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.platformLeads.actions.new</span></button></div></header><div class="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6"><div class="mobile:grid-cols-1 grid w-full grid-cols-5 gap-4"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.platformLeads.metrics.total</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visLine truncated
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
import { buildAdminLeadListVM } from "@hivegrid/view-models";
|
||||
import { createInstance } from "i18next";
|
||||
import { I18nextProvider, initReactI18next } from "react-i18next";
|
||||
import { MemoryRouter } from "react-router";
|
||||
|
||||
import deTranslations from "../../../../../public/locales/de/translations.json";
|
||||
|
||||
import { AdminPlatformLeadsPage } from "./AdminPlatformLeadsPage";
|
||||
|
||||
const visualI18n = createInstance();
|
||||
void visualI18n.use(initReactI18next).init({
|
||||
lng: "de",
|
||||
fallbackLng: "de",
|
||||
defaultNS: "translation",
|
||||
resources: { de: { translation: deTranslations } },
|
||||
interpolation: { escapeValue: false },
|
||||
initImmediate: false,
|
||||
});
|
||||
|
||||
export function createPlatformLeadsInterimVisualVM() {
|
||||
return buildAdminLeadListVM({
|
||||
rows: [
|
||||
{
|
||||
id: "lead_visual_1",
|
||||
firstName: "Petra",
|
||||
lastName: "Muster",
|
||||
email: "petra@example.test",
|
||||
phone: "+49 30 123456",
|
||||
company: "Muster SHK GmbH",
|
||||
status: "new",
|
||||
sourceId: "source_hivegrid",
|
||||
sourceDisplayName: "HiveGrid Website",
|
||||
assignedToAdminUserId: "operator_haris",
|
||||
assigneeLabel: "Haris Vertrieb",
|
||||
duplicateHintOfLeadId: null,
|
||||
capturedAt: "2026-07-16T06:00:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
{
|
||||
id: "lead_visual_2",
|
||||
firstName: "Noah",
|
||||
lastName: "Geerkens",
|
||||
email: "noah@example.test",
|
||||
phone: null,
|
||||
company: "Geerkens GmbH",
|
||||
status: "qualified",
|
||||
sourceId: "source_partner",
|
||||
sourceDisplayName: "Partner-Empfehlung",
|
||||
assignedToAdminUserId: null,
|
||||
assigneeLabel: null,
|
||||
duplicateHintOfLeadId: "lead_visual_duplicate",
|
||||
capturedAt: "2026-07-15T14:30:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
],
|
||||
sourceOptions: [
|
||||
{ id: "source_hivegrid", label: "HiveGrid Website" },
|
||||
{ id: "source_partner", label: "Partner-Empfehlung" },
|
||||
],
|
||||
assigneeOptions: [{ id: "operator_haris", label: "Haris Vertrieb" }],
|
||||
filters: {
|
||||
query: "",
|
||||
status: "all",
|
||||
sourceId: "all",
|
||||
assignedToAdminUserId: "all",
|
||||
archive: "active",
|
||||
},
|
||||
summary: { total: 31, newCount: 12, qualifiedCount: 8, unassignedCount: 5, archivedCount: 3 },
|
||||
pagination: { hasPrevious: false, nextCursor: "lead_visual_next" },
|
||||
permissions: { canCreate: true, canWrite: true, canAdminSources: true },
|
||||
});
|
||||
}
|
||||
|
||||
const noOp = (): void => undefined;
|
||||
|
||||
/** Shared AD-28 fixture for the R-LEADS Chromium pixel baseline. */
|
||||
export function PlatformLeadsInterimVisualFixture(): React.JSX.Element {
|
||||
return (
|
||||
<I18nextProvider i18n={visualI18n}>
|
||||
<MemoryRouter initialEntries={["/leads"]}>
|
||||
<AdminPlatformLeadsPage
|
||||
vm={createPlatformLeadsInterimVisualVM()}
|
||||
actions={{
|
||||
onApplyFilters: noOp,
|
||||
onFirstPage: noOp,
|
||||
onNew: noOp,
|
||||
onNextPage: noOp,
|
||||
onReset: noOp,
|
||||
onSources: noOp,
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
</I18nextProvider>
|
||||
);
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { buildAdminLeadDetailVM, buildAdminLeadListVM, buildAdminLeadSourcesVM } from "@hivegrid/view-models";
|
||||
import { createMemoryRouter, RouterProvider } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminPlatformLeadDetailPage } from "./AdminPlatformLeadDetailPage";
|
||||
import { AdminPlatformLeadNewPage } from "./AdminPlatformLeadNewPage";
|
||||
import { AdminPlatformLeadsPage } from "./AdminPlatformLeadsPage";
|
||||
import { AdminPlatformLeadSourcesPage } from "./AdminPlatformLeadSourcesPage";
|
||||
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
class ResizeObserverMock {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
);
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
vi.mock("~/locale/format", () => ({
|
||||
useLocaleFormatters: () => ({ dateTime: (value: string | Date) => String(value) }),
|
||||
}));
|
||||
|
||||
const assignees = [{ id: "operator_haris", label: "Haris Vertrieb" }];
|
||||
const sources = [{ id: "source_hivegrid", label: "HiveGrid Website" }];
|
||||
|
||||
describe("R-LEADS interim visual baseline", () => {
|
||||
it("renders list, manual intake, detail and source administration from VM props", () => {
|
||||
const listVm = buildAdminLeadListVM({
|
||||
rows: [
|
||||
{
|
||||
id: "lead_1",
|
||||
firstName: "Petra",
|
||||
lastName: "Muster",
|
||||
email: "petra@example.test",
|
||||
phone: "+49 30 123456",
|
||||
company: "Muster SHK GmbH",
|
||||
status: "new",
|
||||
sourceId: "source_hivegrid",
|
||||
sourceDisplayName: "HiveGrid Website",
|
||||
assignedToAdminUserId: "operator_haris",
|
||||
assigneeLabel: "Haris Vertrieb",
|
||||
duplicateHintOfLeadId: null,
|
||||
capturedAt: "2026-07-16T06:00:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
],
|
||||
sourceOptions: sources,
|
||||
assigneeOptions: assignees,
|
||||
permissions: { canCreate: true, canWrite: true, canAdminSources: true },
|
||||
});
|
||||
const detailVm = buildAdminLeadDetailVM({
|
||||
lead: {
|
||||
id: "lead_1",
|
||||
firstName: "Petra",
|
||||
lastName: "Muster",
|
||||
email: "petra@example.test",
|
||||
phone: "+49 30 123456",
|
||||
company: "Muster SHK GmbH",
|
||||
message: "Wir interessieren uns für HiveGrid.",
|
||||
status: "new",
|
||||
sourceId: "source_hivegrid",
|
||||
sourceDisplayName: "HiveGrid Website",
|
||||
sourceDetail: "Kontaktformular",
|
||||
externalId: "submission_1",
|
||||
assignedToAdminUserId: "operator_haris",
|
||||
assigneeLabel: "Haris Vertrieb",
|
||||
duplicateHintOfLeadId: null,
|
||||
capturedAt: "2026-07-16T06:00:00.000Z",
|
||||
createdAt: "2026-07-16T06:00:00.000Z",
|
||||
updatedAt: "2026-07-16T06:00:00.000Z",
|
||||
archivedAt: null,
|
||||
attribution: {
|
||||
utmSource: "messe",
|
||||
utmMedium: "qr",
|
||||
utmCampaign: "mhk-berlin",
|
||||
utmTerm: null,
|
||||
utmContent: null,
|
||||
referrer: "https://example.test/",
|
||||
landingPage: "https://hivegrid.de/demo",
|
||||
},
|
||||
qualification: {
|
||||
score: 70,
|
||||
scoreBand: "hot",
|
||||
scoreVersion: 1,
|
||||
enrichmentStatus: "complete",
|
||||
enrichmentProvider: "fixture",
|
||||
enrichmentData: { industry: "SHK", region: "DACH" },
|
||||
enrichedAt: "2026-07-16T06:10:00.000Z",
|
||||
},
|
||||
duplicateCandidates: [],
|
||||
conversion: { companyId: null, contactId: null, dealId: null },
|
||||
activities: [
|
||||
{
|
||||
id: "activity_1",
|
||||
type: "captured",
|
||||
actorAdminUserId: null,
|
||||
actorLabel: null,
|
||||
note: null,
|
||||
createdAt: "2026-07-16T06:00:00.000Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
assigneeOptions: assignees,
|
||||
permissions: { canWrite: true, canAssign: true, canMerge: true },
|
||||
});
|
||||
const sourceVm = buildAdminLeadSourcesVM({
|
||||
rows: [
|
||||
{
|
||||
id: "source_hivegrid",
|
||||
key: "hivegrid-website",
|
||||
displayName: "HiveGrid Website",
|
||||
enabled: true,
|
||||
defaultAssigneeAdminUserId: "operator_haris",
|
||||
defaultAssigneeLabel: "Haris Vertrieb",
|
||||
notifyAdminUserIds: ["operator_haris"],
|
||||
notifyAdminUserLabels: ["Haris Vertrieb"],
|
||||
rateLimitPerMinute: 60,
|
||||
leadCount: 30,
|
||||
credentials: [
|
||||
{
|
||||
id: "credential_1",
|
||||
keyPrefix: "hgpls_demo",
|
||||
createdAt: "2026-07-16T06:00:00.000Z",
|
||||
expiresAt: null,
|
||||
revokedAt: null,
|
||||
lastUsedAt: "2026-07-16T06:05:00.000Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
assigneeOptions: assignees,
|
||||
canAdmin: true,
|
||||
now: "2026-07-16T12:00:00.000Z",
|
||||
revealedCredential: { sourceId: "source_hivegrid", plaintext: "shown-exactly-once" },
|
||||
});
|
||||
|
||||
const router = createMemoryRouter(
|
||||
[
|
||||
{
|
||||
path: "*",
|
||||
element: (
|
||||
<main data-ui-id="ui.admin.platformLeads.interim.visualBaseline">
|
||||
<AdminPlatformLeadsPage
|
||||
vm={listVm}
|
||||
actions={{
|
||||
onApplyFilters: () => undefined,
|
||||
onFirstPage: () => undefined,
|
||||
onNew: () => undefined,
|
||||
onNextPage: () => undefined,
|
||||
onReset: () => undefined,
|
||||
onSources: () => undefined,
|
||||
}}
|
||||
/>
|
||||
<AdminPlatformLeadNewPage
|
||||
sourceOptions={sources}
|
||||
assigneeOptions={assignees}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
actions={{ onBack: () => undefined, onCreate: () => undefined }}
|
||||
/>
|
||||
<AdminPlatformLeadDetailPage
|
||||
vm={detailVm}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
actions={{ onBack: () => undefined, onSubmit: () => undefined }}
|
||||
/>
|
||||
<AdminPlatformLeadSourcesPage
|
||||
vm={sourceVm}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
actions={{ onBack: () => undefined, onSubmit: () => undefined }}
|
||||
/>
|
||||
</main>
|
||||
),
|
||||
},
|
||||
],
|
||||
{ initialEntries: ["/leads"] }
|
||||
);
|
||||
const { container } = render(<RouterProvider router={router} />);
|
||||
|
||||
expect(container.querySelectorAll("[data-ui-id^='ui.admin.platformLeads.']")).toHaveLength(5);
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { platformLeadFormHandler } from "./platformLeadForm";
|
||||
|
||||
describe("platformLeadFormHandler", () => {
|
||||
it("hands the complete form payload to the route-owned action callback", () => {
|
||||
const action = vi.fn();
|
||||
const { container } = render(
|
||||
<form onSubmit={platformLeadFormHandler(action)}>
|
||||
<input name="intent" value="status" readOnly />
|
||||
<input name="reason" value="verified reason" readOnly />
|
||||
</form>
|
||||
);
|
||||
|
||||
const form = container.querySelector("form");
|
||||
expect(form).not.toBeNull();
|
||||
fireEvent.submit(form!);
|
||||
|
||||
expect(action).toHaveBeenCalledOnce();
|
||||
expect(Object.fromEntries((action.mock.calls[0]?.[0] as FormData).entries())).toEqual({ intent: "status", reason: "verified reason" });
|
||||
});
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import type { FormEventHandler } from "react";
|
||||
|
||||
export type PlatformLeadFormAction = (input: FormData) => void;
|
||||
|
||||
/** Keeps React Router submission inside the route while screens stay presentational. */
|
||||
export function platformLeadFormHandler(action: PlatformLeadFormAction): FormEventHandler<HTMLFormElement> {
|
||||
return (event) => {
|
||||
event.preventDefault();
|
||||
action(new FormData(event.currentTarget));
|
||||
};
|
||||
}
|
||||
+62
@@ -0,0 +1,62 @@
|
||||
import "@testing-library/jest-dom";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
let mockedPermissions = ["admin.metrics.view"];
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (value: string) => value }),
|
||||
}));
|
||||
|
||||
vi.mock("~/utils/data/useAdminData", () => ({
|
||||
useAdminData: () => ({
|
||||
isSuperAdmin: false,
|
||||
permissions: mockedPermissions,
|
||||
}),
|
||||
}));
|
||||
|
||||
import { AdminOperationsShell } from "./AdminOperationsShell";
|
||||
|
||||
function expectOperationsLink(name: RegExp, href: string) {
|
||||
expect(screen.getAllByRole("link", { name }).some((link) => link.getAttribute("href") === href)).toBe(true);
|
||||
}
|
||||
|
||||
describe("AdminOperationsShell", () => {
|
||||
afterEach(() => {
|
||||
mockedPermissions = ["admin.metrics.view"];
|
||||
});
|
||||
|
||||
it("shows the overview and technical operation routes for metrics access", () => {
|
||||
render(
|
||||
<MemoryRouter initialEntries={["/system"]}>
|
||||
<AdminOperationsShell>
|
||||
<div>content</div>
|
||||
</AdminOperationsShell>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expectOperationsLink(/shared\.overview/, "/system");
|
||||
expectOperationsLink(/admin\.health\.subsystems\.system\.label/, "/system/health");
|
||||
expectOperationsLink(/admin\.health\.subsystems\.deploy\.label/, "/system/deploys");
|
||||
expectOperationsLink(/admin\.health\.subsystems\.queues\.label/, "/system/jobs");
|
||||
expect(screen.queryByRole("link", { name: /admin\.health\.subsystems\.webhooks\.label/ })).not.toBeInTheDocument();
|
||||
expect(screen.queryByRole("link", { name: /admin\.health\.subsystems\.billing\.label/ })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows Webhook Inbox and Billing-Sync only with their matching permissions", () => {
|
||||
mockedPermissions = ["admin.events.view", "admin.account.subscription"];
|
||||
|
||||
render(
|
||||
<MemoryRouter initialEntries={["/system/webhooks"]}>
|
||||
<AdminOperationsShell>
|
||||
<div>content</div>
|
||||
</AdminOperationsShell>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expectOperationsLink(/admin\.health\.subsystems\.webhooks\.label/, "/system/webhooks");
|
||||
expectOperationsLink(/admin\.health\.subsystems\.billing\.label/, "/system/billing");
|
||||
expect(screen.queryByRole("link", { name: /shared\.overview/ })).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import {
|
||||
FeatherActivity,
|
||||
FeatherCreditCard,
|
||||
FeatherHeartPulse,
|
||||
FeatherRadioTower,
|
||||
FeatherRocket,
|
||||
FeatherServer,
|
||||
} from "@subframe/core";
|
||||
|
||||
import type { DefaultPermission } from "~/application/dtos/shared/DefaultPermissions";
|
||||
import SidebarIconsLayout, { type IconDto } from "~/components/ui/layouts/SidebarIconsLayout";
|
||||
import { ADMIN_AREA_ACCESS } from "~/services/admin/admin-access-contract";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { useAdminData } from "~/utils/data/useAdminData";
|
||||
import { getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
|
||||
type AdminOperationsNavigationItem = IconDto & {
|
||||
permission: DefaultPermission;
|
||||
};
|
||||
|
||||
function identifiedIcon(id: string, icon: ReactNode): ReactNode {
|
||||
return <span data-ui-id={id}>{icon}</span>;
|
||||
}
|
||||
|
||||
export function AdminOperationsShell({ children }: { children: ReactNode }) {
|
||||
const { t } = useTranslation();
|
||||
const adminData = useAdminData();
|
||||
const routePath = (path: string) => adminPath(path, { mode: "host-aware" });
|
||||
|
||||
const items: AdminOperationsNavigationItem[] = [
|
||||
{
|
||||
name: t("shared.overview"),
|
||||
href: routePath("system"),
|
||||
exact: true,
|
||||
icon: identifiedIcon("ui.nav.admin.operations.overview", <FeatherActivity className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.operations.overview", <FeatherActivity className="size-5" aria-hidden="true" />),
|
||||
permission: ADMIN_AREA_ACCESS.health,
|
||||
},
|
||||
{
|
||||
name: t("admin.health.subsystems.system.label"),
|
||||
href: routePath("system/health"),
|
||||
icon: identifiedIcon("ui.nav.admin.operations.system", <FeatherServer className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.operations.system", <FeatherServer className="size-5" aria-hidden="true" />),
|
||||
permission: ADMIN_AREA_ACCESS.system,
|
||||
},
|
||||
{
|
||||
name: t("admin.health.subsystems.deploy.label"),
|
||||
href: routePath("system/deploys"),
|
||||
icon: identifiedIcon("ui.nav.admin.operations.deploys", <FeatherRocket className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.operations.deploys", <FeatherRocket className="size-5" aria-hidden="true" />),
|
||||
permission: ADMIN_AREA_ACCESS.deploys,
|
||||
},
|
||||
{
|
||||
name: t("admin.health.subsystems.queues.label"),
|
||||
href: routePath("system/jobs"),
|
||||
icon: identifiedIcon("ui.nav.admin.operations.jobs", <FeatherRadioTower className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.operations.jobs", <FeatherRadioTower className="size-5" aria-hidden="true" />),
|
||||
permission: ADMIN_AREA_ACCESS.jobs,
|
||||
},
|
||||
{
|
||||
name: t("admin.health.subsystems.webhooks.label"),
|
||||
href: routePath("system/webhooks"),
|
||||
icon: identifiedIcon("ui.nav.admin.operations.webhooks", <FeatherHeartPulse className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.operations.webhooks", <FeatherHeartPulse className="size-5" aria-hidden="true" />),
|
||||
permission: "admin.events.view",
|
||||
},
|
||||
{
|
||||
name: t("admin.health.subsystems.billing.label"),
|
||||
href: routePath("system/billing"),
|
||||
icon: identifiedIcon("ui.nav.admin.operations.billing", <FeatherCreditCard className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.operations.billing", <FeatherCreditCard className="size-5" aria-hidden="true" />),
|
||||
permission: "admin.account.subscription",
|
||||
},
|
||||
];
|
||||
|
||||
const visibleItems = items.filter((item) => getUserHasPermission(adminData, item.permission));
|
||||
|
||||
return (
|
||||
<SidebarIconsLayout items={visibleItems} sticky>
|
||||
{children}
|
||||
</SidebarIconsLayout>
|
||||
);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import {
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { LoadingIndicatorSkeleton } from "~/ui";
|
||||
|
||||
export function AdminSalesLoadingPage(): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.loading">
|
||||
<PageHeader
|
||||
title={t("admin.sales.loading.title")}
|
||||
subtitle={t("admin.sales.loading.body")}
|
||||
/>
|
||||
<PageBody>
|
||||
<LoadingIndicatorSkeleton
|
||||
variant="list"
|
||||
role="status"
|
||||
aria-label={t("admin.sales.loading.body")}
|
||||
/>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
import type { AdminBookingSettingsVM } from "@hivegrid/view-models";
|
||||
import { FeatherSettings2 } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
const DAYS = [
|
||||
"monday",
|
||||
"tuesday",
|
||||
"wednesday",
|
||||
"thursday",
|
||||
"friday",
|
||||
"saturday",
|
||||
"sunday",
|
||||
] as const;
|
||||
|
||||
export function AdminBookingSettingsPage(props: {
|
||||
readonly mode: "meeting-types" | "availability";
|
||||
readonly vm: AdminBookingSettingsVM;
|
||||
readonly bookingsHref: string;
|
||||
readonly calendarsHref: string;
|
||||
readonly meetingTypesHref: string;
|
||||
readonly availabilityHref: string;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onSaveMeetingType: (input: Record<string, unknown>) => void;
|
||||
readonly onSaveBookingPage: (input: Record<string, unknown>) => void;
|
||||
readonly onReplaceAvailability: (input: Record<string, unknown>) => void;
|
||||
};
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [type, setType] = useState({
|
||||
name: t("admin.sales.booking.settings.defaults.meetingTypeName"),
|
||||
slug: t("admin.sales.booking.settings.defaults.meetingTypeSlug"),
|
||||
durationMinutes: "30",
|
||||
bufferBeforeMinutes: "0",
|
||||
bufferAfterMinutes: "15",
|
||||
slotIncrementMinutes: "15",
|
||||
minimumNoticeMinutes: "240",
|
||||
bookingHorizonDays: "60",
|
||||
hosts: [props.vm.hosts[0]?.id].filter(Boolean) as string[],
|
||||
active: true,
|
||||
});
|
||||
const [page, setPage] = useState({
|
||||
meetingTypeId: props.vm.meetingTypes[0]?.id ?? "",
|
||||
title: t("admin.sales.booking.settings.defaults.pageTitle"),
|
||||
slug: t("admin.sales.booking.settings.defaults.meetingTypeSlug"),
|
||||
published: false,
|
||||
});
|
||||
const existingDays = new Set(
|
||||
props.vm.availability.rules.map((rule) => rule.dayOfWeek)
|
||||
);
|
||||
const [availability, setAvailability] = useState({
|
||||
timeZone: props.vm.availability.timeZone,
|
||||
days: new Set(
|
||||
existingDays.size
|
||||
? existingDays
|
||||
: DAYS.filter((day) => !["saturday", "sunday"].includes(day))
|
||||
),
|
||||
start: String(
|
||||
Math.floor((props.vm.availability.rules[0]?.startMinutes ?? 540) / 60)
|
||||
).padStart(2, "0") + ":00",
|
||||
end: String(
|
||||
Math.floor((props.vm.availability.rules[0]?.endMinutes ?? 1020) / 60)
|
||||
).padStart(2, "0") + ":00",
|
||||
overrideDate: "",
|
||||
overrideUnavailable: true,
|
||||
});
|
||||
const titleKey =
|
||||
props.mode === "meeting-types"
|
||||
? "admin.sales.booking.settings.meetingTypes.title"
|
||||
: "admin.sales.booking.settings.availability.title";
|
||||
return (
|
||||
<PageShell uiId={`ui.admin.sales.booking.${props.mode}`}>
|
||||
<PageHeader
|
||||
icon={<FeatherSettings2 className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t(titleKey)}
|
||||
subtitle={t(
|
||||
props.mode === "meeting-types"
|
||||
? "admin.sales.booking.settings.meetingTypes.description"
|
||||
: "admin.sales.booking.settings.availability.description"
|
||||
)}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.bookingsHref}>
|
||||
{t("admin.sales.booking.title")}
|
||||
</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>{t(titleKey)}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="flex w-full flex-wrap gap-2">
|
||||
<Link to={props.calendarsHref} className="contents no-underline">
|
||||
<Button variant="tertiary">
|
||||
{t("admin.sales.booking.settings.navigation.calendars")}
|
||||
</Button>
|
||||
</Link>
|
||||
<Link to={props.meetingTypesHref} className="contents no-underline">
|
||||
<Button variant="tertiary">
|
||||
{t("admin.sales.booking.settings.navigation.meetingTypes")}
|
||||
</Button>
|
||||
</Link>
|
||||
<Link to={props.availabilityHref} className="contents no-underline">
|
||||
<Button variant="tertiary">
|
||||
{t("admin.sales.booking.settings.navigation.availability")}
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
{props.errorMessage ? (
|
||||
<Card variant="negative">{props.errorMessage}</Card>
|
||||
) : null}
|
||||
{props.mode === "meeting-types" ? (
|
||||
<>
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.settings.meetingTypes.formTitle")}
|
||||
</h2>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.name")}>
|
||||
<TextInput.Input value={type.name} onChange={(event) => setType({ ...type, name: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.slug")}>
|
||||
<TextInput.Input value={type.slug} onChange={(event) => setType({ ...type, slug: event.target.value })} />
|
||||
</TextInput>
|
||||
{(["durationMinutes", "bufferBeforeMinutes", "bufferAfterMinutes", "slotIncrementMinutes", "minimumNoticeMinutes", "bookingHorizonDays"] as const).map((field) => (
|
||||
<TextInput key={field} showLabel label={t(`admin.sales.booking.settings.fields.${field}`)}>
|
||||
<TextInput.Input type="number" value={type[field]} onChange={(event) => setType({ ...type, [field]: event.target.value })} />
|
||||
</TextInput>
|
||||
))}
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{props.vm.hosts.map((host) => (
|
||||
<Checkbox
|
||||
key={host.id}
|
||||
label={host.label}
|
||||
checked={type.hosts.includes(host.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
setType({
|
||||
...type,
|
||||
hosts: checked
|
||||
? [...new Set([...type.hosts, host.id])]
|
||||
: type.hosts.filter((id) => id !== host.id),
|
||||
})
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={!type.name || !type.slug || !type.hosts.length}
|
||||
onClick={() =>
|
||||
props.actions.onSaveMeetingType({
|
||||
intent: "save-meeting-type",
|
||||
name: type.name,
|
||||
slug: type.slug,
|
||||
description: null,
|
||||
durationMinutes: Number(type.durationMinutes),
|
||||
bufferBeforeMinutes: Number(type.bufferBeforeMinutes),
|
||||
bufferAfterMinutes: Number(type.bufferAfterMinutes),
|
||||
slotIncrementMinutes: Number(type.slotIncrementMinutes),
|
||||
minimumNoticeMinutes: Number(type.minimumNoticeMinutes),
|
||||
bookingHorizonDays: Number(type.bookingHorizonDays),
|
||||
hostAdminUserIds: type.hosts,
|
||||
reminderOffsetsMinutes: [1440, 60],
|
||||
active: type.active,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.booking.settings.saveMeetingType")}
|
||||
</Button>
|
||||
</Card>
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.settings.pages.formTitle")}
|
||||
</h2>
|
||||
<Select showLabel label={t("admin.sales.booking.settings.fields.meetingType")} value={page.meetingTypeId} onValueChange={(meetingTypeId) => setPage({ ...page, meetingTypeId })}>
|
||||
{props.vm.meetingTypes.map((item) => <Select.Item key={item.id} value={item.id}>{item.name}</Select.Item>)}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.title")}>
|
||||
<TextInput.Input value={page.title} onChange={(event) => setPage({ ...page, title: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.slug")}>
|
||||
<TextInput.Input value={page.slug} onChange={(event) => setPage({ ...page, slug: event.target.value })} />
|
||||
</TextInput>
|
||||
<Checkbox label={t("admin.sales.booking.settings.fields.published")} checked={page.published} onCheckedChange={(published) => setPage({ ...page, published })} />
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={!page.meetingTypeId || !page.title || !page.slug}
|
||||
onClick={() => props.actions.onSaveBookingPage({
|
||||
intent: "save-booking-page",
|
||||
...page,
|
||||
description: null,
|
||||
maxBookingsPerEmailPerDay: 3,
|
||||
})}
|
||||
>
|
||||
{t("admin.sales.booking.settings.savePage")}
|
||||
</Button>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
{props.vm.meetingTypes.map((item) => (
|
||||
<Card key={item.id}>
|
||||
<div className="flex w-full justify-between gap-3">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{item.name}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.booking.settings.meetingTypes.summary", {
|
||||
minutes: item.durationMinutes,
|
||||
count: item.hostAdminUserIds.length,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe={item.active ? "subtle-positive" : "subtle-neutral"}>{t(item.active ? "admin.sales.booking.status.active" : "admin.sales.booking.status.draft")}</BadgeFeedback>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<Card>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.timeZone")}>
|
||||
<TextInput.Input value={availability.timeZone} onChange={(event) => setAvailability({ ...availability, timeZone: event.target.value })} />
|
||||
</TextInput>
|
||||
<div className="grid w-full grid-cols-2 gap-3 mobile:grid-cols-1">
|
||||
{DAYS.map((day) => (
|
||||
<Checkbox
|
||||
key={day}
|
||||
label={t(`admin.sales.booking.settings.days.${day}`)}
|
||||
checked={availability.days.has(day)}
|
||||
onCheckedChange={(checked) => {
|
||||
const days = new Set(availability.days);
|
||||
checked ? days.add(day) : days.delete(day);
|
||||
setAvailability({ ...availability, days });
|
||||
}}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.start")}>
|
||||
<TextInput.Input type="time" value={availability.start} onChange={(event) => setAvailability({ ...availability, start: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.end")}>
|
||||
<TextInput.Input type="time" value={availability.end} onChange={(event) => setAvailability({ ...availability, end: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.booking.settings.fields.overrideDate")}>
|
||||
<TextInput.Input type="date" value={availability.overrideDate} onChange={(event) => setAvailability({ ...availability, overrideDate: event.target.value })} />
|
||||
</TextInput>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={!availability.timeZone || !availability.days.size}
|
||||
onClick={() => {
|
||||
const minutes = (value: string) => {
|
||||
const [hours, mins] = value.split(":").map(Number);
|
||||
return (hours ?? 0) * 60 + (mins ?? 0);
|
||||
};
|
||||
props.actions.onReplaceAvailability({
|
||||
intent: "replace-availability",
|
||||
timeZone: availability.timeZone,
|
||||
rules: [...availability.days].map((dayOfWeek) => ({
|
||||
dayOfWeek,
|
||||
startMinutes: minutes(availability.start),
|
||||
endMinutes: minutes(availability.end),
|
||||
})),
|
||||
overrides: availability.overrideDate
|
||||
? [{
|
||||
date: availability.overrideDate,
|
||||
kind: "unavailable",
|
||||
startMinutes: null,
|
||||
endMinutes: null,
|
||||
reason: null,
|
||||
}]
|
||||
: [],
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("admin.sales.booking.settings.saveAvailability")}
|
||||
</Button>
|
||||
</Card>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+160
@@ -0,0 +1,160 @@
|
||||
import type { AdminBookingWorkspaceVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherCalendarClock,
|
||||
FeatherExternalLink,
|
||||
FeatherLink,
|
||||
FeatherUsers,
|
||||
} from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
|
||||
export function AdminBookingWorkspacePage(props: {
|
||||
readonly vm: AdminBookingWorkspaceVM;
|
||||
readonly salesHref: string;
|
||||
readonly settingsHrefs?: {
|
||||
readonly calendars: string;
|
||||
readonly meetingTypes: string;
|
||||
readonly availability: string;
|
||||
};
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.booking.workspace">
|
||||
<PageHeader
|
||||
icon={<FeatherCalendarClock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.booking.title")}
|
||||
subtitle={t("admin.sales.booking.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.salesHref}>
|
||||
{t("admin.sales.navigation.title")}
|
||||
</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>
|
||||
{t("admin.sales.booking.title")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
{props.settingsHrefs ? (
|
||||
<div className="flex w-full flex-wrap gap-2">
|
||||
<Link to={props.settingsHrefs.calendars} className="contents no-underline">
|
||||
<Button variant="tertiary">{t("admin.sales.booking.settings.navigation.calendars")}</Button>
|
||||
</Link>
|
||||
<Link to={props.settingsHrefs.meetingTypes} className="contents no-underline">
|
||||
<Button variant="tertiary">{t("admin.sales.booking.settings.navigation.meetingTypes")}</Button>
|
||||
</Link>
|
||||
<Link to={props.settingsHrefs.availability} className="contents no-underline">
|
||||
<Button variant="tertiary">{t("admin.sales.booking.settings.navigation.availability")}</Button>
|
||||
</Link>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{props.vm.externalProviderProofPending ? (
|
||||
<Card>
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.providerGate.title")}
|
||||
</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.booking.providerGate.body")}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-warning">
|
||||
{t("admin.sales.booking.providerGate.badge")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
<div className="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<StatsCard label={t("admin.sales.booking.metrics.upcoming")} value={props.vm.stats.upcoming} trend="neutral" percentage="" comparisonText="" icon={<FeatherCalendarClock />} />
|
||||
<StatsCard label={t("admin.sales.booking.metrics.pages")} value={props.vm.stats.publishedPages} trend="neutral" percentage="" comparisonText="" icon={<FeatherLink />} />
|
||||
<StatsCard label={t("admin.sales.booking.metrics.types")} value={props.vm.stats.activeMeetingTypes} trend="neutral" percentage="" comparisonText="" icon={<FeatherUsers />} />
|
||||
<StatsCard label={t("admin.sales.booking.metrics.calendars")} value={props.vm.stats.connectedCalendars} trend={props.vm.stats.connectedCalendars ? "positive" : "negative"} percentage="" comparisonText="" icon={<FeatherCalendarClock />} />
|
||||
</div>
|
||||
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.pages.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.booking.pages.description")}
|
||||
</p>
|
||||
</div>
|
||||
{props.vm.pages.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.booking.pages.empty")} body={t("admin.sales.booking.pages.emptyBody")} />
|
||||
) : (
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
{props.vm.pages.map((page) => (
|
||||
<Card key={page.id}>
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{page.title}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{page.meetingTypeName}</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe={page.published ? "subtle-positive" : "subtle-neutral"}>
|
||||
{t(page.published ? "admin.sales.booking.status.published" : "admin.sales.booking.status.draft")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<a href={page.bookingUrl} target="_blank" rel="noreferrer" className="contents no-underline">
|
||||
<Button variant="neutral" icon={<FeatherExternalLink />}>
|
||||
{t("admin.sales.booking.pages.open")}
|
||||
</Button>
|
||||
</a>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.bookings.title")}
|
||||
</h2>
|
||||
{props.vm.bookings.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.booking.bookings.empty")} body={t("admin.sales.booking.bookings.emptyBody")} />
|
||||
) : (
|
||||
<Table>
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.sales.booking.bookings.contact")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.booking.bookings.type")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.booking.bookings.startsAt")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.booking.bookings.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.booking.bookings.provider")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
{props.vm.bookings.map((booking) => (
|
||||
<Table.Row key={booking.id}>
|
||||
<Table.Cell>{booking.contactName}</Table.Cell>
|
||||
<Table.Cell>{booking.meetingTypeName}</Table.Cell>
|
||||
<Table.Cell>{formatters.dateTime(booking.startsAt)}</Table.Cell>
|
||||
<Table.Cell><BadgeFeedback farbe={booking.status === "confirmed" ? "subtle-positive" : booking.status === "provider_sync_failed" ? "subtle-negative" : "subtle-information"}>{t(`admin.sales.booking.status.${booking.status}`)}</BadgeFeedback></Table.Cell>
|
||||
<Table.Cell>{t(booking.providerSynced ? "admin.sales.booking.provider.synced" : "admin.sales.booking.provider.pending")}</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</section>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+184
@@ -0,0 +1,184 @@
|
||||
import type { AdminCalendarConnectionsVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherCalendar,
|
||||
FeatherRefreshCw,
|
||||
FeatherShieldCheck,
|
||||
} from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
|
||||
export function AdminCalendarConnectionsPage(props: {
|
||||
readonly vm: AdminCalendarConnectionsVM;
|
||||
readonly bookingsHref: string;
|
||||
readonly connectHref: (
|
||||
provider: "google_calendar" | "microsoft_calendar"
|
||||
) => string;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onDisconnect: (input: {
|
||||
readonly calendarConnectionId: string;
|
||||
readonly dataConnectionId: string;
|
||||
}) => void;
|
||||
};
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.booking.calendars">
|
||||
<PageHeader
|
||||
icon={<FeatherCalendar className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.booking.calendars.title")}
|
||||
subtitle={t("admin.sales.booking.calendars.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.bookingsHref}>
|
||||
{t("admin.sales.booking.title")}
|
||||
</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>
|
||||
{t("admin.sales.booking.calendars.title")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
{props.errorMessage ? (
|
||||
<Card variant="negative">
|
||||
<p className="text-body-small-regular-0 text-text-feedback-negative">
|
||||
{props.errorMessage}
|
||||
</p>
|
||||
</Card>
|
||||
) : null}
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
{props.vm.providers.map((provider) => (
|
||||
<Card key={provider.provider}>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex items-start gap-3">
|
||||
<FeatherShieldCheck className="text-heading-3 font-heading-3 text-icon-neutral-tertiary" />
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(
|
||||
`admin.sales.booking.calendars.providers.${provider.provider}`
|
||||
)}
|
||||
</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(
|
||||
provider.configured
|
||||
? "admin.sales.booking.calendars.providerReady"
|
||||
: "admin.sales.booking.calendars.providerGate"
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
provider.connected
|
||||
? "subtle-positive"
|
||||
: provider.configured
|
||||
? "subtle-information"
|
||||
: "subtle-warning"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
provider.connected
|
||||
? "admin.sales.booking.calendars.connected"
|
||||
: provider.configured
|
||||
? "admin.sales.booking.calendars.ready"
|
||||
: "admin.sales.booking.calendars.externalGate"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<Link
|
||||
className="contents no-underline"
|
||||
to={props.connectHref(provider.provider)}
|
||||
>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
icon={<FeatherRefreshCw />}
|
||||
disabled={!provider.configured}
|
||||
>
|
||||
{t(
|
||||
provider.connected
|
||||
? "admin.sales.booking.calendars.reconnect"
|
||||
: "admin.sales.booking.calendars.connect"
|
||||
)}
|
||||
</Button>
|
||||
</Link>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
{props.vm.calendars.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.booking.calendars.empty")}
|
||||
body={t("admin.sales.booking.calendars.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3">
|
||||
{props.vm.calendars.map((calendar) => (
|
||||
<Card key={calendar.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4 mobile:items-start">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{calendar.label || calendar.accountEmail}
|
||||
</p>
|
||||
<p className="truncate text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{calendar.accountEmail} · {calendar.timeZone}
|
||||
</p>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{calendar.lastSyncAt
|
||||
? t("admin.sales.booking.calendars.lastSync", {
|
||||
value: formatters.dateTime(calendar.lastSyncAt),
|
||||
})
|
||||
: t("admin.sales.booking.calendars.notSynced")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mobile:flex-col mobile:items-end">
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
calendar.status === "active"
|
||||
? "subtle-positive"
|
||||
: "subtle-warning"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
`admin.sales.booking.calendars.status.${calendar.status}`
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
<Button
|
||||
size="small"
|
||||
variant="destructive"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onDisconnect({
|
||||
calendarConnectionId: calendar.id,
|
||||
dataConnectionId: calendar.dataConnectionId,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.booking.calendars.disconnect")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+158
@@ -0,0 +1,158 @@
|
||||
import type { AdminPublicBookingManageVM } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Alert, Button, Card, EmptyState, TextArea, TextInput } from "~/ui";
|
||||
|
||||
export function AdminPublicBookingManagePage(props: {
|
||||
readonly vm: AdminPublicBookingManageVM;
|
||||
readonly result: "cancelled" | "rescheduled" | null;
|
||||
readonly replacementManageUrl: string | null;
|
||||
readonly errorCode: string | null;
|
||||
readonly pending: boolean;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
if (props.result) {
|
||||
return (
|
||||
<PublicFrame>
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t(
|
||||
`admin.sales.booking.manage.results.${props.result}.title`
|
||||
)}
|
||||
body={t(
|
||||
`admin.sales.booking.manage.results.${props.result}.body`
|
||||
)}
|
||||
/>
|
||||
{props.replacementManageUrl ? (
|
||||
<a href={props.replacementManageUrl}>
|
||||
<Button>
|
||||
{t("admin.sales.booking.manage.openReplacement")}
|
||||
</Button>
|
||||
</a>
|
||||
) : null}
|
||||
</PublicFrame>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<PublicFrame>
|
||||
<header className="flex w-full flex-col gap-2">
|
||||
<p className="text-body-small-medium-150 font-body-small-medium-150 text-text-brand">
|
||||
{props.vm.meetingTypeName}
|
||||
</p>
|
||||
<h1 className="text-heading-1 font-heading-1 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.manage.title")}
|
||||
</h1>
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.booking.manage.current", {
|
||||
value: props.vm.currentStartsAtLabel,
|
||||
})}
|
||||
</p>
|
||||
</header>
|
||||
{props.errorCode ? (
|
||||
<Alert
|
||||
variant="error"
|
||||
title={t("admin.sales.booking.manage.error")}
|
||||
description={t(
|
||||
`admin.sales.booking.manage.errors.${props.errorCode}`,
|
||||
{
|
||||
defaultValue: t(
|
||||
"admin.sales.booking.manage.errors.invalid_request"
|
||||
),
|
||||
}
|
||||
)}
|
||||
/>
|
||||
) : null}
|
||||
<form
|
||||
method="get"
|
||||
className="flex w-full items-end gap-3 mobile:flex-col mobile:items-stretch"
|
||||
>
|
||||
<input type="hidden" name="tz" value={props.vm.timeZone} />
|
||||
<TextInput
|
||||
showLabel
|
||||
fillContainer
|
||||
label={t("admin.sales.booking.manage.date")}
|
||||
>
|
||||
<TextInput.Input
|
||||
name="date"
|
||||
type="date"
|
||||
defaultValue={props.vm.date}
|
||||
/>
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary">
|
||||
{t("admin.sales.booking.manage.showSlots")}
|
||||
</Button>
|
||||
</form>
|
||||
<Card>
|
||||
<form method="post" className="flex w-full flex-col gap-4">
|
||||
<input type="hidden" name="intent" value="reschedule" />
|
||||
<input type="hidden" name="date" value={props.vm.date} />
|
||||
<input type="hidden" name="timeZone" value={props.vm.timeZone} />
|
||||
<fieldset className="flex w-full flex-col gap-3">
|
||||
<legend className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.manage.chooseSlot")}
|
||||
</legend>
|
||||
{props.vm.slots.length === 0 ? (
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.booking.manage.noSlots")}
|
||||
</p>
|
||||
) : (
|
||||
props.vm.slots.map((slot) => (
|
||||
<label
|
||||
key={slot.value}
|
||||
className="flex min-h-10 items-center gap-2 rounded-md border border-solid border-border-neutral px-3 py-2 focus-within:shadow-focus"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="slot"
|
||||
value={slot.value}
|
||||
required
|
||||
/>
|
||||
<span>{slot.label}</span>
|
||||
</label>
|
||||
))
|
||||
)}
|
||||
</fieldset>
|
||||
<Button
|
||||
type="submit"
|
||||
loading={props.pending}
|
||||
disabled={props.pending || props.vm.slots.length === 0}
|
||||
>
|
||||
{t("admin.sales.booking.manage.reschedule")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
<Card>
|
||||
<form method="post" className="flex w-full flex-col gap-4">
|
||||
<input type="hidden" name="intent" value="cancel" />
|
||||
<TextArea
|
||||
showLabel
|
||||
label={t("admin.sales.booking.manage.cancelReason")}
|
||||
>
|
||||
<TextArea.Input name="reason" required />
|
||||
</TextArea>
|
||||
<Button
|
||||
type="submit"
|
||||
variant="destructive"
|
||||
loading={props.pending}
|
||||
disabled={props.pending}
|
||||
>
|
||||
{t("admin.sales.booking.manage.cancel")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
</PublicFrame>
|
||||
);
|
||||
}
|
||||
|
||||
function PublicFrame(props: {
|
||||
readonly children: React.ReactNode;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<main className="flex min-h-screen w-full justify-center bg-surface-neutral-secondary px-6 py-12 mobile:px-4 mobile:py-6">
|
||||
<div className="flex w-full max-w-[720px] flex-col gap-6">
|
||||
{props.children}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+223
@@ -0,0 +1,223 @@
|
||||
import type { AdminPublicBookingVM } from "@hivegrid/view-models";
|
||||
import { FeatherClock } from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import {
|
||||
Alert,
|
||||
Button,
|
||||
Card,
|
||||
EmptyState,
|
||||
TextArea,
|
||||
TextInput,
|
||||
} from "~/ui";
|
||||
|
||||
export function AdminPublicBookingPage(props: {
|
||||
readonly vm: AdminPublicBookingVM;
|
||||
readonly confirmed: boolean;
|
||||
readonly errorCode: string | null;
|
||||
readonly manageUrl: string | null;
|
||||
readonly pending: boolean;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
if (props.confirmed) {
|
||||
return (
|
||||
<PublicFrame>
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.booking.public.confirmed")}
|
||||
body={t("admin.sales.booking.public.confirmedBody")}
|
||||
/>
|
||||
{props.manageUrl ? (
|
||||
<a href={props.manageUrl}>
|
||||
<Button>{t("admin.sales.booking.public.manage")}</Button>
|
||||
</a>
|
||||
) : null}
|
||||
</PublicFrame>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<PublicFrame>
|
||||
<header className="flex w-full flex-col gap-2">
|
||||
<p className="text-body-small-medium-150 font-body-small-medium-150 text-text-brand">
|
||||
{props.vm.meetingTypeName}
|
||||
</p>
|
||||
<h1 className="text-heading-1 font-heading-1 text-text-neutral-primary">
|
||||
{props.vm.title}
|
||||
</h1>
|
||||
{props.vm.description ? (
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">
|
||||
{props.vm.description}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="flex items-center gap-2 text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
<FeatherClock />
|
||||
{t("admin.sales.booking.public.duration", {
|
||||
value: props.vm.durationMinutes,
|
||||
})}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{props.errorCode ? (
|
||||
<Alert
|
||||
variant="error"
|
||||
title={t("admin.sales.booking.public.error")}
|
||||
description={t(
|
||||
`admin.sales.booking.public.errors.${props.errorCode}`,
|
||||
{
|
||||
defaultValue: t(
|
||||
"admin.sales.booking.public.errors.invalid_request"
|
||||
),
|
||||
}
|
||||
)}
|
||||
/>
|
||||
) : null}
|
||||
|
||||
<form
|
||||
method="get"
|
||||
className="flex w-full items-end gap-3 mobile:flex-col mobile:items-stretch"
|
||||
>
|
||||
<input type="hidden" name="tz" value={props.vm.timeZone} />
|
||||
<TextInput
|
||||
showLabel
|
||||
fillContainer
|
||||
label={t("admin.sales.booking.public.date")}
|
||||
>
|
||||
<TextInput.Input
|
||||
name="date"
|
||||
type="date"
|
||||
defaultValue={props.vm.date}
|
||||
/>
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary">
|
||||
{t("admin.sales.booking.public.showSlots")}
|
||||
</Button>
|
||||
</form>
|
||||
|
||||
<Card>
|
||||
<form method="post" className="flex w-full flex-col gap-6">
|
||||
<input
|
||||
type="hidden"
|
||||
name="submissionId"
|
||||
value={props.vm.submissionId}
|
||||
/>
|
||||
<input type="hidden" name="date" value={props.vm.date} />
|
||||
<input type="hidden" name="timeZone" value={props.vm.timeZone} />
|
||||
<fieldset className="flex w-full flex-col gap-3">
|
||||
<legend className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{t("admin.sales.booking.public.chooseSlot")}
|
||||
</legend>
|
||||
{props.vm.slots.length === 0 ? (
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.booking.public.noSlots")}
|
||||
</p>
|
||||
) : (
|
||||
<div className="grid w-full grid-cols-2 gap-2 mobile:grid-cols-1">
|
||||
{props.vm.slots.map((slot) => (
|
||||
<label
|
||||
key={slot.value}
|
||||
className="flex min-h-10 cursor-pointer items-center gap-2 rounded-md border border-solid border-border-neutral px-3 py-2 focus-within:shadow-focus"
|
||||
>
|
||||
<input
|
||||
type="radio"
|
||||
name="slot"
|
||||
value={slot.value}
|
||||
required
|
||||
/>
|
||||
<span className="text-body-small-medium-150 font-body-small-medium-150 text-text-neutral-primary">
|
||||
{slot.label}
|
||||
</span>
|
||||
</label>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</fieldset>
|
||||
|
||||
<div className="grid w-full grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput
|
||||
showLabel
|
||||
fillContainer
|
||||
label={t("admin.sales.booking.public.firstName")}
|
||||
>
|
||||
<TextInput.Input
|
||||
name="firstName"
|
||||
autoComplete="given-name"
|
||||
required
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
fillContainer
|
||||
label={t("admin.sales.booking.public.lastName")}
|
||||
>
|
||||
<TextInput.Input
|
||||
name="lastName"
|
||||
autoComplete="family-name"
|
||||
required
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextInput
|
||||
showLabel
|
||||
fillContainer
|
||||
label={t("admin.sales.booking.public.email")}
|
||||
>
|
||||
<TextInput.Input
|
||||
name="email"
|
||||
type="email"
|
||||
autoComplete="email"
|
||||
required
|
||||
/>
|
||||
</TextInput>
|
||||
{props.vm.questions.map((question) =>
|
||||
question.multiline ? (
|
||||
<TextArea
|
||||
key={question.id}
|
||||
showLabel
|
||||
label={question.label}
|
||||
>
|
||||
<TextArea.Input
|
||||
name={`answer:${question.id}`}
|
||||
required={question.required}
|
||||
/>
|
||||
</TextArea>
|
||||
) : (
|
||||
<TextInput
|
||||
key={question.id}
|
||||
showLabel
|
||||
fillContainer
|
||||
label={question.label}
|
||||
>
|
||||
<TextInput.Input
|
||||
name={`answer:${question.id}`}
|
||||
required={question.required}
|
||||
/>
|
||||
</TextInput>
|
||||
)
|
||||
)}
|
||||
<Button
|
||||
type="submit"
|
||||
disabled={props.pending || props.vm.slots.length === 0}
|
||||
loading={props.pending}
|
||||
>
|
||||
{props.pending
|
||||
? t("admin.sales.booking.public.submitting")
|
||||
: t("admin.sales.booking.public.submit")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
</PublicFrame>
|
||||
);
|
||||
}
|
||||
|
||||
function PublicFrame(props: {
|
||||
readonly children: React.ReactNode;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<main className="flex min-h-screen w-full justify-center bg-surface-neutral-secondary px-6 py-12 mobile:px-4 mobile:py-6">
|
||||
<div className="flex w-full max-w-[720px] flex-col gap-6">
|
||||
{props.children}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28f booking interim visual baseline > renders operational stats, public pages and provider state 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.booking.workspace"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.booking.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.booking.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/sales/deals" data-discover="true">admin.sales.navigation.title</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">admin.sales.booking.title</span></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-center justify-between gap-4"><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">admin.sales.booking.providerGate.title</p><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.booking.providerGate.body</p></div><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-warning"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-warning"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">admin.sales.booking.providerGate.badge</span></div></div></div><div class="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.booking.metrics.upcoming</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.booking.metrics.pages</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="tLine truncated
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28f booking settings interim baseline > renders calendar connection health and provider gates 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.booking.calendars"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.booking.calendars.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.booking.calendars.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/sales/bookings" data-discover="true">admin.sales.booking.title</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">admin.sales.booking.calendars.title</span></div><div class="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start justify-between gap-4"><div class="flex items-start gap-3"><span class="text-heading-3 font-heading-3 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">admin.sales.booking.calendars.providers.google_calendar</p><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.booking.calendars.providerReady</p></div></div><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-positive"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-positive"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-feedback-positive">admin.sales.booking.calendars.connected</span></div></div><a class="contents no-underline" href="/connect/google_calendar" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.booking.calendars.reconnect</span></button></a></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start justify-between gap-4"><div class="flex items-start gap-3"><span class="text-heading-3 font-heading-3 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutraLine truncated
|
||||
|
||||
exports[`VA-P28f booking settings interim baseline > renders meeting type and page configuration 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.booking.meeting-types"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.booking.settings.meetingTypes.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.booking.settings.meetingTypes.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/sales/bookings" data-discover="true">admin.sales.booking.title</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">admin.sales.booking.settings.meetingTypes.title</span></div><div class="flex w-full flex-wrap gap-2"><a class="contents no-underline" href="/sales/settings/calendars" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.booking.settings.navigation.calendars</span></button></a><a class="contents no-underline" href="/sales/settings/meeting-types" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.booking.settings.navigation.meetingTypes</span></button></a><a class="contents no-underline" href="/sales/settings/availability" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surfaceLine truncated
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28f public booking management visual baseline > renders reschedule and cancellation controls without admin chrome 1`] = `"<main class="flex min-h-screen w-full justify-center bg-surface-neutral-secondary px-6 py-12 mobile:px-4 mobile:py-6"><div class="flex w-full max-w-[720px] flex-col gap-6"><header class="flex w-full flex-col gap-2"><p class="text-body-small-medium-150 font-body-small-medium-150 text-text-brand">Demo</p><h1 class="text-heading-1 font-heading-1 text-text-neutral-primary">admin.sales.booking.manage.title</h1><p class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">admin.sales.booking.manage.current</p></header><form method="get" class="flex w-full items-end gap-3 mobile:flex-col mobile:items-stretch"><input type="hidden" value="Europe/Berlin" name="tz"><label class="group/be48ca43 flex h-full w-full min-w-[192px] cursor-pointer flex-col items-start justify-center gap-4 max-w-none"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.sales.booking.manage.date</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:shadow-focus"><div class="flex grow shrink-0 basis-0 items-center self-stretch"><div class="hidden items-center gap-2 pr-2"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex grow shrink-0 basis-0 flex-col items-start self-stretch"><input class="group/b0d608f7 subframe-text-input-control h-full w-full border-none bg-transparent px-0 py-0 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle" style="box-shadow: none;" type="date" value="2026-08-02" name="date"></div><div class="hidden items-center gap-1 pl-2"></div></div><div class="group/39db4fac h-5 w-5 cursor-pointer flex-col items-center justify-center gap-4 hidden"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-primary group-hover/39db4fac:text-body-large-0 group-hover/39db4fac:font-body-large-0 group-active/39db4fac:text-body-default-regular-0 group-active/39db4fac:font-body-default-regular-0 icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></label><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="submit"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.booking.manage.showSlots</span></button></form><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><form method="post" class="flex w-full flex-col gap-4"><input type="hidden" value="reschedule" name="intent"><input type="hidden" value="2026-08-02" name="date"><input type="hidden" value="Europe/Berlin" name="timeZone"><fieldset class="flex w-full flex-col gap-3"><legend class="text-heading-3 font-heading-3 text-text-neutral-primary">admin.sales.booking.manage.chooseSlot</legend><label class="flex min-h-10 items-center gap-2 rounded-md border border-solid border-border-neutral px-3 py-2 focus-within:shadow-focus"><input required="" type="radio" value="2026-08-02T10:00:00.000Z|2026-08-02T10:30:00.000Z" name="slot"><span>Sonntag, 2. August 2026 um 12:00</span></label></fieldset><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-leLine truncated
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28f public booking visual baseline > renders date, slot and contact intake without admin chrome 1`] = `"<main class="flex min-h-screen w-full justify-center bg-surface-neutral-secondary px-6 py-12 mobile:px-4 mobile:py-6"><div class="flex w-full max-w-[720px] flex-col gap-6"><header class="flex w-full flex-col gap-2"><p class="text-body-small-medium-150 font-body-small-medium-150 text-text-brand">Erstgespräch</p><h1 class="text-heading-1 font-heading-1 text-text-neutral-primary">Erstgespräch buchen</h1><p class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary">Wir lernen uns kennen.</p><div class="flex items-center gap-2 text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span>admin.sales.booking.public.duration</div></header><form method="get" class="flex w-full items-end gap-3 mobile:flex-col mobile:items-stretch"><input type="hidden" value="Europe/Berlin" name="tz"><label class="group/be48ca43 flex h-full w-full min-w-[192px] cursor-pointer flex-col items-start justify-center gap-4 max-w-none"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.sales.booking.public.date</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:shadow-focus"><div class="flex grow shrink-0 basis-0 items-center self-stretch"><div class="hidden items-center gap-2 pr-2"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex grow shrink-0 basis-0 flex-col items-start self-stretch"><input class="group/b0d608f7 subframe-text-input-control h-full w-full border-none bg-transparent px-0 py-0 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle" style="box-shadow: none;" type="date" value="2026-08-03" name="date"></div><div class="hidden items-center gap-1 pl-2"></div></div><div class="group/39db4fac h-5 w-5 cursor-pointer flex-col items-center justify-center gap-4 hidden"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-primary group-hover/39db4fac:text-body-large-0 group-hover/39db4fac:font-body-large-0 group-active/39db4fac:text-body-default-regular-0 group-active/39db4fac:font-body-default-regular-0 icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></label><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="submit"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.booking.public.showSlots</span></button></form><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><form method="post" class="flex w-full flex-col gap-6"><input type="hidden" value="submission_1" name="submissionId"><input type="hidden" value="2026-08-03" name="date"><input type="hidden" value="Europe/Berlin" name="timeZone"><fieldset class="flex w-full flex-col gap-3"><legend class="text-heading-3 font-heading-3 text-text-neutral-primary">admin.sales.booking.public.chooseSlot</legend><div class="grid w-full grid-cols-2 gap-2 mobile:grid-cols-1"><label class="flex min-h-10 cursor-pointer items-center gap-2 rounded-md border border-solid border-border-neutral px-3 py-2 focus-within:shadow-focus"><input required="" type="radio" valLine truncated
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
// @vitest-environment jsdom
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminBookingWorkspacePage } from "./AdminBookingWorkspacePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("VA-P28f booking accessibility", () => {
|
||||
it("keeps the booking workspace and public-page action accessible", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminBookingWorkspacePage
|
||||
salesHref="/sales/deals"
|
||||
vm={{
|
||||
stats: {
|
||||
upcoming: 0,
|
||||
publishedPages: 1,
|
||||
activeMeetingTypes: 1,
|
||||
connectedCalendars: 0,
|
||||
},
|
||||
meetingTypes: [],
|
||||
pages: [
|
||||
{
|
||||
id: "page-1",
|
||||
title: "Erstgespräch",
|
||||
slug: "erstgespraech",
|
||||
meetingTypeName: "Erstgespräch",
|
||||
published: true,
|
||||
bookingUrl:
|
||||
"https://meet.hivegrid.de/erstgespraech",
|
||||
},
|
||||
],
|
||||
bookings: [],
|
||||
externalProviderProofPending: true,
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminBookingWorkspacePage } from "./AdminBookingWorkspacePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
stats: {
|
||||
upcoming: 1,
|
||||
publishedPages: 1,
|
||||
activeMeetingTypes: 2,
|
||||
connectedCalendars: 1,
|
||||
},
|
||||
meetingTypes: [
|
||||
{
|
||||
id: "type-1",
|
||||
name: "Demo",
|
||||
durationMinutes: 45,
|
||||
hostCount: 2,
|
||||
active: true,
|
||||
},
|
||||
],
|
||||
pages: [
|
||||
{
|
||||
id: "page-1",
|
||||
title: "HiveGrid Demo",
|
||||
slug: "demo",
|
||||
meetingTypeName: "Demo",
|
||||
published: true,
|
||||
bookingUrl: "https://meet.hivegrid.de/demo",
|
||||
},
|
||||
],
|
||||
bookings: [
|
||||
{
|
||||
id: "booking-1",
|
||||
contactName: "Ada Lovelace",
|
||||
meetingTypeName: "Demo",
|
||||
startsAt: "2026-08-03T08:00:00.000Z",
|
||||
endsAt: "2026-08-03T08:45:00.000Z",
|
||||
status: "confirmed" as const,
|
||||
providerSynced: true,
|
||||
},
|
||||
],
|
||||
externalProviderProofPending: true,
|
||||
};
|
||||
|
||||
describe("VA-P28f booking interim visual baseline", () => {
|
||||
it("renders operational stats, public pages and provider state", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminBookingWorkspacePage
|
||||
vm={vm}
|
||||
salesHref="/sales/deals"
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("Ada Lovelace");
|
||||
expect(
|
||||
container.querySelector(
|
||||
'[data-ui-id="ui.admin.sales.booking.workspace"]'
|
||||
)
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+45
@@ -0,0 +1,45 @@
|
||||
// @vitest-environment jsdom
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminBookingSettingsPage } from "./AdminBookingSettingsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("VA-P28f booking settings accessibility", () => {
|
||||
it("keeps availability settings accessible", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminBookingSettingsPage
|
||||
mode="availability"
|
||||
vm={{
|
||||
meetingTypes: [],
|
||||
pages: [],
|
||||
hosts: [{ id: "admin-1", label: "Raffael Sheikh" }],
|
||||
availability: {
|
||||
timeZone: "Europe/Berlin",
|
||||
rules: [],
|
||||
overrides: [],
|
||||
},
|
||||
}}
|
||||
bookingsHref="/sales/bookings"
|
||||
calendarsHref="/sales/settings/calendars"
|
||||
meetingTypesHref="/sales/settings/meeting-types"
|
||||
availabilityHref="/sales/settings/availability"
|
||||
submitting={false}
|
||||
actions={{
|
||||
onSaveMeetingType: vi.fn(),
|
||||
onSaveBookingPage: vi.fn(),
|
||||
onReplaceAvailability: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminBookingSettingsPage } from "./AdminBookingSettingsPage";
|
||||
import { AdminCalendarConnectionsPage } from "./AdminCalendarConnectionsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const hrefs = {
|
||||
bookingsHref: "/sales/bookings",
|
||||
calendarsHref: "/sales/settings/calendars",
|
||||
meetingTypesHref: "/sales/settings/meeting-types",
|
||||
availabilityHref: "/sales/settings/availability",
|
||||
};
|
||||
const vm = {
|
||||
meetingTypes: [{
|
||||
id: "type-1",
|
||||
name: "Demo",
|
||||
slug: "demo",
|
||||
durationMinutes: 45,
|
||||
active: true,
|
||||
hostAdminUserIds: ["admin-1"],
|
||||
}],
|
||||
pages: [{
|
||||
id: "page-1",
|
||||
meetingTypeId: "type-1",
|
||||
title: "Demo",
|
||||
slug: "demo",
|
||||
published: true,
|
||||
}],
|
||||
hosts: [{ id: "admin-1", label: "Raffael Sheikh" }],
|
||||
availability: {
|
||||
timeZone: "Europe/Berlin",
|
||||
rules: [{
|
||||
dayOfWeek: "monday" as const,
|
||||
startMinutes: 540,
|
||||
endMinutes: 1020,
|
||||
}],
|
||||
overrides: [],
|
||||
},
|
||||
};
|
||||
const actions = {
|
||||
onSaveMeetingType: vi.fn(),
|
||||
onSaveBookingPage: vi.fn(),
|
||||
onReplaceAvailability: vi.fn(),
|
||||
};
|
||||
|
||||
describe("VA-P28f booking settings interim baseline", () => {
|
||||
it("renders meeting type and page configuration", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminBookingSettingsPage
|
||||
mode="meeting-types"
|
||||
vm={vm}
|
||||
{...hrefs}
|
||||
submitting={false}
|
||||
actions={actions}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
expect(container).toHaveTextContent("Demo");
|
||||
expect(container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders calendar connection health and provider gates", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminCalendarConnectionsPage
|
||||
vm={{
|
||||
calendars: [{
|
||||
id: "calendar-1",
|
||||
dataConnectionId: "connection-1",
|
||||
provider: "google_calendar",
|
||||
accountEmail: "sales@example.test",
|
||||
label: "Sales",
|
||||
timeZone: "Europe/Berlin",
|
||||
status: "active",
|
||||
lastSyncAt: "2026-07-25T08:00:00.000Z",
|
||||
healthMessageKey: null,
|
||||
}],
|
||||
providers: [
|
||||
{ provider: "google_calendar", configured: true, connected: true },
|
||||
{ provider: "microsoft_calendar", configured: false, connected: false },
|
||||
],
|
||||
}}
|
||||
bookingsHref="/sales/bookings"
|
||||
connectHref={(provider) => `/connect/${provider}`}
|
||||
submitting={false}
|
||||
actions={{ onDisconnect: vi.fn() }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
expect(container).toHaveTextContent("sales@example.test");
|
||||
expect(container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
)).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// @vitest-environment jsdom
|
||||
import { describe, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminPublicBookingManagePage } from "./AdminPublicBookingManagePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("VA-P28f public booking management accessibility", () => {
|
||||
it("names the date, slot, reason and both actions", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<AdminPublicBookingManagePage
|
||||
vm={{
|
||||
title: "Demo buchen",
|
||||
meetingTypeName: "Demo",
|
||||
currentStartsAtLabel: "Samstag, 1. August 2026 um 12:00",
|
||||
date: "2026-08-02",
|
||||
timeZone: "Europe/Berlin",
|
||||
slots: [
|
||||
{
|
||||
value:
|
||||
"2026-08-02T10:00:00.000Z|2026-08-02T10:30:00.000Z",
|
||||
label: "Sonntag, 2. August 2026 um 12:00",
|
||||
},
|
||||
],
|
||||
}}
|
||||
result={null}
|
||||
replacementManageUrl={null}
|
||||
errorCode={null}
|
||||
pending={false}
|
||||
/>
|
||||
);
|
||||
});
|
||||
});
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminPublicBookingManagePage } from "./AdminPublicBookingManagePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
title: "Demo buchen",
|
||||
meetingTypeName: "Demo",
|
||||
currentStartsAtLabel: "Samstag, 1. August 2026 um 12:00",
|
||||
date: "2026-08-02",
|
||||
timeZone: "Europe/Berlin",
|
||||
slots: [
|
||||
{
|
||||
value: "2026-08-02T10:00:00.000Z|2026-08-02T10:30:00.000Z",
|
||||
label: "Sonntag, 2. August 2026 um 12:00",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("VA-P28f public booking management visual baseline", () => {
|
||||
it("renders reschedule and cancellation controls without admin chrome", () => {
|
||||
const { container } = render(
|
||||
<AdminPublicBookingManagePage
|
||||
vm={vm}
|
||||
result={null}
|
||||
replacementManageUrl={null}
|
||||
errorCode={null}
|
||||
pending={false}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(container.querySelector('input[name="slot"]')).toBeRequired();
|
||||
expect(container.querySelector('textarea[name="reason"]')).toBeRequired();
|
||||
expect(
|
||||
container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
// @vitest-environment jsdom
|
||||
import { describe, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminPublicBookingPage } from "./AdminPublicBookingPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("VA-P28f public booking accessibility", () => {
|
||||
it("names the date, slot and contact controls", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<AdminPublicBookingPage
|
||||
confirmed={false}
|
||||
errorCode={null}
|
||||
manageUrl={null}
|
||||
pending={false}
|
||||
vm={{
|
||||
title: "Erstgespräch buchen",
|
||||
description: null,
|
||||
meetingTypeName: "Erstgespräch",
|
||||
durationMinutes: 30,
|
||||
date: "2026-08-03",
|
||||
timeZone: "Europe/Berlin",
|
||||
submissionId: "submission_1",
|
||||
slots: [
|
||||
{
|
||||
value:
|
||||
"2026-08-03T08:00:00.000Z|2026-08-03T08:30:00.000Z",
|
||||
label: "Mo., 03.08., 10:00",
|
||||
},
|
||||
],
|
||||
questions: [],
|
||||
}}
|
||||
/>
|
||||
);
|
||||
});
|
||||
});
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminPublicBookingPage } from "./AdminPublicBookingPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
title: "Erstgespräch buchen",
|
||||
description: "Wir lernen uns kennen.",
|
||||
meetingTypeName: "Erstgespräch",
|
||||
durationMinutes: 30,
|
||||
date: "2026-08-03",
|
||||
timeZone: "Europe/Berlin",
|
||||
submissionId: "submission_1",
|
||||
slots: [
|
||||
{
|
||||
value: "2026-08-03T08:00:00.000Z|2026-08-03T08:30:00.000Z",
|
||||
label: "Mo., 03.08., 10:00",
|
||||
},
|
||||
],
|
||||
questions: [
|
||||
{
|
||||
id: "goal",
|
||||
label: "Was möchtest du besprechen?",
|
||||
required: true,
|
||||
multiline: true,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
describe("VA-P28f public booking visual baseline", () => {
|
||||
it("renders date, slot and contact intake without admin chrome", () => {
|
||||
const { container } = render(
|
||||
<AdminPublicBookingPage
|
||||
vm={vm}
|
||||
confirmed={false}
|
||||
errorCode={null}
|
||||
manageUrl={null}
|
||||
pending={false}
|
||||
/>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("Erstgespräch buchen");
|
||||
expect(container.querySelector('input[name="slot"]')).toBeRequired();
|
||||
expect(
|
||||
container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
)
|
||||
).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+289
@@ -0,0 +1,289 @@
|
||||
import type {
|
||||
AdminSalesCompanyDetailVM,
|
||||
AdminSalesDataManagementVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import { FeatherBriefcase, FeatherBuilding, FeatherUsers } from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback, Breadcrumbs, Card, EmptyState, Table } from "~/ui";
|
||||
|
||||
export function AdminSalesCompaniesPage(props: {
|
||||
readonly vm: AdminSalesDataManagementVM;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.companies.list">
|
||||
<PageHeader
|
||||
icon={<FeatherBuilding className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.companies.title")}
|
||||
subtitle={t("admin.sales.companies.subtitle")}
|
||||
/>
|
||||
<PageBody>
|
||||
{props.vm.companies.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.companies.empty.title")}
|
||||
body={t("admin.sales.companies.empty.body")}
|
||||
/>
|
||||
) : (
|
||||
<Card>
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.company")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.location")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.industry")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.contacts")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.deals")}
|
||||
</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{props.vm.companies.map((company) => (
|
||||
<Table.Row key={company.id}>
|
||||
<Table.Cell>
|
||||
<Link
|
||||
className="font-body-small-medium-0 text-text-brand hover:underline"
|
||||
to={company.detailHref}
|
||||
>
|
||||
{company.name}
|
||||
</Link>
|
||||
<span className="block text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{company.domain ?? company.legalName ?? t("shared.notSet")}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{company.locationLabel || t("shared.notSet")}
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{company.industry ?? t("shared.notSet")}
|
||||
</Table.Cell>
|
||||
<Table.Cell>{company.contactCount}</Table.Cell>
|
||||
<Table.Cell>{company.dealCount}</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</Card>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminSalesCompanyDetailPage(props: {
|
||||
readonly vm: AdminSalesCompanyDetailVM;
|
||||
readonly companiesHref: string;
|
||||
}): React.JSX.Element {
|
||||
const { t, i18n } = useTranslation();
|
||||
const formatDate = (value: string) =>
|
||||
new Intl.DateTimeFormat(i18n.language, {
|
||||
dateStyle: "medium",
|
||||
timeStyle: "short",
|
||||
}).format(new Date(value));
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.companies.detail">
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.companiesHref}>
|
||||
{t("admin.sales.companies.title")}
|
||||
</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>{props.vm.name}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
</PageBody>
|
||||
<PageHeader
|
||||
icon={<FeatherBuilding className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={props.vm.name}
|
||||
subtitle={
|
||||
props.vm.legalName ??
|
||||
props.vm.domain ??
|
||||
t("admin.sales.companies.detail.subtitle")
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<div className="grid w-full grid-cols-3 gap-4 tablet:grid-cols-1">
|
||||
<InfoCard
|
||||
label={t("admin.sales.companies.detail.location")}
|
||||
value={props.vm.locationLabel}
|
||||
/>
|
||||
<InfoCard
|
||||
label={t("admin.sales.companies.detail.industry")}
|
||||
value={props.vm.industry}
|
||||
/>
|
||||
<InfoCard
|
||||
label={t("admin.sales.companies.detail.employeeRange")}
|
||||
value={props.vm.employeeRange}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1">
|
||||
<Card>
|
||||
<SectionHeading
|
||||
icon={<FeatherUsers />}
|
||||
title={t("admin.sales.companies.detail.contacts")}
|
||||
/>
|
||||
{props.vm.contacts.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.companies.detail.emptyContacts")}
|
||||
body={t("admin.sales.companies.detail.emptyContactsBody")}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.contact")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.companies.table.channels")}
|
||||
</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{props.vm.contacts.map((contact) => (
|
||||
<Table.Row key={contact.id}>
|
||||
<Table.Cell>
|
||||
<Link className="text-text-brand hover:underline" to={contact.href}>
|
||||
{contact.name}
|
||||
</Link>
|
||||
<span className="block text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{contact.jobTitle ?? t("shared.notSet")}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{contact.email ?? contact.phone ?? t("shared.notSet")}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionHeading
|
||||
icon={<FeatherBriefcase />}
|
||||
title={t("admin.sales.companies.detail.deals")}
|
||||
/>
|
||||
{props.vm.deals.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.companies.detail.emptyDeals")}
|
||||
body={t("admin.sales.companies.detail.emptyDealsBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{props.vm.deals.map((deal) => (
|
||||
<Link
|
||||
key={deal.id}
|
||||
to={deal.href}
|
||||
className="flex items-center justify-between rounded-md border border-border-default p-3 hover:bg-surface-neutral-secondary"
|
||||
>
|
||||
<span>
|
||||
<span className="block text-body-small-medium-0 text-text-neutral-primary">
|
||||
{deal.title}
|
||||
</span>
|
||||
<span className="text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{deal.stageName} · {deal.amountLabel || t("shared.notSet")}
|
||||
</span>
|
||||
</span>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
deal.status === "won"
|
||||
? "subtle-positive"
|
||||
: deal.status === "lost"
|
||||
? "subtle-negative"
|
||||
: "subtle-neutral"
|
||||
}
|
||||
>
|
||||
{t(`admin.sales.companies.dealStatus.${deal.status}`)}
|
||||
</BadgeFeedback>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
<Card>
|
||||
<SectionHeading
|
||||
title={t("admin.sales.companies.detail.timeline")}
|
||||
/>
|
||||
{props.vm.activities.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.companies.detail.emptyTimeline")}
|
||||
body={t("admin.sales.companies.detail.emptyTimelineBody")}
|
||||
/>
|
||||
) : (
|
||||
<ol className="flex w-full flex-col gap-3">
|
||||
{props.vm.activities.map((activity) => (
|
||||
<li
|
||||
key={activity.id}
|
||||
className="flex items-start justify-between gap-4 border-b border-border-default pb-3 last:border-0 last:pb-0"
|
||||
>
|
||||
<span>
|
||||
{activity.href ? (
|
||||
<Link className="text-text-brand hover:underline" to={activity.href}>
|
||||
{activity.summary}
|
||||
</Link>
|
||||
) : (
|
||||
activity.summary
|
||||
)}
|
||||
</span>
|
||||
<time className="shrink-0 text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatDate(activity.occurredAtIso)}
|
||||
</time>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
)}
|
||||
</Card>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function InfoCard(props: {
|
||||
readonly label: string;
|
||||
readonly value: string | null;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<span className="text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{props.label}
|
||||
</span>
|
||||
<strong className="text-body-default-medium-0 text-text-neutral-primary">
|
||||
{props.value || t("shared.notSet")}
|
||||
</strong>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionHeading(props: {
|
||||
readonly icon?: React.ReactNode;
|
||||
readonly title: string;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<h2 className="flex items-center gap-2 text-body-large-0 font-body-large-0 text-text-neutral-primary">
|
||||
{props.icon}
|
||||
{props.title}
|
||||
</h2>
|
||||
);
|
||||
}
|
||||
+715
@@ -0,0 +1,715 @@
|
||||
import type {
|
||||
AdminSalesDataManagementVM,
|
||||
AdminSalesImportPreviewVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherDatabase,
|
||||
FeatherDownload,
|
||||
FeatherFileUp,
|
||||
FeatherSearch,
|
||||
FeatherSettings2,
|
||||
FeatherTags,
|
||||
FeatherUsers,
|
||||
} from "@subframe/core";
|
||||
import { useMemo, useRef, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type AdminSalesContactsActions = {
|
||||
readonly onBulkUpdate: (input: {
|
||||
readonly contactIds: readonly string[];
|
||||
readonly locale: string | null;
|
||||
readonly addTagIds: readonly string[];
|
||||
}) => void;
|
||||
readonly onCreateTag: (input: {
|
||||
readonly name: string;
|
||||
readonly color: string | null;
|
||||
}) => void;
|
||||
readonly onCreateCustomField: (input: {
|
||||
readonly target: "contact" | "deal";
|
||||
readonly key: string;
|
||||
readonly label: string;
|
||||
readonly type: "text" | "number" | "boolean" | "date" | "single_select";
|
||||
readonly options: readonly string[];
|
||||
readonly required: boolean;
|
||||
readonly position: number;
|
||||
}) => void;
|
||||
readonly onPreviewImport: (file: File) => void;
|
||||
readonly onConfirmImport: (importJobId: string) => void;
|
||||
readonly onExport: (contactIds: readonly string[]) => void;
|
||||
};
|
||||
|
||||
export function AdminSalesContactsPage(props: {
|
||||
readonly vm: AdminSalesDataManagementVM;
|
||||
readonly view?: "contacts" | "fields-tags" | "import-export";
|
||||
readonly preview?: AdminSalesImportPreviewVM | null;
|
||||
readonly submitting: boolean;
|
||||
readonly successMessage?: string | null;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: AdminSalesContactsActions;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const view = props.view ?? "contacts";
|
||||
const fileInput = useRef<HTMLInputElement>(null);
|
||||
const [query, setQuery] = useState("");
|
||||
const [selectedIds, setSelectedIds] = useState<readonly string[]>([]);
|
||||
const [bulkLocale, setBulkLocale] = useState("unchanged");
|
||||
const [bulkTagId, setBulkTagId] = useState("none");
|
||||
const [tagName, setTagName] = useState("");
|
||||
const [tagColor, setTagColor] = useState("#2563eb");
|
||||
const [fieldTarget, setFieldTarget] = useState<"contact" | "deal">("contact");
|
||||
const [fieldKey, setFieldKey] = useState("");
|
||||
const [fieldLabel, setFieldLabel] = useState("");
|
||||
const [fieldType, setFieldType] =
|
||||
useState<AdminSalesDataManagementVM["customFields"][number]["type"]>(
|
||||
"text"
|
||||
);
|
||||
const [fieldOptions, setFieldOptions] = useState("");
|
||||
const [fieldRequired, setFieldRequired] = useState(false);
|
||||
|
||||
const visibleContacts = useMemo(() => {
|
||||
const normalized = query.trim().toLocaleLowerCase("de-DE");
|
||||
if (!normalized) return props.vm.contacts;
|
||||
return props.vm.contacts.filter((contact) =>
|
||||
[
|
||||
contact.name,
|
||||
contact.email,
|
||||
contact.phone,
|
||||
contact.companyName,
|
||||
...contact.tags.map((tag) => tag.name),
|
||||
]
|
||||
.filter(Boolean)
|
||||
.some((value) =>
|
||||
String(value).toLocaleLowerCase("de-DE").includes(normalized)
|
||||
)
|
||||
);
|
||||
}, [props.vm.contacts, query]);
|
||||
|
||||
const allVisibleSelected =
|
||||
visibleContacts.length > 0 &&
|
||||
visibleContacts.every((contact) => selectedIds.includes(contact.id));
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.contacts.data">
|
||||
<PageHeader
|
||||
icon={<FeatherUsers className={PAGE_HEADER_ICON_CLASS} />}
|
||||
subtitleTone="secondary"
|
||||
title={t(
|
||||
view === "fields-tags"
|
||||
? "admin.sales.data.fieldsTagsTitle"
|
||||
: view === "import-export"
|
||||
? "admin.sales.data.importExportTitle"
|
||||
: props.vm.titleKey
|
||||
)}
|
||||
subtitle={t(
|
||||
view === "fields-tags"
|
||||
? "admin.sales.data.fieldsTagsSubtitle"
|
||||
: view === "import-export"
|
||||
? "admin.sales.data.importExportSubtitle"
|
||||
: "admin.sales.data.subtitle"
|
||||
)}
|
||||
actions={
|
||||
view === "import-export" ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{props.vm.permissions.canExport ? (
|
||||
<Button
|
||||
variant="neutral"
|
||||
icon={<FeatherDownload />}
|
||||
loading={props.submitting}
|
||||
onClick={() => props.actions.onExport(selectedIds)}
|
||||
>
|
||||
{selectedIds.length
|
||||
? t("admin.sales.data.actions.exportSelected", {
|
||||
count: selectedIds.length,
|
||||
})
|
||||
: t("admin.sales.data.actions.exportAll")}
|
||||
</Button>
|
||||
) : null}
|
||||
{props.vm.permissions.canWrite ? (
|
||||
<Button
|
||||
icon={<FeatherFileUp />}
|
||||
onClick={() => fileInput.current?.click()}
|
||||
>
|
||||
{t("admin.sales.data.actions.import")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
{view === "import-export" ? (
|
||||
<input
|
||||
ref={fileInput}
|
||||
className="sr-only"
|
||||
type="file"
|
||||
accept=".csv,text/csv"
|
||||
aria-label={t("admin.sales.data.import.fileLabel")}
|
||||
onChange={(event) => {
|
||||
const file = event.target.files?.[0];
|
||||
if (file) props.actions.onPreviewImport(file);
|
||||
event.target.value = "";
|
||||
}}
|
||||
/>
|
||||
) : null}
|
||||
{props.successMessage ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{props.successMessage}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{props.errorMessage ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{props.errorMessage}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
{view === "import-export" && props.preview ? (
|
||||
<Card>
|
||||
<div className="flex w-full flex-wrap items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">
|
||||
{t("admin.sales.data.import.previewTitle")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.data.import.previewDescription", {
|
||||
fileName: props.preview.fileName,
|
||||
count: props.preview.rowCount,
|
||||
})}
|
||||
</p>
|
||||
<div className="mt-2 flex flex-wrap gap-2">
|
||||
{props.preview.mapping.map((mapping) => (
|
||||
<BadgeFeedback key={mapping} farbe="subtle-information">
|
||||
{mapping.replace("=", " → ")}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onConfirmImport(props.preview!.jobId)
|
||||
}
|
||||
>
|
||||
{t("admin.sales.data.import.confirm")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{view === "contacts" ? (
|
||||
<div className="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<StatsCard
|
||||
label={t("admin.sales.data.metrics.contacts")}
|
||||
value={props.vm.summary.contactCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherUsers />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.data.metrics.tagged")}
|
||||
value={props.vm.summary.taggedContactCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherTags />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.data.metrics.fields")}
|
||||
value={props.vm.summary.customFieldCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherSettings2 />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.data.metrics.jobs")}
|
||||
value={props.vm.summary.activeJobCount}
|
||||
trend={props.vm.summary.activeJobCount ? "positive" : "neutral"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherDatabase />}
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{view === "contacts" ? (
|
||||
<Card>
|
||||
<div className="flex w-full flex-wrap items-end justify-between gap-4">
|
||||
<TextInput
|
||||
className="min-w-[280px] grow"
|
||||
label={t("admin.sales.data.search.label")}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
value={query}
|
||||
onChange={(event) => setQuery(event.target.value)}
|
||||
placeholder={t("admin.sales.data.search.placeholder")}
|
||||
/>
|
||||
</TextInput>
|
||||
<FeatherSearch className="mb-2 text-icon-neutral-tertiary" />
|
||||
</div>
|
||||
{visibleContacts.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.data.empty.title")}
|
||||
body={t("admin.sales.data.empty.body")}
|
||||
/>
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>
|
||||
<Checkbox
|
||||
checked={allVisibleSelected}
|
||||
onCheckedChange={(checked) =>
|
||||
setSelectedIds(
|
||||
checked
|
||||
? visibleContacts.map((contact) => contact.id)
|
||||
: []
|
||||
)
|
||||
}
|
||||
label={t("admin.sales.data.table.selectAll")}
|
||||
hideLabel
|
||||
/>
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.data.table.contact")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.data.table.company")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.data.table.channels")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.data.table.tags")}
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell>
|
||||
{t("admin.sales.data.table.fields")}
|
||||
</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{visibleContacts.map((contact) => (
|
||||
<Table.Row key={contact.id}>
|
||||
<Table.Cell>
|
||||
<Checkbox
|
||||
checked={selectedIds.includes(contact.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
setSelectedIds((current) =>
|
||||
checked
|
||||
? [...new Set([...current, contact.id])]
|
||||
: current.filter((id) => id !== contact.id)
|
||||
)
|
||||
}
|
||||
label={t("admin.sales.data.table.selectContact", {
|
||||
name: contact.name,
|
||||
})}
|
||||
hideLabel
|
||||
/>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Link
|
||||
to={contact.detailHref}
|
||||
className="font-body-small-medium-0 text-text-brand hover:underline"
|
||||
>
|
||||
{contact.name}
|
||||
</Link>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{contact.companyName ?? t("shared.notSet")}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-col text-body-extra-small-regular-150 text-text-neutral-secondary">
|
||||
<span>{contact.email ?? t("shared.notSet")}</span>
|
||||
<span>{contact.phone ?? t("shared.notSet")}</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{contact.tags.length
|
||||
? contact.tags.map((tag) => (
|
||||
<BadgeFeedback key={tag.id} farbe="subtle-neutral">
|
||||
{tag.name}
|
||||
</BadgeFeedback>
|
||||
))
|
||||
: t("shared.notSet")}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-col text-body-extra-small-regular-150 text-text-neutral-secondary">
|
||||
{contact.customFields.length
|
||||
? contact.customFields.map((field) => (
|
||||
<span key={field.definitionId}>
|
||||
{field.label}: {field.valueLabel || t("shared.notSet")}
|
||||
</span>
|
||||
))
|
||||
: t("shared.notSet")}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{view === "contacts" &&
|
||||
props.vm.permissions.canWrite &&
|
||||
selectedIds.length > 0 ? (
|
||||
<Card>
|
||||
<SectionTitle
|
||||
title={t("admin.sales.data.bulk.title", {
|
||||
count: selectedIds.length,
|
||||
})}
|
||||
description={t("admin.sales.data.bulk.description")}
|
||||
/>
|
||||
<div className="grid w-full grid-cols-[1fr_1fr_auto] items-end gap-4 mobile:grid-cols-1">
|
||||
<Select
|
||||
label={t("admin.sales.data.bulk.locale")}
|
||||
showLabel
|
||||
value={bulkLocale}
|
||||
onValueChange={setBulkLocale}
|
||||
>
|
||||
<Select.Item value="unchanged">
|
||||
{t("admin.sales.data.bulk.unchanged")}
|
||||
</Select.Item>
|
||||
<Select.Item value="de-DE">
|
||||
{t("admin.sales.data.bulk.locales.de")}
|
||||
</Select.Item>
|
||||
<Select.Item value="en">
|
||||
{t("admin.sales.data.bulk.locales.en")}
|
||||
</Select.Item>
|
||||
</Select>
|
||||
<Select
|
||||
label={t("admin.sales.data.bulk.addTag")}
|
||||
showLabel
|
||||
value={bulkTagId}
|
||||
onValueChange={setBulkTagId}
|
||||
>
|
||||
<Select.Item value="none">
|
||||
{t("admin.sales.data.bulk.noTag")}
|
||||
</Select.Item>
|
||||
{props.vm.tags.map((tag) => (
|
||||
<Select.Item key={tag.id} value={tag.id}>
|
||||
{tag.name}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={bulkLocale === "unchanged" && bulkTagId === "none"}
|
||||
onClick={() =>
|
||||
props.actions.onBulkUpdate({
|
||||
contactIds: selectedIds,
|
||||
locale: bulkLocale === "unchanged" ? null : bulkLocale,
|
||||
addTagIds: bulkTagId === "none" ? [] : [bulkTagId],
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.data.bulk.apply")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{view === "fields-tags" ? (
|
||||
<div className="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1">
|
||||
<Card>
|
||||
<SectionTitle
|
||||
title={t("admin.sales.data.tags.title")}
|
||||
description={t("admin.sales.data.tags.description")}
|
||||
/>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{props.vm.tags.map((tag) => (
|
||||
<BadgeFeedback key={tag.id} farbe="subtle-neutral">
|
||||
{tag.name}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
{props.vm.permissions.canWrite ? (
|
||||
<div className="grid w-full grid-cols-[1fr_120px_auto] items-end gap-3 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.data.tags.name")} showLabel>
|
||||
<TextInput.Input
|
||||
value={tagName}
|
||||
onChange={(event) => setTagName(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.data.tags.color")} showLabel>
|
||||
<TextInput.Input
|
||||
value={tagColor}
|
||||
onChange={(event) => setTagColor(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<Button
|
||||
disabled={!tagName.trim()}
|
||||
onClick={() =>
|
||||
props.actions.onCreateTag({
|
||||
name: tagName.trim(),
|
||||
color: tagColor,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.data.tags.create")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<SectionTitle
|
||||
title={t("admin.sales.data.fields.title")}
|
||||
description={t("admin.sales.data.fields.description")}
|
||||
/>
|
||||
<div className="flex flex-col gap-2">
|
||||
{props.vm.customFields.map((field) => (
|
||||
<div
|
||||
key={field.id}
|
||||
className="flex items-center justify-between rounded-md border border-border-default p-3"
|
||||
>
|
||||
<span className="flex flex-col">
|
||||
<span className="text-body-small-medium-0 text-text-neutral-primary">
|
||||
{field.label}
|
||||
</span>
|
||||
<span className="text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{field.key} · {field.type}
|
||||
</span>
|
||||
</span>
|
||||
<BadgeFeedback
|
||||
farbe={field.required ? "subtle-warning" : "subtle-neutral"}
|
||||
>
|
||||
{field.target}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
{props.vm.permissions.canWrite ? (
|
||||
<div className="grid w-full grid-cols-2 gap-3 mobile:grid-cols-1">
|
||||
<Select
|
||||
label={t("admin.sales.data.fields.target")}
|
||||
showLabel
|
||||
value={fieldTarget}
|
||||
onValueChange={(value) =>
|
||||
setFieldTarget(value as "contact" | "deal")
|
||||
}
|
||||
>
|
||||
<Select.Item value="contact">
|
||||
{t("admin.sales.data.fields.contact")}
|
||||
</Select.Item>
|
||||
<Select.Item value="deal">
|
||||
{t("admin.sales.data.fields.deal")}
|
||||
</Select.Item>
|
||||
</Select>
|
||||
<Select
|
||||
label={t("admin.sales.data.fields.type")}
|
||||
showLabel
|
||||
value={fieldType}
|
||||
onValueChange={(value) =>
|
||||
setFieldType(value as typeof fieldType)
|
||||
}
|
||||
>
|
||||
{(
|
||||
[
|
||||
"text",
|
||||
"number",
|
||||
"boolean",
|
||||
"date",
|
||||
"single_select",
|
||||
] as const
|
||||
).map((type) => (
|
||||
<Select.Item key={type} value={type}>
|
||||
{t(`admin.sales.data.fields.types.${type}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput label={t("admin.sales.data.fields.key")} showLabel>
|
||||
<TextInput.Input
|
||||
value={fieldKey}
|
||||
onChange={(event) => setFieldKey(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.data.fields.label")} showLabel>
|
||||
<TextInput.Input
|
||||
value={fieldLabel}
|
||||
onChange={(event) => setFieldLabel(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
{fieldType === "single_select" ? (
|
||||
<TextInput
|
||||
label={t("admin.sales.data.fields.options")}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
value={fieldOptions}
|
||||
onChange={(event) => setFieldOptions(event.target.value)}
|
||||
placeholder={t(
|
||||
"admin.sales.data.fields.optionsPlaceholder"
|
||||
)}
|
||||
/>
|
||||
</TextInput>
|
||||
) : null}
|
||||
<Checkbox
|
||||
checked={fieldRequired}
|
||||
onCheckedChange={setFieldRequired}
|
||||
label={t("admin.sales.data.fields.required")}
|
||||
/>
|
||||
<Button
|
||||
disabled={
|
||||
!fieldKey.trim() ||
|
||||
!fieldLabel.trim() ||
|
||||
(fieldType === "single_select" && !fieldOptions.trim())
|
||||
}
|
||||
onClick={() =>
|
||||
props.actions.onCreateCustomField({
|
||||
target: fieldTarget,
|
||||
key: fieldKey.trim(),
|
||||
label: fieldLabel.trim(),
|
||||
type: fieldType,
|
||||
options: fieldOptions
|
||||
.split(",")
|
||||
.map((value) => value.trim())
|
||||
.filter(Boolean),
|
||||
required: fieldRequired,
|
||||
position: props.vm.customFields.length,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.data.fields.create")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{view === "import-export" ? (
|
||||
<Card>
|
||||
<SectionTitle
|
||||
title={t("admin.sales.data.jobs.title")}
|
||||
description={t("admin.sales.data.jobs.description")}
|
||||
/>
|
||||
{props.vm.importJobs.length === 0 &&
|
||||
props.vm.exportJobs.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.data.jobs.empty")}
|
||||
body={t("admin.sales.data.jobs.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
<JobList
|
||||
title={t("admin.sales.data.jobs.imports")}
|
||||
jobs={props.vm.importJobs.map((job) => ({
|
||||
id: job.id,
|
||||
label: job.fileName,
|
||||
status: job.status,
|
||||
detail: `${job.acceptedRows}/${job.totalRows} · ${job.rejectedRows}`,
|
||||
href: job.errorReportHref,
|
||||
}))}
|
||||
/>
|
||||
<JobList
|
||||
title={t("admin.sales.data.jobs.exports")}
|
||||
jobs={props.vm.exportJobs.map((job) => ({
|
||||
id: job.id,
|
||||
label: t("admin.sales.data.jobs.exportLabel"),
|
||||
status: job.status,
|
||||
detail: String(job.rowCount),
|
||||
href: job.artifactHref,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
) : null}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionTitle(props: {
|
||||
readonly title: string;
|
||||
readonly description: string;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-body-large-0 font-body-large-0 text-text-neutral-primary">
|
||||
{props.title}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-150 text-text-neutral-secondary">
|
||||
{props.description}
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function JobList(props: {
|
||||
readonly title: string;
|
||||
readonly jobs: readonly {
|
||||
readonly id: string;
|
||||
readonly label: string;
|
||||
readonly status: string;
|
||||
readonly detail: string;
|
||||
readonly href: string | null;
|
||||
}[];
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<section className="flex flex-col gap-2">
|
||||
<h3 className="text-body-default-medium-0 text-text-neutral-primary">
|
||||
{props.title}
|
||||
</h3>
|
||||
{props.jobs.map((job) => (
|
||||
<div
|
||||
key={job.id}
|
||||
className="flex items-center justify-between rounded-md border border-border-default p-3"
|
||||
>
|
||||
<span className="flex flex-col">
|
||||
<span className="text-body-small-medium-0 text-text-neutral-primary">
|
||||
{job.label}
|
||||
</span>
|
||||
<span className="text-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{job.detail}
|
||||
</span>
|
||||
</span>
|
||||
<BadgeFeedback farbe={jobTone(job.status)}>
|
||||
{job.status}
|
||||
</BadgeFeedback>
|
||||
{job.href ? (
|
||||
<Link
|
||||
to={job.href}
|
||||
reloadDocument
|
||||
className="text-body-small-medium-0 text-text-brand hover:underline"
|
||||
>
|
||||
{t("admin.sales.data.jobs.download")}
|
||||
</Link>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function jobTone(
|
||||
status: string
|
||||
): "subtle-neutral" | "subtle-information" | "subtle-positive" | "subtle-negative" {
|
||||
if (status === "completed") return "subtle-positive";
|
||||
if (status === "failed") return "subtle-negative";
|
||||
if (status === "running") return "subtle-information";
|
||||
return "subtle-neutral";
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28b data-management interim visual baseline > renders accessible company list and detail surfaces 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.companies.list"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.companies.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.companies.subtitle</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><table class="group/142dfde7 h-fit w-full border border-solid border-border-default bg-surface-neutral-primary border-collapse"><thead><tr><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.company</span></div></th><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.location</span></div></th><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.industry</span></div></th><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.contacts</span></div></th><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.deals</span></div></th></tr></thead><tbody class="border-b border-solid border-border-default"><tr class="group/5d119f8d border-t border-solid border-border-default bg-surface-neutral-secondary"><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1"><a class="font-body-small-medium-0 text-text-brand hover:underline" href="/sales/companies/company_1" data-discover="true">Analytical Engines</a><span class="block text-body-extra-small-regular-150 text-text-neutral-tertiary">analytical.example</span></div></td><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1">London, GB</div></td><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1">Technology</div></td><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1">1</div></td><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1">1</div></td></tr></tbody></table></div></div></div>"`;
|
||||
|
||||
exports[`VA-P28b data-management interim visual baseline > renders accessible company list and detail surfaces 2`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.companies.detail"><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/sales/companies" data-discover="true">admin.sales.companies.title</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">Analytical Engines</span></div></div><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Analytical Engines</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Analytical Engines Ltd.</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid w-full grid-cols-3 gap-4 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><span class="text-body-extra-small-regular-150 text-text-neutral-tertiary">admin.sales.companies.detail.location</span><strong class="text-body-default-medium-0 text-text-neutral-primary">London, GB</strong></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><span class="text-body-extra-small-regular-150 text-text-neutral-tertiary">admin.sales.companies.detail.industry</span><strong class="text-body-default-medium-0 text-text-neutral-primary">Technology</strong></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><span class="text-body-extra-small-regular-150 text-text-neutral-tertiary">admin.sales.companies.detail.employeeRange</span><strong class="text-body-default-medium-0 text-text-neutral-primary">11-50</strong></div></div><div class="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><h2 class="flex items-center gap-2 text-body-large-0 font-body-large-0 text-text-neutral-primary"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span>admin.sales.companies.detail.contacts</h2><table class="group/142dfde7 h-fit w-full border border-solid border-border-default bg-surface-neutral-primary border-collapse"><thead><tr><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.contact</span></div></th><th class="h-10"><div class="flex h-full w-full items-center gap-1 border-r border-solid border-border-default px-4 text-left last:border-r-0"><span class="whitespace-nowrap text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">admin.sales.companies.table.channels</span></div></th></tr></thead><tbody class="border-b border-solid border-border-default"><tr class="group/5d119f8d border-t border-solid border-border-default bg-surface-neutral-secondary"><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1"><a class="text-text-brand hover:underline" href="/sales/contacts/contact_1" data-discover="true">Ada Lovelace</a><span class="block text-body-extra-small-regular-150 text-text-neutral-tertiary">Founder</span></div></td><td><div class="group/291d4418 flex h-full min-h-[48px] w-full min-w-[0px] items-center border-r border-solid border-border-default px-4 py-1">ada@example.com</div></td></tr></tbody></table></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md boLine truncated
|
||||
|
||||
exports[`VA-P28b data-management interim visual baseline > renders contacts, typed fields, tags, jobs and bulk actions 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.contacts.data"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.data.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">admin.sales.data.subtitle</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.data.metrics.contacts</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">2</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.data.metrics.tagged</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.data.metrics.fields</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class=Line truncated
|
||||
|
||||
exports[`VA-P28b data-management interim visual baseline > renders the focused fields/tags and import/export surfaces 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.contacts.data"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.data.fieldsTagsTitle</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">admin.sales.data.fieldsTagsSubtitle</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex flex-col gap-1"><h2 class="text-body-large-0 font-body-large-0 text-text-neutral-primary">admin.sales.data.tags.title</h2><p class="text-body-small-regular-150 text-text-neutral-secondary">admin.sales.data.tags.description</p></div><div class="flex flex-wrap gap-2"><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-neutral"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-neutral-on-subtle"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">VIP</span></div></div><div class="grid w-full grid-cols-[1fr_120px_auto] items-end gap-3 mobile:grid-cols-1"><label class="group/be48ca43 flex h-full w-full min-w-[192px] max-w-[320px] cursor-pointer flex-col items-start justify-center gap-4"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.sales.data.tags.name</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:shadow-focus"><div class="flex grow shrink-0 basis-0 items-center self-stretch"><div class="hidden items-center gap-2 pr-2"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex grow shrink-0 basis-0 flex-col items-start self-stretch"><input class="group/b0d608f7 subframe-text-input-control h-full w-full border-none bg-transparent px-0 py-0 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary outline-none placeholder:text-text-neutral-subtle" style="box-shadow: none;" type="text" value=""></div><div class="hidden items-center gap-1 pl-2"></div></div><div class="group/39db4fac h-5 w-5 cursor-pointer flex-col items-center justify-center gap-4 hidden"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-primary group-hover/39db4fac:text-body-large-0 group-hover/39db4fac:font-body-large-0 group-active/39db4fac:text-body-default-regular-0 group-active/39db4fac:font-body-default-regular-0 icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></label><label class="group/be48ca43 flex h-full w-full min-w-[192px] max-w-[320px] cursor-pointer flex-col items-start justify-center gap-4"><div class="flex-col items-start gap-3 flex"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.sales.data.tags.color</span></div><div class="flex h-9 w-full min-w-[80px] flex-none items-center gap-2 rounded-sm border border-solid border-border-strong bg-surface-neutral-primary px-3 group-hover/be48ca43:border group-hover/be48ca43:border-solid group-hover/be48ca43:border-brand-brand-border-solid-hover group-hover/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:bg-surface-neutral-secondary group-focus-within/be48ca43:shadow-focus"><div class="flex grow shrink-0 basis-0 items-center self-stretch"><div class="hidden items-center gap-2 pr-2"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div><div class="flex grow shrink-0 basis-0 flex-col items-start self-stretch"><input class="group/b0d608f7 subframe-text-input-contLine truncated
|
||||
|
||||
exports[`VA-P28b data-management interim visual baseline > renders the focused fields/tags and import/export surfaces 2`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.contacts.data"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.data.importExportTitle</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">admin.sales.data.importExportSubtitle</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><div class="flex flex-wrap gap-2"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-surface-feedback-solid-neutral hover:bg-surface-feedback-solid-neutral-hover active:bg-surface-feedback-solid-neutral-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.data.actions.exportAll</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.data.actions.import</span></button></div></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><input class="sr-only" accept=".csv,text/csv" aria-label="admin.sales.data.import.fileLabel" type="file"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex flex-col gap-1"><h2 class="text-body-large-0 font-body-large-0 text-text-neutral-primary">admin.sales.data.jobs.title</h2><p class="text-body-small-regular-150 text-text-neutral-secondary">admin.sales.data.jobs.description</p></div><div class="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1"><section class="flex flex-col gap-2"><h3 class="text-body-default-medium-0 text-text-neutral-primary">admin.sales.data.jobs.imports</h3><div class="flex items-center justify-between rounded-md border border-border-default p-3"><span class="flex flex-col"><span class="text-body-small-medium-0 text-text-neutral-primary">kontakte.csv</span><span class="text-body-extra-small-regular-150 text-text-neutral-tertiary">0/2 · 0</span></sLine truncated
|
||||
+293
@@ -0,0 +1,293 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import {
|
||||
buildAdminSalesCompanyDetailVM,
|
||||
buildAdminSalesDataManagementVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminSalesContactsPage } from "./AdminSalesContactsPage";
|
||||
import {
|
||||
AdminSalesCompaniesPage,
|
||||
AdminSalesCompanyDetailPage,
|
||||
} from "./AdminSalesCompaniesPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) =>
|
||||
values?.count === undefined ? key : `${key}:${values.count}`,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = buildAdminSalesDataManagementVM({
|
||||
source: {
|
||||
companies: [
|
||||
{
|
||||
id: "company_1",
|
||||
name: "Analytical Engines",
|
||||
legalName: "Analytical Engines Ltd.",
|
||||
domain: "analytical.example",
|
||||
phone: "+44 20 0000",
|
||||
region: "London",
|
||||
countryCode: "GB",
|
||||
industry: "Technology",
|
||||
contactCount: 1,
|
||||
dealCount: 1,
|
||||
},
|
||||
],
|
||||
contacts: [
|
||||
{
|
||||
id: "contact_1",
|
||||
firstName: "Ada",
|
||||
lastName: "Lovelace",
|
||||
email: "ada@example.com",
|
||||
phone: "+49 30 123456",
|
||||
locale: "de-DE",
|
||||
company: { name: "Analytical Engines" },
|
||||
tags: [{ id: "tag_1", name: "VIP", color: "#2563eb" }],
|
||||
customFields: [
|
||||
{
|
||||
definitionId: "field_1",
|
||||
label: "Kundenstufe",
|
||||
type: "single_select",
|
||||
value: "A",
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "contact_2",
|
||||
firstName: "Grace",
|
||||
lastName: "Hopper",
|
||||
email: "grace@example.com",
|
||||
phone: null,
|
||||
locale: "en",
|
||||
company: { name: "Compiler Systems" },
|
||||
tags: [],
|
||||
customFields: [],
|
||||
},
|
||||
],
|
||||
tags: [{ id: "tag_1", name: "VIP", color: "#2563eb" }],
|
||||
customFields: [
|
||||
{
|
||||
id: "field_1",
|
||||
target: "contact",
|
||||
key: "customer_tier",
|
||||
label: "Kundenstufe",
|
||||
type: "single_select",
|
||||
options: ["A", "B"],
|
||||
required: true,
|
||||
position: 0,
|
||||
},
|
||||
],
|
||||
importJobs: [
|
||||
{
|
||||
id: "import_1",
|
||||
createdAt: new Date("2026-07-24T10:00:00Z"),
|
||||
fileName: "kontakte.csv",
|
||||
status: "pending",
|
||||
totalRows: 2,
|
||||
acceptedRows: 0,
|
||||
rejectedRows: 0,
|
||||
errorReportKey: null,
|
||||
},
|
||||
],
|
||||
exportJobs: [
|
||||
{
|
||||
id: "export_1",
|
||||
createdAt: new Date("2026-07-24T09:00:00Z"),
|
||||
status: "completed",
|
||||
rowCount: 2,
|
||||
artifactKey: "admin-sales/exports/export_1.csv",
|
||||
expiresAt: new Date("2026-07-31T09:00:00Z"),
|
||||
},
|
||||
],
|
||||
},
|
||||
buildContactHref: (id) => `/sales/contacts/${id}`,
|
||||
buildCompanyHref: (id) => `/sales/companies/${id}`,
|
||||
permissions: { canRead: true, canWrite: true, canExport: true },
|
||||
});
|
||||
|
||||
describe("VA-P28b data-management interim visual baseline", () => {
|
||||
it("renders contacts, typed fields, tags, jobs and bulk actions", () => {
|
||||
const onBulkUpdate = vi.fn();
|
||||
const { container, getAllByRole } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesContactsPage
|
||||
vm={vm}
|
||||
preview={{
|
||||
jobId: "import_1",
|
||||
fileName: "kontakte.csv",
|
||||
rowCount: 2,
|
||||
headers: ["Vorname", "Nachname"],
|
||||
mapping: ["Vorname=firstName", "Nachname=lastName"],
|
||||
}}
|
||||
submitting={false}
|
||||
actions={{
|
||||
onBulkUpdate,
|
||||
onCreateTag: vi.fn(),
|
||||
onCreateCustomField: vi.fn(),
|
||||
onPreviewImport: vi.fn(),
|
||||
onConfirmImport: vi.fn(),
|
||||
onExport: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("Ada Lovelace");
|
||||
expect(container).toHaveTextContent("Kundenstufe");
|
||||
fireEvent.click(getAllByRole("checkbox")[1]!);
|
||||
expect(container).toHaveTextContent("admin.sales.data.bulk.title:1");
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders the focused fields/tags and import/export surfaces", () => {
|
||||
const common = {
|
||||
vm,
|
||||
submitting: false,
|
||||
actions: {
|
||||
onBulkUpdate: vi.fn(),
|
||||
onCreateTag: vi.fn(),
|
||||
onCreateCustomField: vi.fn(),
|
||||
onPreviewImport: vi.fn(),
|
||||
onConfirmImport: vi.fn(),
|
||||
onExport: vi.fn(),
|
||||
},
|
||||
} as const;
|
||||
const { container: fields } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesContactsPage {...common} view="fields-tags" />
|
||||
</MemoryRouter>
|
||||
);
|
||||
const { container: jobs } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesContactsPage {...common} view="import-export" />
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(fields).toHaveTextContent("admin.sales.data.fieldsTagsTitle");
|
||||
expect(fields).toHaveTextContent("VIP");
|
||||
expect(jobs).toHaveTextContent("admin.sales.data.importExportTitle");
|
||||
expect(jobs).toHaveTextContent("kontakte.csv");
|
||||
expect(stableMarkup(fields.innerHTML)).toMatchSnapshot();
|
||||
expect(stableMarkup(jobs.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders accessible company list and detail surfaces", async () => {
|
||||
const detailVm = buildAdminSalesCompanyDetailVM({
|
||||
source: {
|
||||
id: "company_1",
|
||||
name: "Analytical Engines",
|
||||
legalName: "Analytical Engines Ltd.",
|
||||
domain: "analytical.example",
|
||||
website: "https://analytical.example",
|
||||
phone: "+44 20 0000",
|
||||
region: "London",
|
||||
countryCode: "GB",
|
||||
industry: "Technology",
|
||||
employeeRange: "11-50",
|
||||
contacts: [
|
||||
{
|
||||
id: "contact_1",
|
||||
firstName: "Ada",
|
||||
lastName: "Lovelace",
|
||||
jobTitle: "Founder",
|
||||
email: "ada@example.com",
|
||||
phone: null,
|
||||
},
|
||||
],
|
||||
deals: [
|
||||
{
|
||||
id: "deal_1",
|
||||
title: "Enterprise",
|
||||
status: "open",
|
||||
amountCents: 12_500,
|
||||
currencyCode: "EUR",
|
||||
stageName: "Demo",
|
||||
},
|
||||
],
|
||||
activities: [
|
||||
{
|
||||
id: "activity_1",
|
||||
type: "deal_created",
|
||||
summary: "Deal angelegt",
|
||||
occurredAt: new Date("2026-07-24T12:00:00.000Z"),
|
||||
contactId: null,
|
||||
dealId: "deal_1",
|
||||
},
|
||||
],
|
||||
},
|
||||
locale: "de-DE",
|
||||
buildContactHref: (id) => `/sales/contacts/${id}`,
|
||||
buildDealHref: (id) => `/sales/deals/${id}`,
|
||||
});
|
||||
const { container: list } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesCompaniesPage vm={vm} />
|
||||
</MemoryRouter>
|
||||
);
|
||||
const { container: detail } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesCompanyDetailPage
|
||||
vm={detailVm}
|
||||
companiesHref="/sales/companies"
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(list).toHaveTextContent("Analytical Engines");
|
||||
expect(detail).toHaveTextContent("Ada Lovelace");
|
||||
expect(stableMarkup(list.innerHTML)).toMatchSnapshot();
|
||||
expect(stableMarkup(detail.innerHTML)).toMatchSnapshot();
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminSalesCompanyDetailPage
|
||||
vm={detailVm}
|
||||
companiesHref="/sales/companies"
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
|
||||
it("is accessible with a pending reviewed import", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminSalesContactsPage
|
||||
vm={vm}
|
||||
preview={{
|
||||
jobId: "import_1",
|
||||
fileName: "kontakte.csv",
|
||||
rowCount: 2,
|
||||
headers: ["Vorname", "Nachname"],
|
||||
mapping: ["Vorname=firstName", "Nachname=lastName"],
|
||||
}}
|
||||
submitting={false}
|
||||
actions={{
|
||||
onBulkUpdate: vi.fn(),
|
||||
onCreateTag: vi.fn(),
|
||||
onCreateCustomField: vi.fn(),
|
||||
onPreviewImport: vi.fn(),
|
||||
onConfirmImport: vi.fn(),
|
||||
onExport: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function stableMarkup(value: string): string {
|
||||
return value
|
||||
.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
)
|
||||
.replace(
|
||||
/(<time\b[^>]*>)[\s\S]*?(<\/time>)/gu,
|
||||
"$1__DATE_TIME__$2"
|
||||
);
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import path from "node:path";
|
||||
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
describe("admin sales data locale copy", () => {
|
||||
it("renders bulk locale choices through translation keys", () => {
|
||||
const source = readFileSync(
|
||||
path.resolve(
|
||||
process.cwd(),
|
||||
"apps/web/app/components/screens/admin/sales/data/AdminSalesContactsPage.tsx",
|
||||
),
|
||||
"utf8",
|
||||
);
|
||||
|
||||
expect(source).toContain('t("admin.sales.data.bulk.locales.de")');
|
||||
expect(source).toContain('t("admin.sales.data.bulk.locales.en")');
|
||||
expect(source).not.toContain('value="de-DE">Deutsch');
|
||||
expect(source).not.toContain('value="en">English');
|
||||
});
|
||||
});
|
||||
+822
@@ -0,0 +1,822 @@
|
||||
import type {
|
||||
AdminDealDetailVM,
|
||||
AdminSalesTaskVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherArrowRight,
|
||||
FeatherBriefcase,
|
||||
FeatherCalendar,
|
||||
FeatherCheck,
|
||||
FeatherClock,
|
||||
FeatherEdit3,
|
||||
FeatherHistory,
|
||||
FeatherCalendarPlus,
|
||||
FeatherMail,
|
||||
FeatherPhone,
|
||||
} from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBackLink, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import {
|
||||
AdminSalesTaskCreateDialog,
|
||||
type AdminSalesTaskCreateInput,
|
||||
} from "../tasks/AdminSalesTaskCreateDialog";
|
||||
import { AdminSalesTaskList } from "../tasks/AdminSalesTaskList";
|
||||
|
||||
export type AdminSalesDealDetailActions = {
|
||||
readonly onMove: (input: {
|
||||
readonly dealId: string;
|
||||
readonly targetStageId: string;
|
||||
readonly lossReasonId: string | null;
|
||||
readonly lossReasonNote: string | null;
|
||||
readonly reason: string;
|
||||
}) => void;
|
||||
readonly onUpdate: (input: {
|
||||
readonly dealId: string;
|
||||
readonly amountCents: number | null;
|
||||
readonly currencyCode: string;
|
||||
readonly expectedCloseDate: string | null;
|
||||
readonly nextStep: string | null;
|
||||
readonly nextStepDueAt: string | null;
|
||||
readonly reason: string;
|
||||
}) => void;
|
||||
readonly onReplaceBuyingCenter: (input: {
|
||||
readonly dealId: string;
|
||||
readonly contactIds: readonly string[];
|
||||
readonly primaryContactId: string | null;
|
||||
readonly roles: Readonly<Record<string, string>>;
|
||||
readonly reason: string;
|
||||
}) => void;
|
||||
readonly onPromoteTenant: (input: {
|
||||
readonly dealId: string;
|
||||
readonly mode: "link_existing" | "create_new";
|
||||
readonly tenantId: string | null;
|
||||
readonly tenantName: string | null;
|
||||
readonly tenantSlug: string | null;
|
||||
readonly ownerEmail: string | null;
|
||||
readonly ownerFirstName: string | null;
|
||||
readonly ownerLastName: string | null;
|
||||
readonly confirmed: true;
|
||||
readonly reason: string;
|
||||
}) => void;
|
||||
readonly onCreateTask: (input: AdminSalesTaskCreateInput) => void;
|
||||
readonly onCompleteTask: (taskId: string) => void;
|
||||
readonly onCall: (contactId: string) => void;
|
||||
};
|
||||
|
||||
export function AdminSalesDealDetailPage(props: {
|
||||
readonly vm: AdminDealDetailVM;
|
||||
readonly taskVm: {
|
||||
readonly tasks: readonly AdminSalesTaskVM[];
|
||||
readonly currentAdminUserId: string;
|
||||
readonly timeZone: string;
|
||||
readonly canWrite: boolean;
|
||||
};
|
||||
readonly backHref: string;
|
||||
readonly emailComposeHref?: string | null;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: AdminSalesDealDetailActions;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [editOpen, setEditOpen] = useState(false);
|
||||
const [buyingCenterOpen, setBuyingCenterOpen] = useState(false);
|
||||
const [moveOpen, setMoveOpen] = useState(false);
|
||||
const [createTaskOpen, setCreateTaskOpen] = useState(false);
|
||||
const [promotionOpen, setPromotionOpen] = useState(false);
|
||||
const [promotionMode, setPromotionMode] = useState<
|
||||
"link_existing" | "create_new"
|
||||
>("link_existing");
|
||||
const [promotionTenantId, setPromotionTenantId] = useState(
|
||||
props.vm.tenantOptions[0]?.id ?? ""
|
||||
);
|
||||
const primaryPhoneContact = props.vm.contacts.find(
|
||||
(contact) => contact.isPrimary && contact.phone
|
||||
);
|
||||
const [promotionTenantName, setPromotionTenantName] = useState(
|
||||
props.vm.tenantPromotionDefaults.tenantName
|
||||
);
|
||||
const [promotionTenantSlug, setPromotionTenantSlug] = useState(
|
||||
props.vm.tenantPromotionDefaults.tenantSlug
|
||||
);
|
||||
const [promotionOwnerEmail, setPromotionOwnerEmail] = useState(
|
||||
props.vm.tenantPromotionDefaults.ownerEmail
|
||||
);
|
||||
const [promotionOwnerFirstName, setPromotionOwnerFirstName] = useState(
|
||||
props.vm.tenantPromotionDefaults.ownerFirstName
|
||||
);
|
||||
const [promotionOwnerLastName, setPromotionOwnerLastName] = useState(
|
||||
props.vm.tenantPromotionDefaults.ownerLastName
|
||||
);
|
||||
const [promotionConfirmed, setPromotionConfirmed] = useState(false);
|
||||
const [promotionReason, setPromotionReason] = useState("");
|
||||
const [selectedStageId, setSelectedStageId] = useState(props.vm.stageId);
|
||||
const [lossReasonId, setLossReasonId] = useState("");
|
||||
const [lossReasonNote, setLossReasonNote] = useState("");
|
||||
const [amount, setAmount] = useState(props.vm.amountCents === null ? "" : String(props.vm.amountCents / 100));
|
||||
const [expectedCloseDate, setExpectedCloseDate] = useState(props.vm.expectedCloseDate ?? "");
|
||||
const [nextStep, setNextStep] = useState(props.vm.nextStep ?? "");
|
||||
const [nextStepDueAt, setNextStepDueAt] = useState(toLocalDateTime(props.vm.nextStepDueAt));
|
||||
const [contactIds, setContactIds] = useState<ReadonlySet<string>>(new Set(props.vm.contacts.map((contact) => contact.id)));
|
||||
const [primaryContactId, setPrimaryContactId] = useState(props.vm.contacts.find((contact) => contact.isPrimary)?.id ?? "");
|
||||
const [roles, setRoles] = useState<Record<string, string>>(
|
||||
Object.fromEntries(props.vm.contacts.filter((contact) => contact.role).map((contact) => [contact.id, contact.role ?? ""]))
|
||||
);
|
||||
|
||||
const selectedStage = props.vm.stages.find((stage) => stage.id === selectedStageId);
|
||||
const statusTone = props.vm.status === "won" ? "subtle-positive" : props.vm.status === "lost" ? "subtle-negative" : "subtle-neutral";
|
||||
|
||||
function toggleContact(contactId: string, checked: boolean) {
|
||||
setContactIds((current) => {
|
||||
const next = new Set(current);
|
||||
if (checked) next.add(contactId);
|
||||
else {
|
||||
next.delete(contactId);
|
||||
if (primaryContactId === contactId) setPrimaryContactId("");
|
||||
}
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.deals.detail">
|
||||
<PageHeader
|
||||
icon={<FeatherBriefcase className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={props.vm.title}
|
||||
subtitle={props.vm.companyName ?? props.vm.pipelineName}
|
||||
actions={
|
||||
<>
|
||||
<BadgeFeedback farbe={statusTone}>{t(props.vm.statusLabelKey)}</BadgeFeedback>
|
||||
{props.vm.canWrite ? (
|
||||
<>
|
||||
{props.emailComposeHref ? (
|
||||
<Link
|
||||
to={props.emailComposeHref}
|
||||
className="contents no-underline"
|
||||
>
|
||||
<Button variant="neutral" icon={<FeatherMail />}>
|
||||
{t("admin.sales.email.actions.compose")}
|
||||
</Button>
|
||||
</Link>
|
||||
) : null}
|
||||
{primaryPhoneContact ? (
|
||||
<Button
|
||||
variant="neutral"
|
||||
icon={<FeatherPhone />}
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onCall(primaryPhoneContact.id)
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.outbound.call")}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button variant="neutral" icon={<FeatherArrowRight />} onClick={() => setMoveOpen(true)}>
|
||||
{t("admin.sales.deals.actions.move")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="neutral"
|
||||
icon={<FeatherCalendarPlus />}
|
||||
onClick={() => setCreateTaskOpen(true)}
|
||||
>
|
||||
{t("admin.sales.tasks.actions.create")}
|
||||
</Button>
|
||||
<Button icon={<FeatherEdit3 />} onClick={() => setEditOpen(true)}>
|
||||
{t("shared.edit")}
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.backHref}>{t("admin.sales.deals.title")}</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>{props.vm.title}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<PageBackLink to={props.backHref} label={t("admin.sales.deals.actions.backToPipeline")} />
|
||||
{props.errorMessage ? <div className="rounded-md bg-surface-feedback-subtle-negative px-4 py-3 text-text-feedback-negative">{props.errorMessage}</div> : null}
|
||||
|
||||
<div className="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<Metric label={t("admin.sales.deals.fields.stage")} value={props.vm.stageName} icon={<FeatherHistory />} />
|
||||
<Metric label={t("admin.sales.deals.fields.amount")} value={props.vm.amountLabel} icon={<FeatherBriefcase />} />
|
||||
<Metric label={t("admin.sales.deals.fields.probability")} value={props.vm.probabilityLabel} icon={<FeatherCheck />} />
|
||||
<Metric
|
||||
label={t("admin.sales.deals.fields.expectedCloseDate")}
|
||||
value={props.vm.expectedCloseDate ?? t("shared.notSet")}
|
||||
icon={<FeatherCalendar />}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full grid-cols-3 gap-6 tablet:grid-cols-1">
|
||||
<section className="col-span-2 flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5 tablet:col-span-1">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.deals.nextStep.title")}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{t("admin.sales.deals.nextStep.description")}</p>
|
||||
</div>
|
||||
<FeatherClock className="text-heading- text-icon-neutral-tertiary" />
|
||||
</div>
|
||||
{props.vm.nextStep ? (
|
||||
<div className="flex flex-col gap-1 rounded-md bg-surface-neutral-primary p-4">
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">{props.vm.nextStep}</span>
|
||||
{props.vm.nextStepDueAt ? <span className="text-body-small-regular-0 text-text-neutral-tertiary">{props.vm.nextStepDueAt}</span> : null}
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState outlined title={t("admin.sales.deals.nextStep.missing")} body={t("admin.sales.deals.nextStep.emptyDescription")} />
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.deals.contacts.title")}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{t("admin.sales.deals.contacts.description")}</p>
|
||||
</div>
|
||||
{props.vm.canWrite ? (
|
||||
<Button variant="tertiary" size="small" onClick={() => setBuyingCenterOpen(true)}>
|
||||
{t("shared.edit")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
{props.vm.contacts.length === 0 ? (
|
||||
<EmptyState title={t("admin.sales.deals.contacts.empty")} />
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{props.vm.contacts.map((contact) => (
|
||||
<div key={contact.id} className="flex items-start justify-between gap-3 rounded-md bg-surface-neutral-primary px-3 py-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
{contact.href ? (
|
||||
<Link
|
||||
to={contact.href}
|
||||
className="text-body-small-medium-0 text-text-brand hover:underline"
|
||||
>
|
||||
{contact.name}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="text-body-small-medium-0 text-text-neutral-primary">{contact.name}</span>
|
||||
)}
|
||||
{contact.role ? <span className="text-body-extra-small-regular-0 text-text-neutral-tertiary">{contact.role}</span> : null}
|
||||
</div>
|
||||
{contact.isPrimary ? <BadgeFeedback farbe="subtle-positive" size="small">{t("admin.sales.deals.contacts.primary")}</BadgeFeedback> : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section className="flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div className="flex items-start justify-between gap-4 mobile:flex-col">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("admin.sales.deals.tenantPromotion.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.deals.tenantPromotion.description")}
|
||||
</p>
|
||||
</div>
|
||||
{props.vm.canPromoteTenant ? (
|
||||
<Button
|
||||
variant="neutral"
|
||||
data-ui-id="ui.admin.sales.deals.tenantPromotionAction"
|
||||
onClick={() => setPromotionOpen(true)}
|
||||
>
|
||||
{t("admin.sales.deals.tenantPromotion.action")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
{props.vm.promotedTenantId ? (
|
||||
<div className="flex items-center justify-between gap-4 rounded-md bg-surface-feedback-subtle-positive px-4 py-3 mobile:flex-col mobile:items-start">
|
||||
<div className="flex flex-col gap-1">
|
||||
{props.vm.promotedTenantHref ? (
|
||||
<Link
|
||||
to={props.vm.promotedTenantHref}
|
||||
className="text-body-default-medium-0 text-text-brand hover:underline"
|
||||
>
|
||||
{props.vm.promotedTenantName ??
|
||||
props.vm.promotedTenantId}
|
||||
</Link>
|
||||
) : (
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">
|
||||
{props.vm.promotedTenantName ??
|
||||
props.vm.promotedTenantId}
|
||||
</span>
|
||||
)}
|
||||
{props.vm.promotedAtLabel ? (
|
||||
<span className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.deals.tenantPromotion.linkedAt", {
|
||||
date: props.vm.promotedAtLabel,
|
||||
})}
|
||||
</span>
|
||||
) : null}
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-positive">
|
||||
{t("admin.sales.deals.tenantPromotion.linked")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
) : props.vm.status !== "won" ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.deals.tenantPromotion.wonRequired")}
|
||||
body={t("admin.sales.deals.tenantPromotion.wonRequiredBody")}
|
||||
/>
|
||||
) : (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.deals.tenantPromotion.notLinked")}
|
||||
body={t("admin.sales.deals.tenantPromotion.notLinkedBody")}
|
||||
/>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<div className="grid w-full grid-cols-2 gap-6 tablet:grid-cols-1">
|
||||
<section className="flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("admin.sales.tasks.deal.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.tasks.deal.description")}
|
||||
</p>
|
||||
</div>
|
||||
{props.taskVm.canWrite ? (
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherCalendarPlus />}
|
||||
onClick={() => setCreateTaskOpen(true)}
|
||||
>
|
||||
{t("admin.sales.tasks.actions.create")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<AdminSalesTaskList
|
||||
tasks={props.taskVm.tasks}
|
||||
emptyTitleKey="admin.sales.tasks.empty.deal"
|
||||
emptyBodyKey="admin.sales.tasks.empty.dealBody"
|
||||
submitting={props.submitting}
|
||||
onComplete={props.actions.onCompleteTask}
|
||||
/>
|
||||
</section>
|
||||
<TimelineSection
|
||||
title={t("admin.sales.deals.history.title")}
|
||||
empty={t("admin.sales.deals.history.empty")}
|
||||
rows={props.vm.history.map((entry) => ({
|
||||
id: entry.id,
|
||||
title: entry.transitionLabel,
|
||||
subtitle: entry.reason,
|
||||
meta: entry.enteredAtLabel,
|
||||
}))}
|
||||
/>
|
||||
<TimelineSection
|
||||
title={t("admin.sales.deals.activity.title")}
|
||||
empty={t("admin.sales.deals.activity.empty")}
|
||||
rows={props.vm.activities.map((activity) => ({
|
||||
id: activity.id,
|
||||
title: activity.summary,
|
||||
subtitle: t(activity.typeLabelKey),
|
||||
meta: activity.occurredAtLabel,
|
||||
}))}
|
||||
/>
|
||||
</div>
|
||||
</PageBody>
|
||||
|
||||
<Dialog open={editOpen} onOpenChange={setEditOpen}>
|
||||
<Dialog.Content className="w-[560px] max-w-[92vw] p-6" data-ui-id="ui.admin.sales.deals.editDialog">
|
||||
<div className="flex flex-col gap-4">
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.deals.edit.title")}</h2>
|
||||
<div className="grid grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.deals.fields.amount")} showLabel>
|
||||
<TextInput.Input type="number" min="0" step="0.01" value={amount} onChange={(event) => setAmount(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.deals.fields.expectedCloseDate")} showLabel>
|
||||
<TextInput.Input type="date" value={expectedCloseDate} onChange={(event) => setExpectedCloseDate(event.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextArea label={t("admin.sales.deals.fields.nextStep")} showLabel>
|
||||
<TextArea.Input value={nextStep} onChange={(event) => setNextStep(event.target.value)} />
|
||||
</TextArea>
|
||||
<TextInput label={t("admin.sales.deals.fields.nextStepDueAt")} showLabel>
|
||||
<TextInput.Input type="datetime-local" value={nextStepDueAt} onChange={(event) => setNextStepDueAt(event.target.value)} />
|
||||
</TextInput>
|
||||
<DialogActions
|
||||
cancelLabel={t("shared.cancel")}
|
||||
saveLabel={t("shared.save")}
|
||||
submitting={props.submitting}
|
||||
onCancel={() => setEditOpen(false)}
|
||||
onSave={() => {
|
||||
const parsedAmount = amount.trim() ? Math.round(Number(amount.replace(",", ".")) * 100) : null;
|
||||
props.actions.onUpdate({
|
||||
dealId: props.vm.id,
|
||||
amountCents: Number.isSafeInteger(parsedAmount) && (parsedAmount ?? 0) >= 0 ? parsedAmount : null,
|
||||
currencyCode: props.vm.currencyCode,
|
||||
expectedCloseDate: expectedCloseDate || null,
|
||||
nextStep: nextStep.trim() || null,
|
||||
nextStepDueAt: nextStepDueAt ? new Date(nextStepDueAt).toISOString() : null,
|
||||
reason: t("admin.sales.deals.audit.updated"),
|
||||
});
|
||||
setEditOpen(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
<AdminSalesTaskCreateDialog
|
||||
open={createTaskOpen}
|
||||
onOpenChange={setCreateTaskOpen}
|
||||
contactId={
|
||||
props.vm.contacts.find((contact) => contact.isPrimary)?.id ?? null
|
||||
}
|
||||
dealId={props.vm.id}
|
||||
assignedToAdminUserId={props.taskVm.currentAdminUserId}
|
||||
timeZone={props.taskVm.timeZone}
|
||||
submitting={props.submitting}
|
||||
onCreate={props.actions.onCreateTask}
|
||||
/>
|
||||
|
||||
<Dialog open={moveOpen} onOpenChange={setMoveOpen}>
|
||||
<Dialog.Content className="w-[480px] max-w-[92vw] p-6" data-ui-id="ui.admin.sales.deals.moveDialog">
|
||||
<div className="flex flex-col gap-4">
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.deals.move.title")}</h2>
|
||||
<Select label={t("admin.sales.deals.fields.stage")} showLabel value={selectedStageId} onValueChange={setSelectedStageId}>
|
||||
{props.vm.stages.map((stage) => (
|
||||
<Select.Item key={stage.id} value={stage.id}>{stage.name}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
{selectedStage?.kind === "lost" ? (
|
||||
<>
|
||||
<Select label={t("admin.sales.deals.fields.lossReason")} showLabel value={lossReasonId} onValueChange={setLossReasonId}>
|
||||
{props.vm.lossReasons.map((reason) => (
|
||||
<Select.Item key={reason.id} value={reason.id}>{reason.label}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextArea label={t("admin.sales.deals.fields.lossReasonNote")} showLabel>
|
||||
<TextArea.Input value={lossReasonNote} onChange={(event) => setLossReasonNote(event.target.value)} />
|
||||
</TextArea>
|
||||
</>
|
||||
) : null}
|
||||
<DialogActions
|
||||
cancelLabel={t("shared.cancel")}
|
||||
saveLabel={t("admin.sales.deals.actions.move")}
|
||||
submitting={props.submitting}
|
||||
disabled={!selectedStage || (selectedStage.kind === "lost" && !lossReasonId)}
|
||||
onCancel={() => setMoveOpen(false)}
|
||||
onSave={() => {
|
||||
if (!selectedStage) return;
|
||||
props.actions.onMove({
|
||||
dealId: props.vm.id,
|
||||
targetStageId: selectedStage.id,
|
||||
lossReasonId: selectedStage.kind === "lost" ? lossReasonId : null,
|
||||
lossReasonNote: selectedStage.kind === "lost" ? lossReasonNote.trim() || null : null,
|
||||
reason: t("admin.sales.deals.audit.stageMove", { stage: selectedStage.name }),
|
||||
});
|
||||
setMoveOpen(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
<Dialog open={buyingCenterOpen} onOpenChange={setBuyingCenterOpen}>
|
||||
<Dialog.Content className="w-[640px] max-w-[92vw] p-6" data-ui-id="ui.admin.sales.deals.buyingCenterDialog">
|
||||
<div className="flex max-h-[80vh] flex-col gap-4 overflow-y-auto">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.deals.contacts.editTitle")}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{t("admin.sales.deals.contacts.editDescription")}</p>
|
||||
</div>
|
||||
{props.vm.contactOptions.map((contact) => {
|
||||
const selected = contactIds.has(contact.id);
|
||||
return (
|
||||
<div key={contact.id} className="grid grid-cols-[1fr_160px] items-end gap-3 rounded-md border border-border-default p-3 mobile:grid-cols-1">
|
||||
<Checkbox
|
||||
checked={selected}
|
||||
onCheckedChange={(checked) => toggleContact(contact.id, checked)}
|
||||
label={contact.label}
|
||||
description={contact.companyName ?? undefined}
|
||||
/>
|
||||
<TextInput label={t("admin.sales.deals.contacts.role")} showLabel>
|
||||
<TextInput.Input
|
||||
disabled={!selected}
|
||||
value={roles[contact.id] ?? ""}
|
||||
onChange={(event) => setRoles((current) => ({ ...current, [contact.id]: event.target.value }))}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
<Select
|
||||
label={t("admin.sales.deals.contacts.primary")}
|
||||
showLabel
|
||||
value={primaryContactId}
|
||||
onValueChange={setPrimaryContactId}
|
||||
disabled={contactIds.size === 0}
|
||||
>
|
||||
{[...contactIds].map((contactId) => {
|
||||
const option = props.vm.contactOptions.find((contact) => contact.id === contactId);
|
||||
return option ? <Select.Item key={option.id} value={option.id}>{option.label}</Select.Item> : null;
|
||||
})}
|
||||
</Select>
|
||||
<DialogActions
|
||||
cancelLabel={t("shared.cancel")}
|
||||
saveLabel={t("shared.save")}
|
||||
submitting={props.submitting}
|
||||
disabled={contactIds.size > 0 && !primaryContactId}
|
||||
onCancel={() => setBuyingCenterOpen(false)}
|
||||
onSave={() => {
|
||||
props.actions.onReplaceBuyingCenter({
|
||||
dealId: props.vm.id,
|
||||
contactIds: [...contactIds],
|
||||
primaryContactId: primaryContactId || null,
|
||||
roles: Object.fromEntries([...contactIds].filter((id) => roles[id]?.trim()).map((id) => [id, roles[id]!.trim()])),
|
||||
reason: t("admin.sales.deals.audit.buyingCenter"),
|
||||
});
|
||||
setBuyingCenterOpen(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
|
||||
<Dialog open={promotionOpen} onOpenChange={setPromotionOpen}>
|
||||
<Dialog.Content
|
||||
className="w-[600px] max-w-[92vw] p-6"
|
||||
data-ui-id="ui.admin.sales.deals.tenantPromotionDialog"
|
||||
>
|
||||
<div className="flex max-h-[80vh] flex-col gap-4 overflow-y-auto">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("admin.sales.deals.tenantPromotion.dialogTitle")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.deals.tenantPromotion.dialogDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<Select
|
||||
label={t("admin.sales.deals.tenantPromotion.mode")}
|
||||
showLabel
|
||||
value={promotionMode}
|
||||
onValueChange={(value) =>
|
||||
setPromotionMode(value as "link_existing" | "create_new")
|
||||
}
|
||||
>
|
||||
<Select.Item value="link_existing">
|
||||
{t("admin.sales.deals.tenantPromotion.linkExisting")}
|
||||
</Select.Item>
|
||||
<Select.Item value="create_new">
|
||||
{t("admin.sales.deals.tenantPromotion.createNew")}
|
||||
</Select.Item>
|
||||
</Select>
|
||||
{promotionMode === "link_existing" ? (
|
||||
props.vm.tenantOptions.length > 0 ? (
|
||||
<Select
|
||||
label={t("admin.sales.deals.tenantPromotion.tenant")}
|
||||
showLabel
|
||||
value={promotionTenantId}
|
||||
onValueChange={setPromotionTenantId}
|
||||
>
|
||||
{props.vm.tenantOptions.map((tenant) => (
|
||||
<Select.Item key={tenant.id} value={tenant.id}>
|
||||
{tenant.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
) : (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t(
|
||||
"admin.sales.deals.tenantPromotion.noExistingTenants"
|
||||
)}
|
||||
body={t(
|
||||
"admin.sales.deals.tenantPromotion.noExistingTenantsBody"
|
||||
)}
|
||||
/>
|
||||
)
|
||||
) : (
|
||||
<>
|
||||
<div className="grid grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput
|
||||
label={t(
|
||||
"admin.sales.deals.tenantPromotion.tenantName"
|
||||
)}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
value={promotionTenantName}
|
||||
onChange={(event) =>
|
||||
setPromotionTenantName(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
label={t(
|
||||
"admin.sales.deals.tenantPromotion.tenantSlug"
|
||||
)}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
value={promotionTenantSlug}
|
||||
onChange={(event) =>
|
||||
setPromotionTenantSlug(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextInput
|
||||
label={t(
|
||||
"admin.sales.deals.tenantPromotion.ownerEmail"
|
||||
)}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
type="email"
|
||||
value={promotionOwnerEmail}
|
||||
onChange={(event) =>
|
||||
setPromotionOwnerEmail(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<div className="grid grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput
|
||||
label={t(
|
||||
"admin.sales.deals.tenantPromotion.ownerFirstName"
|
||||
)}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
value={promotionOwnerFirstName}
|
||||
onChange={(event) =>
|
||||
setPromotionOwnerFirstName(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
label={t(
|
||||
"admin.sales.deals.tenantPromotion.ownerLastName"
|
||||
)}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
value={promotionOwnerLastName}
|
||||
onChange={(event) =>
|
||||
setPromotionOwnerLastName(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
<TextArea
|
||||
label={t("admin.sales.deals.tenantPromotion.reason")}
|
||||
showLabel
|
||||
>
|
||||
<TextArea.Input
|
||||
value={promotionReason}
|
||||
onChange={(event) => setPromotionReason(event.target.value)}
|
||||
/>
|
||||
</TextArea>
|
||||
<Checkbox
|
||||
checked={promotionConfirmed}
|
||||
onCheckedChange={setPromotionConfirmed}
|
||||
label={t("admin.sales.deals.tenantPromotion.confirm")}
|
||||
description={t(
|
||||
"admin.sales.deals.tenantPromotion.confirmDescription"
|
||||
)}
|
||||
/>
|
||||
<DialogActions
|
||||
cancelLabel={t("shared.cancel")}
|
||||
saveLabel={t("admin.sales.deals.tenantPromotion.action")}
|
||||
submitting={props.submitting}
|
||||
disabled={
|
||||
!promotionConfirmed ||
|
||||
promotionReason.trim().length < 5 ||
|
||||
(promotionMode === "link_existing"
|
||||
? !promotionTenantId
|
||||
: !promotionTenantName.trim() ||
|
||||
!promotionTenantSlug.trim() ||
|
||||
!promotionOwnerEmail.trim() ||
|
||||
!promotionOwnerFirstName.trim() ||
|
||||
!promotionOwnerLastName.trim())
|
||||
}
|
||||
onCancel={() => setPromotionOpen(false)}
|
||||
onSave={() => {
|
||||
if (!promotionConfirmed) return;
|
||||
props.actions.onPromoteTenant({
|
||||
dealId: props.vm.id,
|
||||
mode: promotionMode,
|
||||
tenantId:
|
||||
promotionMode === "link_existing"
|
||||
? promotionTenantId
|
||||
: null,
|
||||
tenantName:
|
||||
promotionMode === "create_new"
|
||||
? promotionTenantName.trim()
|
||||
: null,
|
||||
tenantSlug:
|
||||
promotionMode === "create_new"
|
||||
? promotionTenantSlug.trim()
|
||||
: null,
|
||||
ownerEmail:
|
||||
promotionMode === "create_new"
|
||||
? promotionOwnerEmail.trim()
|
||||
: null,
|
||||
ownerFirstName:
|
||||
promotionMode === "create_new"
|
||||
? promotionOwnerFirstName.trim()
|
||||
: null,
|
||||
ownerLastName:
|
||||
promotionMode === "create_new"
|
||||
? promotionOwnerLastName.trim()
|
||||
: null,
|
||||
confirmed: true,
|
||||
reason: promotionReason.trim(),
|
||||
});
|
||||
setPromotionOpen(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function Metric(props: { readonly label: string; readonly value: string; readonly icon: React.ReactNode }) {
|
||||
return (
|
||||
<div className="flex items-start justify-between gap-3 rounded-lg border border-border-default bg-surface-neutral-secondary p-4">
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-body-small-regular-0 text-text-neutral-tertiary">{props.label}</span>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{props.value}</span>
|
||||
</div>
|
||||
<span className="text-heading- text-icon-neutral-tertiary">{props.icon}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TimelineSection(props: {
|
||||
readonly title: string;
|
||||
readonly empty: string;
|
||||
readonly rows: readonly { readonly id: string; readonly title: string; readonly subtitle: string | null; readonly meta: string }[];
|
||||
}) {
|
||||
return (
|
||||
<section className="flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{props.title}</h2>
|
||||
{props.rows.length === 0 ? (
|
||||
<EmptyState title={props.empty} />
|
||||
) : (
|
||||
<ol className="flex flex-col">
|
||||
{props.rows.map((row) => (
|
||||
<li key={row.id} className="relative flex gap-3 border-l border-border-default pb-5 pl-5 last:border-transparent last:pb-0">
|
||||
<span className="absolute -left-1.5 top-1 h-3 w-3 rounded-full border-2 border-border-brand bg-surface-neutral-secondary" />
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 text-text-neutral-primary">{row.title}</span>
|
||||
{row.subtitle ? <span className="text-body-extra-small-regular-0 text-text-neutral-secondary">{row.subtitle}</span> : null}
|
||||
<span className="text-body-extra-small-regular-0 text-text-neutral-tertiary">{row.meta}</span>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
)}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function DialogActions(props: {
|
||||
readonly cancelLabel: string;
|
||||
readonly saveLabel: string;
|
||||
readonly submitting: boolean;
|
||||
readonly disabled?: boolean;
|
||||
readonly onCancel: () => void;
|
||||
readonly onSave: () => void;
|
||||
}) {
|
||||
return (
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={props.onCancel}>{props.cancelLabel}</Button>
|
||||
<Button loading={props.submitting} disabled={props.disabled} onClick={props.onSave}>{props.saveLabel}</Button>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function toLocalDateTime(value: string | null): string {
|
||||
if (!value) return "";
|
||||
const date = new Date(value);
|
||||
if (!Number.isFinite(date.getTime())) return "";
|
||||
const local = new Date(date.getTime() - date.getTimezoneOffset() * 60_000);
|
||||
return local.toISOString().slice(0, 16);
|
||||
}
|
||||
+302
@@ -0,0 +1,302 @@
|
||||
import type { AdminDealPipelineCardVM, AdminDealPipelineVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherAlertTriangle,
|
||||
FeatherBriefcase,
|
||||
FeatherCalendarClock,
|
||||
FeatherSettings2,
|
||||
FeatherTrendingUp,
|
||||
FeatherUsers,
|
||||
} from "@subframe/core";
|
||||
import { useState, type ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { AppLink } from "~/components/app/AppLink";
|
||||
|
||||
import { SortableKanbanBoard, type SortableKanbanColumn } from "~/components/ui/kanban/SortableKanbanBoard";
|
||||
import { useRecommendedSidebarCollapse } from "~/components/app/AppShellSidebarContext";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { KanbanCard } from "~/ui/components/KanbanCard";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
|
||||
export type AdminSalesDealPipelineActions = {
|
||||
readonly onSwitchPipeline: (pipelineId: string) => void;
|
||||
readonly onMove: (input: {
|
||||
readonly dealId: string;
|
||||
readonly targetStageId: string;
|
||||
readonly lossReasonId: string | null;
|
||||
readonly lossReasonNote: string | null;
|
||||
readonly reason: string;
|
||||
}) => void;
|
||||
readonly onCreateDefaultPipeline: () => void;
|
||||
readonly onOpenSettings: () => void;
|
||||
};
|
||||
|
||||
export function AdminSalesDealPipelinePage(props: {
|
||||
readonly vm: AdminDealPipelineVM;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: AdminSalesDealPipelineActions;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
useRecommendedSidebarCollapse(props.vm.pipelineId ? `admin-sales:${props.vm.pipelineId}` : null);
|
||||
const [pendingMove, setPendingMove] = useState<{ dealId: string; targetStageId: string } | null>(null);
|
||||
const [lossReasonId, setLossReasonId] = useState("");
|
||||
const [lossReasonNote, setLossReasonNote] = useState("");
|
||||
const [resetToken, setResetToken] = useState(0);
|
||||
|
||||
const stageById = new Map(props.vm.stages.map((stage) => [stage.id, stage]));
|
||||
|
||||
function requestMove(dealId: string, targetStageId: string) {
|
||||
const target = stageById.get(targetStageId);
|
||||
if (!target) return;
|
||||
if (target.kind === "lost") {
|
||||
setLossReasonId(props.vm.lossReasons[0]?.id ?? "");
|
||||
setLossReasonNote("");
|
||||
setPendingMove({ dealId, targetStageId });
|
||||
return;
|
||||
}
|
||||
props.actions.onMove({
|
||||
dealId,
|
||||
targetStageId,
|
||||
lossReasonId: null,
|
||||
lossReasonNote: null,
|
||||
reason: t("admin.sales.deals.audit.stageMove", { stage: target.name }),
|
||||
});
|
||||
}
|
||||
|
||||
function cancelLostMove() {
|
||||
setPendingMove(null);
|
||||
setResetToken((value) => value + 1);
|
||||
}
|
||||
|
||||
if (props.vm.status === "empty") {
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.deals.pipeline">
|
||||
<PageHeader
|
||||
icon={<FeatherBriefcase className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t(props.vm.titleKey)}
|
||||
subtitle={t("admin.sales.deals.subtitle")}
|
||||
/>
|
||||
<PageBody>
|
||||
<EmptyState
|
||||
title={t("admin.sales.deals.empty.title")}
|
||||
body={t("admin.sales.deals.empty.description")}
|
||||
action={
|
||||
props.vm.permissions.canConfigure ? (
|
||||
<Button onClick={props.actions.onCreateDefaultPipeline} loading={props.submitting}>
|
||||
{t("admin.sales.deals.actions.createDefaultPipeline")}
|
||||
</Button>
|
||||
) : undefined
|
||||
}
|
||||
/>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
const columns: SortableKanbanColumn<AdminDealPipelineCardVM>[] = props.vm.columns.map((column) => ({
|
||||
id: column.id,
|
||||
label: column.name,
|
||||
name: (
|
||||
<div className="flex items-center gap-2">
|
||||
<span>{column.name}</span>
|
||||
<BadgeFeedback farbe={column.kind === "won" ? "subtle-positive" : column.kind === "lost" ? "subtle-negative" : "subtle-neutral"} size="small">
|
||||
{column.probabilityLabel}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
),
|
||||
price: column.amountLabel,
|
||||
badge: (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{String(column.dealCount)}
|
||||
</BadgeFeedback>
|
||||
),
|
||||
accentColor: column.color ?? undefined,
|
||||
cards: column.cards,
|
||||
emptyContent: t("admin.sales.deals.emptyStage"),
|
||||
}));
|
||||
|
||||
function renderCard(card: AdminDealPipelineCardVM, dragHandle?: ReactNode): ReactNode {
|
||||
return (
|
||||
<KanbanCard
|
||||
titleSlot={
|
||||
<div className="flex w-full flex-col gap-1">
|
||||
<AppLink href={card.detailHref} className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-feedback-link-default">
|
||||
{card.title}
|
||||
</AppLink>
|
||||
{card.companyName ? <span className="text-body-small-regular-0 text-text-neutral-tertiary">{card.companyName}</span> : null}
|
||||
</div>
|
||||
}
|
||||
valueSlot={
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">{card.amountLabel}</span>
|
||||
<span className="text-body-extra-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.deals.weighted", { value: card.weightedAmountLabel })}
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
tagsSlot={
|
||||
<div className="flex w-full items-center gap-2">
|
||||
{dragHandle}
|
||||
{card.isOverdue ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("admin.sales.deals.aging.overdue", { days: card.ageDays })}
|
||||
</BadgeFeedback>
|
||||
) : (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("admin.sales.deals.aging.days", { days: card.ageDays })}
|
||||
</BadgeFeedback>
|
||||
)}
|
||||
{card.contactCount > 0 ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("admin.sales.deals.contacts.count", { count: card.contactCount })}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
}
|
||||
footerLeftSlot={
|
||||
<div className="flex max-w-40 flex-col gap-1">
|
||||
<span className="truncate text-body-extra-small-medium-0 text-text-neutral-secondary">
|
||||
{card.nextStep ?? t("admin.sales.deals.nextStep.missing")}
|
||||
</span>
|
||||
{card.primaryContactName ? (
|
||||
<span className="truncate text-body-extra-small-regular-0 text-text-neutral-tertiary">{card.primaryContactName}</span>
|
||||
) : null}
|
||||
</div>
|
||||
}
|
||||
footerRightSlot={
|
||||
props.vm.permissions.canWrite ? (
|
||||
<Select
|
||||
label={t("admin.sales.deals.actions.move")}
|
||||
triggerAriaLabel={t("admin.sales.deals.actions.move")}
|
||||
value=""
|
||||
onValueChange={(stageId) => requestMove(card.id, stageId)}
|
||||
data-ui-id={`ui.admin.sales.deals.card.${card.id}.move`}
|
||||
>
|
||||
{props.vm.stages.map((stage) => (
|
||||
<Select.Item key={stage.id} value={stage.id}>
|
||||
{stage.name}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
) : card.expectedCloseDateLabel ? (
|
||||
<span className="text-body-extra-small-regular-0 text-text-neutral-tertiary">{card.expectedCloseDateLabel}</span>
|
||||
) : null
|
||||
}
|
||||
flagVariant={card.isOverdue ? "warning" : "neutral"}
|
||||
data-ui-id={`ui.admin.sales.deals.card.${card.id}`}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.deals.pipeline">
|
||||
<PageHeader
|
||||
icon={<FeatherBriefcase className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={props.vm.pipelineName ?? t(props.vm.titleKey)}
|
||||
subtitle={props.vm.pipelineDescription ?? t("admin.sales.deals.subtitle")}
|
||||
actions={
|
||||
<>
|
||||
<Select
|
||||
label={t("admin.sales.deals.fields.pipeline")}
|
||||
triggerAriaLabel={t("admin.sales.deals.fields.pipeline")}
|
||||
value={props.vm.pipelineId ?? ""}
|
||||
onValueChange={props.actions.onSwitchPipeline}
|
||||
>
|
||||
{props.vm.pipelineOptions.map((pipeline) => (
|
||||
<Select.Item key={pipeline.id} value={pipeline.id}>
|
||||
{pipeline.name}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
{props.vm.permissions.canConfigure ? (
|
||||
<Button variant="neutral" icon={<FeatherSettings2 />} onClick={props.actions.onOpenSettings}>
|
||||
{t("admin.sales.deals.actions.pipelineSettings")}
|
||||
</Button>
|
||||
) : null}
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
{props.errorMessage ? (
|
||||
<div className="flex items-center gap-2 rounded-md border border-border-negative-solid bg-surface-feedback-subtle-negative px-4 py-3 text-text-feedback-negative">
|
||||
<FeatherAlertTriangle />
|
||||
<span>{props.errorMessage}</span>
|
||||
</div>
|
||||
) : null}
|
||||
<div className="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<StatsCard trend="neutral" label={t("admin.sales.deals.summary.deals")} value={String(props.vm.summary.dealCount)} icon={<FeatherBriefcase />} />
|
||||
<StatsCard trend="neutral" label={t("admin.sales.deals.summary.pipelineValue")} value={props.vm.summary.pipelineValue} icon={<FeatherTrendingUp />} />
|
||||
<StatsCard trend="positive" label={t("admin.sales.deals.summary.weightedForecast")} value={props.vm.summary.weightedForecast} icon={<FeatherCalendarClock />} />
|
||||
<StatsCard
|
||||
trend={props.vm.summary.overdueCount > 0 ? "negative" : "neutral"}
|
||||
label={t("admin.sales.deals.summary.overdue")}
|
||||
value={String(props.vm.summary.overdueCount)}
|
||||
icon={<FeatherUsers />}
|
||||
/>
|
||||
</div>
|
||||
<div className="w-full overflow-x-auto pb-4">
|
||||
<SortableKanbanBoard
|
||||
columns={columns}
|
||||
renderCard={renderCard}
|
||||
getCardLabel={(card) => card.title}
|
||||
onCardMove={(dealId, targetStageId) => requestMove(dealId, targetStageId)}
|
||||
disabled={!props.vm.permissions.canWrite || props.submitting}
|
||||
resetToken={resetToken}
|
||||
dragHandlePlacement="inline"
|
||||
data-ui-id="ui.admin.sales.deals.board"
|
||||
/>
|
||||
</div>
|
||||
</PageBody>
|
||||
|
||||
<Dialog open={pendingMove !== null} onOpenChange={(open) => (open ? undefined : cancelLostMove())}>
|
||||
<Dialog.Content className="w-[480px] max-w-[92vw] p-6" data-ui-id="ui.admin.sales.deals.lostDialog">
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.deals.lost.title")}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{t("admin.sales.deals.lost.description")}</p>
|
||||
</div>
|
||||
<Select label={t("admin.sales.deals.fields.lossReason")} showLabel value={lossReasonId} onValueChange={setLossReasonId}>
|
||||
{props.vm.lossReasons.map((reason) => (
|
||||
<Select.Item key={reason.id} value={reason.id}>
|
||||
{reason.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextArea label={t("admin.sales.deals.fields.lossReasonNote")} showLabel>
|
||||
<TextArea.Input value={lossReasonNote} onChange={(event) => setLossReasonNote(event.target.value)} />
|
||||
</TextArea>
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={cancelLostMove}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
disabled={!pendingMove || !lossReasonId}
|
||||
loading={props.submitting}
|
||||
onClick={() => {
|
||||
if (!pendingMove) return;
|
||||
props.actions.onMove({
|
||||
dealId: pendingMove.dealId,
|
||||
targetStageId: pendingMove.targetStageId,
|
||||
lossReasonId,
|
||||
lossReasonNote: lossReasonNote.trim() || null,
|
||||
reason: t("admin.sales.deals.audit.lost"),
|
||||
});
|
||||
setPendingMove(null);
|
||||
}}
|
||||
>
|
||||
{t("admin.sales.deals.actions.markLost")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+250
@@ -0,0 +1,250 @@
|
||||
import type { AdminDealRequiredFieldKeyVM } from "@hivegrid/view-models";
|
||||
import { FeatherPlus, FeatherSettings2, FeatherTrash2 } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBackLink, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
type StageDraft = {
|
||||
readonly id: string;
|
||||
readonly kind: "open" | "won" | "lost";
|
||||
readonly name: string;
|
||||
readonly probabilityPercent: string;
|
||||
readonly agingThresholdDays: string;
|
||||
readonly requiredFields: readonly AdminDealRequiredFieldKeyVM[];
|
||||
};
|
||||
|
||||
const requiredFields: readonly AdminDealRequiredFieldKeyVM[] = [
|
||||
"amountCents",
|
||||
"expectedCloseDate",
|
||||
"nextStep",
|
||||
"companyId",
|
||||
"primaryContactId",
|
||||
"lossReasonId",
|
||||
];
|
||||
|
||||
const initialStageTemplates: readonly Omit<StageDraft, "name">[] = [
|
||||
{ id: "lead", kind: "open", probabilityPercent: "10", agingThresholdDays: "7", requiredFields: [] },
|
||||
{ id: "demo", kind: "open", probabilityPercent: "30", agingThresholdDays: "10", requiredFields: ["nextStep"] },
|
||||
{ id: "trial", kind: "open", probabilityPercent: "50", agingThresholdDays: "14", requiredFields: ["nextStep"] },
|
||||
{ id: "quote", kind: "open", probabilityPercent: "75", agingThresholdDays: "10", requiredFields: ["amountCents", "expectedCloseDate", "nextStep"] },
|
||||
{ id: "won", kind: "won", probabilityPercent: "100", agingThresholdDays: "", requiredFields: ["amountCents", "companyId", "primaryContactId"] },
|
||||
{ id: "lost", kind: "lost", probabilityPercent: "0", agingThresholdDays: "", requiredFields: ["lossReasonId"] },
|
||||
];
|
||||
|
||||
export function AdminSalesPipelineSettingsPage(props: {
|
||||
readonly existingPipelines: readonly { readonly id: string; readonly name: string; readonly isDefault: boolean }[];
|
||||
readonly backHref: string;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onCreate: (input: {
|
||||
readonly name: string;
|
||||
readonly description: string | null;
|
||||
readonly isDefault: boolean;
|
||||
readonly stages: readonly {
|
||||
readonly name: string;
|
||||
readonly position: number;
|
||||
readonly kind: "open" | "won" | "lost";
|
||||
readonly probabilityBasisPoints: number;
|
||||
readonly agingThresholdDays: number | null;
|
||||
readonly requiredFields: readonly AdminDealRequiredFieldKeyVM[];
|
||||
}[];
|
||||
readonly lossReasons: readonly string[];
|
||||
readonly reason: string;
|
||||
}) => void;
|
||||
};
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [name, setName] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [isDefault, setIsDefault] = useState(props.existingPipelines.length === 0);
|
||||
const [lossReasons, setLossReasons] = useState(() =>
|
||||
["noBudget", "noNeed", "competitor", "timing", "badFit", "noResponse"]
|
||||
.map((key) => t(`admin.sales.pipelineSettings.defaults.lossReasons.${key}`))
|
||||
.join("\n")
|
||||
);
|
||||
const [stages, setStages] = useState<readonly StageDraft[]>(() =>
|
||||
initialStageTemplates.map((stage) => ({
|
||||
...stage,
|
||||
name: t(`admin.sales.pipelineSettings.defaults.stages.${stage.id}`),
|
||||
}))
|
||||
);
|
||||
|
||||
function updateStage(id: string, patch: Partial<StageDraft>) {
|
||||
setStages((current) => current.map((stage) => (stage.id === id ? { ...stage, ...patch } : stage)));
|
||||
}
|
||||
|
||||
function addOpenStage() {
|
||||
const openStages = stages.filter((stage) => stage.kind === "open");
|
||||
const terminalStart = stages.findIndex((stage) => stage.kind !== "open");
|
||||
const draft: StageDraft = {
|
||||
id: `open-${Date.now()}`,
|
||||
kind: "open",
|
||||
name: t("admin.sales.pipelineSettings.newStage"),
|
||||
probabilityPercent: String(Math.min(90, (openStages.length + 1) * 10)),
|
||||
agingThresholdDays: "10",
|
||||
requiredFields: ["nextStep"],
|
||||
};
|
||||
setStages((current) => [
|
||||
...current.slice(0, terminalStart < 0 ? current.length : terminalStart),
|
||||
draft,
|
||||
...current.slice(terminalStart < 0 ? current.length : terminalStart),
|
||||
]);
|
||||
}
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.pipelineSettings">
|
||||
<PageHeader
|
||||
icon={<FeatherSettings2 className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.pipelineSettings.title")}
|
||||
subtitle={t("admin.sales.pipelineSettings.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.backHref}>{t("admin.sales.deals.title")}</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>
|
||||
{t("admin.sales.pipelineSettings.title")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<PageBackLink to={props.backHref} label={t("admin.sales.deals.actions.backToPipeline")} />
|
||||
{props.errorMessage ? <div className="rounded-md bg-surface-feedback-subtle-negative px-4 py-3 text-text-feedback-negative">{props.errorMessage}</div> : null}
|
||||
|
||||
<section className="flex w-full flex-col gap-5 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div className="grid grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.pipelineSettings.fields.name")} showLabel>
|
||||
<TextInput.Input value={name} onChange={(event) => setName(event.target.value)} />
|
||||
</TextInput>
|
||||
<Checkbox
|
||||
checked={isDefault}
|
||||
onCheckedChange={setIsDefault}
|
||||
label={t("admin.sales.pipelineSettings.fields.default")}
|
||||
description={t("admin.sales.pipelineSettings.fields.defaultDescription")}
|
||||
className="self-end pb-2"
|
||||
/>
|
||||
</div>
|
||||
<TextArea label={t("admin.sales.pipelineSettings.fields.description")} showLabel>
|
||||
<TextArea.Input value={description} onChange={(event) => setDescription(event.target.value)} />
|
||||
</TextArea>
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div className="flex items-center justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.pipelineSettings.stages.title")}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{t("admin.sales.pipelineSettings.stages.description")}</p>
|
||||
</div>
|
||||
<Button variant="neutral" icon={<FeatherPlus />} onClick={addOpenStage}>{t("admin.sales.pipelineSettings.stages.add")}</Button>
|
||||
</div>
|
||||
<div className="flex flex-col gap-3">
|
||||
{stages.map((stage, index) => (
|
||||
<div key={stage.id} className="flex w-full flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-4">
|
||||
<div className="grid grid-cols-[1fr_160px_160px_auto] items-end gap-3 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.pipelineSettings.fields.stageName")} showLabel>
|
||||
<TextInput.Input value={stage.name} onChange={(event) => updateStage(stage.id, { name: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.pipelineSettings.fields.probability")} showLabel>
|
||||
<TextInput.Input
|
||||
type="number"
|
||||
min="0"
|
||||
max="100"
|
||||
disabled={stage.kind !== "open"}
|
||||
value={stage.probabilityPercent}
|
||||
onChange={(event) => updateStage(stage.id, { probabilityPercent: event.target.value })}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.pipelineSettings.fields.aging")} showLabel>
|
||||
<TextInput.Input
|
||||
type="number"
|
||||
min="1"
|
||||
max="365"
|
||||
disabled={stage.kind !== "open"}
|
||||
value={stage.agingThresholdDays}
|
||||
onChange={(event) => updateStage(stage.id, { agingThresholdDays: event.target.value })}
|
||||
/>
|
||||
</TextInput>
|
||||
<div className="flex items-center gap-2">
|
||||
<BadgeFeedback farbe={stage.kind === "won" ? "subtle-positive" : stage.kind === "lost" ? "subtle-negative" : "subtle-neutral"}>
|
||||
{t(`admin.sales.pipelineSettings.kind.${stage.kind}`)}
|
||||
</BadgeFeedback>
|
||||
{stage.kind === "open" && stages.filter((item) => item.kind === "open").length > 1 ? (
|
||||
<IconButton
|
||||
variant="destructive"
|
||||
icon={<FeatherTrash2 />}
|
||||
aria-label={t("admin.sales.pipelineSettings.stages.remove", { position: index + 1 })}
|
||||
onClick={() => setStages((current) => current.filter((item) => item.id !== stage.id))}
|
||||
/>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
{requiredFields.map((field) => (
|
||||
<Checkbox
|
||||
key={field}
|
||||
checked={stage.requiredFields.includes(field)}
|
||||
onCheckedChange={(checked) =>
|
||||
updateStage(stage.id, {
|
||||
requiredFields: checked
|
||||
? [...stage.requiredFields, field]
|
||||
: stage.requiredFields.filter((candidate) => candidate !== field),
|
||||
})
|
||||
}
|
||||
label={t(`admin.sales.pipelineSettings.requiredFields.${field}`)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">{t("admin.sales.pipelineSettings.lossReasons.title")}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{t("admin.sales.pipelineSettings.lossReasons.description")}</p>
|
||||
</div>
|
||||
<TextArea label={t("admin.sales.pipelineSettings.lossReasons.label")} showLabel>
|
||||
<TextArea.Input value={lossReasons} onChange={(event) => setLossReasons(event.target.value)} />
|
||||
</TextArea>
|
||||
</section>
|
||||
|
||||
<div className="flex w-full justify-end">
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={!name.trim() || stages.some((stage) => !stage.name.trim())}
|
||||
onClick={() =>
|
||||
props.actions.onCreate({
|
||||
name: name.trim(),
|
||||
description: description.trim() || null,
|
||||
isDefault,
|
||||
stages: stages.map((stage, position) => ({
|
||||
name: stage.name.trim(),
|
||||
position,
|
||||
kind: stage.kind,
|
||||
probabilityBasisPoints: Math.round(Number(stage.probabilityPercent) * 100),
|
||||
agingThresholdDays: stage.agingThresholdDays ? Number(stage.agingThresholdDays) : null,
|
||||
requiredFields: stage.requiredFields,
|
||||
})),
|
||||
lossReasons: lossReasons.split("\n").map((value) => value.trim()).filter(Boolean),
|
||||
reason: t("admin.sales.pipelineSettings.audit.created"),
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.pipelineSettings.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28b deal pipeline interim visual baseline > renders a wired board and routes a lost drop through the required dialog 1`] = `"<span data-radix-focus-guard="" tabindex="0" style="outline: none; opacity: 0; position: fixed; pointer-events: none;" data-aria-hidden="true" aria-hidden="true"></span><div data-aria-hidden="true" aria-hidden="true"><div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.deals.pipeline"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">SaaS Sales</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">HiveGrid Vertrieb</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><div class="group/bb88f90b flex w-full min-w-[192px] max-w-[320px] cursor-pointer flex-col items-start gap-4"><div class="hidden flex-col items-start gap-3"><span class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">admin.sales.deals.fields.pipeline</span></div><div class="flex w-full flex-col items-start gap-4 rounded-[4px]"><div class="flex w-full flex-col items-start rounded-sm border border-solid border-border-strong bg-surface-neutral-primary group-hover/bb88f90b:border group-hover/bb88f90b:border-solid group-hover/bb88f90b:border-brand-brand-border-solid-hover group-hover/bb88f90b:bg-surface-neutral-secondary group-focus-within/bb88f90b:bg-surface-neutral-secondary group-focus-within/bb88f90b:shadow-focus"><button class="select-module_trigger__L7Z7z group/7ce1d396 flex h-9 w-full min-w-0 items-center justify-between gap-2 overflow-hidden px-3 py-3 text-left" type="button" role="combobox" aria-controls="radix-_r_0_" aria-expanded="false" aria-autocomplete="none" dir="ltr" data-state="closed" aria-label="admin.sales.deals.fields.pipeline"><span class="group/21c51472 min-w-0 truncate whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-subtle select-module_value__4AkUy"><span style="pointer-events: none;"><span class="group/c3085a74 text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-tertiary h-auto grow shrink-0 basis-0">SaaS Sales</span></span></span><span class="flex-none text-body-default-medium-0 font-body-default-medium-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></button></div></div></div><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-surface-feedback-solid-neutral hover:bg-surface-feedback-solid-neutral-hover active:bg-surface-feedback-solid-neutral-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.deals.actions.pipelineSettings</span></button></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.deals.summary.deals</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrappLine truncated
|
||||
|
||||
exports[`VA-P28b deal pipeline interim visual baseline > renders deal history, buying center, activity and pipeline settings from injected models 1`] = `
|
||||
"<main data-ui-id="ui.admin.sales.deals.interim.visualBaseline"><div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.deals.detail"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Muster GmbH</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Muster GmbH</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-positive"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-positive"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-feedback-positive">admin.sales.deals.status.won</span></div><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-surface-feedback-solid-neutral hover:bg-surface-feedback-solid-neutral-hover active:bg-surface-feedback-solid-neutral-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.deals.actions.move</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-surface-feedback-solid-neutral hover:bg-surface-feedback-solid-neutral-hover active:bg-surface-feedback-solid-neutral-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.tasks.actions.create</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-centLine truncated
|
||||
admin.sales.pipelineSettings.defaults.lossReasons.noNeed
|
||||
admin.sales.pipelineSettings.defaults.lossReasons.competitor
|
||||
admin.sales.pipelineSettings.defaults.lossReasons.timing
|
||||
admin.sales.pipelineSettings.defaults.lossReasons.badFit
|
||||
admin.sales.pipelineSettings.defaults.lossReasons.noResponse</textarea></div></div></label></section><div class="flex w-full justify-end"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button" disabled=""><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.pipelineSettings.actions.create</span></button></div></div></div></main>"
|
||||
`;
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
// @vitest-environment jsdom
|
||||
import {
|
||||
buildAdminDealDetailVM,
|
||||
buildAdminDealPipelineVM,
|
||||
} from "@hivegrid/view-models";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { beforeAll, describe, it, vi } from "vitest";
|
||||
import { MemoryRouter } from "react-router";
|
||||
|
||||
import {
|
||||
assertNoA11yViolations,
|
||||
expectNoA11yViolations,
|
||||
} from "~/utils/test/a11y";
|
||||
import { AdminSalesDealDetailPage } from "./AdminSalesDealDetailPage";
|
||||
import { AdminSalesDealPipelinePage } from "./AdminSalesDealPipelinePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) => (values ? `${key}:${Object.values(values).join("/")}` : key),
|
||||
}),
|
||||
}));
|
||||
|
||||
beforeAll(() => {
|
||||
globalThis.ResizeObserver = class {
|
||||
observe(): void {}
|
||||
unobserve(): void {}
|
||||
disconnect(): void {}
|
||||
} as typeof ResizeObserver;
|
||||
});
|
||||
|
||||
describe("VA-P28b deal pipeline accessibility", () => {
|
||||
it("keeps board, drag handle and keyboard stage alternative named", async () => {
|
||||
const vm = buildAdminDealPipelineVM({
|
||||
now: new Date("2026-07-24T12:00:00.000Z"),
|
||||
locale: "de-DE",
|
||||
pipelines: [{ id: "pipeline_1", name: "SaaS Sales", isDefault: true }],
|
||||
board: {
|
||||
pipeline: { id: "pipeline_1", name: "SaaS Sales", description: null },
|
||||
stages: [
|
||||
{
|
||||
id: "demo",
|
||||
name: "Demo",
|
||||
kind: "open",
|
||||
probabilityBasisPoints: 3_000,
|
||||
agingThresholdDays: 10,
|
||||
color: "#2563eb",
|
||||
requiredFields: ["nextStep"],
|
||||
deals: [
|
||||
{
|
||||
id: "deal_1",
|
||||
title: "Musterbetrieb",
|
||||
companyName: "Musterbetrieb",
|
||||
ownerAdminUserId: "admin_1",
|
||||
amountCents: 100_000,
|
||||
currencyCode: "EUR",
|
||||
probabilityBasisPoints: 3_000,
|
||||
expectedCloseDate: null,
|
||||
nextStep: "Demo",
|
||||
nextStepDueAt: null,
|
||||
stageEnteredAt: new Date("2026-07-20T12:00:00.000Z"),
|
||||
lossReasonLabel: null,
|
||||
contacts: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "won",
|
||||
name: "Abschluss",
|
||||
kind: "won",
|
||||
probabilityBasisPoints: 10_000,
|
||||
agingThresholdDays: null,
|
||||
color: "#16a34a",
|
||||
requiredFields: [],
|
||||
deals: [],
|
||||
},
|
||||
],
|
||||
lossReasons: [],
|
||||
},
|
||||
buildDealHref: (id) => `/sales/deals/${id}`,
|
||||
permissions: { canRead: true, canWrite: true, canConfigure: true },
|
||||
});
|
||||
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminSalesDealPipelinePage
|
||||
vm={vm}
|
||||
submitting={false}
|
||||
actions={{
|
||||
onSwitchPipeline: vi.fn(),
|
||||
onMove: vi.fn(),
|
||||
onCreateDefaultPipeline: vi.fn(),
|
||||
onOpenSettings: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
|
||||
it("keeps the explicit tenant-promotion confirmation accessible", async () => {
|
||||
const vm = buildAdminDealDetailVM({
|
||||
now: new Date("2026-07-24T12:00:00.000Z"),
|
||||
locale: "de-DE",
|
||||
deal: {
|
||||
id: "deal_1",
|
||||
title: "Musterbetrieb",
|
||||
status: "won",
|
||||
pipelineId: "pipeline_1",
|
||||
pipelineName: "SaaS Sales",
|
||||
stageId: "won",
|
||||
stageName: "Abschluss",
|
||||
companyName: "Musterbetrieb",
|
||||
amountCents: 100_000,
|
||||
currencyCode: "EUR",
|
||||
probabilityBasisPoints: 10_000,
|
||||
expectedCloseDate: null,
|
||||
nextStep: null,
|
||||
nextStepDueAt: null,
|
||||
stageEnteredAt: new Date("2026-07-20T12:00:00.000Z"),
|
||||
lossReasonLabel: null,
|
||||
lossReasonNote: null,
|
||||
promotedTenantId: null,
|
||||
promotedTenantName: null,
|
||||
promotedAt: null,
|
||||
contacts: [
|
||||
{
|
||||
id: "contact_1",
|
||||
name: "Ada Lovelace",
|
||||
firstName: "Ada",
|
||||
lastName: "Lovelace",
|
||||
email: "ada@example.test",
|
||||
role: "Champion",
|
||||
isPrimary: true,
|
||||
},
|
||||
],
|
||||
history: [],
|
||||
activities: [],
|
||||
},
|
||||
stages: [
|
||||
{
|
||||
id: "won",
|
||||
name: "Abschluss",
|
||||
kind: "won",
|
||||
requiredFields: [],
|
||||
},
|
||||
],
|
||||
lossReasons: [],
|
||||
contactOptions: [
|
||||
{
|
||||
id: "contact_1",
|
||||
name: "Ada Lovelace",
|
||||
companyName: "Musterbetrieb",
|
||||
},
|
||||
],
|
||||
tenantOptions: [
|
||||
{
|
||||
id: "tenant_1",
|
||||
name: "Bestandskunde",
|
||||
slug: "bestandskunde",
|
||||
},
|
||||
],
|
||||
canWrite: true,
|
||||
});
|
||||
const rendered = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesDealDetailPage
|
||||
vm={vm}
|
||||
taskVm={{
|
||||
tasks: [],
|
||||
currentAdminUserId: "admin_1",
|
||||
timeZone: "Europe/Berlin",
|
||||
canWrite: true,
|
||||
}}
|
||||
backHref="/sales/deals"
|
||||
submitting={false}
|
||||
actions={{
|
||||
onMove: vi.fn(),
|
||||
onUpdate: vi.fn(),
|
||||
onReplaceBuyingCenter: vi.fn(),
|
||||
onPromoteTenant: vi.fn(),
|
||||
onCreateTask: vi.fn(),
|
||||
onCompleteTask: vi.fn(),
|
||||
onCall: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
fireEvent.click(
|
||||
rendered.container.querySelector(
|
||||
'[data-ui-id="ui.admin.sales.deals.tenantPromotionAction"]'
|
||||
)!
|
||||
);
|
||||
assertNoA11yViolations(document.body);
|
||||
});
|
||||
});
|
||||
+266
@@ -0,0 +1,266 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { buildAdminDealDetailVM, buildAdminDealPipelineVM } from "@hivegrid/view-models";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminSalesDealDetailPage } from "./AdminSalesDealDetailPage";
|
||||
import { AdminSalesDealPipelinePage } from "./AdminSalesDealPipelinePage";
|
||||
import { AdminSalesPipelineSettingsPage } from "./AdminSalesPipelineSettingsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) => `${key}${values ? `:${Object.values(values).join("/")}` : ""}`,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("~/components/ui/kanban/SortableKanbanBoard", () => ({
|
||||
SortableKanbanBoard: (props: {
|
||||
columns: readonly { id: string; cards: readonly { id: string }[] }[];
|
||||
renderCard: (card: { id: string }, handle?: React.ReactNode) => React.ReactNode;
|
||||
onCardMove: (cardId: string, stageId: string, index: number) => void;
|
||||
}) => (
|
||||
<div data-ui-id="ui.admin.sales.deals.board">
|
||||
{props.columns.flatMap((column) =>
|
||||
column.cards.map((card) => (
|
||||
<div key={card.id}>
|
||||
{props.renderCard(card, <button type="button" aria-label={`drag-${card.id}`} />)}
|
||||
{props.columns.filter((target) => target.id !== column.id).map((target) => (
|
||||
<button
|
||||
key={target.id}
|
||||
type="button"
|
||||
data-ui-id={`move.${card.id}.${target.id}`}
|
||||
onClick={() => props.onCardMove(card.id, target.id, 0)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
),
|
||||
}));
|
||||
|
||||
class ResizeObserverStub {
|
||||
observe(): void {}
|
||||
unobserve(): void {}
|
||||
disconnect(): void {}
|
||||
}
|
||||
globalThis.ResizeObserver = globalThis.ResizeObserver ?? (ResizeObserverStub as unknown as typeof ResizeObserver);
|
||||
|
||||
const now = new Date("2026-07-24T12:00:00.000Z");
|
||||
|
||||
function createBoardVM() {
|
||||
return buildAdminDealPipelineVM({
|
||||
now,
|
||||
locale: "de-DE",
|
||||
pipelines: [{ id: "pipeline_1", name: "SaaS Sales", isDefault: true }],
|
||||
board: {
|
||||
pipeline: { id: "pipeline_1", name: "SaaS Sales", description: "HiveGrid Vertrieb" },
|
||||
stages: [
|
||||
{
|
||||
id: "demo",
|
||||
name: "Demo",
|
||||
kind: "open",
|
||||
probabilityBasisPoints: 3_000,
|
||||
agingThresholdDays: 7,
|
||||
color: "#2563eb",
|
||||
requiredFields: ["nextStep"],
|
||||
deals: [
|
||||
{
|
||||
id: "deal_1",
|
||||
title: "Muster GmbH",
|
||||
companyName: "Muster GmbH",
|
||||
ownerAdminUserId: "admin_1",
|
||||
amountCents: 480_000,
|
||||
currencyCode: "EUR",
|
||||
probabilityBasisPoints: 3_000,
|
||||
expectedCloseDate: new Date("2026-08-15T00:00:00.000Z"),
|
||||
nextStep: "Demo mit Buying-Center",
|
||||
nextStepDueAt: new Date("2026-07-28T09:00:00.000Z"),
|
||||
stageEnteredAt: new Date("2026-07-14T12:00:00.000Z"),
|
||||
lossReasonLabel: null,
|
||||
contacts: [{ name: "Ada Lovelace", isPrimary: true }],
|
||||
},
|
||||
],
|
||||
},
|
||||
{
|
||||
id: "lost",
|
||||
name: "Verloren",
|
||||
kind: "lost",
|
||||
probabilityBasisPoints: 0,
|
||||
agingThresholdDays: null,
|
||||
color: "#dc2626",
|
||||
requiredFields: ["lossReasonId"],
|
||||
deals: [],
|
||||
},
|
||||
],
|
||||
lossReasons: [{ id: "reason_1", label: "Kein Budget" }],
|
||||
},
|
||||
buildDealHref: (id) => `/sales/deals/${id}`,
|
||||
permissions: { canRead: true, canWrite: true, canConfigure: true },
|
||||
});
|
||||
}
|
||||
|
||||
describe("VA-P28b deal pipeline interim visual baseline", () => {
|
||||
it("renders a wired board and routes a lost drop through the required dialog", () => {
|
||||
const onMove = vi.fn();
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesDealPipelinePage
|
||||
vm={createBoardVM()}
|
||||
submitting={false}
|
||||
actions={{
|
||||
onSwitchPipeline: vi.fn(),
|
||||
onMove,
|
||||
onCreateDefaultPipeline: vi.fn(),
|
||||
onOpenSettings: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
fireEvent.click(container.querySelector('[data-ui-id="move.deal_1.lost"]')!);
|
||||
expect(document.querySelector('[data-ui-id="ui.admin.sales.deals.lostDialog"]')).toBeInTheDocument();
|
||||
expect(onMove).not.toHaveBeenCalled();
|
||||
const stableMarkup = document.body.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders deal history, buying center, activity and pipeline settings from injected models", () => {
|
||||
const detail = buildAdminDealDetailVM({
|
||||
now,
|
||||
locale: "de-DE",
|
||||
deal: {
|
||||
id: "deal_1",
|
||||
title: "Muster GmbH",
|
||||
status: "won",
|
||||
pipelineId: "pipeline_1",
|
||||
pipelineName: "SaaS Sales",
|
||||
stageId: "won",
|
||||
stageName: "Abschluss",
|
||||
companyName: "Muster GmbH",
|
||||
amountCents: 480_000,
|
||||
currencyCode: "EUR",
|
||||
probabilityBasisPoints: 10_000,
|
||||
expectedCloseDate: new Date("2026-08-15T00:00:00.000Z"),
|
||||
nextStep: "Demo mit Buying-Center",
|
||||
nextStepDueAt: new Date("2026-07-28T09:00:00.000Z"),
|
||||
stageEnteredAt: new Date("2026-07-20T12:00:00.000Z"),
|
||||
lossReasonLabel: null,
|
||||
lossReasonNote: null,
|
||||
promotedTenantId: null,
|
||||
promotedTenantName: null,
|
||||
promotedAt: null,
|
||||
contacts: [
|
||||
{
|
||||
id: "contact_1",
|
||||
name: "Ada Lovelace",
|
||||
firstName: "Ada",
|
||||
lastName: "Lovelace",
|
||||
email: "ada@example.test",
|
||||
role: "Champion",
|
||||
isPrimary: true,
|
||||
},
|
||||
],
|
||||
history: [{
|
||||
id: "history_1",
|
||||
fromStageName: "Lead",
|
||||
toStageName: "Demo",
|
||||
actorAdminUserId: "admin_1",
|
||||
enteredAt: new Date("2026-07-20T12:00:00.000Z"),
|
||||
reason: "Demo vereinbart",
|
||||
}],
|
||||
activities: [{
|
||||
id: "activity_1",
|
||||
type: "deal_stage_changed",
|
||||
summary: "Deal nach Demo verschoben",
|
||||
occurredAt: new Date("2026-07-20T12:00:00.000Z"),
|
||||
}],
|
||||
},
|
||||
stages: [
|
||||
{ id: "won", name: "Abschluss", kind: "won", requiredFields: [] },
|
||||
{ id: "lost", name: "Verloren", kind: "lost", requiredFields: ["lossReasonId"] },
|
||||
],
|
||||
lossReasons: [{ id: "reason_1", label: "Kein Budget" }],
|
||||
contactOptions: [{ id: "contact_1", name: "Ada Lovelace", companyName: "Muster GmbH" }],
|
||||
tenantOptions: [{ id: "tenant_1", name: "Bestandskunde GmbH", slug: "bestandskunde" }],
|
||||
canWrite: true,
|
||||
});
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<main data-ui-id="ui.admin.sales.deals.interim.visualBaseline">
|
||||
<AdminSalesDealDetailPage
|
||||
vm={detail}
|
||||
taskVm={{
|
||||
currentAdminUserId: "admin_1",
|
||||
timeZone: "Europe/Berlin",
|
||||
canWrite: true,
|
||||
tasks: [
|
||||
{
|
||||
id: "task_1",
|
||||
title: "Demo-Unterlagen senden",
|
||||
description: "Buying-Center vor dem Termin vorbereiten",
|
||||
contactId: "contact_1",
|
||||
contactName: "Ada Lovelace",
|
||||
contactHref: "/sales/contacts/contact_1",
|
||||
dealId: "deal_1",
|
||||
dealTitle: "Muster GmbH",
|
||||
dealHref: "/sales/deals/deal_1",
|
||||
assignedToAdminUserId: "admin_1",
|
||||
dueAtIso: "2026-07-28T09:00:00.000Z",
|
||||
dueAtLabel: "28.07.2026, 11:00",
|
||||
timeZone: "Europe/Berlin",
|
||||
reminderAtLabel: "28.07.2026, 09:00",
|
||||
priority: "high",
|
||||
priorityLabelKey: "admin.sales.tasks.priority.high",
|
||||
status: "open",
|
||||
statusLabelKey: "admin.sales.tasks.status.open",
|
||||
source: "manual",
|
||||
sourceLabelKey: "admin.sales.tasks.source.manual",
|
||||
recurrenceLabelKey: null,
|
||||
isOverdue: false,
|
||||
canComplete: true,
|
||||
},
|
||||
],
|
||||
}}
|
||||
backHref="/sales/deals"
|
||||
submitting={false}
|
||||
actions={{
|
||||
onMove: vi.fn(),
|
||||
onUpdate: vi.fn(),
|
||||
onReplaceBuyingCenter: vi.fn(),
|
||||
onPromoteTenant: vi.fn(),
|
||||
onCreateTask: vi.fn(),
|
||||
onCompleteTask: vi.fn(),
|
||||
onCall: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
<AdminSalesPipelineSettingsPage
|
||||
existingPipelines={[{ id: "pipeline_1", name: "SaaS Sales", isDefault: true }]}
|
||||
backHref="/sales/deals"
|
||||
submitting={false}
|
||||
actions={{ onCreate: vi.fn() }}
|
||||
/>
|
||||
</main>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("Lead → Demo");
|
||||
expect(container).toHaveTextContent("Ada Lovelace");
|
||||
fireEvent.click(
|
||||
container.querySelector(
|
||||
'[data-ui-id="ui.admin.sales.deals.tenantPromotionAction"]'
|
||||
)!
|
||||
);
|
||||
expect(
|
||||
document.querySelector(
|
||||
'[data-ui-id="ui.admin.sales.deals.tenantPromotionDialog"]'
|
||||
)
|
||||
).toBeInTheDocument();
|
||||
expect(container.querySelector('[data-ui-id="ui.admin.sales.pipelineSettings"]')).toBeInTheDocument();
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+203
@@ -0,0 +1,203 @@
|
||||
import type { AdminEmailConnectionsVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherMail,
|
||||
FeatherRefreshCw,
|
||||
FeatherShieldCheck,
|
||||
} from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import {
|
||||
AdminEmailWorkspaceNav,
|
||||
type AdminEmailWorkspaceHrefs,
|
||||
} from "./AdminEmailWorkspaceNav";
|
||||
|
||||
export type AdminEmailAccountsActions = {
|
||||
readonly onDisconnect: (input: {
|
||||
readonly mailboxId: string;
|
||||
readonly connectionId: string;
|
||||
readonly provider: "google_mail" | "microsoft_mail";
|
||||
}) => void;
|
||||
};
|
||||
|
||||
export function AdminEmailAccountsPage(props: {
|
||||
readonly vm: AdminEmailConnectionsVM;
|
||||
readonly hrefs?: AdminEmailWorkspaceHrefs;
|
||||
readonly salesHref: string;
|
||||
readonly connectHref: (
|
||||
provider: "google_mail" | "microsoft_mail"
|
||||
) => string;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: AdminEmailAccountsActions;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.email.accounts">
|
||||
<PageHeader
|
||||
icon={<FeatherMail className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.email.accounts.title")}
|
||||
subtitle={t("admin.sales.email.accounts.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
{props.hrefs ? (
|
||||
<AdminEmailWorkspaceNav active="accounts" hrefs={props.hrefs} />
|
||||
) : null}
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.salesHref}>
|
||||
{t("admin.sales.navigation.title")}
|
||||
</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>
|
||||
{t("admin.sales.email.accounts.title")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
|
||||
{props.errorMessage ? (
|
||||
<Card variant="negative">
|
||||
<p className="text-body-small-regular-0 text-text-feedback-negative">
|
||||
{props.errorMessage}
|
||||
</p>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
{props.vm.providers.map((provider) => (
|
||||
<Card key={provider.provider}>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<FeatherShieldCheck className="text-heading- font-heading- text-icon-neutral-tertiary" />
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(
|
||||
`admin.sales.email.accounts.providers.${provider.provider}`
|
||||
)}
|
||||
</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(
|
||||
provider.configured
|
||||
? "admin.sales.email.accounts.providerReady"
|
||||
: "admin.sales.email.accounts.providerExternalGate"
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
provider.connected
|
||||
? "subtle-positive"
|
||||
: provider.configured
|
||||
? "subtle-information"
|
||||
: "subtle-warning"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
provider.connected
|
||||
? "admin.sales.email.accounts.connected"
|
||||
: provider.configured
|
||||
? "admin.sales.email.accounts.ready"
|
||||
: "admin.sales.email.accounts.externalGate"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<Link
|
||||
to={props.connectHref(provider.provider)}
|
||||
className="contents no-underline"
|
||||
>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
disabled={!provider.configured}
|
||||
icon={<FeatherRefreshCw />}
|
||||
>
|
||||
{t(
|
||||
provider.connected
|
||||
? "admin.sales.email.accounts.reconnect"
|
||||
: "admin.sales.email.accounts.connect"
|
||||
)}
|
||||
</Button>
|
||||
</Link>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{props.vm.accounts.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.email.accounts.empty")}
|
||||
body={t("admin.sales.email.accounts.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-3">
|
||||
{props.vm.accounts.map((account) => (
|
||||
<Card key={account.id}>
|
||||
<div className="flex w-full items-center justify-between gap-4 mobile:items-start">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{account.displayName || account.emailAddress}
|
||||
</p>
|
||||
<p className="truncate text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{account.emailAddress}
|
||||
</p>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{account.lastSyncAt
|
||||
? t("admin.sales.email.accounts.lastSync", {
|
||||
value: formatters.dateTime(
|
||||
account.lastSyncAt
|
||||
),
|
||||
})
|
||||
: t("admin.sales.email.accounts.notSynced")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex items-center gap-2 mobile:flex-col mobile:items-end">
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
account.status === "active"
|
||||
? "subtle-positive"
|
||||
: account.status === "degraded"
|
||||
? "subtle-warning"
|
||||
: "subtle-neutral"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
`admin.sales.email.accounts.status.${account.status}`
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="small"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onDisconnect({
|
||||
mailboxId: account.id,
|
||||
connectionId: account.connectionId,
|
||||
provider: account.provider,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.accounts.disconnect")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+152
@@ -0,0 +1,152 @@
|
||||
import type { AdminEmailDomainsVM } from "@hivegrid/view-models";
|
||||
import { FeatherGlobe } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { CopyToClipboardButton } from "~/ui/components/CopyToClipboardButton";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { AdminEmailWorkspaceNav, type AdminEmailWorkspaceHrefs } from "./AdminEmailWorkspaceNav";
|
||||
|
||||
export function AdminEmailDomainsPage(props: {
|
||||
readonly vm: AdminEmailDomainsVM;
|
||||
readonly hrefs: AdminEmailWorkspaceHrefs;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onSaveDomain: (input: {
|
||||
domain: string;
|
||||
spfRecordName: string;
|
||||
spfExpectedValue: string;
|
||||
dkimRecordName: string;
|
||||
dkimExpectedValue: string;
|
||||
}) => void;
|
||||
};
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [domain, setDomain] = useState({
|
||||
domain: "",
|
||||
spfRecordName: "",
|
||||
spfExpectedValue: "",
|
||||
dkimRecordName: "",
|
||||
dkimExpectedValue: "",
|
||||
});
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.email.domains">
|
||||
<PageHeader
|
||||
icon={<FeatherGlobe className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.email.domains.title")}
|
||||
subtitle={t("admin.sales.email.domains.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<AdminEmailWorkspaceNav active="domains" hrefs={props.hrefs} />
|
||||
{props.errorMessage ? <Card variant="negative">{props.errorMessage}</Card> : null}
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-3 gap-4">
|
||||
<Card>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.sales.email.domains.tracking")}</p>
|
||||
<BadgeFeedback farbe={props.vm.tracking.enabled ? "subtle-information" : "subtle-neutral"}>
|
||||
{t(props.vm.tracking.enabled ? "admin.sales.email.domains.enabled" : "admin.sales.email.domains.disabled")}
|
||||
</BadgeFeedback>
|
||||
</Card>
|
||||
<Card>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.sales.email.domains.liveOpen")}</p>
|
||||
<BadgeFeedback farbe={props.vm.tracking.liveOpenEnabled ? "subtle-warning" : "subtle-neutral"}>
|
||||
{t(props.vm.tracking.liveOpenEnabled ? "admin.sales.email.domains.enabled" : "admin.sales.email.domains.disabled")}
|
||||
</BadgeFeedback>
|
||||
</Card>
|
||||
<Card>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.sales.email.domains.retention")}</p>
|
||||
<p className="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">
|
||||
{t("admin.sales.email.domains.days", {
|
||||
count: props.vm.tracking.retentionDays,
|
||||
})}
|
||||
</p>
|
||||
</Card>
|
||||
</div>
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.domains.add")}</h2>
|
||||
{(Object.keys(domain) as (keyof typeof domain)[]).map((key) => (
|
||||
<TextInput key={key} showLabel label={t(`admin.sales.email.domains.fields.${key}`)}>
|
||||
<TextInput.Input value={domain[key]} onChange={(event) => setDomain({ ...domain, [key]: event.target.value })} />
|
||||
</TextInput>
|
||||
))}
|
||||
<Button loading={props.submitting} disabled={Object.values(domain).some((value) => !value)} onClick={() => props.actions.onSaveDomain(domain)}>
|
||||
{t("admin.sales.email.domains.save")}
|
||||
</Button>
|
||||
</Card>
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.domains.bcc")}</h2>
|
||||
{props.vm.bccAddresses.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.email.domains.bccEmpty")} body={t("admin.sales.email.domains.bccEmptyBody")} />
|
||||
) : (
|
||||
props.vm.bccAddresses.map((address) => (
|
||||
<div
|
||||
key={address.id}
|
||||
className="border-border-default flex w-full items-center justify-between gap-3 border-b border-solid py-3 last:border-b-0"
|
||||
>
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{address.mailboxLabel}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{address.displayAddress}</p>
|
||||
</div>
|
||||
<CopyToClipboardButton
|
||||
clipboardText={address.displayAddress}
|
||||
tooltipText={t("admin.sales.email.domains.copyBcc")}
|
||||
successKey="admin.sales.email.domains.toast.bccCopied"
|
||||
/>
|
||||
</div>
|
||||
))
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
{props.vm.domains.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.email.domains.empty")} body={t("admin.sales.email.domains.emptyBody")} />
|
||||
) : (
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
{props.vm.domains.map((item) => (
|
||||
<Card key={item.id}>
|
||||
<div className="flex w-full items-center justify-between gap-3">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{item.domain}</h2>
|
||||
<BadgeFeedback farbe={item.status === "verified" ? "subtle-positive" : "subtle-warning"}>
|
||||
{t(`admin.sales.email.domains.status.${item.status}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<DnsRow
|
||||
label={t("admin.sales.email.domains.spf")}
|
||||
name={item.spfRecordName}
|
||||
value={item.spfExpectedValue}
|
||||
status={item.spfStatus}
|
||||
statusLabel={t(`admin.sales.email.domains.status.${item.spfStatus}`)}
|
||||
/>
|
||||
<DnsRow
|
||||
label={t("admin.sales.email.domains.dkim")}
|
||||
name={item.dkimRecordName}
|
||||
value={item.dkimExpectedValue}
|
||||
status={item.dkimStatus}
|
||||
statusLabel={t(`admin.sales.email.domains.status.${item.dkimStatus}`)}
|
||||
/>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function DnsRow(props: { readonly label: string; readonly name: string; readonly value: string; readonly status: string; readonly statusLabel: string }) {
|
||||
return (
|
||||
<div className="border-border-default flex w-full flex-col gap-1 rounded-md border border-solid p-3">
|
||||
<div className="flex items-center justify-between gap-2">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{props.label}</span>
|
||||
<BadgeFeedback farbe={props.status === "verified" ? "subtle-positive" : "subtle-warning"}>{props.statusLabel}</BadgeFeedback>
|
||||
</div>
|
||||
<code className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary break-all">{props.name}</code>
|
||||
<code className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary break-all">{props.value}</code>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+176
@@ -0,0 +1,176 @@
|
||||
import type { AdminEmailInboxVM } from "@hivegrid/view-models";
|
||||
import { FeatherInbox, FeatherMail, FeatherPaperclip } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
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 { Select } from "~/ui/components/Select";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { AdminEmailWorkspaceNav, type AdminEmailWorkspaceHrefs } from "./AdminEmailWorkspaceNav";
|
||||
|
||||
export function AdminEmailInboxPage(props: {
|
||||
readonly vm: AdminEmailInboxVM;
|
||||
readonly hrefs: AdminEmailWorkspaceHrefs;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onOpenThread: (threadId: string) => void;
|
||||
readonly onAssign: (input: { readonly messageId: string; readonly contactId: string | null; readonly dealId: string | null }) => void;
|
||||
};
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [contactId, setContactId] = useState("");
|
||||
const [dealId, setDealId] = useState("");
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.email.inbox">
|
||||
<PageHeader
|
||||
icon={<FeatherInbox className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.email.inbox.title")}
|
||||
subtitle={t("admin.sales.email.inbox.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<AdminEmailWorkspaceNav active="inbox" hrefs={props.hrefs} />
|
||||
{props.errorMessage ? <Card variant="negative">{props.errorMessage}</Card> : null}
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-3 gap-4">
|
||||
<StatsCard label={t("admin.sales.email.inbox.stats.threads")} value={String(props.vm.stats.threads)} />
|
||||
<StatsCard label={t("admin.sales.email.inbox.stats.unread")} value={String(props.vm.stats.unread)} />
|
||||
<StatsCard label={t("admin.sales.email.inbox.stats.assignmentQueue")} value={String(props.vm.stats.assignmentQueue)} />
|
||||
</div>
|
||||
{props.vm.threads.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.email.inbox.empty")} body={t("admin.sales.email.inbox.emptyBody")} />
|
||||
) : (
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-[minmax(280px,0.9fr)_minmax(0,1.4fr)] gap-4">
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
{props.vm.threads.map((thread) => (
|
||||
<Card key={thread.id}>
|
||||
<button type="button" className="flex w-full flex-col items-start gap-2 text-left" onClick={() => props.actions.onOpenThread(thread.id)}>
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary truncate">
|
||||
{thread.subject || t("admin.sales.email.inbox.noSubject")}
|
||||
</span>
|
||||
<BadgeFeedback farbe={thread.matchStatus === "matched" || thread.matchStatus === "manual" ? "subtle-positive" : "subtle-warning"}>
|
||||
{t(`admin.sales.email.inbox.match.${thread.matchStatus}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary truncate">{thread.fromAddress}</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary line-clamp-2">{thread.preview}</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary flex items-center gap-2">
|
||||
<FeatherMail />
|
||||
{thread.messageCount}
|
||||
{thread.attachmentCount > 0 ? (
|
||||
<>
|
||||
<FeatherPaperclip />
|
||||
{thread.attachmentCount}
|
||||
</>
|
||||
) : null}
|
||||
</span>
|
||||
</button>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
{props.vm.selectedThread ? (
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{props.vm.selectedThread.subject || t("admin.sales.email.inbox.noSubject")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.email.inbox.threadMessages", {
|
||||
count: props.vm.selectedThread.messages.length,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
{props.vm.selectedThread.messages.map((message) => (
|
||||
<Card key={message.id} variant={message.direction === "inbound" ? "default" : "information"}>
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">{message.fromAddress}</span>
|
||||
<p className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary whitespace-pre-wrap">
|
||||
{message.bodyText}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{message.eventTypes.map((event) => (
|
||||
<BadgeFeedback key={event} farbe="subtle-information">
|
||||
{t(`admin.sales.email.events.${event}`)}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
{message.attachments.map((attachment) => (
|
||||
<Link
|
||||
key={attachment.id}
|
||||
to={attachment.downloadHref}
|
||||
reloadDocument
|
||||
>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherPaperclip />}
|
||||
>
|
||||
{attachment.filename}
|
||||
</Button>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
{props.vm.selectedThread.messages.some((message) => message.direction === "inbound") &&
|
||||
(props.vm.assignmentOptions.contacts.length > 0 || props.vm.assignmentOptions.deals.length > 0) ? (
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-[1fr_1fr_auto] items-end gap-3">
|
||||
<Select
|
||||
showLabel
|
||||
label={t("admin.sales.email.inbox.assignmentContact")}
|
||||
placeholder={t("admin.sales.email.inbox.assignmentOptional")}
|
||||
value={contactId}
|
||||
onValueChange={setContactId}
|
||||
>
|
||||
{props.vm.assignmentOptions.contacts.map((contact) => (
|
||||
<Select.Item key={contact.id} value={contact.id}>
|
||||
{contact.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
showLabel
|
||||
label={t("admin.sales.email.inbox.assignmentDeal")}
|
||||
placeholder={t("admin.sales.email.inbox.assignmentOptional")}
|
||||
value={dealId}
|
||||
onValueChange={setDealId}
|
||||
>
|
||||
{props.vm.assignmentOptions.deals.map((deal) => (
|
||||
<Select.Item key={deal.id} value={deal.id}>
|
||||
{deal.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={!contactId && !dealId}
|
||||
onClick={() =>
|
||||
props.actions.onAssign({
|
||||
messageId: props.vm.selectedThread!.messages.at(-1)!.id,
|
||||
contactId: contactId || null,
|
||||
dealId: dealId || null,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.inbox.assign")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
</Card>
|
||||
) : (
|
||||
<EmptyState outlined title={t("admin.sales.email.inbox.selectThread")} body={t("admin.sales.email.inbox.selectThreadBody")} />
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+421
@@ -0,0 +1,421 @@
|
||||
import type { AdminEmailScheduledVM } from "@hivegrid/view-models";
|
||||
import { FeatherClock } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Switch } from "~/ui/components/Switch";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { AdminEmailWorkspaceNav, type AdminEmailWorkspaceHrefs } from "./AdminEmailWorkspaceNav";
|
||||
|
||||
export function AdminEmailScheduledPage(props: {
|
||||
readonly vm: AdminEmailScheduledVM;
|
||||
readonly hrefs: AdminEmailWorkspaceHrefs;
|
||||
readonly composeDefaults?: {
|
||||
readonly contactId: string | null;
|
||||
readonly dealId: string | null;
|
||||
readonly toAddress: string;
|
||||
};
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onQueueEmail: (input: {
|
||||
mailboxId: string;
|
||||
contactId: string | null;
|
||||
dealId: string | null;
|
||||
toAddress: string;
|
||||
subject: string;
|
||||
body: string;
|
||||
scheduledFor: string;
|
||||
timeZone: string;
|
||||
noReplyAfterDays: number | null;
|
||||
idempotencyKey: string;
|
||||
}) => void;
|
||||
readonly onSavePolicy: (input: {
|
||||
timeZone: string;
|
||||
workdayStartMinutes: number;
|
||||
workdayEndMinutes: number;
|
||||
allowedWeekDays: number[];
|
||||
dailySendLimit: number;
|
||||
bulkDailySendLimit: number;
|
||||
consentRulesConfigured: boolean;
|
||||
trackingEnabled: boolean;
|
||||
liveOpenEnabled: boolean;
|
||||
}) => void;
|
||||
readonly onQueueBulkEmail: (input: {
|
||||
mailboxId: string;
|
||||
name: string;
|
||||
contactIds: string[];
|
||||
subjectTemplate: string;
|
||||
bodyTemplate: string;
|
||||
scheduledFor: string;
|
||||
timeZone: string;
|
||||
noReplyAfterDays: number | null;
|
||||
idempotencyKey: string;
|
||||
}) => void;
|
||||
};
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const defaultMailbox = props.vm.mailboxes[0]?.id ?? "";
|
||||
const [draft, setDraft] = useState({
|
||||
mailboxId: defaultMailbox,
|
||||
toAddress: props.composeDefaults?.toAddress ?? "",
|
||||
subject: "",
|
||||
body: "",
|
||||
scheduledFor: "",
|
||||
noReplyAfterDays: "3",
|
||||
});
|
||||
const current = props.vm.policy;
|
||||
const [policy, setPolicy] = useState({
|
||||
timeZone: current?.timeZone ?? "Europe/Berlin",
|
||||
dailySendLimit: String(current?.dailySendLimit ?? 50),
|
||||
bulkDailySendLimit: String(current?.bulkDailySendLimit ?? 25),
|
||||
consentRulesConfigured: current?.consentRulesConfigured ?? false,
|
||||
trackingEnabled: current?.trackingEnabled ?? false,
|
||||
liveOpenEnabled: current?.liveOpenEnabled ?? false,
|
||||
});
|
||||
const [bulk, setBulk] = useState({
|
||||
name: "",
|
||||
subjectTemplate: "",
|
||||
bodyTemplate: "",
|
||||
scheduledFor: "",
|
||||
});
|
||||
const [bulkContactIds, setBulkContactIds] = useState<Set<string>>(new Set());
|
||||
const toggleBulkContact = (contactId: string, checked: boolean) => {
|
||||
setBulkContactIds((current) => {
|
||||
const next = new Set(current);
|
||||
if (checked) next.add(contactId);
|
||||
else next.delete(contactId);
|
||||
return next;
|
||||
});
|
||||
};
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.email.scheduled">
|
||||
<PageHeader
|
||||
icon={<FeatherClock className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.email.scheduled.title")}
|
||||
subtitle={t("admin.sales.email.scheduled.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<AdminEmailWorkspaceNav active="scheduled" hrefs={props.hrefs} />
|
||||
{props.errorMessage ? <Card variant="negative">{props.errorMessage}</Card> : null}
|
||||
{props.vm.outboundLocked ? (
|
||||
<Card variant="warning">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t("admin.sales.email.scheduled.locked")}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.email.scheduled.lockedBody")}
|
||||
</p>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.scheduled.compose")}</h2>
|
||||
<Select
|
||||
showLabel
|
||||
label={t("admin.sales.email.scheduled.fields.mailbox")}
|
||||
value={draft.mailboxId}
|
||||
onValueChange={(mailboxId) => setDraft({ ...draft, mailboxId })}
|
||||
>
|
||||
{props.vm.mailboxes.map((mailbox) => (
|
||||
<Select.Item key={mailbox.id} value={mailbox.id}>
|
||||
{mailbox.displayName ?? mailbox.emailAddress}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.recipient")}>
|
||||
<TextInput.Input type="email" value={draft.toAddress} onChange={(event) => setDraft({ ...draft, toAddress: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.subject")}>
|
||||
<TextInput.Input value={draft.subject} onChange={(event) => setDraft({ ...draft, subject: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextArea showLabel label={t("admin.sales.email.scheduled.fields.body")}>
|
||||
<TextArea.Input value={draft.body} onChange={(event) => setDraft({ ...draft, body: event.target.value })} />
|
||||
</TextArea>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-3">
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.sendAt")}>
|
||||
<TextInput.Input
|
||||
type="datetime-local"
|
||||
value={draft.scheduledFor}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
scheduledFor: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.noReply")}>
|
||||
<TextInput.Input
|
||||
type="number"
|
||||
min={1}
|
||||
max={90}
|
||||
value={draft.noReplyAfterDays}
|
||||
onChange={(event) =>
|
||||
setDraft({
|
||||
...draft,
|
||||
noReplyAfterDays: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={props.vm.outboundLocked || !draft.mailboxId || !draft.toAddress || !draft.subject || !draft.body || !draft.scheduledFor}
|
||||
onClick={() =>
|
||||
props.actions.onQueueEmail({
|
||||
mailboxId: draft.mailboxId,
|
||||
contactId: props.composeDefaults?.contactId ?? null,
|
||||
dealId: props.composeDefaults?.dealId ?? null,
|
||||
toAddress: draft.toAddress,
|
||||
subject: draft.subject,
|
||||
body: draft.body,
|
||||
scheduledFor: new Date(draft.scheduledFor).toISOString(),
|
||||
timeZone: policy.timeZone,
|
||||
noReplyAfterDays: draft.noReplyAfterDays ? Number(draft.noReplyAfterDays) : null,
|
||||
idempotencyKey: `ui:${crypto.randomUUID()}`,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.scheduled.queue")}
|
||||
</Button>
|
||||
</Card>
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.scheduled.policy")}</h2>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.timeZone")}>
|
||||
<TextInput.Input value={policy.timeZone} onChange={(event) => setPolicy({ ...policy, timeZone: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.dailyLimit")}>
|
||||
<TextInput.Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={policy.dailySendLimit}
|
||||
onChange={(event) =>
|
||||
setPolicy({
|
||||
...policy,
|
||||
dailySendLimit: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.bulkLimit")}>
|
||||
<TextInput.Input
|
||||
type="number"
|
||||
min={1}
|
||||
value={policy.bulkDailySendLimit}
|
||||
onChange={(event) =>
|
||||
setPolicy({
|
||||
...policy,
|
||||
bulkDailySendLimit: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<PolicySwitch
|
||||
label={t("admin.sales.email.scheduled.fields.consent")}
|
||||
checked={policy.consentRulesConfigured}
|
||||
onChange={(checked) => setPolicy({ ...policy, consentRulesConfigured: checked })}
|
||||
/>
|
||||
<PolicySwitch
|
||||
label={t("admin.sales.email.scheduled.fields.tracking")}
|
||||
checked={policy.trackingEnabled}
|
||||
onChange={(checked) =>
|
||||
setPolicy({
|
||||
...policy,
|
||||
trackingEnabled: checked,
|
||||
liveOpenEnabled: checked ? policy.liveOpenEnabled : false,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<PolicySwitch
|
||||
label={t("admin.sales.email.scheduled.fields.liveOpen")}
|
||||
checked={policy.liveOpenEnabled}
|
||||
onChange={(checked) => setPolicy({ ...policy, liveOpenEnabled: checked })}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onSavePolicy({
|
||||
timeZone: policy.timeZone,
|
||||
workdayStartMinutes: 9 * 60,
|
||||
workdayEndMinutes: 18 * 60,
|
||||
allowedWeekDays: [1, 2, 3, 4, 5],
|
||||
dailySendLimit: Number(policy.dailySendLimit),
|
||||
bulkDailySendLimit: Number(policy.bulkDailySendLimit),
|
||||
consentRulesConfigured: policy.consentRulesConfigured,
|
||||
trackingEnabled: policy.trackingEnabled,
|
||||
liveOpenEnabled: policy.liveOpenEnabled,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.scheduled.savePolicy")}
|
||||
</Button>
|
||||
</Card>
|
||||
</div>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.scheduled.bulkBuilder")}</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.email.scheduled.bulkBuilderBody")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
<div className="flex w-full flex-col gap-3">
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.bulkName")}>
|
||||
<TextInput.Input value={bulk.name} onChange={(event) => setBulk({ ...bulk, name: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.subjectTemplate")}>
|
||||
<TextInput.Input
|
||||
value={bulk.subjectTemplate}
|
||||
onChange={(event) =>
|
||||
setBulk({
|
||||
...bulk,
|
||||
subjectTemplate: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextArea
|
||||
showLabel
|
||||
label={t("admin.sales.email.scheduled.fields.bodyTemplate")}
|
||||
helpText={t("admin.sales.email.scheduled.bulkPlaceholders", {
|
||||
placeholders: "{{first_name}}, {{last_name}}, {{full_name}}, {{email}}",
|
||||
})}
|
||||
>
|
||||
<TextArea.Input
|
||||
value={bulk.bodyTemplate}
|
||||
onChange={(event) =>
|
||||
setBulk({
|
||||
...bulk,
|
||||
bodyTemplate: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextArea>
|
||||
<TextInput showLabel label={t("admin.sales.email.scheduled.fields.sendAt")}>
|
||||
<TextInput.Input
|
||||
type="datetime-local"
|
||||
value={bulk.scheduledFor}
|
||||
onChange={(event) =>
|
||||
setBulk({
|
||||
...bulk,
|
||||
scheduledFor: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<div className="border-border-default flex max-h-80 w-full flex-col gap-3 overflow-y-auto rounded-md border border-solid p-3">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.email.scheduled.bulkSelection", {
|
||||
count: bulkContactIds.size,
|
||||
})}
|
||||
</span>
|
||||
{props.vm.contacts.length === 0 ? (
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.email.scheduled.bulkContactsEmpty")}
|
||||
</p>
|
||||
) : (
|
||||
props.vm.contacts.map((contact) => (
|
||||
<Checkbox
|
||||
key={contact.id}
|
||||
checked={bulkContactIds.has(contact.id)}
|
||||
onCheckedChange={(checked) => toggleBulkContact(contact.id, checked)}
|
||||
label={contact.label}
|
||||
description={contact.email}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={
|
||||
props.vm.outboundLocked ||
|
||||
!draft.mailboxId ||
|
||||
!bulk.name ||
|
||||
!bulk.subjectTemplate ||
|
||||
!bulk.bodyTemplate ||
|
||||
!bulk.scheduledFor ||
|
||||
bulkContactIds.size === 0
|
||||
}
|
||||
onClick={() =>
|
||||
props.actions.onQueueBulkEmail({
|
||||
mailboxId: draft.mailboxId,
|
||||
name: bulk.name,
|
||||
contactIds: [...bulkContactIds],
|
||||
subjectTemplate: bulk.subjectTemplate,
|
||||
bodyTemplate: bulk.bodyTemplate,
|
||||
scheduledFor: new Date(bulk.scheduledFor).toISOString(),
|
||||
timeZone: policy.timeZone,
|
||||
noReplyAfterDays: draft.noReplyAfterDays ? Number(draft.noReplyAfterDays) : null,
|
||||
idempotencyKey: `ui-bulk:${crypto.randomUUID()}`,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.scheduled.queueBulk")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
{props.vm.scheduled.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.email.scheduled.empty")} body={t("admin.sales.email.scheduled.emptyBody")} />
|
||||
) : (
|
||||
<Card>
|
||||
{props.vm.scheduled.map((item) => (
|
||||
<div key={item.id} className="border-border-default flex w-full items-center justify-between gap-3 border-b border-solid py-3 last:border-b-0">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{item.subject}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{item.recipients.join(", ")}</p>
|
||||
</div>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
item.status === "sent"
|
||||
? "subtle-positive"
|
||||
: item.status === "failed" || item.status === "blocked"
|
||||
? "subtle-warning"
|
||||
: "subtle-information"
|
||||
}
|
||||
>
|
||||
{t(`admin.sales.email.scheduled.status.${item.status}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
)}
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.scheduled.bulkRuns")}</h2>
|
||||
{props.vm.bulkRuns.map((run) => (
|
||||
<div key={run.id} className="border-border-default flex w-full items-center justify-between gap-3 border-b border-solid py-3 last:border-b-0">
|
||||
<span>{run.name}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{run.sentCount}/{run.recipientCount}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
</div>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function PolicySwitch(props: { readonly label: string; readonly checked: boolean; readonly onChange: (checked: boolean) => void }) {
|
||||
return (
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<span className="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">{props.label}</span>
|
||||
<Switch checked={props.checked} onCheckedChange={props.onChange} aria-label={props.label} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
import type { AdminEmailTemplatesVM } from "@hivegrid/view-models";
|
||||
import { FeatherFileText } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { PAGE_HEADER_ICON_CLASS, PageBody, PageHeader, PageShell } from "~/components/screens/shared/PageShell";
|
||||
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 { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { AdminEmailWorkspaceNav, type AdminEmailWorkspaceHrefs } from "./AdminEmailWorkspaceNav";
|
||||
|
||||
export function AdminEmailTemplatesPage(props: {
|
||||
readonly vm: AdminEmailTemplatesVM;
|
||||
readonly hrefs: AdminEmailWorkspaceHrefs;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onSaveTemplate: (input: { name: string; subjectTemplate: string; htmlTemplate: string; allowedPlaceholders: string[] }) => void;
|
||||
readonly onSaveSnippet: (input: { shortcut: string; title: string; content: string }) => void;
|
||||
readonly onSaveSignature: (input: { html: string; text: string | null }) => void;
|
||||
};
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [template, setTemplate] = useState({
|
||||
name: "",
|
||||
subjectTemplate: "",
|
||||
htmlTemplate: "",
|
||||
placeholders: "contact.firstName,company.name",
|
||||
});
|
||||
const [snippet, setSnippet] = useState({
|
||||
shortcut: "",
|
||||
title: "",
|
||||
content: "",
|
||||
});
|
||||
const [signature, setSignature] = useState(props.vm.signature?.text ?? "");
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.email.templates">
|
||||
<PageHeader
|
||||
icon={<FeatherFileText className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.email.templates.title")}
|
||||
subtitle={t("admin.sales.email.templates.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<AdminEmailWorkspaceNav active="templates" hrefs={props.hrefs} />
|
||||
{props.errorMessage ? <Card variant="negative">{props.errorMessage}</Card> : null}
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.templates.newTemplate")}</h2>
|
||||
<TextInput showLabel label={t("admin.sales.email.templates.fields.name")}>
|
||||
<TextInput.Input value={template.name} onChange={(event) => setTemplate({ ...template, name: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.templates.fields.subject")}>
|
||||
<TextInput.Input
|
||||
value={template.subjectTemplate}
|
||||
onChange={(event) =>
|
||||
setTemplate({
|
||||
...template,
|
||||
subjectTemplate: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextArea showLabel label={t("admin.sales.email.templates.fields.body")}>
|
||||
<TextArea.Input
|
||||
value={template.htmlTemplate}
|
||||
onChange={(event) =>
|
||||
setTemplate({
|
||||
...template,
|
||||
htmlTemplate: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextArea>
|
||||
<TextInput showLabel label={t("admin.sales.email.templates.fields.placeholders")}>
|
||||
<TextInput.Input
|
||||
value={template.placeholders}
|
||||
onChange={(event) =>
|
||||
setTemplate({
|
||||
...template,
|
||||
placeholders: event.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={!template.name || !template.subjectTemplate || !template.htmlTemplate}
|
||||
onClick={() =>
|
||||
props.actions.onSaveTemplate({
|
||||
name: template.name,
|
||||
subjectTemplate: template.subjectTemplate,
|
||||
htmlTemplate: template.htmlTemplate,
|
||||
allowedPlaceholders: template.placeholders
|
||||
.split(",")
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean),
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.templates.saveTemplate")}
|
||||
</Button>
|
||||
</Card>
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.templates.snippets")}</h2>
|
||||
<TextInput showLabel label={t("admin.sales.email.templates.fields.shortcut")}>
|
||||
<TextInput.Input value={snippet.shortcut} onChange={(event) => setSnippet({ ...snippet, shortcut: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.sales.email.templates.fields.title")}>
|
||||
<TextInput.Input value={snippet.title} onChange={(event) => setSnippet({ ...snippet, title: event.target.value })} />
|
||||
</TextInput>
|
||||
<TextArea showLabel label={t("admin.sales.email.templates.fields.content")}>
|
||||
<TextArea.Input value={snippet.content} onChange={(event) => setSnippet({ ...snippet, content: event.target.value })} />
|
||||
</TextArea>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={!snippet.shortcut || !snippet.title || !snippet.content}
|
||||
onClick={() => props.actions.onSaveSnippet(snippet)}
|
||||
>
|
||||
{t("admin.sales.email.templates.saveSnippet")}
|
||||
</Button>
|
||||
</Card>
|
||||
</div>
|
||||
<Card>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.email.templates.signature")}</h2>
|
||||
<TextArea showLabel label={t("admin.sales.email.templates.fields.signature")}>
|
||||
<TextArea.Input value={signature} onChange={(event) => setSignature(event.target.value)} />
|
||||
</TextArea>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={!signature}
|
||||
onClick={() =>
|
||||
props.actions.onSaveSignature({
|
||||
html: `<p>${signature}</p>`,
|
||||
text: signature,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.email.templates.saveSignature")}
|
||||
</Button>
|
||||
</Card>
|
||||
<div className="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
{props.vm.templates.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.email.templates.empty")} body={t("admin.sales.email.templates.emptyBody")} />
|
||||
) : (
|
||||
<Card>
|
||||
{props.vm.templates.map((item) => (
|
||||
<div key={item.id} className="border-border-default flex w-full items-center justify-between gap-3 border-b border-solid py-3 last:border-b-0">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{item.name}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{item.subjectTemplate}</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-information">
|
||||
{t("admin.sales.email.templates.version", {
|
||||
value: item.version,
|
||||
})}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
)}
|
||||
<Card>
|
||||
{props.vm.snippets.map((item) => (
|
||||
<div key={item.id} className="border-border-default flex w-full items-start justify-between gap-3 border-b border-solid py-3 last:border-b-0">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{item.title}</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{item.content}</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-neutral">/{item.shortcut}</BadgeFeedback>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
</div>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
import { Link } from "react-router";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
|
||||
export type AdminEmailWorkspaceHrefs = {
|
||||
readonly inbox: string;
|
||||
readonly templates: string;
|
||||
readonly scheduled: string;
|
||||
readonly accounts: string;
|
||||
readonly domains: string;
|
||||
};
|
||||
|
||||
export function AdminEmailWorkspaceNav(props: { readonly active: keyof AdminEmailWorkspaceHrefs; readonly hrefs: AdminEmailWorkspaceHrefs }) {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Tabs>
|
||||
{(Object.keys(props.hrefs) as (keyof AdminEmailWorkspaceHrefs)[]).map((key) => (
|
||||
<Tabs.Item key={key} active={props.active === key}>
|
||||
<Link className="contents no-underline" to={props.hrefs[key]}>
|
||||
{t(`admin.sales.email.navigation.${key}`)}
|
||||
</Link>
|
||||
</Tabs.Item>
|
||||
))}
|
||||
</Tabs>
|
||||
);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28c email account interim screen > renders provider gates and wires disconnect 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.email.accounts"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.email.accounts.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.email.accounts.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/sales/deals" data-discover="true">admin.sales.navigation.title</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">admin.sales.email.accounts.title</span></div><div class="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start justify-between gap-4"><div class="flex min-w-0 items-start gap-3"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">admin.sales.email.accounts.providers.google_mail</p><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.email.accounts.providerReady</p></div></div><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-positive"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-positive"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-feedback-positive">admin.sales.email.accounts.connected</span></div></div><a class="contents no-underline" href="/sales/settings/email-accounts/connect/google_mail" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.email.accounts.reconnect</span></button></a></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start justify-between gap-4"><div class="flex min-w-0 items-start gap-3"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-priLine truncated
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28c email workspace interim screens > keeps the domains screen visually stable 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.email.domains"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.email.domains.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.email.domains.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/inbox" data-discover="true">admin.sales.email.navigation.inbox</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/email-accounts" data-discover="true">admin.sales.email.navigation.accounts</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/templates" data-discover="true">admin.sales.email.navigation.templates</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/scheduled" data-discover="true">admin.sales.email.navigation.scheduled</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brand-brand-border-solid-default bg-surface-neutral-tertiary"><span class="text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary text-body-small-medium-0 font-body-small-medium-0"><a class="contents no-underline" href="/sales/settings/sending-domains" data-discover="true">admin.sales.email.navigation.domains</a></span></div></div></div><Line truncated
|
||||
|
||||
exports[`VA-P28c email workspace interim screens > keeps the inbox screen visually stable 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.email.inbox"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.email.inbox.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.email.inbox.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brand-brand-border-solid-default bg-surface-neutral-tertiary"><span class="text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary text-body-small-medium-0 font-body-small-medium-0"><a class="contents no-underline" href="/sales/email/inbox" data-discover="true">admin.sales.email.navigation.inbox</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/email-accounts" data-discover="true">admin.sales.email.navigation.accounts</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/templates" data-discover="true">admin.sales.email.navigation.templates</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/scheduled" data-discover="true">admin.sales.email.navigation.scheduled</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/sending-domains" data-discover="true">admin.sales.email.navigation.domains</a></span></div></div></div><div clasLine truncated
|
||||
|
||||
exports[`VA-P28c email workspace interim screens > keeps the scheduled screen visually stable 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.email.scheduled"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.email.scheduled.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.email.scheduled.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/inbox" data-discover="true">admin.sales.email.navigation.inbox</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/email-accounts" data-discover="true">admin.sales.email.navigation.accounts</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/templates" data-discover="true">admin.sales.email.navigation.templates</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brand-brand-border-solid-default bg-surface-neutral-tertiary"><span class="text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary text-body-small-medium-0 font-body-small-medium-0"><a class="contents no-underline" href="/sales/email/scheduled" data-discover="true">admin.sales.email.navigation.scheduled</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/sending-domains" data-discover="true">admin.sales.email.navigation.domains</a></span></div></divLine truncated
|
||||
|
||||
exports[`VA-P28c email workspace interim screens > keeps the templates screen visually stable 1`] = `
|
||||
"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.email.templates"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.email.templates.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.email.templates.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex w-full items-end"><div class="flex grow shrink-0 basis-0 items-start"><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/inbox" data-discover="true">admin.sales.email.navigation.inbox</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/email-accounts" data-discover="true">admin.sales.email.navigation.accounts</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus border-b-2 border-x-0 border-t-0 border-solid border-brand-brand-border-solid-default bg-surface-neutral-tertiary"><span class="text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary text-body-small-medium-0 font-body-small-medium-0"><a class="contents no-underline" href="/sales/email/templates" data-discover="true">admin.sales.email.navigation.templates</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/email/scheduled" data-discover="true">admin.sales.email.navigation.scheduled</a></span></div><div class="group/d5612535 flex w-full cursor-pointer items-center justify-center gap-2 rounded-t-md border-b-2 border-solid border-border-default bg-surface-neutral-secondary px-4 py-2.5 hover:border-b-2 hover:border-x-0 hover:border-t-0 hover:border-solid hover:border-brand-brand-border-solid-default hover:bg-surface-neutral-primary active:border-b-2 active:border-x-0 active:border-t-0 active:border-solid active:border-border-default active:bg-surface-neutral-secondary focus-within:shadow-focus"><span class="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary group-hover/d5612535:text-text-neutral-primary"><a class="contents no-underline" href="/sales/settings/sending-domains" data-discover="true">admin.sales.email.navigation.domains</a></span></div></div></div><div class="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4"><div class="group/56067c50 flex Line truncated
|
||||
HiveGrid</textarea></div></div></label><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="button"><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.email.templates.saveSignature</span></button></div><div class="tablet:grid-cols-1 grid w-full grid-cols-2 gap-4"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="border-border-default flex w-full items-center justify-between gap-3 border-b border-solid py-3 last:border-b-0"><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">Demo Follow-up</p><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Nächste Schritte mit {{company.name}}</p></div><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-information"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-information"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">admin.sales.email.templates.version:2</span></div></div></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="border-border-default flex w-full items-start justify-between gap-3 border-b border-solid py-3 last:border-b-0"><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">Einleitung</p><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">Vielen Dank für das Gespräch.</p></div><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-neutral"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-neutral-on-subtle"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-on-subtle">/intro</span></div></div></div></div></div></div>"
|
||||
`;
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminEmailAccountsPage } from "./AdminEmailAccountsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) =>
|
||||
values ? `${key}:${Object.values(values).join("/")}` : key,
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
providers: [
|
||||
{ provider: "google_mail" as const, configured: true, connected: true },
|
||||
{
|
||||
provider: "microsoft_mail" as const,
|
||||
configured: false,
|
||||
connected: false,
|
||||
},
|
||||
],
|
||||
accounts: [
|
||||
{
|
||||
id: "mailbox-1",
|
||||
connectionId: "connection-1",
|
||||
provider: "google_mail" as const,
|
||||
emailAddress: "sales@example.test",
|
||||
displayName: "Sales",
|
||||
status: "active" as const,
|
||||
lastSyncAt: "2026-07-24T10:00:00.000Z",
|
||||
healthMessageKey: null,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function page(onDisconnect = vi.fn()) {
|
||||
return (
|
||||
<MemoryRouter>
|
||||
<AdminEmailAccountsPage
|
||||
vm={vm}
|
||||
salesHref="/sales/deals"
|
||||
connectHref={(provider) =>
|
||||
`/sales/settings/email-accounts/connect/${provider}`
|
||||
}
|
||||
submitting={false}
|
||||
actions={{ onDisconnect }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
}
|
||||
|
||||
describe("VA-P28c email account interim screen", () => {
|
||||
it("renders provider gates and wires disconnect", () => {
|
||||
const onDisconnect = vi.fn();
|
||||
const { container } = render(page(onDisconnect));
|
||||
|
||||
fireEvent.click(
|
||||
screen.getByRole("button", {
|
||||
name: "admin.sales.email.accounts.disconnect",
|
||||
})
|
||||
);
|
||||
expect(onDisconnect).toHaveBeenCalledWith({
|
||||
mailboxId: "mailbox-1",
|
||||
connectionId: "connection-1",
|
||||
provider: "google_mail",
|
||||
});
|
||||
expect(
|
||||
screen.getByRole("button", {
|
||||
name: "admin.sales.email.accounts.connect",
|
||||
})
|
||||
).toBeDisabled();
|
||||
const stableMarkup = container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
);
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("keeps the connection settings accessible", async () => {
|
||||
await expectNoA11yViolations(page());
|
||||
});
|
||||
});
|
||||
+220
@@ -0,0 +1,220 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminEmailDomainsPage } from "./AdminEmailDomainsPage";
|
||||
import { AdminEmailInboxPage } from "./AdminEmailInboxPage";
|
||||
import { AdminEmailScheduledPage } from "./AdminEmailScheduledPage";
|
||||
import { AdminEmailTemplatesPage } from "./AdminEmailTemplatesPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) => (values ? `${key}:${Object.values(values).join("/")}` : key),
|
||||
}),
|
||||
}));
|
||||
|
||||
const hrefs = {
|
||||
inbox: "/sales/email/inbox",
|
||||
accounts: "/sales/settings/email-accounts",
|
||||
templates: "/sales/email/templates",
|
||||
scheduled: "/sales/email/scheduled",
|
||||
domains: "/sales/settings/sending-domains",
|
||||
};
|
||||
const actions = {
|
||||
inbox: { onOpenThread: vi.fn(), onAssign: vi.fn() },
|
||||
templates: {
|
||||
onSaveTemplate: vi.fn(),
|
||||
onSaveSnippet: vi.fn(),
|
||||
onSaveSignature: vi.fn(),
|
||||
},
|
||||
scheduled: {
|
||||
onQueueEmail: vi.fn(),
|
||||
onQueueBulkEmail: vi.fn(),
|
||||
onSavePolicy: vi.fn(),
|
||||
},
|
||||
domains: { onSaveDomain: vi.fn() },
|
||||
};
|
||||
|
||||
const inboxVm = {
|
||||
stats: { threads: 1, unread: 1, assignmentQueue: 1 },
|
||||
threads: [
|
||||
{
|
||||
id: "thread-1",
|
||||
subject: "Demo und Trial",
|
||||
latestMessageAt: "2026-07-24T10:00:00.000Z",
|
||||
messageCount: 2,
|
||||
unreadCount: 1,
|
||||
matchStatus: "ambiguous" as const,
|
||||
preview: "Können wir den Termin verschieben?",
|
||||
fromAddress: "buyer@example.test",
|
||||
contactLabel: null,
|
||||
dealLabel: null,
|
||||
eventTypes: ["delivered"],
|
||||
attachmentCount: 1,
|
||||
},
|
||||
],
|
||||
selectedThread: {
|
||||
id: "thread-1",
|
||||
subject: "Demo und Trial",
|
||||
messages: [
|
||||
{
|
||||
id: "message-1",
|
||||
direction: "inbound" as const,
|
||||
fromAddress: "buyer@example.test",
|
||||
sentAt: "2026-07-24T10:00:00.000Z",
|
||||
bodyText: "Können wir den Termin verschieben?",
|
||||
eventTypes: ["delivered", "opened"],
|
||||
attachments: [
|
||||
{
|
||||
id: "file-1",
|
||||
filename: "anforderungen.pdf",
|
||||
sizeBytes: 2048,
|
||||
downloadHref: "/sales/email/attachments/file-1",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
assignmentOptions: {
|
||||
contacts: [{ id: "contact-1", label: "Ada Lovelace", email: "ada@example.test" }],
|
||||
deals: [{ id: "deal-1", label: "HiveGrid SaaS" }],
|
||||
},
|
||||
};
|
||||
|
||||
const templatesVm = {
|
||||
templates: [
|
||||
{
|
||||
id: "template-1",
|
||||
name: "Demo Follow-up",
|
||||
subjectTemplate: "Nächste Schritte mit {{company.name}}",
|
||||
htmlTemplate: "<p>Hallo</p>",
|
||||
allowedPlaceholders: ["company.name"],
|
||||
version: 2,
|
||||
updatedAt: "2026-07-24T10:00:00.000Z",
|
||||
},
|
||||
],
|
||||
snippets: [
|
||||
{
|
||||
id: "snippet-1",
|
||||
shortcut: "intro",
|
||||
title: "Einleitung",
|
||||
content: "Vielen Dank für das Gespräch.",
|
||||
},
|
||||
],
|
||||
signature: {
|
||||
html: "<p>Raffael<br />HiveGrid</p>",
|
||||
text: "Raffael\nHiveGrid",
|
||||
},
|
||||
};
|
||||
|
||||
const scheduledVm = {
|
||||
outboundLocked: false,
|
||||
policy: {
|
||||
timeZone: "Europe/Berlin",
|
||||
workdayStartMinutes: 540,
|
||||
workdayEndMinutes: 1080,
|
||||
allowedWeekDays: [1, 2, 3, 4, 5],
|
||||
dailySendLimit: 50,
|
||||
bulkDailySendLimit: 25,
|
||||
consentRulesConfigured: true,
|
||||
trackingEnabled: false,
|
||||
liveOpenEnabled: false,
|
||||
trackingRetentionDays: 180,
|
||||
},
|
||||
scheduled: [
|
||||
{
|
||||
id: "scheduled-1",
|
||||
subject: "Demo Follow-up",
|
||||
recipients: ["ada@example.test"],
|
||||
scheduledFor: "2026-07-25T08:00:00.000Z",
|
||||
status: "queued" as const,
|
||||
noReplyAfterDays: 3,
|
||||
errorMessageKey: null,
|
||||
},
|
||||
],
|
||||
bulkRuns: [
|
||||
{
|
||||
id: "bulk-1",
|
||||
name: "Trial Follow-up",
|
||||
status: "running",
|
||||
scheduledFor: "2026-07-25T08:00:00.000Z",
|
||||
recipientCount: 12,
|
||||
sentCount: 5,
|
||||
failedCount: 0,
|
||||
},
|
||||
],
|
||||
reminders: [],
|
||||
mailboxes: [
|
||||
{
|
||||
id: "mailbox-1",
|
||||
emailAddress: "sales@hivegrid.de",
|
||||
displayName: "Sales",
|
||||
},
|
||||
],
|
||||
contacts: [
|
||||
{
|
||||
id: "contact-1",
|
||||
label: "Ada Lovelace",
|
||||
email: "ada@example.test",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
const domainsVm = {
|
||||
domains: [
|
||||
{
|
||||
id: "domain-1",
|
||||
domain: "hivegrid.de",
|
||||
status: "verified",
|
||||
spfStatus: "verified",
|
||||
dkimStatus: "pending",
|
||||
spfRecordName: "hivegrid.de",
|
||||
spfExpectedValue: "v=spf1 include:spf.mailjet.com ~all",
|
||||
dkimRecordName: "mail._domainkey.hivegrid.de",
|
||||
dkimExpectedValue: "k=rsa; p=public-key",
|
||||
lastCheckedAt: "2026-07-24T10:00:00.000Z",
|
||||
},
|
||||
],
|
||||
bccAddresses: [
|
||||
{
|
||||
id: "bcc-1",
|
||||
mailboxId: "mailbox-1",
|
||||
mailboxLabel: "Sales",
|
||||
displayAddress: "signed-capability@bcc.hivegrid.de",
|
||||
rotatedAt: null,
|
||||
},
|
||||
],
|
||||
tracking: {
|
||||
enabled: false,
|
||||
liveOpenEnabled: false,
|
||||
retentionDays: 180,
|
||||
},
|
||||
};
|
||||
|
||||
describe("VA-P28c email workspace interim screens", () => {
|
||||
it.each([
|
||||
["inbox", <AdminEmailInboxPage vm={inboxVm} hrefs={hrefs} submitting={false} actions={actions.inbox} />],
|
||||
["templates", <AdminEmailTemplatesPage vm={templatesVm} hrefs={hrefs} submitting={false} actions={actions.templates} />],
|
||||
["scheduled", <AdminEmailScheduledPage vm={scheduledVm} hrefs={hrefs} submitting={false} actions={actions.scheduled} />],
|
||||
["domains", <AdminEmailDomainsPage vm={domainsVm} hrefs={hrefs} submitting={false} actions={actions.domains} />],
|
||||
])("keeps the %s screen visually stable", (_name, page) => {
|
||||
const { container } = render(<MemoryRouter>{page}</MemoryRouter>);
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it.each([
|
||||
<AdminEmailInboxPage vm={inboxVm} hrefs={hrefs} submitting={false} actions={actions.inbox} />,
|
||||
<AdminEmailTemplatesPage vm={templatesVm} hrefs={hrefs} submitting={false} actions={actions.templates} />,
|
||||
<AdminEmailScheduledPage vm={scheduledVm} hrefs={hrefs} submitting={false} actions={actions.scheduled} />,
|
||||
<AdminEmailDomainsPage vm={domainsVm} hrefs={hrefs} submitting={false} actions={actions.domains} />,
|
||||
])("has no automated accessibility violations", async (page) => {
|
||||
await expectNoA11yViolations(<MemoryRouter>{page}</MemoryRouter>);
|
||||
});
|
||||
});
|
||||
|
||||
function stableMarkup(markup: string) {
|
||||
return markup.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
}
|
||||
+175
@@ -0,0 +1,175 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherCheckCircle, FeatherFilter, FeatherLayers, FeatherToggleLeft } from "@subframe/core";
|
||||
import type { AdminFeatureFlagRolloutData } from "@hivegrid/view-models";
|
||||
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type AdminFeatureFlagBulkPageActions = {
|
||||
readonly onApplyOverride: (input: {
|
||||
readonly tenantIds: readonly string[];
|
||||
readonly value: boolean;
|
||||
readonly reason: string;
|
||||
readonly note: string;
|
||||
readonly expiresAt: string;
|
||||
}) => void;
|
||||
};
|
||||
|
||||
export function AdminFeatureFlagBulkPage({
|
||||
vm,
|
||||
actions,
|
||||
}: {
|
||||
readonly vm: AdminFeatureFlagRolloutData;
|
||||
readonly actions: AdminFeatureFlagBulkPageActions;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [selected, setSelected] = useState<ReadonlySet<string>>(() => new Set());
|
||||
const [reason, setReason] = useState("");
|
||||
const [note, setNote] = useState("");
|
||||
const [expiresAt, setExpiresAt] = useState("");
|
||||
const [value, setValue] = useState(true);
|
||||
const allSelected = vm.tenants.length > 0 && selected.size === vm.tenants.length;
|
||||
const selectedRows = useMemo(() => vm.tenants.filter((tenant) => selected.has(tenant.id)), [selected, vm.tenants]);
|
||||
|
||||
function toggleTenant(tenantId: string, checked: boolean) {
|
||||
setSelected((current) => {
|
||||
const next = new Set(current);
|
||||
if (checked) next.add(tenantId);
|
||||
else next.delete(tenantId);
|
||||
return next;
|
||||
});
|
||||
}
|
||||
|
||||
function toggleAll(checked: boolean) {
|
||||
setSelected(checked ? new Set(vm.tenants.map((tenant) => tenant.id)) : new Set());
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
className="mobile:px-4 mb-12 w-full space-y-5 px-6 py-6"
|
||||
data-ui="admin-feature-flag-bulk-page"
|
||||
data-ui-id="ui.admin.sales.featureFlags.bulkPage"
|
||||
>
|
||||
<header className="border-border-default flex flex-wrap items-start justify-between gap-4 border-b pb-5">
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("featureFlags.rollout.title")}</h1>
|
||||
<BadgeFeedback farbe="subtle-information" size="small">
|
||||
{t(`featureFlags.rollout.lifecycle.${vm.flag.lifecycleStage}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("featureFlags.rollout.description", { flag: vm.flag.label || vm.flag.key })}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe={vm.flag.defaultValue ? "subtle-positive" : "subtle-neutral"}>
|
||||
{t(vm.flag.defaultValue ? "featureFlags.rollout.defaultEnabled" : "featureFlags.rollout.defaultDisabled")}
|
||||
</BadgeFeedback>
|
||||
</header>
|
||||
|
||||
<div className="mobile:grid-cols-1 grid gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
<StatsCard label={t("featureFlags.rollout.summary.enabled")} value={vm.summary.enabled} percentage="" comparisonText="" icon={<FeatherCheckCircle />} />
|
||||
<StatsCard label={t("featureFlags.rollout.summary.overrides")} value={vm.summary.overrides} percentage="" comparisonText="" icon={<FeatherToggleLeft />} />
|
||||
<StatsCard label={t("featureFlags.rollout.summary.filtered")} value={vm.summary.filtered} percentage="" comparisonText="" icon={<FeatherFilter />} />
|
||||
<StatsCard label={t("featureFlags.rollout.summary.defaulted")} value={vm.summary.defaulted} percentage="" comparisonText="" icon={<FeatherLayers />} />
|
||||
</div>
|
||||
|
||||
{vm.updatedCount !== null ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{t("featureFlags.rollout.bulk.success", { count: vm.updatedCount })}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
{vm.tenants.length === 0 ? (
|
||||
<BannerAlert type="information" fillContainer>
|
||||
{t("featureFlags.rollout.empty")}
|
||||
</BannerAlert>
|
||||
) : (
|
||||
<div className="grid gap-4 xl:grid-cols-[minmax(0,1.35fr)_minmax(320px,0.65fr)]">
|
||||
<Card>
|
||||
<div className="flex w-full flex-wrap items-center justify-between gap-3">
|
||||
<div className="flex flex-col items-start">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("featureFlags.rollout.tenants.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("featureFlags.rollout.tenants.selected", { count: selected.size })}
|
||||
</span>
|
||||
</div>
|
||||
<Checkbox
|
||||
checked={allSelected}
|
||||
indeterminate={selected.size > 0 && !allSelected}
|
||||
onCheckedChange={toggleAll}
|
||||
label={t("featureFlags.rollout.tenants.selectAll")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="border-border-default w-full overflow-hidden rounded-md border">
|
||||
<div className="divide-border-default divide-y">
|
||||
{vm.tenants.map((tenant) => (
|
||||
<div key={tenant.id} className="bg-surface-neutral-primary flex w-full items-center justify-between gap-4 px-4 py-3">
|
||||
<div className="flex min-w-0 items-center gap-3">
|
||||
<Checkbox
|
||||
checked={selected.has(tenant.id)}
|
||||
onCheckedChange={(checked) => toggleTenant(tenant.id, checked)}
|
||||
label={tenant.name}
|
||||
/>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-secondary">
|
||||
{tenant.slug}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{tenant.status ? <BadgeFeedback farbe="subtle-neutral" size="small">{tenant.status}</BadgeFeedback> : null}
|
||||
{tenant.size ? <BadgeFeedback farbe="ghost-neutral" size="small">{tenant.size}</BadgeFeedback> : null}
|
||||
<BadgeFeedback farbe={tenant.effectiveValue ? "subtle-positive" : "subtle-neutral"} size="small">
|
||||
{t(tenant.effectiveValue ? "featureFlags.rollout.enabled" : "featureFlags.rollout.disabled")}
|
||||
</BadgeFeedback>
|
||||
<BadgeFeedback farbe="ghost-information" size="small">{t(tenant.sourceLabelKey)}</BadgeFeedback>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<Card variant={selected.size > 0 ? "information" : "default"}>
|
||||
<div className="flex w-full flex-col items-start gap-1">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("featureFlags.rollout.bulk.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("featureFlags.rollout.bulk.description", { count: selectedRows.length })}
|
||||
</span>
|
||||
</div>
|
||||
<div className="flex w-full gap-2">
|
||||
<Button variant={value ? "primary" : "tertiary"} onClick={() => setValue(true)}>
|
||||
{t("featureFlags.rollout.bulk.enable")}
|
||||
</Button>
|
||||
<Button variant={!value ? "neutral" : "tertiary"} onClick={() => setValue(false)}>
|
||||
{t("featureFlags.rollout.bulk.disable")}
|
||||
</Button>
|
||||
</div>
|
||||
<TextInput showLabel label={t("featureFlags.rollout.bulk.expiresAt")} fillContainer>
|
||||
<TextInput.Input type="datetime-local" value={expiresAt} onChange={(event) => setExpiresAt(event.currentTarget.value)} />
|
||||
</TextInput>
|
||||
<TextArea showLabel label={t("featureFlags.rollout.bulk.note")} className="max-w-none">
|
||||
<TextArea.Input value={note} onChange={(event) => setNote(event.currentTarget.value)} />
|
||||
</TextArea>
|
||||
<TextArea showLabel label={t("featureFlags.rollout.bulk.reason")} className="max-w-none" error={reason.trim().length > 0 && reason.trim().length < 5} errorText={t("featureFlags.rollout.bulk.reasonTooShort")}>
|
||||
<TextArea.Input value={reason} onChange={(event) => setReason(event.currentTarget.value)} />
|
||||
</TextArea>
|
||||
<Button
|
||||
disabled={selected.size === 0 || reason.trim().length < 5}
|
||||
onClick={() => actions.onApplyOverride({ tenantIds: [...selected], value, reason, note, expiresAt })}
|
||||
>
|
||||
{t("featureFlags.rollout.bulk.apply", { count: selected.size })}
|
||||
</Button>
|
||||
</Card>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+76
@@ -0,0 +1,76 @@
|
||||
import { createInstance } from "i18next";
|
||||
import { I18nextProvider, initReactI18next } from "react-i18next";
|
||||
|
||||
import type { AdminFeatureFlagRolloutData } from "@hivegrid/view-models";
|
||||
|
||||
import deTranslations from "../../../../../../public/locales/de/translations.json";
|
||||
|
||||
import { AdminFeatureFlagBulkPage } from "./AdminFeatureFlagBulkPage";
|
||||
|
||||
const visualI18n = createInstance();
|
||||
void visualI18n.use(initReactI18next).init({
|
||||
lng: "de",
|
||||
fallbackLng: "de",
|
||||
defaultNS: "translation",
|
||||
resources: { de: { translation: deTranslations } },
|
||||
interpolation: { escapeValue: false },
|
||||
initImmediate: false,
|
||||
});
|
||||
|
||||
export const featureFlagBulkVisualVM: AdminFeatureFlagRolloutData = {
|
||||
updatedCount: null,
|
||||
flag: {
|
||||
key: "sales_workspace",
|
||||
label: "Sales Workspace",
|
||||
defaultValue: false,
|
||||
lifecycleStage: "rollout",
|
||||
},
|
||||
summary: {
|
||||
enabled: 2,
|
||||
disabled: 1,
|
||||
overrides: 1,
|
||||
filtered: 1,
|
||||
defaulted: 1,
|
||||
},
|
||||
tenants: [
|
||||
{
|
||||
id: "tenant-geerkens",
|
||||
name: "Geerkens GmbH",
|
||||
slug: "geerkens",
|
||||
size: "51-100",
|
||||
status: "active",
|
||||
effectiveValue: true,
|
||||
source: "filter",
|
||||
sourceLabelKey: "featureFlags.rollout.source.filter",
|
||||
},
|
||||
{
|
||||
id: "tenant-muster",
|
||||
name: "Muster SHK GmbH",
|
||||
slug: "muster-shk",
|
||||
size: "11-25",
|
||||
status: "trial",
|
||||
effectiveValue: true,
|
||||
source: "override",
|
||||
sourceLabelKey: "featureFlags.rollout.source.override",
|
||||
},
|
||||
{
|
||||
id: "tenant-nord",
|
||||
name: "Nordwärme AG",
|
||||
slug: "nordwaerme",
|
||||
size: "26-50",
|
||||
status: "active",
|
||||
effectiveValue: false,
|
||||
source: "default",
|
||||
sourceLabelKey: "featureFlags.rollout.source.default",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/** Shared AD-28 fixture for the M033 feature-flag rollout baseline. */
|
||||
export function AdminFeatureFlagBulkVisualFixture(): React.JSX.Element {
|
||||
return (
|
||||
<I18nextProvider i18n={visualI18n}>
|
||||
<AdminFeatureFlagBulkPage vm={featureFlagBulkVisualVM} actions={{ onApplyOverride: () => undefined }} />
|
||||
</I18nextProvider>
|
||||
);
|
||||
}
|
||||
+322
@@ -0,0 +1,322 @@
|
||||
import type { AdminLeadAutomationVM } from "@hivegrid/view-models";
|
||||
import { FeatherGitBranch, FeatherSlidersHorizontal, FeatherTarget } from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBackLink,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type AdminSalesLeadSettingsActions = {
|
||||
readonly onCreateAssignmentRule: (input: {
|
||||
readonly name: string;
|
||||
readonly priority: number;
|
||||
readonly sourceId: string | null;
|
||||
readonly region: string | null;
|
||||
readonly strategy: "fixed" | "round_robin";
|
||||
readonly fixedAssigneeAdminUserId: string | null;
|
||||
readonly roundRobinAdminUserIds: readonly string[];
|
||||
}) => void;
|
||||
readonly onCreateScoreRule: (input: {
|
||||
readonly name: string;
|
||||
readonly priority: number;
|
||||
readonly field: "source" | "region" | "country" | "company" | "has_email" | "has_phone";
|
||||
readonly operator: "equals" | "not_equals" | "contains" | "present";
|
||||
readonly value: string | null;
|
||||
readonly points: number;
|
||||
}) => void;
|
||||
};
|
||||
|
||||
export function AdminSalesLeadSettingsPage(props: {
|
||||
readonly vm: AdminLeadAutomationVM;
|
||||
readonly backHref: string;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: AdminSalesLeadSettingsActions;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [assignmentName, setAssignmentName] = useState("");
|
||||
const [assignmentPriority, setAssignmentPriority] = useState("100");
|
||||
const [sourceId, setSourceId] = useState("all");
|
||||
const [region, setRegion] = useState("");
|
||||
const [strategy, setStrategy] = useState<"fixed" | "round_robin">("fixed");
|
||||
const [fixedAssigneeId, setFixedAssigneeId] = useState(props.vm.assigneeOptions[0]?.id ?? "");
|
||||
const [roundRobinIds, setRoundRobinIds] = useState<readonly string[]>([]);
|
||||
const [scoreName, setScoreName] = useState("");
|
||||
const [scorePriority, setScorePriority] = useState("100");
|
||||
const [scoreField, setScoreField] = useState<
|
||||
"source" | "region" | "country" | "company" | "has_email" | "has_phone"
|
||||
>("source");
|
||||
const [scoreOperator, setScoreOperator] = useState<"equals" | "not_equals" | "contains" | "present">("equals");
|
||||
const [scoreValue, setScoreValue] = useState("");
|
||||
const [scorePoints, setScorePoints] = useState("10");
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.leadSettings">
|
||||
<PageHeader
|
||||
icon={<FeatherSlidersHorizontal className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.leadSettings.title")}
|
||||
subtitle={t("admin.sales.leadSettings.description")}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.backHref}>{t("admin.sales.navigation.leads")}</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>
|
||||
{t("admin.sales.leadSettings.title")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<PageBackLink to={props.backHref} label={t("admin.sales.leadSettings.back")} />
|
||||
{props.errorMessage ? (
|
||||
<Card variant="negative">
|
||||
<p className="text-body-small-regular-0 text-text-feedback-negative">{props.errorMessage}</p>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
<div className="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1">
|
||||
<Card>
|
||||
<SectionHeader
|
||||
icon={<FeatherGitBranch />}
|
||||
title={t("admin.sales.leadSettings.assignment.title")}
|
||||
description={t("admin.sales.leadSettings.assignment.description")}
|
||||
/>
|
||||
{props.vm.assignmentRules.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.leadSettings.assignment.empty")}
|
||||
body={t("admin.sales.leadSettings.assignment.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{props.vm.assignmentRules.map((rule) => (
|
||||
<div
|
||||
key={rule.id}
|
||||
className="flex w-full items-start justify-between gap-3 rounded-md border border-solid border-border-default p-3"
|
||||
>
|
||||
<div className="min-w-0">
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{rule.name}
|
||||
</p>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{[rule.sourceLabel, rule.region, ...rule.assigneeLabels].filter(Boolean).join(" · ")}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe={rule.active ? "subtle-positive" : "subtle-neutral"} size="small">
|
||||
{t(`admin.sales.leadSettings.strategy.${rule.strategy}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<SectionHeader
|
||||
icon={<FeatherTarget />}
|
||||
title={t("admin.sales.leadSettings.scoring.title")}
|
||||
description={t("admin.sales.leadSettings.scoring.description")}
|
||||
/>
|
||||
{props.vm.scoreRules.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.leadSettings.scoring.empty")}
|
||||
body={t("admin.sales.leadSettings.scoring.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{props.vm.scoreRules.map((rule) => (
|
||||
<div
|
||||
key={rule.id}
|
||||
className="flex w-full items-start justify-between gap-3 rounded-md border border-solid border-border-default p-3"
|
||||
>
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{rule.name}
|
||||
</p>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(`admin.sales.leadSettings.fields.${rule.field}`)} ·{" "}
|
||||
{t(`admin.sales.leadSettings.operators.${rule.operator}`)}
|
||||
{rule.value ? ` · ${rule.value}` : ""}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe={rule.points >= 0 ? "subtle-positive" : "subtle-negative"}>
|
||||
{rule.points > 0 ? `+${rule.points}` : rule.points}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{props.vm.canConfigure ? (
|
||||
<div className="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1">
|
||||
<Card>
|
||||
<SectionHeader
|
||||
title={t("admin.sales.leadSettings.assignment.create")}
|
||||
description={t("admin.sales.leadSettings.assignment.createDescription")}
|
||||
/>
|
||||
<div className="grid w-full grid-cols-2 gap-3 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.name")} showLabel>
|
||||
<TextInput.Input value={assignmentName} onChange={(event) => setAssignmentName(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.priority")} showLabel>
|
||||
<TextInput.Input type="number" min="0" value={assignmentPriority} onChange={(event) => setAssignmentPriority(event.target.value)} />
|
||||
</TextInput>
|
||||
<Select label={t("admin.sales.leadSettings.fields.source")} showLabel value={sourceId} onValueChange={setSourceId}>
|
||||
<Select.Item value="all">{t("admin.sales.leadSettings.allSources")}</Select.Item>
|
||||
{props.vm.sourceOptions.map((source) => (
|
||||
<Select.Item key={source.id} value={source.id}>{source.label}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.region")} showLabel>
|
||||
<TextInput.Input value={region} onChange={(event) => setRegion(event.target.value)} />
|
||||
</TextInput>
|
||||
<Select
|
||||
label={t("admin.sales.leadSettings.fields.strategy")}
|
||||
showLabel
|
||||
value={strategy}
|
||||
onValueChange={(value) => setStrategy(value as "fixed" | "round_robin")}
|
||||
>
|
||||
<Select.Item value="fixed">{t("admin.sales.leadSettings.strategy.fixed")}</Select.Item>
|
||||
<Select.Item value="round_robin">{t("admin.sales.leadSettings.strategy.round_robin")}</Select.Item>
|
||||
</Select>
|
||||
{strategy === "fixed" ? (
|
||||
<Select
|
||||
label={t("admin.sales.leadSettings.fields.assignee")}
|
||||
showLabel
|
||||
value={fixedAssigneeId}
|
||||
onValueChange={setFixedAssigneeId}
|
||||
>
|
||||
{props.vm.assigneeOptions.map((assignee) => (
|
||||
<Select.Item key={assignee.id} value={assignee.id}>{assignee.label}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
<p className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.leadSettings.fields.roundRobinMembers")}
|
||||
</p>
|
||||
{props.vm.assigneeOptions.map((assignee) => (
|
||||
<Checkbox
|
||||
key={assignee.id}
|
||||
checked={roundRobinIds.includes(assignee.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
setRoundRobinIds((current) =>
|
||||
checked ? [...current, assignee.id] : current.filter((id) => id !== assignee.id)
|
||||
)
|
||||
}
|
||||
label={assignee.label}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={!assignmentName.trim() || (strategy === "fixed" ? !fixedAssigneeId : roundRobinIds.length === 0)}
|
||||
onClick={() =>
|
||||
props.actions.onCreateAssignmentRule({
|
||||
name: assignmentName.trim(),
|
||||
priority: Number(assignmentPriority),
|
||||
sourceId: sourceId === "all" ? null : sourceId,
|
||||
region: region.trim() || null,
|
||||
strategy,
|
||||
fixedAssigneeAdminUserId: strategy === "fixed" ? fixedAssigneeId : null,
|
||||
roundRobinAdminUserIds: strategy === "round_robin" ? roundRobinIds : [],
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.leadSettings.actions.createAssignment")}
|
||||
</Button>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<SectionHeader
|
||||
title={t("admin.sales.leadSettings.scoring.create")}
|
||||
description={t("admin.sales.leadSettings.scoring.createDescription")}
|
||||
/>
|
||||
<div className="grid w-full grid-cols-2 gap-3 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.name")} showLabel>
|
||||
<TextInput.Input value={scoreName} onChange={(event) => setScoreName(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.priority")} showLabel>
|
||||
<TextInput.Input type="number" min="0" value={scorePriority} onChange={(event) => setScorePriority(event.target.value)} />
|
||||
</TextInput>
|
||||
<Select label={t("admin.sales.leadSettings.fields.field")} showLabel value={scoreField} onValueChange={(value) => setScoreField(value as typeof scoreField)}>
|
||||
{(["source", "region", "country", "company", "has_email", "has_phone"] as const).map((field) => (
|
||||
<Select.Item key={field} value={field}>{t(`admin.sales.leadSettings.fields.${field}`)}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select label={t("admin.sales.leadSettings.fields.operator")} showLabel value={scoreOperator} onValueChange={(value) => setScoreOperator(value as typeof scoreOperator)}>
|
||||
{(["equals", "not_equals", "contains", "present"] as const).map((operator) => (
|
||||
<Select.Item key={operator} value={operator}>{t(`admin.sales.leadSettings.operators.${operator}`)}</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.value")} showLabel>
|
||||
<TextInput.Input disabled={scoreOperator === "present"} value={scoreValue} onChange={(event) => setScoreValue(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.leadSettings.fields.points")} showLabel>
|
||||
<TextInput.Input type="number" min="-1000" max="1000" value={scorePoints} onChange={(event) => setScorePoints(event.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<Button
|
||||
loading={props.submitting}
|
||||
disabled={!scoreName.trim()}
|
||||
onClick={() =>
|
||||
props.actions.onCreateScoreRule({
|
||||
name: scoreName.trim(),
|
||||
priority: Number(scorePriority),
|
||||
field: scoreField,
|
||||
operator: scoreOperator,
|
||||
value: scoreOperator === "present" ? null : scoreValue.trim() || null,
|
||||
points: Number(scorePoints),
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.leadSettings.actions.createScore")}
|
||||
</Button>
|
||||
</Card>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.leadSettings.readOnly.title")}
|
||||
body={t("admin.sales.leadSettings.readOnly.body")}
|
||||
/>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionHeader(props: {
|
||||
readonly icon?: React.ReactNode;
|
||||
readonly title: string;
|
||||
readonly description: string;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<div className="flex w-full items-start gap-3">
|
||||
{props.icon ? <span className="text-icon-brand-primary">{props.icon}</span> : null}
|
||||
<div>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{props.title}</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">{props.description}</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28b lead automation interim visual baseline > renders assignment, scoring and their configured state from an injected VM 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.leadSettings"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.leadSettings.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.leadSettings.description</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/leads" data-discover="true">admin.sales.navigation.leads</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">admin.sales.leadSettings.title</span></div><div><a class="contents no-underline" href="/leads" data-discover="true"><button class="group/3b777358 flex cursor-pointer items-center justify-center rounded-md text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled h-8 gap-2 px-3 py-2 border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.leadSettings.back</span></button></a></div><div class="grid w-full grid-cols-2 gap-5 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start gap-3"><span class="text-icon-brand-primary"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div><h2 class="text-heading-3 font-heading-3 text-text-neutral-primary">admin.sales.leadSettings.assignment.title</h2><p class="text-body-small-regular-0 text-text-neutral-tertiary">admin.sales.leadSettings.assignment.description</p></div></div><div class="flex w-full flex-col gap-2"><div class="flex w-full items-start justify-between gap-3 rounded-md border border-solid border-border-default p-3"><div class="min-w-0"><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">DACH Website</p><p class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">HiveGrid Website · DACH · Ada Admin · Berta Sales</p></div><div class="group/896531e4 flex items-center gap-2 rounded-round px-2.5 h-5 py-0.5 bg-surface-feedback-subtle-positive"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-positive"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-feedback-positive">admin.sales.leadSettings.strategy.round_robin</span></div></div></div></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><diLine truncated
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// @vitest-environment jsdom
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminSalesLeadSettingsPage } from "./AdminSalesLeadSettingsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
describe("VA-P28b lead automation accessibility", () => {
|
||||
it("keeps typed assignment and scoring controls named and reachable", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminSalesLeadSettingsPage
|
||||
vm={{
|
||||
assignmentRules: [],
|
||||
scoreRules: [],
|
||||
sourceOptions: [{ id: "source-1", label: "Website" }],
|
||||
assigneeOptions: [{ id: "admin-1", label: "Ada Admin" }],
|
||||
canConfigure: true,
|
||||
}}
|
||||
backHref="/leads"
|
||||
submitting={false}
|
||||
actions={{
|
||||
onCreateAssignmentRule: vi.fn(),
|
||||
onCreateScoreRule: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
+73
@@ -0,0 +1,73 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminSalesLeadSettingsPage } from "./AdminSalesLeadSettingsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key }),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
assignmentRules: [
|
||||
{
|
||||
id: "assignment-1",
|
||||
name: "DACH Website",
|
||||
priority: 10,
|
||||
active: true,
|
||||
sourceLabel: "HiveGrid Website",
|
||||
region: "DACH",
|
||||
strategy: "round_robin" as const,
|
||||
assigneeLabels: ["Ada Admin", "Berta Sales"],
|
||||
nextAssigneeIndex: 1,
|
||||
},
|
||||
],
|
||||
scoreRules: [
|
||||
{
|
||||
id: "score-1",
|
||||
name: "E-Mail vorhanden",
|
||||
priority: 10,
|
||||
active: true,
|
||||
field: "has_email",
|
||||
operator: "present",
|
||||
value: null,
|
||||
points: 10,
|
||||
version: 1,
|
||||
},
|
||||
],
|
||||
sourceOptions: [{ id: "source-1", label: "HiveGrid Website" }],
|
||||
assigneeOptions: [
|
||||
{ id: "admin-1", label: "Ada Admin" },
|
||||
{ id: "admin-2", label: "Berta Sales" },
|
||||
],
|
||||
canConfigure: true,
|
||||
};
|
||||
|
||||
describe("VA-P28b lead automation interim visual baseline", () => {
|
||||
it("renders assignment, scoring and their configured state from an injected VM", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesLeadSettingsPage
|
||||
vm={vm}
|
||||
backHref="/leads"
|
||||
submitting={false}
|
||||
actions={{
|
||||
onCreateAssignmentRule: vi.fn(),
|
||||
onCreateScoreRule: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("DACH Website");
|
||||
expect(container).toHaveTextContent("Ada Admin");
|
||||
expect(container.querySelector('[data-ui-id="ui.admin.sales.leadSettings"]')).toBeInTheDocument();
|
||||
const stableMarkup = container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
);
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import type { AdminRoleEditorVM } from "@hivegrid/view-models";
|
||||
|
||||
import { Alert, BadgeFeedback, Button, Card, Checkbox, TextArea } from "~/ui";
|
||||
|
||||
export type AdminRolesActions = {
|
||||
onSaveRole: (input: { roleId: string; permissions: string[]; reason: string }) => void | Promise<void>;
|
||||
};
|
||||
|
||||
export function AdminRolesPage({
|
||||
vm,
|
||||
actions,
|
||||
busy = false,
|
||||
errorKey,
|
||||
}: {
|
||||
vm: AdminRoleEditorVM;
|
||||
actions: AdminRolesActions;
|
||||
busy?: boolean;
|
||||
errorKey?: string;
|
||||
}) {
|
||||
const { t } = useTranslation();
|
||||
const [selectedRoleId, setSelectedRoleId] = useState(vm.roles[0]?.id ?? "");
|
||||
const selectedRole = vm.roles.find((role) => role.id === selectedRoleId);
|
||||
const [permissionsByRole, setPermissionsByRole] = useState<Record<string, string[]>>(() =>
|
||||
Object.fromEntries(vm.roles.map((role) => [role.id, role.permissions]))
|
||||
);
|
||||
const [reason, setReason] = useState("");
|
||||
const selectedPermissions = permissionsByRole[selectedRoleId] ?? [];
|
||||
const selectedAreas = vm.permissionGroups.filter((group) =>
|
||||
group.permissions.some((permission) => selectedPermissions.includes(permission.name))
|
||||
);
|
||||
const roleName = (role: (typeof vm.roles)[number]) =>
|
||||
role.systemKey ? t(`admin.sales.adminRoles.roleNames.${role.systemKey}`) : role.name;
|
||||
const roleDescription = (role: (typeof vm.roles)[number]) =>
|
||||
role.systemKey ? t(`admin.sales.adminRoles.roleDescriptions.${role.systemKey}`) : role.description;
|
||||
|
||||
return (
|
||||
<main data-ui-id="ui.admin.sales.security.adminRolesPage" className="flex w-full flex-col gap-6 px-6 py-6">
|
||||
<header className="flex flex-col gap-1">
|
||||
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("admin.sales.adminRoles.title")}</h1>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminRoles.description")}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{errorKey ? <Alert variant="error" role="alert" description={t(errorKey)} /> : null}
|
||||
|
||||
<div className="grid grid-cols-1 gap-6 xl:grid-cols-[320px_minmax(0,1fr)]">
|
||||
<div className="flex flex-col gap-3">
|
||||
{vm.roles.map((role) => (
|
||||
<button key={role.id} type="button" className="w-full text-left" onClick={() => setSelectedRoleId(role.id)}>
|
||||
<Card className={selectedRoleId === role.id ? "border-brand-brand-border-solid-default" : undefined}>
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div className="flex flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{roleName(role)}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{roleDescription(role)}</span>
|
||||
</div>
|
||||
<BadgeFeedback farbe={role.isSystem ? "subtle-brand-primary" : "subtle-neutral"}>
|
||||
{role.isSystem ? t("admin.sales.adminRoles.system") : t("admin.sales.adminRoles.custom")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminRoles.assigned", { count: role.assignedUsers })}
|
||||
</span>
|
||||
</Card>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{selectedRole ? (
|
||||
<Card>
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{roleName(selectedRole)}</h2>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminRoles.permissionDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.adminRoles.visibleAreasTitle")}
|
||||
</span>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminRoles.visibleAreasDescription")}
|
||||
</p>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{selectedAreas.map((group) => (
|
||||
<BadgeFeedback key={group.key} farbe="subtle-brand-primary">
|
||||
{t(`admin.sales.adminRoles.permissionGroups.${group.key}.title`)}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
{vm.permissionGroups.map((group) => (
|
||||
<fieldset key={group.key} className="flex w-full flex-col gap-3">
|
||||
<legend className="text-body-large font-body-large text-text-neutral-primary">
|
||||
{t(`admin.sales.adminRoles.permissionGroups.${group.key}.title`)}
|
||||
</legend>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{t(`admin.sales.adminRoles.permissionGroups.${group.key}.description`)}
|
||||
</p>
|
||||
<div className="grid w-full grid-cols-1 gap-3 md:grid-cols-2">
|
||||
{group.permissions.map((permission) => (
|
||||
<Checkbox
|
||||
key={permission.name}
|
||||
label={`${t(`admin.sales.adminRoles.permissionResources.${permission.resource}`)} · ${t(
|
||||
`admin.sales.adminRoles.permissionActions.${permission.action}`
|
||||
)}`}
|
||||
checked={selectedPermissions.includes(permission.name)}
|
||||
disabled={selectedRole.systemKey === "super_admin"}
|
||||
onCheckedChange={(checked) =>
|
||||
setPermissionsByRole((current) => ({
|
||||
...current,
|
||||
[selectedRoleId]: checked
|
||||
? [...new Set([...(current[selectedRoleId] ?? []), permission.name])]
|
||||
: (current[selectedRoleId] ?? []).filter((name) => name !== permission.name),
|
||||
}))
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</fieldset>
|
||||
))}
|
||||
<TextArea showLabel label={t("admin.sales.adminUserDetail.reason")}>
|
||||
<TextArea.Input value={reason} onChange={(event) => setReason(event.target.value)} />
|
||||
</TextArea>
|
||||
<Button
|
||||
loading={busy}
|
||||
disabled={selectedRole.systemKey === "super_admin" || reason.trim().length < 5}
|
||||
onClick={() => void actions.onSaveRole({ roleId: selectedRoleId, permissions: selectedPermissions, reason })}
|
||||
>
|
||||
{t("admin.sales.adminRoles.save")}
|
||||
</Button>
|
||||
</Card>
|
||||
) : null}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+155
@@ -0,0 +1,155 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import type { AdminSecurityProfileVM } from "@hivegrid/view-models";
|
||||
|
||||
import { Alert, BadgeFeedback, Button, Card, EmptyState, Table, TextInput } from "~/ui";
|
||||
|
||||
export type AdminSecurityProfileActions = {
|
||||
onRevokeSession: (input: { sessionId: string; reason: string }) => void | Promise<void>;
|
||||
};
|
||||
|
||||
export function AdminSecurityProfilePage({
|
||||
vm,
|
||||
actions,
|
||||
busy = false,
|
||||
errorKey,
|
||||
}: {
|
||||
vm: AdminSecurityProfileVM;
|
||||
actions: AdminSecurityProfileActions;
|
||||
busy?: boolean;
|
||||
errorKey?: string;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [reason, setReason] = useState("");
|
||||
const formatDate = (value: string) =>
|
||||
new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
|
||||
|
||||
return (
|
||||
<main data-ui-id="ui.admin.sales.security.adminSecurityProfilePage" className="flex w-full flex-col gap-6 px-6 py-6">
|
||||
<Alert description={t("admin.sales.security.authentikNotice")} />
|
||||
{errorKey ? (
|
||||
<Alert variant="error" description={t(errorKey)} role="alert" />
|
||||
) : null}
|
||||
|
||||
<section className="grid grid-cols-1 gap-4 xl:grid-cols-2">
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{vm.identity.displayName}</h2>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{vm.identity.email}</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe={vm.identity.status === "active" ? "subtle-positive" : "subtle-negative"}>
|
||||
{t(`admin.sales.security.status.${vm.identity.status}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<dl className="grid w-full grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<SecurityFact
|
||||
label={t("admin.sales.security.authentik")}
|
||||
value={t(vm.identity.authentikConnected ? "admin.sales.security.yes" : "admin.sales.security.no")}
|
||||
/>
|
||||
<SecurityFact
|
||||
label={t("admin.sales.security.mfa")}
|
||||
value={t(vm.identity.mfaAssured ? "admin.sales.security.yes" : "admin.sales.security.no")}
|
||||
/>
|
||||
<SecurityFact
|
||||
label={t("admin.sales.security.lastLogin")}
|
||||
value={vm.identity.lastSsoLoginAt ? formatDate(vm.identity.lastSsoLoginAt) : t("admin.sales.security.never")}
|
||||
/>
|
||||
</dl>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.security.roles")}</h2>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.security.rolesDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{vm.roles.map((role) => (
|
||||
<BadgeFeedback key={role.id} farbe="subtle-brand-primary">
|
||||
{role.systemKey ? t(`admin.sales.adminRoles.roleNames.${role.systemKey}`) : role.name}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
</Card>
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-3">
|
||||
<div className="flex flex-col">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.security.sessions")}</h2>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.security.sessionsDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<TextInput label={t("admin.sales.security.reasonLabel")} showLabel>
|
||||
<TextInput.Input
|
||||
aria-describedby="admin-security-revoke-reason-help"
|
||||
value={reason}
|
||||
onChange={(event) => setReason(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<p
|
||||
id="admin-security-revoke-reason-help"
|
||||
className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary"
|
||||
>
|
||||
{t("admin.sales.security.reasonHelp")}
|
||||
</p>
|
||||
{vm.sessions.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.security.emptySessionsTitle")} body={t("admin.sales.security.emptySessionsBody")} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.sales.security.session")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.security.lastSeen")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.security.expires")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.security.actions")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{vm.sessions.map((session) => (
|
||||
<Table.Row key={session.id}>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{session.current ? t("admin.sales.security.currentSession") : session.approxLocation ?? t("admin.sales.security.unknown")}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{session.userAgent ?? t("admin.sales.security.unknown")}
|
||||
</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{formatDate(session.lastSeenAt)}</Table.Cell>
|
||||
<Table.Cell>{formatDate(session.expiresAt)}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
disabled={session.current || reason.trim().length < 5}
|
||||
loading={busy}
|
||||
onClick={() => void actions.onRevokeSession({ sessionId: session.id, reason })}
|
||||
>
|
||||
{session.current ? t("admin.sales.security.current") : t("admin.sales.security.revoke")}
|
||||
</Button>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function SecurityFact({ label, value }: { label: string; value: string }) {
|
||||
return (
|
||||
<div className="flex flex-col">
|
||||
<dt className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-secondary">{label}</dt>
|
||||
<dd className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-primary">{value}</dd>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+186
@@ -0,0 +1,186 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import type { AdminUserDetailVM } from "@hivegrid/view-models";
|
||||
|
||||
import { Alert, BadgeFeedback, Breadcrumbs, Button, Card, Checkbox, EmptyState, Table, TextArea } from "~/ui";
|
||||
|
||||
export type AdminUserDetailActions = {
|
||||
onBack: () => void;
|
||||
onSaveRoles: (input: { roleKeys: string[]; reason: string }) => void | Promise<void>;
|
||||
onDisable: (reason: string) => void | Promise<void>;
|
||||
onRevokeSession: (input: { sessionId: string; reason: string }) => void | Promise<void>;
|
||||
};
|
||||
|
||||
export function AdminUserDetailPage({
|
||||
vm,
|
||||
actions,
|
||||
busy = false,
|
||||
errorKey,
|
||||
}: {
|
||||
vm: AdminUserDetailVM;
|
||||
actions: AdminUserDetailActions;
|
||||
busy?: boolean;
|
||||
errorKey?: string;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [selectedRoles, setSelectedRoles] = useState(() => vm.user.roles.map((role) => role.systemKey).filter((key): key is string => Boolean(key)));
|
||||
const [reason, setReason] = useState("");
|
||||
const formatDate = (value: string) =>
|
||||
new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
|
||||
|
||||
const toggleRole = (roleKey: string, checked: boolean) =>
|
||||
setSelectedRoles((current) => (checked ? [...new Set([...current, roleKey])] : current.filter((key) => key !== roleKey)));
|
||||
|
||||
return (
|
||||
<main data-ui-id="ui.admin.sales.security.adminUserDetailPage" className="flex w-full flex-col gap-6 px-6 py-6">
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<button type="button" onClick={actions.onBack}>
|
||||
{t("admin.sales.adminUsers.title")}
|
||||
</button>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>{vm.user.displayName}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<header className="flex flex-col gap-1">
|
||||
<div className="flex flex-wrap items-center gap-3">
|
||||
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{vm.user.displayName}</h1>
|
||||
<BadgeFeedback farbe={vm.user.status === "active" ? "subtle-positive" : "subtle-negative"}>
|
||||
{t(`admin.sales.security.status.${vm.user.status}`)}
|
||||
</BadgeFeedback>
|
||||
<BadgeFeedback farbe={vm.user.authentikConnected ? "subtle-positive" : "subtle-warning"}>
|
||||
{t(
|
||||
vm.user.authentikConnected
|
||||
? "admin.sales.adminUsers.activationConnected"
|
||||
: "admin.sales.adminUsers.activationPending"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
{vm.self ? <BadgeFeedback farbe="subtle-brand-primary">{t("admin.sales.adminUserDetail.self")}</BadgeFeedback> : null}
|
||||
</div>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">{vm.user.email}</p>
|
||||
</header>
|
||||
|
||||
{errorKey ? <Alert variant="error" role="alert" description={t(errorKey)} /> : null}
|
||||
{vm.self ? <Alert variant="warning" description={t("admin.sales.adminUserDetail.selfProtection")} /> : null}
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.adminUserDetail.rolesTitle")}</h2>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminUserDetail.rolesDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-2" aria-label={t("admin.sales.adminUserDetail.effectiveRoles")}>
|
||||
{vm.user.roles.map((role) => (
|
||||
<BadgeFeedback key={role.id} farbe="subtle-brand-primary">
|
||||
{role.systemKey ? t(`admin.sales.adminRoles.roleNames.${role.systemKey}`) : role.name}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-col gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.adminUserDetail.visibleAreas")}
|
||||
</span>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{vm.effectiveAreas.map((area) => (
|
||||
<BadgeFeedback key={area} farbe="subtle-neutral">
|
||||
{t(`admin.sales.adminRoles.permissionGroups.${area}.title`)}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid w-full grid-cols-1 gap-3 md:grid-cols-2">
|
||||
{vm.availableRoles
|
||||
.filter((role): role is typeof role & { systemKey: string } => Boolean(role.systemKey))
|
||||
.map((role) => (
|
||||
<Checkbox
|
||||
key={role.id}
|
||||
label={t(`admin.sales.adminRoles.roleNames.${role.systemKey}`)}
|
||||
checked={selectedRoles.includes(role.systemKey)}
|
||||
onCheckedChange={(checked) => toggleRole(role.systemKey, checked)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<TextArea showLabel label={t("admin.sales.adminUserDetail.reason")} helpText={t("admin.sales.adminUserDetail.reasonHelp")}>
|
||||
<TextArea.Input value={reason} onChange={(event) => setReason(event.target.value)} />
|
||||
</TextArea>
|
||||
<div className="flex flex-wrap gap-3">
|
||||
<Button
|
||||
loading={busy}
|
||||
disabled={reason.trim().length < 5 || selectedRoles.length === 0}
|
||||
onClick={() => void actions.onSaveRoles({ roleKeys: selectedRoles, reason })}
|
||||
>
|
||||
{t("admin.sales.adminUserDetail.saveRoles")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="destructive"
|
||||
loading={busy}
|
||||
disabled={vm.self || vm.user.status !== "active" || reason.trim().length < 5}
|
||||
onClick={() => void actions.onDisable(reason)}
|
||||
>
|
||||
{t("admin.sales.adminUserDetail.disable")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
<section className="flex flex-col gap-3">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.security.sessions")}</h2>
|
||||
{vm.sessions.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.security.emptySessionsTitle")} body={t("admin.sales.security.emptySessionsBody")} />
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.sales.security.session")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.security.lastSeen")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.security.expires")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.security.actions")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{vm.sessions.map((session) => (
|
||||
<Table.Row key={session.id}>
|
||||
<Table.Cell>{session.current ? t("admin.sales.security.currentSession") : session.approxLocation ?? t("admin.sales.security.unknown")}</Table.Cell>
|
||||
<Table.Cell>{formatDate(session.lastSeenAt)}</Table.Cell>
|
||||
<Table.Cell>{formatDate(session.expiresAt)}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
disabled={session.current || reason.trim().length < 5}
|
||||
onClick={() => void actions.onRevokeSession({ sessionId: session.id, reason })}
|
||||
>
|
||||
{t("admin.sales.security.revoke")}
|
||||
</Button>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-3">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.adminUserDetail.auditTitle")}</h2>
|
||||
{vm.audit.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.sales.adminUserDetail.auditEmptyTitle")} body={t("admin.sales.adminUserDetail.auditEmptyBody")} />
|
||||
) : (
|
||||
<div className="flex flex-col gap-3">
|
||||
{vm.audit.map((event) => (
|
||||
<Card key={event.id}>
|
||||
<div className="flex w-full flex-col gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{event.summary}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{formatDate(event.createdAt)}
|
||||
</span>
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+201
@@ -0,0 +1,201 @@
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherLockKeyhole, FeatherUserCheck, FeatherUsers } from "@subframe/core";
|
||||
|
||||
import type { AdminUserListVM } from "@hivegrid/view-models";
|
||||
|
||||
import { Alert, BadgeFeedback, Button, Card, Checkbox, EmptyState, StatsCard, Table, TextArea, TextInput } from "~/ui";
|
||||
|
||||
export type AdminUsersActions = {
|
||||
onOpenUser: (userId: string) => void;
|
||||
onCreateUser: (input: {
|
||||
email: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
roleKeys: string[];
|
||||
reason: string;
|
||||
}) => void | Promise<void>;
|
||||
};
|
||||
|
||||
export function AdminUsersPage({
|
||||
vm,
|
||||
actions,
|
||||
busy = false,
|
||||
errorKey,
|
||||
}: {
|
||||
vm: AdminUserListVM;
|
||||
actions: AdminUsersActions;
|
||||
busy?: boolean;
|
||||
errorKey?: string;
|
||||
}) {
|
||||
const { t, i18n } = useTranslation();
|
||||
const [email, setEmail] = useState("");
|
||||
const [firstName, setFirstName] = useState("");
|
||||
const [lastName, setLastName] = useState("");
|
||||
const [reason, setReason] = useState("");
|
||||
const [selectedRoles, setSelectedRoles] = useState<string[]>(() => {
|
||||
const viewer = vm.availableRoles.find((role) => role.systemKey === "viewer");
|
||||
return viewer?.systemKey ? [viewer.systemKey] : [];
|
||||
});
|
||||
const formatDate = (value: string) =>
|
||||
new Intl.DateTimeFormat(i18n.language, { dateStyle: "medium", timeStyle: "short" }).format(new Date(value));
|
||||
const toggleRole = (roleKey: string, checked: boolean) =>
|
||||
setSelectedRoles((current) =>
|
||||
checked ? [...new Set([...current, roleKey])] : current.filter((key) => key !== roleKey)
|
||||
);
|
||||
|
||||
return (
|
||||
<main data-ui-id="ui.admin.sales.security.adminUsersPage" className="flex w-full flex-col gap-6 px-6 py-6">
|
||||
<header className="flex flex-col gap-1">
|
||||
<h1 className="text-heading-2 font-heading-2 text-text-neutral-primary">{t("admin.sales.adminUsers.title")}</h1>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminUsers.description")}
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<section className="grid grid-cols-1 gap-4 md:grid-cols-3">
|
||||
<StatsCard
|
||||
label={t("admin.sales.adminUsers.total")}
|
||||
value={String(vm.summary.total)}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherUsers />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.adminUsers.active")}
|
||||
value={String(vm.summary.active)}
|
||||
trend="positive"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherUserCheck />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.adminUsers.locked")}
|
||||
value={String(vm.summary.locked)}
|
||||
trend={vm.summary.locked > 0 ? "negative" : "neutral"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherLockKeyhole />}
|
||||
/>
|
||||
</section>
|
||||
|
||||
{errorKey ? <Alert variant="error" role="alert" description={t(errorKey)} /> : null}
|
||||
|
||||
<Card>
|
||||
<div className="flex flex-col gap-1">
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">{t("admin.sales.adminUsers.prepareTitle")}</h2>
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{t("admin.sales.adminUsers.prepareDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<div className="grid w-full grid-cols-1 gap-4 lg:grid-cols-3">
|
||||
<TextInput label={t("admin.sales.adminUsers.firstName")} showLabel>
|
||||
<TextInput.Input value={firstName} onChange={(event) => setFirstName(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.adminUsers.lastName")} showLabel>
|
||||
<TextInput.Input value={lastName} onChange={(event) => setLastName(event.target.value)} />
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.adminUsers.email")} showLabel>
|
||||
<TextInput.Input type="email" value={email} onChange={(event) => setEmail(event.target.value)} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<fieldset className="grid w-full grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<legend className="mb-3 text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.adminUsers.roles")}
|
||||
</legend>
|
||||
{vm.availableRoles
|
||||
.filter((role): role is typeof role & { systemKey: string } => Boolean(role.systemKey))
|
||||
.map((role) => (
|
||||
<Checkbox
|
||||
key={role.id}
|
||||
label={t(`admin.sales.adminRoles.roleNames.${role.systemKey}`)}
|
||||
checked={selectedRoles.includes(role.systemKey)}
|
||||
onCheckedChange={(checked) => toggleRole(role.systemKey, checked)}
|
||||
/>
|
||||
))}
|
||||
</fieldset>
|
||||
<TextArea showLabel label={t("admin.sales.adminUserDetail.reason")}>
|
||||
<TextArea.Input value={reason} onChange={(event) => setReason(event.target.value)} />
|
||||
</TextArea>
|
||||
<Button
|
||||
loading={busy}
|
||||
disabled={
|
||||
!email.includes("@") ||
|
||||
firstName.trim().length === 0 ||
|
||||
selectedRoles.length === 0 ||
|
||||
reason.trim().length < 5
|
||||
}
|
||||
onClick={() =>
|
||||
void actions.onCreateUser({ email, firstName, lastName, roleKeys: selectedRoles, reason })
|
||||
}
|
||||
>
|
||||
{t("admin.sales.adminUsers.prepareAction")}
|
||||
</Button>
|
||||
</Card>
|
||||
|
||||
{vm.users.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.adminUsers.emptyTitle")}
|
||||
body={t("admin.sales.adminUsers.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="w-full overflow-x-auto">
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.sales.adminUsers.person")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.adminUsers.roles")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.adminUsers.lastActive")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.adminUsers.statusLabel")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.adminUsers.activationLabel")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.sales.adminUsers.actions")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{vm.users.map((user) => (
|
||||
<Table.Row key={user.id}>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{user.displayName}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{user.email}</span>
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-wrap gap-2">
|
||||
{user.roles.map((role) => (
|
||||
<BadgeFeedback key={role.id} farbe="subtle-brand-primary">
|
||||
{role.systemKey ? t(`admin.sales.adminRoles.roleNames.${role.systemKey}`) : role.name}
|
||||
</BadgeFeedback>
|
||||
))}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>{user.lastActiveAt ? formatDate(user.lastActiveAt) : t("admin.sales.security.never")}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={user.status === "active" ? "subtle-positive" : "subtle-negative"}>
|
||||
{t(`admin.sales.security.status.${user.status}`)}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={user.authentikConnected ? "subtle-positive" : "subtle-warning"}>
|
||||
{t(
|
||||
user.authentikConnected
|
||||
? "admin.sales.adminUsers.activationConnected"
|
||||
: "admin.sales.adminUsers.activationPending"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<Button variant="tertiary" size="small" onClick={() => actions.onOpenUser(user.id)}>
|
||||
{t("admin.sales.adminUsers.open")}
|
||||
</Button>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
</div>
|
||||
)}
|
||||
</main>
|
||||
);
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { ADMIN_PERMISSIONS } from "@hivegrid/db/admin-permissions";
|
||||
import {
|
||||
adminPermissionGroupKey,
|
||||
adminPermissionPresentation,
|
||||
} from "@hivegrid/view-models";
|
||||
|
||||
import deTranslations from "../../../../../../public/locales/de/translations.json";
|
||||
import enTranslations from "../../../../../../public/locales/en/translations.json";
|
||||
|
||||
function lookup(root: unknown, path: string): unknown {
|
||||
return path.split(".").reduce<unknown>((value, segment) => {
|
||||
if (!value || typeof value !== "object" || !(segment in value)) return undefined;
|
||||
return (value as Record<string, unknown>)[segment];
|
||||
}, root);
|
||||
}
|
||||
|
||||
describe("admin role editor translations", () => {
|
||||
it("provides understandable resource, action, and group labels for the full permission catalog", () => {
|
||||
for (const locale of [deTranslations, enTranslations]) {
|
||||
for (const name of ADMIN_PERMISSIONS) {
|
||||
const permission = adminPermissionPresentation({ name, description: name });
|
||||
const group = adminPermissionGroupKey(name);
|
||||
expect(
|
||||
lookup(locale, `admin.sales.adminRoles.permissionResources.${permission.resource}`),
|
||||
`${name} resource`
|
||||
).toEqual(expect.any(String));
|
||||
expect(
|
||||
lookup(locale, `admin.sales.adminRoles.permissionActions.${permission.action}`),
|
||||
`${name} action`
|
||||
).toEqual(expect.any(String));
|
||||
expect(
|
||||
lookup(locale, `admin.sales.adminRoles.permissionGroups.${group}.title`),
|
||||
`${name} group`
|
||||
).toEqual(expect.any(String));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
+121
@@ -0,0 +1,121 @@
|
||||
import { createInstance } from "i18next";
|
||||
import { I18nextProvider, initReactI18next } from "react-i18next";
|
||||
|
||||
import { buildAdminRoleEditorVM, buildAdminUserListVM } from "@hivegrid/view-models";
|
||||
|
||||
import deTranslations from "../../../../../../public/locales/de/translations.json";
|
||||
|
||||
import { AdminUsersPage } from "./AdminUsersPage";
|
||||
import { AdminRolesPage } from "./AdminRolesPage";
|
||||
|
||||
const visualI18n = createInstance();
|
||||
void visualI18n.use(initReactI18next).init({
|
||||
lng: "de",
|
||||
fallbackLng: "de",
|
||||
defaultNS: "translation",
|
||||
resources: { de: { translation: deTranslations } },
|
||||
interpolation: { escapeValue: false },
|
||||
initImmediate: false,
|
||||
});
|
||||
|
||||
export function createAdminSecurityInterimVisualVM() {
|
||||
return buildAdminUserListVM(
|
||||
[
|
||||
{
|
||||
id: "admin_visual_raffael",
|
||||
email: "raffael@hivegrid.de",
|
||||
firstName: "Raffael",
|
||||
lastName: "Sheikh",
|
||||
status: "active",
|
||||
authentikSubject: "authentik-raffael",
|
||||
lastSsoLoginAt: new Date("2026-07-24T08:15:00.000Z"),
|
||||
roles: [{ role: { id: "role_super_admin", name: "Super Admin", systemKey: "super_admin" } }],
|
||||
sessions: [{ lastSeenAt: new Date("2026-07-24T08:30:00.000Z") }],
|
||||
},
|
||||
{
|
||||
id: "admin_visual_haris",
|
||||
email: "haris@hivegrid.de",
|
||||
firstName: "Haris",
|
||||
lastName: "Vertrieb",
|
||||
status: "active",
|
||||
authentikSubject: "authentik-haris",
|
||||
lastSsoLoginAt: new Date("2026-07-23T13:10:00.000Z"),
|
||||
roles: [{ role: { id: "role_sales", name: "Sales", systemKey: "sales" } }],
|
||||
sessions: [{ lastSeenAt: new Date("2026-07-24T07:45:00.000Z") }],
|
||||
},
|
||||
{
|
||||
id: "admin_visual_locked",
|
||||
email: "locked@example.test",
|
||||
firstName: "Gesperrte",
|
||||
lastName: "Person",
|
||||
status: "locked",
|
||||
authentikSubject: null,
|
||||
lastSsoLoginAt: null,
|
||||
roles: [{ role: { id: "role_viewer", name: "Viewer", systemKey: "viewer" } }],
|
||||
sessions: [],
|
||||
},
|
||||
],
|
||||
[
|
||||
{ id: "role_super_admin", name: "Super Admin", systemKey: "super_admin" },
|
||||
{ id: "role_sales", name: "Sales", systemKey: "sales" },
|
||||
{ id: "role_sales_manager", name: "Sales Manager", systemKey: "sales_manager" },
|
||||
{ id: "role_support", name: "Support", systemKey: "support" },
|
||||
{ id: "role_engineering", name: "Engineering", systemKey: "engineering" },
|
||||
{ id: "role_executive", name: "Executive", systemKey: "executive" },
|
||||
{ id: "role_viewer", name: "Viewer", systemKey: "viewer" },
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
const representativePermissions = [
|
||||
"admin.dashboard.view",
|
||||
"admin_identity.users.manage",
|
||||
"admin.accounts.view",
|
||||
"admin_sales.crm.read_all",
|
||||
"admin_sales.communication.read_all",
|
||||
"admin.featureFlags.manage",
|
||||
"admin.pricing.view",
|
||||
"admin.marketing.leads.view",
|
||||
];
|
||||
|
||||
export function createAdminRolesInterimVisualVM() {
|
||||
return buildAdminRoleEditorVM({
|
||||
roles: [
|
||||
{
|
||||
id: "role_sales_manager",
|
||||
name: "Sales Manager",
|
||||
description: "Sales Manager",
|
||||
systemKey: "sales_manager",
|
||||
isSystem: true,
|
||||
permissions: representativePermissions.map((name) => ({ permission: { name } })),
|
||||
_count: { users: 3 },
|
||||
},
|
||||
],
|
||||
permissions: representativePermissions.map((name) => ({ name, description: name })),
|
||||
});
|
||||
}
|
||||
|
||||
const noOp = (): void => undefined;
|
||||
|
||||
/** Shared AD-28 fixture for the VR-P28a Chromium baseline. */
|
||||
export function AdminSecurityInterimVisualFixture(): React.JSX.Element {
|
||||
return (
|
||||
<I18nextProvider i18n={visualI18n}>
|
||||
<AdminUsersPage
|
||||
vm={createAdminSecurityInterimVisualVM()}
|
||||
actions={{ onOpenUser: noOp, onCreateUser: noOp }}
|
||||
/>
|
||||
</I18nextProvider>
|
||||
);
|
||||
}
|
||||
|
||||
export function AdminRolesInterimVisualFixture(): React.JSX.Element {
|
||||
return (
|
||||
<I18nextProvider i18n={visualI18n}>
|
||||
<AdminRolesPage
|
||||
vm={createAdminRolesInterimVisualVM()}
|
||||
actions={{ onSaveRole: noOp }}
|
||||
/>
|
||||
</I18nextProvider>
|
||||
);
|
||||
}
|
||||
+332
@@ -0,0 +1,332 @@
|
||||
import type { AdminSalesContactDetailVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherBriefcase,
|
||||
FeatherBuilding2,
|
||||
FeatherCalendarPlus,
|
||||
FeatherClock,
|
||||
FeatherMail,
|
||||
FeatherPhone,
|
||||
FeatherUser,
|
||||
} from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBackLink,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
|
||||
import {
|
||||
AdminSalesTaskCreateDialog,
|
||||
type AdminSalesTaskCreateInput,
|
||||
} from "./AdminSalesTaskCreateDialog";
|
||||
import { AdminSalesTaskList } from "./AdminSalesTaskList";
|
||||
|
||||
export function AdminSalesContactDetailPage(props: {
|
||||
readonly vm: AdminSalesContactDetailVM;
|
||||
readonly currentAdminUserId: string;
|
||||
readonly backHref: string;
|
||||
readonly emailComposeHref?: string | null;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onCreateTask: (input: AdminSalesTaskCreateInput) => void;
|
||||
readonly onAddNote: (body: string) => void;
|
||||
readonly onCompleteTask: (taskId: string) => void;
|
||||
readonly onCall: () => void;
|
||||
};
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [createTaskOpen, setCreateTaskOpen] = useState(false);
|
||||
const [note, setNote] = useState("");
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.contacts.detail">
|
||||
<PageHeader
|
||||
icon={<FeatherUser className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={props.vm.name}
|
||||
subtitle={
|
||||
[props.vm.jobTitle, props.vm.company?.name].filter(Boolean).join(" · ") ||
|
||||
t("admin.sales.contacts.detail.subtitle")
|
||||
}
|
||||
actions={
|
||||
props.vm.canWrite ? (
|
||||
<div className="flex items-center gap-2">
|
||||
{props.emailComposeHref ? (
|
||||
<Link
|
||||
to={props.emailComposeHref}
|
||||
className="contents no-underline"
|
||||
>
|
||||
<Button variant="secondary" icon={<FeatherMail />}>
|
||||
{t("admin.sales.email.actions.compose")}
|
||||
</Button>
|
||||
</Link>
|
||||
) : null}
|
||||
{props.vm.phone ? (
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={<FeatherPhone />}
|
||||
loading={props.submitting}
|
||||
onClick={props.actions.onCall}
|
||||
>
|
||||
{t("admin.sales.telephony.outbound.call")}
|
||||
</Button>
|
||||
) : null}
|
||||
<Button
|
||||
icon={<FeatherCalendarPlus />}
|
||||
onClick={() => setCreateTaskOpen(true)}
|
||||
>
|
||||
{t("admin.sales.tasks.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.backHref}>{t("admin.sales.contacts.title")}</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>{props.vm.name}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<PageBackLink
|
||||
to={props.backHref}
|
||||
label={t("admin.sales.contacts.actions.back")}
|
||||
/>
|
||||
{props.errorMessage ? (
|
||||
<div className="rounded-md bg-surface-feedback-subtle-negative px-4 py-3 text-text-feedback-negative">
|
||||
{props.errorMessage}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="grid w-full grid-cols-3 gap-4 tablet:grid-cols-1">
|
||||
<ContactFact
|
||||
icon={<FeatherMail />}
|
||||
label={t("admin.sales.contacts.fields.email")}
|
||||
value={props.vm.email ?? t("shared.notSet")}
|
||||
/>
|
||||
<ContactFact
|
||||
icon={<FeatherPhone />}
|
||||
label={t("admin.sales.contacts.fields.phone")}
|
||||
value={props.vm.phone ?? t("shared.notSet")}
|
||||
/>
|
||||
<ContactFact
|
||||
icon={<FeatherBuilding2 />}
|
||||
label={t("admin.sales.contacts.fields.company")}
|
||||
value={props.vm.company?.name ?? t("shared.notSet")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full grid-cols-2 gap-6 tablet:grid-cols-1">
|
||||
<section className="flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("admin.sales.contacts.deals.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.contacts.deals.description")}
|
||||
</p>
|
||||
</div>
|
||||
{props.vm.deals.length === 0 ? (
|
||||
<EmptyState
|
||||
title={t("admin.sales.contacts.deals.empty")}
|
||||
body={t("admin.sales.contacts.deals.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex flex-col gap-2">
|
||||
{props.vm.deals.map((deal) => (
|
||||
<Link
|
||||
key={deal.id}
|
||||
to={deal.href}
|
||||
className="flex items-center justify-between gap-3 rounded-md bg-surface-neutral-primary px-4 py-3 hover:bg-surface-neutral-tertiary"
|
||||
>
|
||||
<span className="flex min-w-0 items-center gap-2">
|
||||
<FeatherBriefcase className="text-icon-neutral-tertiary" />
|
||||
<span className="flex min-w-0 flex-col">
|
||||
<span className="truncate text-body-small-medium-0 text-text-neutral-primary">
|
||||
{deal.title}
|
||||
</span>
|
||||
<span className="text-body-extra-small-regular-0 text-text-neutral-tertiary">
|
||||
{deal.stageName}
|
||||
{deal.role ? ` · ${deal.role}` : ""}
|
||||
</span>
|
||||
</span>
|
||||
</span>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
deal.isPrimary ? "subtle-positive" : "subtle-neutral"
|
||||
}
|
||||
size="small"
|
||||
>
|
||||
{deal.isPrimary
|
||||
? t("admin.sales.contacts.deals.primary")
|
||||
: t(deal.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="flex flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("admin.sales.tasks.contact.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.tasks.contact.description")}
|
||||
</p>
|
||||
</div>
|
||||
{props.vm.canWrite ? (
|
||||
<Button
|
||||
variant="tertiary"
|
||||
size="small"
|
||||
icon={<FeatherCalendarPlus />}
|
||||
onClick={() => setCreateTaskOpen(true)}
|
||||
>
|
||||
{t("admin.sales.tasks.actions.create")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
<AdminSalesTaskList
|
||||
tasks={props.vm.tasks}
|
||||
emptyTitleKey="admin.sales.tasks.empty.contact"
|
||||
emptyBodyKey="admin.sales.tasks.empty.contactBody"
|
||||
submitting={props.submitting}
|
||||
onComplete={props.actions.onCompleteTask}
|
||||
/>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<section className="flex w-full flex-col gap-4 rounded-lg border border-border-default bg-surface-neutral-secondary p-5">
|
||||
<div>
|
||||
<h2 className="text-heading- font-heading- text-text-neutral-primary">
|
||||
{t("admin.sales.contacts.timeline.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.contacts.timeline.description")}
|
||||
</p>
|
||||
</div>
|
||||
{props.vm.canWrite ? (
|
||||
<div className="grid w-full grid-cols-[1fr_auto] items-end gap-3 mobile:grid-cols-1">
|
||||
<TextArea
|
||||
label={t("admin.sales.data.notes.label")}
|
||||
showLabel
|
||||
>
|
||||
<TextArea.Input
|
||||
value={note}
|
||||
maxLength={10_000}
|
||||
onChange={(event) => setNote(event.target.value)}
|
||||
placeholder={t("admin.sales.data.notes.placeholder")}
|
||||
/>
|
||||
</TextArea>
|
||||
<Button
|
||||
variant="neutral"
|
||||
disabled={!note.trim()}
|
||||
loading={props.submitting}
|
||||
onClick={() => {
|
||||
props.actions.onAddNote(note.trim());
|
||||
setNote("");
|
||||
}}
|
||||
>
|
||||
{t("admin.sales.data.notes.add")}
|
||||
</Button>
|
||||
</div>
|
||||
) : null}
|
||||
{props.vm.activities.length === 0 ? (
|
||||
<EmptyState
|
||||
title={t("admin.sales.contacts.timeline.empty")}
|
||||
body={t("admin.sales.contacts.timeline.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<ol className="flex flex-col">
|
||||
{props.vm.activities.map((activity) => (
|
||||
<li
|
||||
key={activity.id}
|
||||
className="relative flex gap-3 border-l border-border-default pb-5 pl-5 last:border-transparent last:pb-0"
|
||||
>
|
||||
<span className="absolute -left-1.5 top-1 h-3 w-3 rounded-full border-2 border-border-brand bg-surface-neutral-secondary" />
|
||||
<div className="flex min-w-0 flex-col gap-1">
|
||||
<span className="text-body-small-medium-0 text-text-neutral-primary">
|
||||
{activity.summary}
|
||||
</span>
|
||||
<span className="inline-flex flex-wrap items-center gap-2 text-body-extra-small-regular-0 text-text-neutral-tertiary">
|
||||
<span>{t(activity.typeLabelKey)}</span>
|
||||
<span aria-hidden>·</span>
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<FeatherClock />
|
||||
{activity.occurredAtLabel}
|
||||
</span>
|
||||
{activity.dealHref ? (
|
||||
<Link
|
||||
to={activity.dealHref}
|
||||
className="text-text-brand hover:underline"
|
||||
>
|
||||
{t("admin.sales.contacts.timeline.openDeal")}
|
||||
</Link>
|
||||
) : null}
|
||||
{activity.recordingHref ? (
|
||||
<a
|
||||
href={activity.recordingHref}
|
||||
className="text-text-brand hover:underline"
|
||||
>
|
||||
{t("admin.sales.telephony.recording.play")}
|
||||
</a>
|
||||
) : null}
|
||||
</span>
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ol>
|
||||
)}
|
||||
</section>
|
||||
</PageBody>
|
||||
|
||||
<AdminSalesTaskCreateDialog
|
||||
open={createTaskOpen}
|
||||
onOpenChange={setCreateTaskOpen}
|
||||
contactId={props.vm.id}
|
||||
dealId={null}
|
||||
assignedToAdminUserId={
|
||||
props.vm.ownerAdminUserId ?? props.currentAdminUserId
|
||||
}
|
||||
timeZone={props.vm.timeZone}
|
||||
submitting={props.submitting}
|
||||
onCreate={props.actions.onCreateTask}
|
||||
/>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function ContactFact(props: {
|
||||
readonly icon: React.ReactNode;
|
||||
readonly label: string;
|
||||
readonly value: string;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<div className="flex items-start justify-between gap-3 rounded-lg border border-border-default bg-surface-neutral-secondary p-4">
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
<span className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{props.label}
|
||||
</span>
|
||||
<span className="truncate text-body-default-medium-0 text-text-neutral-primary">
|
||||
{props.value}
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-heading- text-icon-neutral-tertiary">
|
||||
{props.icon}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+227
@@ -0,0 +1,227 @@
|
||||
import {
|
||||
FeatherCalendarPlus,
|
||||
FeatherRepeat,
|
||||
} from "@subframe/core";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
export type AdminSalesTaskCreateInput = {
|
||||
readonly title: string;
|
||||
readonly description: string | null;
|
||||
readonly contactId: string | null;
|
||||
readonly dealId: string | null;
|
||||
readonly assignedToAdminUserId: string;
|
||||
readonly dueAt: string;
|
||||
readonly timeZone: string;
|
||||
readonly reminderAt: string | null;
|
||||
readonly priority: "low" | "normal" | "high" | "urgent";
|
||||
readonly recurrenceFrequency: "daily" | "weekly" | "monthly" | null;
|
||||
readonly recurrenceInterval: number;
|
||||
readonly recurrenceEndsAt: string | null;
|
||||
readonly reason: string;
|
||||
};
|
||||
|
||||
export function AdminSalesTaskCreateDialog(props: {
|
||||
readonly open: boolean;
|
||||
readonly onOpenChange: (open: boolean) => void;
|
||||
readonly contactId: string | null;
|
||||
readonly dealId: string | null;
|
||||
readonly assignedToAdminUserId: string;
|
||||
readonly timeZone: string;
|
||||
readonly submitting: boolean;
|
||||
readonly onCreate: (input: AdminSalesTaskCreateInput) => void;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [title, setTitle] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
const [dueAt, setDueAt] = useState(defaultLocalDueAt());
|
||||
const [reminderAt, setReminderAt] = useState("");
|
||||
const [priority, setPriority] =
|
||||
useState<AdminSalesTaskCreateInput["priority"]>("normal");
|
||||
const [recurrence, setRecurrence] = useState<
|
||||
"none" | "daily" | "weekly" | "monthly"
|
||||
>("none");
|
||||
const [recurrenceInterval, setRecurrenceInterval] = useState("1");
|
||||
const [recurrenceEndsAt, setRecurrenceEndsAt] = useState("");
|
||||
const valid =
|
||||
Boolean(title.trim() && dueAt) &&
|
||||
Boolean(props.contactId || props.dealId) &&
|
||||
(!reminderAt || new Date(reminderAt) < new Date(dueAt));
|
||||
|
||||
function close() {
|
||||
props.onOpenChange(false);
|
||||
}
|
||||
|
||||
function submit() {
|
||||
if (!valid) return;
|
||||
props.onCreate({
|
||||
title: title.trim(),
|
||||
description: description.trim() || null,
|
||||
contactId: props.contactId,
|
||||
dealId: props.dealId,
|
||||
assignedToAdminUserId: props.assignedToAdminUserId,
|
||||
dueAt: new Date(dueAt).toISOString(),
|
||||
timeZone: props.timeZone,
|
||||
reminderAt: reminderAt ? new Date(reminderAt).toISOString() : null,
|
||||
priority,
|
||||
recurrenceFrequency: recurrence === "none" ? null : recurrence,
|
||||
recurrenceInterval: Math.max(1, Number(recurrenceInterval) || 1),
|
||||
recurrenceEndsAt: recurrenceEndsAt
|
||||
? new Date(`${recurrenceEndsAt}T23:59:59`).toISOString()
|
||||
: null,
|
||||
reason: t("admin.sales.tasks.audit.created"),
|
||||
});
|
||||
setTitle("");
|
||||
setDescription("");
|
||||
close();
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={props.open} onOpenChange={props.onOpenChange}>
|
||||
<Dialog.Content
|
||||
className="w-[620px] max-w-[92vw] p-6"
|
||||
data-ui-id="ui.admin.sales.tasks.createDialog"
|
||||
>
|
||||
<div className="flex max-h-[82vh] flex-col gap-5 overflow-y-auto">
|
||||
<div className="flex items-start gap-3">
|
||||
<FeatherCalendarPlus className="text-heading-2 text-icon-brand" />
|
||||
<div>
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.tasks.create.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.tasks.create.subtitle")}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<TextInput label={t("admin.sales.tasks.fields.title")} showLabel>
|
||||
<TextInput.Input
|
||||
value={title}
|
||||
onChange={(event) => setTitle(event.target.value)}
|
||||
maxLength={240}
|
||||
autoFocus
|
||||
/>
|
||||
</TextInput>
|
||||
<TextArea label={t("admin.sales.tasks.fields.description")} showLabel>
|
||||
<TextArea.Input
|
||||
value={description}
|
||||
onChange={(event) => setDescription(event.target.value)}
|
||||
maxLength={4_000}
|
||||
/>
|
||||
</TextArea>
|
||||
<div className="grid grid-cols-2 gap-4 mobile:grid-cols-1">
|
||||
<TextInput label={t("admin.sales.tasks.fields.dueAt")} showLabel>
|
||||
<TextInput.Input
|
||||
type="datetime-local"
|
||||
value={dueAt}
|
||||
onChange={(event) => setDueAt(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput label={t("admin.sales.tasks.fields.reminderAt")} showLabel>
|
||||
<TextInput.Input
|
||||
type="datetime-local"
|
||||
value={reminderAt}
|
||||
onChange={(event) => setReminderAt(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<Select
|
||||
label={t("admin.sales.tasks.fields.priority")}
|
||||
showLabel
|
||||
value={priority}
|
||||
onValueChange={(value) =>
|
||||
setPriority(value as AdminSalesTaskCreateInput["priority"])
|
||||
}
|
||||
>
|
||||
{(["low", "normal", "high", "urgent"] as const).map((value) => (
|
||||
<Select.Item key={value} value={value}>
|
||||
{t(`admin.sales.tasks.priority.${value}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<div className="rounded-lg border border-border-default bg-surface-neutral-secondary p-4">
|
||||
<div className="mb-4 flex items-center gap-2">
|
||||
<FeatherRepeat className="text-body text-icon-neutral-secondary" />
|
||||
<span className="text-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.tasks.recurrence.title")}
|
||||
</span>
|
||||
</div>
|
||||
<div className="grid grid-cols-3 gap-4 tablet:grid-cols-1">
|
||||
<Select
|
||||
label={t("admin.sales.tasks.fields.recurrence")}
|
||||
showLabel
|
||||
value={recurrence}
|
||||
onValueChange={(value) =>
|
||||
setRecurrence(value as typeof recurrence)
|
||||
}
|
||||
>
|
||||
<Select.Item value="none">
|
||||
{t("admin.sales.tasks.recurrence.none")}
|
||||
</Select.Item>
|
||||
{(["daily", "weekly", "monthly"] as const).map((value) => (
|
||||
<Select.Item key={value} value={value}>
|
||||
{t(`admin.sales.tasks.recurrence.${value}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput
|
||||
label={t("admin.sales.tasks.fields.recurrenceInterval")}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
type="number"
|
||||
min="1"
|
||||
max="365"
|
||||
disabled={recurrence === "none"}
|
||||
value={recurrenceInterval}
|
||||
onChange={(event) => setRecurrenceInterval(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
label={t("admin.sales.tasks.fields.recurrenceEndsAt")}
|
||||
showLabel
|
||||
>
|
||||
<TextInput.Input
|
||||
type="date"
|
||||
disabled={recurrence === "none"}
|
||||
value={recurrenceEndsAt}
|
||||
onChange={(event) => setRecurrenceEndsAt(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
</div>
|
||||
{reminderAt && new Date(reminderAt) >= new Date(dueAt) ? (
|
||||
<p className="text-body-small-regular-0 text-text-feedback-negative">
|
||||
{t("admin.sales.tasks.errors.reminderBeforeDue")}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="flex justify-end gap-2">
|
||||
<Button variant="neutral" onClick={close}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
disabled={!valid || props.submitting}
|
||||
loading={props.submitting}
|
||||
onClick={submit}
|
||||
>
|
||||
{t("admin.sales.tasks.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
|
||||
function defaultLocalDueAt(): string {
|
||||
const value = new Date(Date.now() + 24 * 60 * 60 * 1_000);
|
||||
value.setMinutes(0, 0, 0);
|
||||
const local = new Date(value.getTime() - value.getTimezoneOffset() * 60_000);
|
||||
return local.toISOString().slice(0, 16);
|
||||
}
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
import type { AdminSalesTaskVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherBriefcase,
|
||||
FeatherCalendar,
|
||||
FeatherCheck,
|
||||
FeatherClock,
|
||||
FeatherRepeat,
|
||||
FeatherUser,
|
||||
} from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
|
||||
export function AdminSalesTaskList(props: {
|
||||
readonly tasks: readonly AdminSalesTaskVM[];
|
||||
readonly emptyTitleKey: string;
|
||||
readonly emptyBodyKey?: string;
|
||||
readonly submitting: boolean;
|
||||
readonly onComplete: (taskId: string) => void;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
if (props.tasks.length === 0) {
|
||||
const emptyProps = props.emptyBodyKey
|
||||
? { body: t(props.emptyBodyKey) }
|
||||
: {};
|
||||
return (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t(props.emptyTitleKey)}
|
||||
{...emptyProps}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="flex flex-col gap-3">
|
||||
{props.tasks.map((task) => (
|
||||
<article
|
||||
key={task.id}
|
||||
className="flex items-start justify-between gap-4 rounded-lg border border-border-default bg-surface-neutral-primary p-4 mobile:flex-col"
|
||||
data-task-id={task.id}
|
||||
>
|
||||
<div className="flex min-w-0 flex-1 flex-col gap-3">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h3 className="text-body-default-medium-0 text-text-neutral-primary">
|
||||
{task.title}
|
||||
</h3>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
task.priority === "urgent"
|
||||
? "subtle-negative"
|
||||
: task.priority === "high"
|
||||
? "subtle-warning"
|
||||
: "subtle-neutral"
|
||||
}
|
||||
size="small"
|
||||
>
|
||||
{t(task.priorityLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{task.recurrenceLabelKey ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
<span className="inline-flex items-center gap-1">
|
||||
<FeatherRepeat />
|
||||
{t(task.recurrenceLabelKey)}
|
||||
</span>
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
{task.description ? (
|
||||
<p className="text-body-small-regular-0 text-text-neutral-secondary">
|
||||
{task.description}
|
||||
</p>
|
||||
) : null}
|
||||
<div className="flex flex-wrap gap-x-4 gap-y-2 text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
<span
|
||||
className={`inline-flex items-center gap-1 ${task.isOverdue ? "text-text-feedback-negative" : ""}`}
|
||||
>
|
||||
{task.isOverdue ? <FeatherClock /> : <FeatherCalendar />}
|
||||
{task.dueAtLabel}
|
||||
</span>
|
||||
{task.contactHref && task.contactName ? (
|
||||
<Link
|
||||
className="inline-flex items-center gap-1 text-text-brand hover:underline"
|
||||
to={task.contactHref}
|
||||
>
|
||||
<FeatherUser />
|
||||
{task.contactName}
|
||||
</Link>
|
||||
) : null}
|
||||
{task.dealHref && task.dealTitle ? (
|
||||
<Link
|
||||
className="inline-flex items-center gap-1 text-text-brand hover:underline"
|
||||
to={task.dealHref}
|
||||
>
|
||||
<FeatherBriefcase />
|
||||
{task.dealTitle}
|
||||
</Link>
|
||||
) : null}
|
||||
<span>{t(task.sourceLabelKey)}</span>
|
||||
</div>
|
||||
</div>
|
||||
{task.canComplete ? (
|
||||
<Button
|
||||
variant="neutral"
|
||||
size="small"
|
||||
icon={<FeatherCheck />}
|
||||
disabled={props.submitting}
|
||||
onClick={() => props.onComplete(task.id)}
|
||||
>
|
||||
{t("admin.sales.tasks.actions.complete")}
|
||||
</Button>
|
||||
) : (
|
||||
<BadgeFeedback farbe="subtle-positive">
|
||||
{t(task.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
)}
|
||||
</article>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
import type { AdminSalesTodayVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherAlertTriangle,
|
||||
FeatherCalendarCheck,
|
||||
FeatherClock,
|
||||
FeatherListChecks,
|
||||
} from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
|
||||
import { AdminSalesTaskList } from "./AdminSalesTaskList";
|
||||
|
||||
export function AdminSalesTodayPage(props: {
|
||||
readonly vm: AdminSalesTodayVM;
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onComplete: (taskId: string) => void;
|
||||
};
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.tasks.today">
|
||||
<PageHeader
|
||||
icon={<FeatherListChecks className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t(props.vm.titleKey)}
|
||||
subtitle={t(props.vm.subtitleKey, { timeZone: props.vm.timeZone })}
|
||||
/>
|
||||
<PageBody>
|
||||
{props.errorMessage ? (
|
||||
<div className="rounded-md bg-surface-feedback-subtle-negative px-4 py-3 text-text-feedback-negative">
|
||||
{props.errorMessage}
|
||||
</div>
|
||||
) : null}
|
||||
<div className="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<StatsCard
|
||||
label={t("admin.sales.tasks.metrics.open")}
|
||||
value={props.vm.summary.openCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherListChecks />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.tasks.metrics.overdue")}
|
||||
value={props.vm.summary.overdueCount}
|
||||
trend={props.vm.summary.overdueCount ? "negative" : "positive"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherAlertTriangle />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.tasks.metrics.today")}
|
||||
value={props.vm.summary.dueTodayCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherCalendarCheck />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.tasks.metrics.priority")}
|
||||
value={props.vm.summary.urgentCount}
|
||||
trend={props.vm.summary.urgentCount ? "negative" : "neutral"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherClock />}
|
||||
/>
|
||||
</div>
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.tasks.sections.overdue")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.tasks.sections.overdueDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<AdminSalesTaskList
|
||||
tasks={props.vm.overdue}
|
||||
emptyTitleKey="admin.sales.tasks.empty.overdue"
|
||||
submitting={props.submitting}
|
||||
onComplete={props.actions.onComplete}
|
||||
/>
|
||||
</section>
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.tasks.sections.today")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.tasks.sections.todayDescription")}
|
||||
</p>
|
||||
</div>
|
||||
<AdminSalesTaskList
|
||||
tasks={props.vm.dueToday}
|
||||
emptyTitleKey="admin.sales.tasks.empty.today"
|
||||
emptyBodyKey="admin.sales.tasks.empty.todayBody"
|
||||
submitting={props.submitting}
|
||||
onComplete={props.actions.onComplete}
|
||||
/>
|
||||
</section>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28b task and timeline interim visual baseline > renders linked deals, contextual tasks, and the chronological contact timeline 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.contacts.detail"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">Ada Lovelace</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">CTO · Analytical Engines</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><div class="flex items-center gap-2"><a class="contents no-underline" href="/sales/email/scheduled?contactId=contact_1" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.email.actions.compose</span></button></a><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-brand-brand-secondary-surface-subtle-default hover:bg-brand-brand-secondary-surface-subtle-hover active:bg-brand-brand-secondary-surface-subtle-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-primary loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.sales.telephony.outbound.call</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-bodLine truncated
|
||||
|
||||
exports[`VA-P28b task and timeline interim visual baseline > renders the focused today queue and completes a task through its callback 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.tasks.today"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.tasks.today.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.tasks.today.subtitle</p></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.tasks.metrics.open</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">2</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.tasks.metrics.overdue</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="text-body-large-0 font-body-large-0 text-icon-feedback-negative inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-body-large-0 font-body-large-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.tasks.metrics.today</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive hidden icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></dLine truncated
|
||||
+195
@@ -0,0 +1,195 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import {
|
||||
buildAdminSalesContactDetailVM,
|
||||
buildAdminSalesTodayVM,
|
||||
type AdminSalesTaskSource,
|
||||
} from "@hivegrid/view-models";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminSalesContactDetailPage } from "./AdminSalesContactDetailPage";
|
||||
import { AdminSalesTodayPage } from "./AdminSalesTodayPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string) => key,
|
||||
i18n: { language: "de" },
|
||||
}),
|
||||
}));
|
||||
|
||||
const now = new Date("2026-07-24T12:00:00.000Z");
|
||||
const task: AdminSalesTaskSource = {
|
||||
id: "task_1",
|
||||
title: "Demo nachfassen",
|
||||
description: "Entscheidung und nächste Schritte klären",
|
||||
contactId: "contact_1",
|
||||
contactName: "Ada Lovelace",
|
||||
dealId: "deal_1",
|
||||
dealTitle: "HiveGrid SaaS",
|
||||
assignedToAdminUserId: "admin_1",
|
||||
dueAt: new Date("2026-07-24T14:00:00.000Z"),
|
||||
timeZone: "Europe/Berlin",
|
||||
reminderAt: new Date("2026-07-24T13:00:00.000Z"),
|
||||
priority: "high",
|
||||
status: "open",
|
||||
source: "manual",
|
||||
recurrence: { frequency: "weekly" },
|
||||
};
|
||||
|
||||
describe("VA-P28b task and timeline interim visual baseline", () => {
|
||||
it("renders the focused today queue and completes a task through its callback", () => {
|
||||
const onComplete = vi.fn();
|
||||
const vm = buildAdminSalesTodayVM({
|
||||
now,
|
||||
todayStart: new Date("2026-07-23T22:00:00.000Z"),
|
||||
locale: "de-DE",
|
||||
timeZone: "Europe/Berlin",
|
||||
tasks: [
|
||||
{
|
||||
...task,
|
||||
id: "task_overdue",
|
||||
dueAt: new Date("2026-07-23T09:00:00.000Z"),
|
||||
priority: "urgent",
|
||||
},
|
||||
task,
|
||||
],
|
||||
buildContactHref: (id) => `/sales/contacts/${id}`,
|
||||
buildDealHref: (id) => `/sales/deals/${id}`,
|
||||
permissions: { canRead: true, canWrite: true },
|
||||
});
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesTodayPage
|
||||
vm={vm}
|
||||
submitting={false}
|
||||
actions={{ onComplete }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("Demo nachfassen");
|
||||
fireEvent.click(
|
||||
container.querySelector(
|
||||
'[data-task-id="task_1"] button'
|
||||
) as HTMLButtonElement
|
||||
);
|
||||
expect(onComplete).toHaveBeenCalledWith("task_1");
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("renders linked deals, contextual tasks, and the chronological contact timeline", () => {
|
||||
const vm = buildAdminSalesContactDetailVM({
|
||||
now,
|
||||
locale: "de-DE",
|
||||
defaultTimeZone: "Europe/Berlin",
|
||||
contact: {
|
||||
id: "contact_1",
|
||||
firstName: "Ada",
|
||||
lastName: "Lovelace",
|
||||
jobTitle: "CTO",
|
||||
email: "ada@example.test",
|
||||
phone: "+49 30 123456",
|
||||
locale: "de-DE",
|
||||
timeZone: "Europe/Berlin",
|
||||
ownerAdminUserId: "admin_1",
|
||||
company: { id: "company_1", name: "Analytical Engines" },
|
||||
deals: [
|
||||
{
|
||||
id: "deal_1",
|
||||
title: "HiveGrid SaaS",
|
||||
status: "open",
|
||||
stageName: "Demo",
|
||||
isPrimary: true,
|
||||
role: "Champion",
|
||||
},
|
||||
],
|
||||
tasks: [task],
|
||||
activities: [
|
||||
{
|
||||
id: "activity_1",
|
||||
type: "call",
|
||||
summary: "Demo besprochen",
|
||||
occurredAt: new Date("2026-07-24T10:00:00.000Z"),
|
||||
dealId: "deal_1",
|
||||
recordingId: "recording_1",
|
||||
},
|
||||
{
|
||||
id: "activity_2",
|
||||
type: "task_created",
|
||||
summary: "Aufgabe Demo nachfassen angelegt",
|
||||
occurredAt: new Date("2026-07-24T10:05:00.000Z"),
|
||||
dealId: "deal_1",
|
||||
},
|
||||
],
|
||||
},
|
||||
buildContactHref: (id) => `/sales/contacts/${id}`,
|
||||
buildDealHref: (id) => `/sales/deals/${id}`,
|
||||
buildRecordingHref: (id) => `/sales/calls/recordings/${id}`,
|
||||
canWrite: true,
|
||||
});
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminSalesContactDetailPage
|
||||
vm={vm}
|
||||
currentAdminUserId="admin_1"
|
||||
backHref="/sales/deals"
|
||||
emailComposeHref="/sales/email/scheduled?contactId=contact_1"
|
||||
submitting={false}
|
||||
actions={{
|
||||
onCreateTask: vi.fn(),
|
||||
onAddNote: vi.fn(),
|
||||
onCompleteTask: vi.fn(),
|
||||
onCall: vi.fn(),
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("Ada Lovelace");
|
||||
expect(container).toHaveTextContent("Demo besprochen");
|
||||
expect(container.querySelector('a[href="/sales/deals/deal_1"]')).toBeTruthy();
|
||||
expect(
|
||||
container.querySelector(
|
||||
'a[href="/sales/calls/recordings/recording_1"]'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
container.querySelector(
|
||||
'a[href="/sales/email/scheduled?contactId=contact_1"]'
|
||||
)
|
||||
).toBeTruthy();
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("keeps the focused today queue keyboard and landmark accessible", async () => {
|
||||
const vm = buildAdminSalesTodayVM({
|
||||
now,
|
||||
todayStart: new Date("2026-07-23T22:00:00.000Z"),
|
||||
locale: "de-DE",
|
||||
timeZone: "Europe/Berlin",
|
||||
tasks: [task],
|
||||
buildContactHref: (id) => `/sales/contacts/${id}`,
|
||||
buildDealHref: (id) => `/sales/deals/${id}`,
|
||||
permissions: { canRead: true, canWrite: true },
|
||||
});
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminSalesTodayPage
|
||||
vm={vm}
|
||||
submitting={false}
|
||||
actions={{ onComplete: vi.fn() }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function stableMarkup(value: string): string {
|
||||
return value.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
);
|
||||
}
|
||||
+172
@@ -0,0 +1,172 @@
|
||||
import type { AdminTelephonySettingsVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherPhoneCall,
|
||||
FeatherRefreshCw,
|
||||
FeatherShieldCheck,
|
||||
} from "@subframe/core";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
|
||||
export function AdminTelephonySettingsPage(props: {
|
||||
readonly vm: AdminTelephonySettingsVM;
|
||||
readonly salesHref: string;
|
||||
readonly connectHref: string;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const connected = props.vm.connections.some(
|
||||
(connection) => connection.status !== "revoked"
|
||||
);
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.telephony.settings">
|
||||
<PageHeader
|
||||
icon={<FeatherPhoneCall className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.telephony.settings.title")}
|
||||
subtitle={t("admin.sales.telephony.settings.description")}
|
||||
actions={
|
||||
<Link to={props.connectHref} className="contents no-underline">
|
||||
<Button
|
||||
variant="neutral"
|
||||
icon={<FeatherRefreshCw />}
|
||||
disabled={!props.vm.providerConfigured}
|
||||
>
|
||||
{t(
|
||||
connected
|
||||
? "admin.sales.telephony.settings.reconnect"
|
||||
: "admin.sales.telephony.settings.connect"
|
||||
)}
|
||||
</Button>
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
<Breadcrumbs aria-label={t("components.breadcrumb.ariaLabel")}>
|
||||
<Breadcrumbs.Item>
|
||||
<Link to={props.salesHref}>
|
||||
{t("admin.sales.navigation.title")}
|
||||
</Link>
|
||||
</Breadcrumbs.Item>
|
||||
<Breadcrumbs.Divider aria-hidden="true" />
|
||||
<Breadcrumbs.Item active>
|
||||
{t("admin.sales.telephony.settings.title")}
|
||||
</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4">
|
||||
<div className="flex min-w-0 items-start gap-3">
|
||||
<FeatherShieldCheck className="text-heading- font-heading- text-icon-neutral-tertiary" />
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.telephony.settings.provider")}
|
||||
</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(
|
||||
props.vm.providerConfigured
|
||||
? "admin.sales.telephony.settings.providerReady"
|
||||
: "admin.sales.telephony.settings.externalGate"
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
connected
|
||||
? "subtle-positive"
|
||||
: props.vm.providerConfigured
|
||||
? "subtle-information"
|
||||
: "subtle-warning"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
connected
|
||||
? "admin.sales.telephony.settings.connected"
|
||||
: props.vm.providerConfigured
|
||||
? "admin.sales.telephony.settings.ready"
|
||||
: "admin.sales.telephony.settings.gated"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
</Card>
|
||||
|
||||
{props.vm.connections.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.telephony.settings.empty")}
|
||||
body={t("admin.sales.telephony.settings.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1">
|
||||
{props.vm.connections.map((connection) => (
|
||||
<Card key={connection.id}>
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div className="min-w-0">
|
||||
<p className="truncate text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{connection.label}
|
||||
</p>
|
||||
<p className="truncate text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{connection.providerUserEmail}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
connection.status === "active" &&
|
||||
connection.webhookReady
|
||||
? "subtle-positive"
|
||||
: "subtle-warning"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
connection.webhookReady
|
||||
? "admin.sales.telephony.settings.webhookReady"
|
||||
: "admin.sales.telephony.settings.webhookPending"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
{connection.phoneNumbers.map((number) => (
|
||||
<div
|
||||
key={number.id}
|
||||
className="flex w-full items-center justify-between gap-3"
|
||||
>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{number.label} · {number.e164}
|
||||
</span>
|
||||
{connection.defaultPhoneNumberId === number.id ? (
|
||||
<BadgeFeedback farbe="subtle-information">
|
||||
{t(
|
||||
"admin.sales.telephony.settings.defaultNumber"
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{connection.lastEventAt
|
||||
? t("admin.sales.telephony.settings.lastEvent", {
|
||||
value: formatters.dateTime(connection.lastEventAt),
|
||||
})
|
||||
: t("admin.sales.telephony.settings.noEvent")}
|
||||
</p>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
+926
@@ -0,0 +1,926 @@
|
||||
import type { AdminTelephonyWorkspaceVM } from "@hivegrid/view-models";
|
||||
import {
|
||||
FeatherAlertTriangle,
|
||||
FeatherHeadphones,
|
||||
FeatherList,
|
||||
FeatherPhoneCall,
|
||||
FeatherPhoneIncoming,
|
||||
FeatherPhoneOutgoing,
|
||||
FeatherSettings,
|
||||
FeatherUserPlus,
|
||||
} from "@subframe/core";
|
||||
import { useMemo, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import {
|
||||
PAGE_HEADER_ICON_CLASS,
|
||||
PageBody,
|
||||
PageHeader,
|
||||
PageShell,
|
||||
} from "~/components/screens/shared/PageShell";
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { NumberInput } from "~/ui/components/NumberInput";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Switch } from "~/ui/components/Switch";
|
||||
import { Tabs } from "~/ui/components/Tabs";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
type WorkspaceAction =
|
||||
| {
|
||||
readonly intent: "save-outcome";
|
||||
readonly callSessionId: string;
|
||||
readonly dispositionCode: string;
|
||||
readonly note: string | null;
|
||||
readonly callbackTitle: string | null;
|
||||
readonly callbackDueAt: string | null;
|
||||
}
|
||||
| {
|
||||
readonly intent: "confirm-match";
|
||||
readonly callSessionId: string;
|
||||
readonly contactId: string | null;
|
||||
readonly leadId: string | null;
|
||||
readonly dealId: string | null;
|
||||
}
|
||||
| {
|
||||
readonly intent: "queue-call";
|
||||
readonly contactId: string;
|
||||
readonly dealId: string | null;
|
||||
readonly dialerEntryId: string | null;
|
||||
}
|
||||
| {
|
||||
readonly intent: "create-dialer";
|
||||
readonly name: string;
|
||||
readonly contactIds: readonly string[];
|
||||
}
|
||||
| {
|
||||
readonly intent: "next-dialer";
|
||||
readonly dialerListId: string;
|
||||
}
|
||||
| {
|
||||
readonly intent: "finish-dialer";
|
||||
readonly dialerEntryId: string;
|
||||
readonly outcome: "completed" | "skipped";
|
||||
readonly callSessionId: string | null;
|
||||
}
|
||||
| {
|
||||
readonly intent: "update-policy";
|
||||
readonly outboundEnabled: boolean;
|
||||
readonly dailyCallLimit: number | null;
|
||||
readonly workDayStartMinutes: number | null;
|
||||
readonly workDayEndMinutes: number | null;
|
||||
readonly workDays: readonly number[];
|
||||
readonly timeZone: string | null;
|
||||
}
|
||||
| {
|
||||
readonly intent: "update-recording-policy";
|
||||
readonly enabled: boolean;
|
||||
readonly accepted: boolean;
|
||||
readonly consentText: string | null;
|
||||
readonly consentVersion: string | null;
|
||||
}
|
||||
| {
|
||||
readonly intent: "confirm-recording-consent";
|
||||
readonly callSessionId: string;
|
||||
readonly confirmed: true;
|
||||
};
|
||||
|
||||
export function AdminTelephonyWorkspacePage(props: {
|
||||
readonly vm: AdminTelephonyWorkspaceVM;
|
||||
readonly hrefs: {
|
||||
readonly calls: string;
|
||||
readonly settings: string;
|
||||
readonly newLead: string;
|
||||
};
|
||||
readonly submitting: boolean;
|
||||
readonly errorMessage?: string | null;
|
||||
readonly actions: {
|
||||
readonly onOpenCall: (callId: string) => void;
|
||||
readonly onSubmit: (action: WorkspaceAction) => void;
|
||||
};
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
const selected = props.vm.selectedCall;
|
||||
const [disposition, setDisposition] = useState(
|
||||
selected?.dispositionCode ?? ""
|
||||
);
|
||||
const [note, setNote] = useState(selected?.note ?? "");
|
||||
const [callbackTitle, setCallbackTitle] = useState("");
|
||||
const [callbackDueAt, setCallbackDueAt] = useState("");
|
||||
const [selectedContactId, setSelectedContactId] = useState(
|
||||
props.vm.contacts[0]?.id ?? ""
|
||||
);
|
||||
const [dialerName, setDialerName] = useState("");
|
||||
const [dialerContacts, setDialerContacts] = useState<string[]>([]);
|
||||
const [outboundEnabled, setOutboundEnabled] = useState(
|
||||
props.vm.policy?.outboundEnabled ?? false
|
||||
);
|
||||
const [dailyLimit, setDailyLimit] = useState(
|
||||
String(props.vm.policy?.dailyCallLimit ?? 50)
|
||||
);
|
||||
const [workStart, setWorkStart] = useState(
|
||||
minutesToClock(props.vm.policy?.workDayStartMinutes ?? 540)
|
||||
);
|
||||
const [workEnd, setWorkEnd] = useState(
|
||||
minutesToClock(props.vm.policy?.workDayEndMinutes ?? 1080)
|
||||
);
|
||||
const [workDays, setWorkDays] = useState<number[]>(
|
||||
props.vm.policy?.workDays.length
|
||||
? [...props.vm.policy.workDays]
|
||||
: [1, 2, 3, 4, 5]
|
||||
);
|
||||
const [timeZone, setTimeZone] = useState(
|
||||
props.vm.policy?.timeZone ?? "Europe/Berlin"
|
||||
);
|
||||
const [recordingEnabled, setRecordingEnabled] = useState(
|
||||
props.vm.policy?.recordingEnabled ?? false
|
||||
);
|
||||
const [recordingConsentText, setRecordingConsentText] = useState(
|
||||
props.vm.policy?.recordingConsentText ?? ""
|
||||
);
|
||||
const [recordingConsentVersion, setRecordingConsentVersion] = useState(
|
||||
props.vm.policy?.recordingConsentVersion ?? ""
|
||||
);
|
||||
const [recordingPolicyAccepted, setRecordingPolicyAccepted] =
|
||||
useState(false);
|
||||
const selectedContact = useMemo(
|
||||
() =>
|
||||
props.vm.contacts.find((contact) => contact.id === selectedContactId) ??
|
||||
null,
|
||||
[props.vm.contacts, selectedContactId]
|
||||
);
|
||||
|
||||
return (
|
||||
<PageShell uiId="ui.admin.sales.telephony.workspace">
|
||||
<PageHeader
|
||||
icon={<FeatherPhoneCall className={PAGE_HEADER_ICON_CLASS} />}
|
||||
title={t("admin.sales.telephony.workspace.title")}
|
||||
subtitle={t("admin.sales.telephony.workspace.description")}
|
||||
actions={
|
||||
<Link to={props.hrefs.settings} className="contents no-underline">
|
||||
<Button variant="neutral" icon={<FeatherSettings />}>
|
||||
{t("admin.sales.telephony.workspace.settings")}
|
||||
</Button>
|
||||
</Link>
|
||||
}
|
||||
/>
|
||||
<PageBody>
|
||||
{props.errorMessage ? (
|
||||
<Card variant="negative">{props.errorMessage}</Card>
|
||||
) : null}
|
||||
<div className="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<StatsCard
|
||||
label={t("admin.sales.telephony.metrics.calls")}
|
||||
value={props.vm.summary.calls}
|
||||
icon={<FeatherPhoneCall />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.telephony.metrics.inbound")}
|
||||
value={props.vm.summary.inbound}
|
||||
icon={<FeatherPhoneIncoming />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.telephony.metrics.outbound")}
|
||||
value={props.vm.summary.outbound}
|
||||
icon={<FeatherPhoneOutgoing />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.sales.telephony.metrics.assignmentQueue")}
|
||||
value={props.vm.summary.assignmentQueue}
|
||||
icon={<FeatherAlertTriangle />}
|
||||
trend={
|
||||
props.vm.summary.assignmentQueue > 0 ? "negative" : "positive"
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Tabs>
|
||||
<Tabs.Item active icon={<FeatherPhoneCall />}>
|
||||
{t("admin.sales.telephony.tabs.calls")}
|
||||
</Tabs.Item>
|
||||
<Tabs.Item icon={<FeatherList />}>
|
||||
{t("admin.sales.telephony.tabs.dialer")}
|
||||
</Tabs.Item>
|
||||
<Tabs.Item icon={<FeatherSettings />}>
|
||||
{t("admin.sales.telephony.tabs.policy")}
|
||||
</Tabs.Item>
|
||||
</Tabs>
|
||||
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div className="flex w-full items-end gap-3 mobile:flex-col mobile:items-stretch">
|
||||
<Select
|
||||
showLabel
|
||||
label={t("admin.sales.telephony.outbound.contact")}
|
||||
placeholder={t("admin.sales.telephony.outbound.selectContact")}
|
||||
value={selectedContactId}
|
||||
onValueChange={setSelectedContactId}
|
||||
>
|
||||
{props.vm.contacts.map((contact) => (
|
||||
<Select.Item key={contact.id} value={contact.id}>
|
||||
{contact.label} · {contact.phone}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Button
|
||||
variant="primary"
|
||||
icon={<FeatherPhoneOutgoing />}
|
||||
loading={props.submitting}
|
||||
disabled={
|
||||
!selectedContact ||
|
||||
selectedContact.doNotCall ||
|
||||
!props.vm.policy?.complete ||
|
||||
!props.vm.policy.outboundEnabled
|
||||
}
|
||||
onClick={() => {
|
||||
if (!selectedContact) return;
|
||||
props.actions.onSubmit({
|
||||
intent: "queue-call",
|
||||
contactId: selectedContact.id,
|
||||
dealId: selectedContact.dealId,
|
||||
dialerEntryId: null,
|
||||
});
|
||||
}}
|
||||
>
|
||||
{t("admin.sales.telephony.outbound.call")}
|
||||
</Button>
|
||||
</div>
|
||||
{!props.vm.policy?.complete || !props.vm.policy.outboundEnabled ? (
|
||||
<Card variant="warning">
|
||||
{t("admin.sales.telephony.outbound.locked")}
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{props.vm.calls.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.sales.telephony.empty.title")}
|
||||
body={t("admin.sales.telephony.empty.body")}
|
||||
/>
|
||||
) : (
|
||||
<div className="grid w-full grid-cols-[minmax(280px,0.9fr)_minmax(0,1.4fr)] gap-4 tablet:grid-cols-1">
|
||||
<div className="flex min-w-0 flex-col gap-2">
|
||||
{props.vm.calls.map((call) => (
|
||||
<Card key={call.id}>
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full flex-col items-start gap-2 text-left"
|
||||
onClick={() => props.actions.onOpenCall(call.id)}
|
||||
>
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{call.contactLabel ??
|
||||
call.leadLabel ??
|
||||
call.externalNumber}
|
||||
</span>
|
||||
<BadgeFeedback
|
||||
farbe={
|
||||
call.matchStatus === "confirmed" ||
|
||||
call.matchStatus === "unique"
|
||||
? "subtle-positive"
|
||||
: "subtle-warning"
|
||||
}
|
||||
>
|
||||
{t(
|
||||
`admin.sales.telephony.match.${call.matchStatus}`
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(
|
||||
`admin.sales.telephony.direction.${call.direction}`
|
||||
)}{" "}
|
||||
· {formatters.dateTime(call.startedAt)}
|
||||
</span>
|
||||
<span className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{t(`admin.sales.telephony.status.${call.status}`)}
|
||||
{call.durationSeconds !== null
|
||||
? ` · ${t("admin.sales.telephony.duration", {
|
||||
value: call.durationSeconds,
|
||||
})}`
|
||||
: null}
|
||||
</span>
|
||||
</button>
|
||||
</Card>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{selected ? (
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-5">
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div>
|
||||
<h2 className="text-heading-3 font-heading-3 text-text-neutral-primary">
|
||||
{selected.externalNumber}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatters.dateTime(selected.startedAt)}
|
||||
</p>
|
||||
</div>
|
||||
{selected.recordingStatus ? (
|
||||
<BadgeFeedback farbe="subtle-information">
|
||||
<FeatherHeadphones />
|
||||
{t(
|
||||
`admin.sales.telephony.recording.${selected.recordingStatus}`
|
||||
)}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{selected.matchStatus === "unmatched" ? (
|
||||
<Card variant="warning">
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(
|
||||
"admin.sales.telephony.assignment.unknownTitle"
|
||||
)}
|
||||
</p>
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{t(
|
||||
"admin.sales.telephony.assignment.unknownBody"
|
||||
)}
|
||||
</p>
|
||||
<Link
|
||||
className="contents no-underline"
|
||||
to={`${props.hrefs.newLead}?phone=${encodeURIComponent(selected.externalNumber)}&source=phone`}
|
||||
>
|
||||
<Button
|
||||
variant="secondary"
|
||||
icon={<FeatherUserPlus />}
|
||||
>
|
||||
{t(
|
||||
"admin.sales.telephony.assignment.createLead"
|
||||
)}
|
||||
</Button>
|
||||
</Link>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{props.vm.policy?.recordingEnabled &&
|
||||
!selected.recordingConsentConfirmedAt &&
|
||||
props.vm.permissions.canManageRecording ? (
|
||||
<Card variant="information">
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(
|
||||
"admin.sales.telephony.recording.consentTitle"
|
||||
)}
|
||||
</p>
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-secondary">
|
||||
{t(
|
||||
"admin.sales.telephony.recording.consentBody"
|
||||
)}
|
||||
</p>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "confirm-recording-consent",
|
||||
callSessionId: selected.id,
|
||||
confirmed: true,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t(
|
||||
"admin.sales.telephony.recording.confirmConsent"
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{selected.candidates.length > 0 &&
|
||||
selected.matchStatus !== "confirmed" ? (
|
||||
<div className="flex w-full flex-col gap-2">
|
||||
<h3 className="text-heading-4 font-heading-4 text-text-neutral-primary">
|
||||
{t(
|
||||
"admin.sales.telephony.assignment.candidates"
|
||||
)}
|
||||
</h3>
|
||||
{selected.candidates.map((candidate) => (
|
||||
<div
|
||||
key={candidate.id}
|
||||
className="flex w-full items-center justify-between gap-3 rounded-md border border-border-neutral px-3 py-2"
|
||||
>
|
||||
<div>
|
||||
<p className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{candidate.label}
|
||||
</p>
|
||||
<p className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(
|
||||
"admin.sales.telephony.assignment.confidence",
|
||||
{ value: candidate.confidencePercent }
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="small"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "confirm-match",
|
||||
callSessionId: selected.id,
|
||||
contactId: candidate.contactId,
|
||||
leadId: candidate.leadId,
|
||||
dealId: candidate.dealId,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t(
|
||||
"admin.sales.telephony.assignment.confirm"
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<Select
|
||||
showLabel
|
||||
label={t("admin.sales.telephony.outcome.disposition")}
|
||||
placeholder={t(
|
||||
"admin.sales.telephony.outcome.selectDisposition"
|
||||
)}
|
||||
value={disposition}
|
||||
onValueChange={setDisposition}
|
||||
>
|
||||
{props.vm.dispositions.map((item) => (
|
||||
<Select.Item key={item.code} value={item.code}>
|
||||
{t(item.labelKey)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextArea
|
||||
showLabel
|
||||
label={t("admin.sales.telephony.outcome.note")}
|
||||
>
|
||||
<TextArea.Input
|
||||
value={note}
|
||||
onChange={(event) => setNote(event.target.value)}
|
||||
/>
|
||||
</TextArea>
|
||||
<div className="grid w-full grid-cols-2 gap-3 mobile:grid-cols-1">
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t(
|
||||
"admin.sales.telephony.outcome.callbackTitle"
|
||||
)}
|
||||
>
|
||||
<TextInput.Input
|
||||
value={callbackTitle}
|
||||
onChange={(event) =>
|
||||
setCallbackTitle(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
type="datetime-local"
|
||||
label={t(
|
||||
"admin.sales.telephony.outcome.callbackDueAt"
|
||||
)}
|
||||
>
|
||||
<TextInput.Input
|
||||
type="datetime-local"
|
||||
value={callbackDueAt}
|
||||
onChange={(event) =>
|
||||
setCallbackDueAt(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<Button
|
||||
variant="primary"
|
||||
loading={props.submitting}
|
||||
disabled={!disposition}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "save-outcome",
|
||||
callSessionId: selected.id,
|
||||
dispositionCode: disposition,
|
||||
note: note.trim() || null,
|
||||
callbackTitle: callbackTitle.trim() || null,
|
||||
callbackDueAt: callbackDueAt
|
||||
? new Date(callbackDueAt).toISOString()
|
||||
: null,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.outcome.save")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
) : null}
|
||||
</div>
|
||||
)}
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.telephony.dialer.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.telephony.dialer.description")}
|
||||
</p>
|
||||
</div>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.sales.telephony.dialer.name")}
|
||||
>
|
||||
<TextInput.Input
|
||||
value={dialerName}
|
||||
onChange={(event) => setDialerName(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<div className="grid w-full grid-cols-2 gap-3 tablet:grid-cols-1">
|
||||
{props.vm.contacts.map((contact) => (
|
||||
<Checkbox
|
||||
key={contact.id}
|
||||
label={`${contact.label} · ${contact.phone}`}
|
||||
description={
|
||||
contact.doNotCall
|
||||
? t("admin.sales.telephony.outbound.doNotCall")
|
||||
: undefined
|
||||
}
|
||||
disabled={contact.doNotCall}
|
||||
checked={dialerContacts.includes(contact.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
setDialerContacts((current) =>
|
||||
checked
|
||||
? [...current, contact.id]
|
||||
: current.filter((id) => id !== contact.id)
|
||||
)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={!dialerName.trim() || dialerContacts.length === 0}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "create-dialer",
|
||||
name: dialerName,
|
||||
contactIds: dialerContacts,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.dialer.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
{props.vm.dialerLists.map((list) => (
|
||||
<Card key={list.id}>
|
||||
<div className="flex w-full flex-col gap-3">
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div>
|
||||
<h3 className="text-heading-4 font-heading-4 text-text-neutral-primary">
|
||||
{list.name}
|
||||
</h3>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.telephony.dialer.progress", {
|
||||
completed: list.completed,
|
||||
total: list.total,
|
||||
blocked: list.blocked,
|
||||
})}
|
||||
</p>
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-information">
|
||||
{t(`admin.sales.telephony.dialer.status.${list.status}`)}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
{list.activeEntry ? (
|
||||
<div className="flex w-full items-center justify-between gap-3 rounded-md border border-border-neutral px-3 py-2">
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary">
|
||||
{list.activeEntry.contactLabel} ·{" "}
|
||||
{list.activeEntry.phone}
|
||||
</span>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button
|
||||
variant="primary"
|
||||
size="small"
|
||||
disabled={!list.activeEntry.phone}
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "queue-call",
|
||||
contactId: list.activeEntry!.contactId,
|
||||
dealId: null,
|
||||
dialerEntryId: list.activeEntry!.id,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.outbound.call")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="neutral"
|
||||
size="small"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "finish-dialer",
|
||||
dialerEntryId: list.activeEntry!.id,
|
||||
outcome: "skipped",
|
||||
callSessionId:
|
||||
list.activeEntry!.callSessionId,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.dialer.skip")}
|
||||
</Button>
|
||||
<Button
|
||||
variant="secondary"
|
||||
size="small"
|
||||
loading={props.submitting}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "finish-dialer",
|
||||
dialerEntryId: list.activeEntry!.id,
|
||||
outcome: "completed",
|
||||
callSessionId:
|
||||
list.activeEntry!.callSessionId,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.dialer.complete")}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={list.pending === 0}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "next-dialer",
|
||||
dialerListId: list.id,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.dialer.next")}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</Card>
|
||||
))}
|
||||
</section>
|
||||
|
||||
<section className="flex w-full flex-col gap-4">
|
||||
<div>
|
||||
<h2 className="text-heading-2 font-heading-2 text-text-neutral-primary">
|
||||
{t("admin.sales.telephony.policy.title")}
|
||||
</h2>
|
||||
<p className="text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary">
|
||||
{t("admin.sales.telephony.policy.description")}
|
||||
</p>
|
||||
</div>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t("admin.sales.telephony.policy.enableOutbound")}
|
||||
</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t("admin.sales.telephony.policy.enableOutboundHelp")}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
aria-label={t(
|
||||
"admin.sales.telephony.policy.enableOutbound"
|
||||
)}
|
||||
checked={outboundEnabled}
|
||||
disabled={!props.vm.permissions.canManageSettings}
|
||||
onCheckedChange={setOutboundEnabled}
|
||||
/>
|
||||
</div>
|
||||
<div className="grid w-full grid-cols-4 gap-3 tablet:grid-cols-2 mobile:grid-cols-1">
|
||||
<NumberInput
|
||||
showLabel
|
||||
label={t("admin.sales.telephony.policy.dailyLimit")}
|
||||
>
|
||||
<NumberInput.Input
|
||||
aria-label={t(
|
||||
"admin.sales.telephony.policy.dailyLimit"
|
||||
)}
|
||||
min={1}
|
||||
max={10_000}
|
||||
value={dailyLimit}
|
||||
onChange={(event) => setDailyLimit(event.target.value)}
|
||||
/>
|
||||
</NumberInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
type="time"
|
||||
label={t("admin.sales.telephony.policy.workStart")}
|
||||
>
|
||||
<TextInput.Input
|
||||
type="time"
|
||||
value={workStart}
|
||||
onChange={(event) => setWorkStart(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
type="time"
|
||||
label={t("admin.sales.telephony.policy.workEnd")}
|
||||
>
|
||||
<TextInput.Input
|
||||
type="time"
|
||||
value={workEnd}
|
||||
onChange={(event) => setWorkEnd(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.sales.telephony.policy.timeZone")}
|
||||
>
|
||||
<TextInput.Input
|
||||
value={timeZone}
|
||||
onChange={(event) => setTimeZone(event.target.value)}
|
||||
/>
|
||||
</TextInput>
|
||||
</div>
|
||||
<div className="flex flex-wrap gap-4">
|
||||
{[1, 2, 3, 4, 5, 6, 0].map((day) => (
|
||||
<Checkbox
|
||||
key={day}
|
||||
label={t(`admin.sales.telephony.weekdays.${day}`)}
|
||||
checked={workDays.includes(day)}
|
||||
onCheckedChange={(checked) =>
|
||||
setWorkDays((current) =>
|
||||
checked
|
||||
? [...current, day]
|
||||
: current.filter((value) => value !== day)
|
||||
)
|
||||
}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
<Card variant="information">
|
||||
{t("admin.sales.telephony.policy.recording", {
|
||||
state: t(
|
||||
props.vm.policy?.recordingEnabled
|
||||
? "admin.sales.telephony.policy.enabled"
|
||||
: "admin.sales.telephony.policy.disabled"
|
||||
),
|
||||
days:
|
||||
props.vm.policy?.recordingRetentionDays ?? 90,
|
||||
})}
|
||||
</Card>
|
||||
<Button
|
||||
variant="primary"
|
||||
loading={props.submitting}
|
||||
disabled={
|
||||
!props.vm.permissions.canManageSettings ||
|
||||
!dailyLimit ||
|
||||
!workStart ||
|
||||
!workEnd ||
|
||||
workDays.length === 0 ||
|
||||
!timeZone.trim()
|
||||
}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "update-policy",
|
||||
outboundEnabled,
|
||||
dailyCallLimit: Number(dailyLimit) || null,
|
||||
workDayStartMinutes: clockToMinutes(workStart),
|
||||
workDayEndMinutes: clockToMinutes(workEnd),
|
||||
workDays,
|
||||
timeZone: timeZone.trim() || null,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t("admin.sales.telephony.policy.save")}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
<Card>
|
||||
<div className="flex w-full flex-col gap-4">
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<div>
|
||||
<p className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">
|
||||
{t(
|
||||
"admin.sales.telephony.recording.policyTitle"
|
||||
)}
|
||||
</p>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{t(
|
||||
"admin.sales.telephony.recording.policyBody"
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<Switch
|
||||
aria-label={t(
|
||||
"admin.sales.telephony.recording.policyTitle"
|
||||
)}
|
||||
checked={recordingEnabled}
|
||||
disabled={!props.vm.permissions.canManageRecording}
|
||||
onCheckedChange={setRecordingEnabled}
|
||||
/>
|
||||
</div>
|
||||
<TextArea
|
||||
showLabel
|
||||
label={t(
|
||||
"admin.sales.telephony.recording.consentText"
|
||||
)}
|
||||
>
|
||||
<TextArea.Input
|
||||
value={recordingConsentText}
|
||||
disabled={!recordingEnabled}
|
||||
onChange={(event) =>
|
||||
setRecordingConsentText(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextArea>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t(
|
||||
"admin.sales.telephony.recording.consentVersion"
|
||||
)}
|
||||
>
|
||||
<TextInput.Input
|
||||
value={recordingConsentVersion}
|
||||
disabled={!recordingEnabled}
|
||||
onChange={(event) =>
|
||||
setRecordingConsentVersion(event.target.value)
|
||||
}
|
||||
/>
|
||||
</TextInput>
|
||||
<Checkbox
|
||||
label={t(
|
||||
"admin.sales.telephony.recording.policyAccepted"
|
||||
)}
|
||||
description={t(
|
||||
"admin.sales.telephony.recording.policyAcceptedHelp"
|
||||
)}
|
||||
checked={recordingPolicyAccepted}
|
||||
disabled={
|
||||
!recordingEnabled ||
|
||||
!props.vm.permissions.canManageRecording
|
||||
}
|
||||
onCheckedChange={setRecordingPolicyAccepted}
|
||||
/>
|
||||
<Button
|
||||
variant="secondary"
|
||||
loading={props.submitting}
|
||||
disabled={
|
||||
!props.vm.permissions.canManageRecording ||
|
||||
(recordingEnabled &&
|
||||
(!recordingPolicyAccepted ||
|
||||
!recordingConsentText.trim() ||
|
||||
!recordingConsentVersion.trim()))
|
||||
}
|
||||
onClick={() =>
|
||||
props.actions.onSubmit({
|
||||
intent: "update-recording-policy",
|
||||
enabled: recordingEnabled,
|
||||
accepted: recordingEnabled
|
||||
? recordingPolicyAccepted
|
||||
: false,
|
||||
consentText:
|
||||
recordingConsentText.trim() || null,
|
||||
consentVersion:
|
||||
recordingConsentVersion.trim() || null,
|
||||
})
|
||||
}
|
||||
>
|
||||
{t(
|
||||
"admin.sales.telephony.recording.savePolicy"
|
||||
)}
|
||||
</Button>
|
||||
</div>
|
||||
</Card>
|
||||
</section>
|
||||
</PageBody>
|
||||
</PageShell>
|
||||
);
|
||||
}
|
||||
|
||||
function minutesToClock(minutes: number): string {
|
||||
const hour = Math.floor(minutes / 60);
|
||||
const minute = minutes % 60;
|
||||
return `${String(hour).padStart(2, "0")}:${String(minute).padStart(2, "0")}`;
|
||||
}
|
||||
|
||||
function clockToMinutes(value: string): number | null {
|
||||
const [hour, minute] = value.split(":").map(Number);
|
||||
return Number.isInteger(hour) && Number.isInteger(minute)
|
||||
? hour! * 60 + minute!
|
||||
: null;
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28d telephony settings interim screen > renders the connected provider and default line 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.telephony.settings"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.telephony.settings.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.telephony.settings.description</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><a class="contents no-underline" href="/settings/telephony/connect/aircall" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-surface-feedback-solid-neutral hover:bg-surface-feedback-solid-neutral-hover active:bg-surface-feedback-solid-neutral-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.telephony.settings.reconnect</span></button></a></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="flex items-center gap-2" aria-label="components.breadcrumb.ariaLabel"><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 text-text-neutral-tertiary hover:text-text-neutral-primary"><a href="/sales/deals" data-discover="true">admin.sales.navigation.title</a></span><span class="text-body-small-regular-0 font-body-small-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP" aria-hidden="true"><svg data-visual-icon="true"></svg></span><span class="group/bbdc1640 line-clamp-1 cursor-pointer break-words text-body-small-regular-0 font-body-small-regular-0 hover:text-text-neutral-primary text-text-neutral-primary">admin.sales.telephony.settings.title</span></div><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start justify-between gap-4"><div class="flex min-w-0 items-start gap-3"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><div><p class="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">admin.sales.telephony.settings.provider</p><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.telephony.settings.providerReady</p></div></div><div class="group/896531e4 flex h-6 items-center gap-2 rounded-round px-2.5 py-1 bg-surface-feedback-subtle-positive"><div class="flex h-1 w-1 flex-none flex-col items-start gap-2 rounded-round bg-icon-feedback-positive"></div><span class="whitespace-nowrap text-body-small-medium-0 font-body-small-medium-0 text-text-feedback-positive">admin.sales.telephony.settings.connected</span></div></div></div><div class="grid w-full grid-cols-2 gap-4 tablet:grid-cols-1"><div class="group/56067c50 flex w-full flex-col items-start gap-4 rounded-md border border-solid border-border-default bg-surface-neutral-secondary px-4 py-4 shadow-sm"><div class="flex w-full items-start justify-between gap-3"><div class="min-w-0"><p class="truncate text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">Aircall · Sales</p><p class="truncate text-body-small-regular-150 font-body-small-regular-150 text-text-neutraLine truncated
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`VA-P28d telephony workspace interim UI > keeps the provider-backed call, dialer, and policy surface stable 1`] = `"<div class="flex w-full flex-col items-start" data-ui-id="ui.admin.sales.telephony.workspace"><div class="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:flex-col mobile:px-4"><div class="flex grow shrink-0 basis-0 flex-col items-start gap-1"><div class="flex items-center gap-2"><span class="text-heading- font-heading- text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><h1 class="text-subtitle font-subtitle text-text-neutral-primary mobile:text-heading- mobile:font-heading-">admin.sales.telephony.workspace.title</h1></div><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">admin.sales.telephony.workspace.description</p></div><div class="flex items-center gap-2 mobile:w-full mobile:flex-none mobile:flex-wrap"><a class="contents no-underline" href="/settings/telephony" data-discover="true"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled bg-surface-feedback-solid-neutral hover:bg-surface-feedback-solid-neutral-hover active:bg-surface-feedback-solid-neutral-active" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.sales.telephony.workspace.settings</span></button></a></div></div><div class="flex w-full flex-col gap-6 p-6 mobile:p-4"><div class="grid w-full grid-cols-4 gap-4 tablet:grid-cols-2 mobile:grid-cols-1"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.telephony.metrics.calls</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">2</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hidden text-body-large-0 font-body-large-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-feedback-positive icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></div></div></div></div><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.sales.telephony.metrics.inbound</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="hiddeLine truncated
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminTelephonySettingsPage } from "./AdminTelephonySettingsPage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) =>
|
||||
values ? `${key}:${Object.values(values).join("/")}` : key,
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
providerConfigured: true,
|
||||
connections: [
|
||||
{
|
||||
id: "phone-1",
|
||||
connectionId: "connection-1",
|
||||
label: "Aircall · Sales",
|
||||
status: "active" as const,
|
||||
providerUserEmail: "sales@example.test",
|
||||
defaultPhoneNumberId: "number-1",
|
||||
phoneNumbers: [
|
||||
{
|
||||
id: "number-1",
|
||||
label: "Berlin",
|
||||
e164: "+493012345678",
|
||||
selected: true,
|
||||
},
|
||||
],
|
||||
webhookReady: true,
|
||||
lastEventAt: "2026-07-24T10:00:00.000Z",
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
function page() {
|
||||
return (
|
||||
<MemoryRouter>
|
||||
<AdminTelephonySettingsPage
|
||||
vm={vm}
|
||||
salesHref="/sales/deals"
|
||||
connectHref="/settings/telephony/connect/aircall"
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
}
|
||||
|
||||
describe("VA-P28d telephony settings interim screen", () => {
|
||||
it("renders the connected provider and default line", () => {
|
||||
const { container } = render(page());
|
||||
expect(screen.getByText("sales@example.test")).toBeInTheDocument();
|
||||
expect(screen.getByText(/Berlin · \+493012345678/u)).toBeInTheDocument();
|
||||
const stableMarkup = container.innerHTML.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
);
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("keeps connection settings accessible", async () => {
|
||||
await expectNoA11yViolations(page());
|
||||
});
|
||||
});
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { MemoryRouter } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { expectNoA11yViolations } from "~/utils/test/a11y";
|
||||
import { AdminTelephonyWorkspacePage } from "./AdminTelephonyWorkspacePage";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({
|
||||
t: (key: string, values?: Record<string, unknown>) =>
|
||||
values ? `${key}:${Object.values(values).join("/")}` : key,
|
||||
}),
|
||||
}));
|
||||
|
||||
const vm = {
|
||||
status: "ready" as const,
|
||||
summary: { calls: 2, inbound: 1, outbound: 1, assignmentQueue: 1 },
|
||||
calls: [
|
||||
{
|
||||
id: "call-1",
|
||||
direction: "inbound" as const,
|
||||
status: "completed" as const,
|
||||
matchStatus: "unmatched" as const,
|
||||
externalNumber: "+4930123456",
|
||||
startedAt: "2026-07-24T08:00:00.000Z",
|
||||
durationSeconds: 180,
|
||||
contactLabel: null,
|
||||
leadLabel: null,
|
||||
dealLabel: null,
|
||||
dispositionCode: null,
|
||||
recordingStatus: "clean" as const,
|
||||
},
|
||||
{
|
||||
id: "call-2",
|
||||
direction: "outbound" as const,
|
||||
status: "completed" as const,
|
||||
matchStatus: "confirmed" as const,
|
||||
externalNumber: "+4940123456",
|
||||
startedAt: "2026-07-23T08:00:00.000Z",
|
||||
durationSeconds: 90,
|
||||
contactLabel: "Ada Lovelace",
|
||||
leadLabel: null,
|
||||
dealLabel: "SaaS Trial",
|
||||
dispositionCode: "interested",
|
||||
recordingStatus: null,
|
||||
},
|
||||
],
|
||||
selectedCall: {
|
||||
id: "call-1",
|
||||
direction: "inbound" as const,
|
||||
status: "completed" as const,
|
||||
matchStatus: "unmatched" as const,
|
||||
externalNumber: "+4930123456",
|
||||
startedAt: "2026-07-24T08:00:00.000Z",
|
||||
durationSeconds: 180,
|
||||
note: null,
|
||||
dispositionCode: null,
|
||||
callbackTaskId: null,
|
||||
recordingConsentConfirmedAt: null,
|
||||
contactId: null,
|
||||
leadId: null,
|
||||
dealId: null,
|
||||
recordingStatus: "clean" as const,
|
||||
recordingRetainedUntil: "2026-10-22T08:00:00.000Z",
|
||||
candidates: [],
|
||||
},
|
||||
dispositions: [
|
||||
{
|
||||
code: "reached",
|
||||
labelKey: "admin.sales.telephony.dispositions.reached",
|
||||
},
|
||||
],
|
||||
contacts: [
|
||||
{
|
||||
id: "contact-1",
|
||||
label: "Ada Lovelace",
|
||||
phone: "+4940123456",
|
||||
dealId: "deal-1",
|
||||
doNotCall: false,
|
||||
},
|
||||
],
|
||||
policy: {
|
||||
outboundEnabled: true,
|
||||
complete: true,
|
||||
dailyCallLimit: 50,
|
||||
workDayStartMinutes: 540,
|
||||
workDayEndMinutes: 1080,
|
||||
workDays: [1, 2, 3, 4, 5],
|
||||
timeZone: "Europe/Berlin",
|
||||
recordingEnabled: false,
|
||||
recordingRetentionDays: 90,
|
||||
recordingConsentText: null,
|
||||
recordingConsentVersion: null,
|
||||
},
|
||||
dialerLists: [
|
||||
{
|
||||
id: "dialer-1",
|
||||
name: "Demo Follow-up",
|
||||
status: "active" as const,
|
||||
total: 2,
|
||||
pending: 1,
|
||||
completed: 0,
|
||||
blocked: 0,
|
||||
activeEntry: {
|
||||
id: "entry-1",
|
||||
contactId: "contact-1",
|
||||
contactLabel: "Ada Lovelace",
|
||||
phone: "+4940123456",
|
||||
callSessionId: null,
|
||||
},
|
||||
},
|
||||
],
|
||||
permissions: {
|
||||
canCall: true,
|
||||
canManageSettings: true,
|
||||
canManageRecording: true,
|
||||
},
|
||||
};
|
||||
|
||||
const hrefs = {
|
||||
calls: "/sales/calls",
|
||||
settings: "/settings/telephony",
|
||||
newLead: "/leads/new",
|
||||
};
|
||||
|
||||
describe("VA-P28d telephony workspace interim UI", () => {
|
||||
it("keeps the provider-backed call, dialer, and policy surface stable", () => {
|
||||
const { container } = render(
|
||||
<MemoryRouter>
|
||||
<AdminTelephonyWorkspacePage
|
||||
vm={vm}
|
||||
hrefs={hrefs}
|
||||
submitting={false}
|
||||
actions={{ onOpenCall: vi.fn(), onSubmit: vi.fn() }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
expect(container).toHaveTextContent("+4930123456");
|
||||
expect(
|
||||
screen
|
||||
.getByText("admin.sales.telephony.assignment.createLead")
|
||||
.closest("a")
|
||||
).toHaveAttribute(
|
||||
"href",
|
||||
"/leads/new?phone=%2B4930123456&source=phone"
|
||||
);
|
||||
expect(stableMarkup(container.innerHTML)).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("requires an explicit click before entering the existing lead flow", () => {
|
||||
render(
|
||||
<MemoryRouter>
|
||||
<AdminTelephonyWorkspacePage
|
||||
vm={vm}
|
||||
hrefs={hrefs}
|
||||
submitting={false}
|
||||
actions={{ onOpenCall: vi.fn(), onSubmit: vi.fn() }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
|
||||
const link = screen
|
||||
.getByText("admin.sales.telephony.assignment.createLead")
|
||||
.closest("a");
|
||||
expect(link).toHaveAttribute(
|
||||
"href",
|
||||
"/leads/new?phone=%2B4930123456&source=phone"
|
||||
);
|
||||
});
|
||||
|
||||
it("has no automated accessibility violations", async () => {
|
||||
await expectNoA11yViolations(
|
||||
<MemoryRouter>
|
||||
<AdminTelephonyWorkspacePage
|
||||
vm={vm}
|
||||
hrefs={hrefs}
|
||||
submitting={false}
|
||||
actions={{ onOpenCall: vi.fn(), onSubmit: vi.fn() }}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
function stableMarkup(markup: string) {
|
||||
return markup.replace(
|
||||
/<svg\b[^>]*>[\s\S]*?<\/svg>/gu,
|
||||
'<svg data-visual-icon="true"></svg>'
|
||||
);
|
||||
}
|
||||
+167
@@ -0,0 +1,167 @@
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { useLocation } from "react-router";
|
||||
import { FeatherGitBranch, FeatherKanbanSquare, FeatherPhone, FeatherTags } from "@subframe/core";
|
||||
|
||||
import { UI_NAV_IDS } from "~/application/ui/uiRegistry";
|
||||
import type { DefaultPermission } from "~/application/dtos/shared/DefaultPermissions";
|
||||
import { PAGE_HEADER_ICON_CLASS, PageHeader } from "~/components/screens/shared/PageShell";
|
||||
import IconKeys from "~/components/layouts/icons/IconKeys";
|
||||
import SidebarIconsLayout, { type IconDto } from "~/components/ui/layouts/SidebarIconsLayout";
|
||||
import CurrencyIcon from "~/components/ui/icons/CurrencyIcon";
|
||||
import EmailIcon from "~/components/ui/icons/EmailIcon";
|
||||
import ExclamationTriangleIcon from "~/components/ui/icons/ExclamationTriangleIcon";
|
||||
import GearIcon from "~/components/ui/icons/GearIcon";
|
||||
import GearIconFilled from "~/components/ui/icons/GearIconFilled";
|
||||
import MembershipCardIcon from "~/components/ui/icons/MembershipCardIcon";
|
||||
import UserIcon from "~/components/ui/icons/UserIcon";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { useAdminData } from "~/utils/data/useAdminData";
|
||||
import { getUserHasPermission } from "~/utils/helpers/PermissionsHelper";
|
||||
import { isRouteActive } from "~/utils/navigation/routeMatching";
|
||||
|
||||
type AdminSettingsNavigationItem = IconDto & {
|
||||
description: string;
|
||||
headerIcon: ReactNode;
|
||||
permission?: DefaultPermission;
|
||||
};
|
||||
|
||||
function identifiedIcon(id: string, icon: ReactNode): ReactNode {
|
||||
return <span data-ui-id={id}>{icon}</span>;
|
||||
}
|
||||
|
||||
export function AdminSettingsShell({ children, withPageHeader = false }: { children: ReactNode; withPageHeader?: boolean }) {
|
||||
const { t } = useTranslation();
|
||||
const location = useLocation();
|
||||
const adminData = useAdminData();
|
||||
const settingsPath = (path: string) => adminPath(`settings/${path}`, { mode: "host-aware" });
|
||||
|
||||
const items: AdminSettingsNavigationItem[] = [
|
||||
{
|
||||
name: t("settings.admin.profile.title"),
|
||||
description: t("settings.admin.profile.description"),
|
||||
href: settingsPath("security"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.profile", <UserIcon className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.profile", <UserIcon className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <UserIcon className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_identity.sessions.read",
|
||||
},
|
||||
{
|
||||
name: t("admin.sales.adminUsers.title"),
|
||||
description: t("admin.sales.adminUsers.description"),
|
||||
href: settingsPath("admin-users"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.adminUsers", <MembershipCardIcon className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.adminUsers", <MembershipCardIcon className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <MembershipCardIcon className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_identity.users.read",
|
||||
},
|
||||
{
|
||||
name: t("admin.sales.adminRoles.title"),
|
||||
description: t("admin.sales.adminRoles.description"),
|
||||
href: settingsPath("admin-roles"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.adminRoles", <IconKeys className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.adminRoles", <IconKeys className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <IconKeys className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_identity.roles.read",
|
||||
},
|
||||
{
|
||||
name: t("settings.admin.general.title"),
|
||||
description: t("settings.admin.general.description"),
|
||||
href: settingsPath("general"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.general", <GearIcon className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.general", <GearIconFilled className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <GearIcon className="size-6" aria-hidden="true" />,
|
||||
permission: "admin.settings.general.view",
|
||||
},
|
||||
{
|
||||
name: t("settings.admin.pricing.title"),
|
||||
description: t("settings.admin.pricing.description"),
|
||||
href: settingsPath("pricing"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.pricing", <CurrencyIcon className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.pricing", <CurrencyIcon className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <CurrencyIcon className="size-6" aria-hidden="true" />,
|
||||
permission: "admin.pricing.view",
|
||||
},
|
||||
{
|
||||
name: t("settings.admin.authentication.title"),
|
||||
description: t("settings.admin.authentication.description"),
|
||||
href: settingsPath("authentication"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.authentication", <IconKeys className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.authentication", <IconKeys className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <IconKeys className="size-6" aria-hidden="true" />,
|
||||
permission: "admin.settings.authentication.view",
|
||||
},
|
||||
{
|
||||
name: t("settings.admin.transactionalEmails.title"),
|
||||
description: t("settings.admin.transactionalEmails.description"),
|
||||
href: settingsPath("transactional-emails"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.transactionalEmails", <EmailIcon className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.transactionalEmails", <EmailIcon className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <EmailIcon className="size-6" aria-hidden="true" />,
|
||||
permission: "admin.emails.view",
|
||||
},
|
||||
{
|
||||
name: t("admin.sales.navigation.pipelineSettings"),
|
||||
description: t("admin.sales.pipelineSettings.description"),
|
||||
href: settingsPath("pipelines"),
|
||||
icon: identifiedIcon(UI_NAV_IDS.adminSalesPipelineSettings, <FeatherKanbanSquare className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon(UI_NAV_IDS.adminSalesPipelineSettings, <FeatherKanbanSquare className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <FeatherKanbanSquare className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_sales.crm.write",
|
||||
},
|
||||
{
|
||||
name: t("admin.sales.navigation.leadSettings"),
|
||||
description: t("admin.sales.leadSettings.description"),
|
||||
href: settingsPath("leads"),
|
||||
icon: identifiedIcon(UI_NAV_IDS.adminSalesLeadSettings, <FeatherGitBranch className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon(UI_NAV_IDS.adminSalesLeadSettings, <FeatherGitBranch className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <FeatherGitBranch className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_sales.crm.assign",
|
||||
},
|
||||
{
|
||||
name: t("admin.sales.navigation.fieldsTags"),
|
||||
description: t("admin.sales.data.fieldsTagsSubtitle"),
|
||||
href: settingsPath("fields-tags"),
|
||||
icon: identifiedIcon(UI_NAV_IDS.adminSalesFieldsTags, <FeatherTags className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon(UI_NAV_IDS.adminSalesFieldsTags, <FeatherTags className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <FeatherTags className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_sales.crm.read",
|
||||
},
|
||||
{
|
||||
name: t("admin.sales.navigation.telephonySettings"),
|
||||
description: t("admin.sales.telephony.settings.description"),
|
||||
href: settingsPath("telephony"),
|
||||
icon: identifiedIcon(UI_NAV_IDS.adminSalesTelephonySettings, <FeatherPhone className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon(UI_NAV_IDS.adminSalesTelephonySettings, <FeatherPhone className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <FeatherPhone className="size-6" aria-hidden="true" />,
|
||||
permission: "admin_sales.integrations.manage",
|
||||
},
|
||||
{
|
||||
name: t("settings.admin.danger.title"),
|
||||
description: t("settings.admin.danger.description"),
|
||||
href: settingsPath("danger"),
|
||||
icon: identifiedIcon("ui.nav.admin.settings.danger", <ExclamationTriangleIcon className="size-5" aria-hidden="true" />),
|
||||
iconSelected: identifiedIcon("ui.nav.admin.settings.danger", <ExclamationTriangleIcon className="size-5" aria-hidden="true" />),
|
||||
headerIcon: <ExclamationTriangleIcon className="size-6" aria-hidden="true" />,
|
||||
permission: "admin.settings.danger.reset",
|
||||
bottom: true,
|
||||
},
|
||||
];
|
||||
|
||||
const visibleItems = items.filter((item) => !item.permission || getUserHasPermission(adminData, item.permission));
|
||||
const activeItem = visibleItems.find((item) => isRouteActive(location.pathname, item.href, { exact: item.exact }));
|
||||
|
||||
return (
|
||||
<SidebarIconsLayout label={{ align: "right" }} items={visibleItems} sticky>
|
||||
{withPageHeader && activeItem ? (
|
||||
<PageHeader
|
||||
uiId="ui.admin.settings.pageHeader"
|
||||
icon={<span className={PAGE_HEADER_ICON_CLASS}>{activeItem.headerIcon}</span>}
|
||||
title={activeItem.name}
|
||||
subtitle={activeItem.description}
|
||||
/>
|
||||
) : null}
|
||||
{children}
|
||||
</SidebarIconsLayout>
|
||||
);
|
||||
}
|
||||
+114
@@ -0,0 +1,114 @@
|
||||
import {
|
||||
buildBillingPaymentVM,
|
||||
buildBillingUsageVM,
|
||||
buildSeatUsageVM,
|
||||
buildSubscriptionOverviewVM,
|
||||
toDemoDataSettingsVM,
|
||||
toFirstStepsChecklistVM,
|
||||
} from "@hivegrid/view-models";
|
||||
|
||||
import { BillingPaymentPage } from "./billing/BillingPaymentPage";
|
||||
import { BillingUsagePage } from "./billing/BillingUsagePage";
|
||||
import { SubscriptionOverviewPage } from "./billing/SubscriptionOverviewPage";
|
||||
import { DemoDataSettingsPage } from "./onboarding/DemoDataSettingsPage";
|
||||
import { FirstStepsChecklistPage } from "./onboarding/FirstStepsChecklistPage";
|
||||
|
||||
export const AK_P20_INTERIM_VISUAL_SCREENS = ["subscription", "usage", "billing", "demo-data", "first-steps"] as const;
|
||||
|
||||
export type AkP20InterimVisualScreen = (typeof AK_P20_INTERIM_VISUAL_SCREENS)[number];
|
||||
|
||||
export function createAkP20InterimVisualVMs() {
|
||||
return {
|
||||
subscription: buildSubscriptionOverviewVM({
|
||||
hasSubscription: true,
|
||||
status: "trial",
|
||||
trialEndsAt: "2026-07-14T12:00:00.000Z",
|
||||
now: "2026-07-12T12:00:00.000Z",
|
||||
planCode: "Starter",
|
||||
seatUsage: buildSeatUsageVM({ packageId: null, usage: null, counts: { office: 2, field: 1 } }),
|
||||
products: [
|
||||
{
|
||||
id: "product-1",
|
||||
titleKey: "settings.subscription.seats.package.starter",
|
||||
code: "starter-monthly",
|
||||
quantity: 3,
|
||||
currentPeriodEnd: "2026-08-12T00:00:00.000Z",
|
||||
prices: [{ amount: 49, currency: "eur", billingPeriod: 3, quantity: 1 }],
|
||||
},
|
||||
],
|
||||
entitlements: [
|
||||
{
|
||||
code: "billing",
|
||||
titleKey: "billing:billingPayment.title",
|
||||
enabled: true,
|
||||
value: 1,
|
||||
used: 0,
|
||||
remaining: "unlimited",
|
||||
},
|
||||
],
|
||||
canCancel: true,
|
||||
contactHref: "https://example.test/kontakt",
|
||||
}),
|
||||
usage: buildBillingUsageVM({
|
||||
periodStart: "2026-07-01T00:00:00.000Z",
|
||||
periodEnd: "2026-08-01T00:00:00.000Z",
|
||||
metrics: [
|
||||
{ metricCode: "automation_runs", quantity: 82, quota: 100, remaining: 18, exceeded: false, percentUsed: 82 },
|
||||
{ metricCode: "storage_bytes", quantity: 5368709120, quota: 10737418240, remaining: 5368709120, exceeded: false, percentUsed: 50 },
|
||||
],
|
||||
}),
|
||||
billing: buildBillingPaymentVM({
|
||||
invoices: [
|
||||
{
|
||||
id: "invoice-1",
|
||||
number: "2026-001",
|
||||
issuingDate: "2026-07-01T00:00:00.000Z",
|
||||
amountCents: 9900,
|
||||
currency: "eur",
|
||||
status: "finalized",
|
||||
paymentStatus: "paid",
|
||||
invoiceType: "subscription",
|
||||
downloadHref: "/acme/settings/billing/invoices/invoice-1",
|
||||
},
|
||||
],
|
||||
lastPaymentExternalId: "mollie-payment-1",
|
||||
}),
|
||||
demoData: toDemoDataSettingsVM({
|
||||
demoDataUiEnabled: true,
|
||||
provisioning: {
|
||||
id: "demo-1",
|
||||
entitiesCreated: { kontakt: ["contact-1"], projekt: ["project-1"], task: ["task-1"] },
|
||||
createdAt: "2026-07-01T00:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
checklist: toFirstStepsChecklistVM({
|
||||
id: "checklist-1",
|
||||
status: "active",
|
||||
dismissed: false,
|
||||
items: [
|
||||
{ id: "profile", block: "profile", titleKey: "onboarding.firstSteps.profile", href: "/acme/settings/profile", completed: true },
|
||||
{ id: "projects", block: "projects", titleKey: "onboarding.firstSteps.projects", href: "/acme/projects", completed: false },
|
||||
],
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
const noOp = (): void => undefined;
|
||||
|
||||
/** Shared ready-state fixture for markup and Chromium pixel-regression tests. */
|
||||
export function AkP20InterimVisualFixture({ screen }: { screen: AkP20InterimVisualScreen }): React.JSX.Element {
|
||||
const vm = createAkP20InterimVisualVMs();
|
||||
|
||||
switch (screen) {
|
||||
case "subscription":
|
||||
return <SubscriptionOverviewPage vm={vm.subscription} actions={{ onCancel: noOp, onOpenContact: noOp, onRetry: noOp }} />;
|
||||
case "usage":
|
||||
return <BillingUsagePage vm={vm.usage} actions={{ onRetry: noOp }} />;
|
||||
case "billing":
|
||||
return <BillingPaymentPage vm={vm.billing} actions={{ onDownloadInvoice: noOp, onRetry: noOp }} />;
|
||||
case "demo-data":
|
||||
return <DemoDataSettingsPage vm={vm.demoData} actions={{ onCreate: noOp, onDelete: noOp, onRetry: noOp }} />;
|
||||
case "first-steps":
|
||||
return <FirstStepsChecklistPage vm={vm.checklist} actions={{ onComplete: noOp, onDismiss: noOp, onOpen: noOp, onRetry: noOp }} />;
|
||||
}
|
||||
}
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AK_P20_INTERIM_VISUAL_SCREENS, AkP20InterimVisualFixture } from "./ak-p20-interim.visual-fixture";
|
||||
|
||||
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),
|
||||
currency: (value: number, currency: string) => `${value.toFixed(2)} ${currency}`,
|
||||
currencyFromCents: (value: number, currency: string) => `${(value / 100).toFixed(2)} ${currency}`,
|
||||
date: (value: string) => value,
|
||||
dateTime: (value: string) => value,
|
||||
}),
|
||||
}));
|
||||
|
||||
describe("AK-P20 interim visual baseline", () => {
|
||||
it("renders representative ready states for all five real ~/ui screens", () => {
|
||||
const { container } = render(
|
||||
<main data-ui-id="ui.akP20.interim.visualBaseline">
|
||||
{AK_P20_INTERIM_VISUAL_SCREENS.map((screen) => (
|
||||
<AkP20InterimVisualFixture key={screen} screen={screen} />
|
||||
))}
|
||||
</main>
|
||||
);
|
||||
|
||||
expect(container.querySelectorAll("[data-ui-id$='.page']")).toHaveLength(5);
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+148
@@ -0,0 +1,148 @@
|
||||
// AK-P21 Interim-UI (AD-28) — deterministic fixture VMs for the privacy
|
||||
// interim visual baseline. Marked as INTERIM baseline: re-baseline is
|
||||
// mandatory when David's final D-P21 optics land.
|
||||
|
||||
import {
|
||||
buildAvvVM,
|
||||
buildGdprExportJobsVM,
|
||||
buildPrivacyHubVM,
|
||||
buildSubprocessorsVM,
|
||||
buildTenantDeletionVM,
|
||||
} from "@hivegrid/view-models";
|
||||
|
||||
import { AvvPage } from "./privacy/AvvPage";
|
||||
import { GdprExportJobsPage } from "./privacy/GdprExportJobsPage";
|
||||
import { PrivacyHubPage } from "./privacy/PrivacyHubPage";
|
||||
import { SubprocessorsPage } from "./privacy/SubprocessorsPage";
|
||||
import { TenantDeletionPage } from "./privacy/TenantDeletionPage";
|
||||
|
||||
export const AK_P21_INTERIM_VISUAL_SCREENS = ["hub", "export-jobs", "deletion", "subprocessors", "avv"] as const;
|
||||
|
||||
export type AkP21InterimVisualScreen = (typeof AK_P21_INTERIM_VISUAL_SCREENS)[number];
|
||||
|
||||
const NOW = "2026-07-12T12:00:00.000Z";
|
||||
|
||||
const exportJobInputs = [
|
||||
{
|
||||
id: "job-ready",
|
||||
scope: "user_self",
|
||||
status: "ready",
|
||||
progressPercent: 100,
|
||||
resultSizeBytes: 4_194_304,
|
||||
resultExpiresAt: "2026-07-14T12:00:00.000Z",
|
||||
downloadCount: 1,
|
||||
createdAt: "2026-07-11T12:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "job-processing",
|
||||
scope: "tenant_full",
|
||||
status: "processing",
|
||||
progressPercent: 40,
|
||||
resultSizeBytes: null,
|
||||
resultExpiresAt: null,
|
||||
downloadCount: 0,
|
||||
createdAt: "2026-07-12T10:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "job-expired",
|
||||
scope: "user_self",
|
||||
status: "ready",
|
||||
progressPercent: 100,
|
||||
resultSizeBytes: 1_024,
|
||||
resultExpiresAt: "2026-07-10T12:00:00.000Z",
|
||||
downloadCount: 0,
|
||||
createdAt: "2026-07-07T12:00:00.000Z",
|
||||
},
|
||||
] as const;
|
||||
|
||||
export function createAkP21InterimVisualVMs() {
|
||||
return {
|
||||
hub: buildPrivacyHubVM({
|
||||
now: NOW,
|
||||
tenantSlug: "acme",
|
||||
graceDays: 30,
|
||||
userEmail: "anna@example.test",
|
||||
userPendingDeletion: false,
|
||||
userScheduledDeletionAt: null,
|
||||
recentJobs: [...exportJobInputs],
|
||||
userSelfCountLast24h: 1,
|
||||
userSelfLimitPer24h: 3,
|
||||
permissions: { tenantExport: true, tenantDeletion: true, subprocessors: true, avv: true },
|
||||
activeTenantDeletion: { id: "req-1", gracePeriodEndsAt: "2026-08-01T12:00:00.000Z" },
|
||||
}),
|
||||
exportJobs: buildGdprExportJobsVM({
|
||||
now: NOW,
|
||||
jobs: [...exportJobInputs],
|
||||
userSelfCountLast24h: 1,
|
||||
tenantFullActive: true,
|
||||
tenantExportAllowed: true,
|
||||
userSelfLimitPer24h: 3,
|
||||
downloadTtlHours: 72,
|
||||
}),
|
||||
deletion: buildTenantDeletionVM({
|
||||
now: NOW,
|
||||
tenantSlug: "acme",
|
||||
graceDays: 30,
|
||||
requiresOtp: true,
|
||||
request: {
|
||||
id: "req-1",
|
||||
status: "pending",
|
||||
reason: "voluntary",
|
||||
reasonText: null,
|
||||
gracePeriodEndsAt: "2026-08-01T12:00:00.000Z",
|
||||
createdAt: "2026-07-02T12:00:00.000Z",
|
||||
},
|
||||
}),
|
||||
subprocessors: buildSubprocessorsVM({
|
||||
subprocessors: [
|
||||
{
|
||||
id: "sub-1",
|
||||
name: "Hetzner Online GmbH",
|
||||
purposeText: "Hosting & Storage",
|
||||
country: "DE",
|
||||
isEuEea: true,
|
||||
dataCategories: ["alle"],
|
||||
dpaUrl: "https://example.test/dpa",
|
||||
activeSince: "2026-01-01T00:00:00.000Z",
|
||||
},
|
||||
{
|
||||
id: "sub-2",
|
||||
name: "Mailjet SAS",
|
||||
purposeText: "Transaktions-E-Mails",
|
||||
country: "FR",
|
||||
isEuEea: true,
|
||||
dataCategories: ["kontakt", "kommunikation"],
|
||||
dpaUrl: null,
|
||||
activeSince: null,
|
||||
},
|
||||
],
|
||||
}),
|
||||
avv: buildAvvVM({
|
||||
currentVersion: "1.1",
|
||||
pdfAvailable: false,
|
||||
acceptances: [
|
||||
{ id: "avv-1", avvVersion: "1.0", signerName: "Anna Admin", signerRole: "Geschäftsführung", pdfFileId: null, createdAt: "2026-06-01T12:00:00.000Z" },
|
||||
],
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
const noop = () => undefined;
|
||||
/** Deterministic breadcrumb target so the interim baseline stays stable. */
|
||||
const HUB_HREF = "/acme/settings/compliance/data-export";
|
||||
|
||||
export function AkP21InterimVisualFixture({ screen }: { screen: AkP21InterimVisualScreen }) {
|
||||
const vms = createAkP21InterimVisualVMs();
|
||||
switch (screen) {
|
||||
case "hub":
|
||||
return <PrivacyHubPage vm={vms.hub} csrf="test-csrf" actions={{ onOpenSection: noop, onDownloadJob: noop, onRetry: noop }} />;
|
||||
case "export-jobs":
|
||||
return <GdprExportJobsPage hubHref={HUB_HREF} vm={vms.exportJobs} actions={{ onStart: noop, onDownload: noop, onRetry: noop }} />;
|
||||
case "deletion":
|
||||
return <TenantDeletionPage hubHref={HUB_HREF} vm={vms.deletion} actions={{ onRequest: noop, onCancelRequest: noop, onOpenExport: noop, onRetry: noop }} />;
|
||||
case "subprocessors":
|
||||
return <SubprocessorsPage hubHref={HUB_HREF} vm={vms.subprocessors} actions={{ onRetry: noop }} />;
|
||||
case "avv":
|
||||
return <AvvPage hubHref={HUB_HREF} vm={vms.avv} actions={{ onAccept: noop, onRetry: noop }} />;
|
||||
}
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
// @vitest-environment jsdom
|
||||
// AK-P21 — INTERIM visual baseline (AD-28). Re-baseline is mandatory when
|
||||
// David's final D-P21 Subframe optics replace the interim privacy screens.
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import React from "react";
|
||||
import { render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AK_P21_INTERIM_VISUAL_SCREENS, AkP21InterimVisualFixture } from "./ak-p21-interim.visual-fixture";
|
||||
|
||||
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),
|
||||
currency: (value: number, currency: string) => `${value.toFixed(2)} ${currency}`,
|
||||
currencyFromCents: (value: number, currency: string) => `${(value / 100).toFixed(2)} ${currency}`,
|
||||
date: (value: string) => value,
|
||||
dateTime: (value: string) => value,
|
||||
}),
|
||||
}));
|
||||
|
||||
vi.mock("react-router", async () => {
|
||||
const actual = await vi.importActual<typeof import("react-router")>("react-router");
|
||||
return {
|
||||
...actual,
|
||||
Form: ({ children, ...props }: React.ComponentProps<"form">) => <form {...props}>{children}</form>,
|
||||
// The baseline renders the screens without a router provider; the
|
||||
// breadcrumb Link only needs to contribute its href to the snapshot.
|
||||
Link: ({ to, children, ...props }: { to: string } & React.ComponentProps<"a">) => (
|
||||
<a href={to} {...props}>
|
||||
{children}
|
||||
</a>
|
||||
),
|
||||
};
|
||||
});
|
||||
|
||||
describe("AK-P21 interim visual baseline", () => {
|
||||
it("renders representative ready states for all five privacy ~/ui screens", () => {
|
||||
const { container } = render(
|
||||
<main data-ui-id="ui.akP21.interim.visualBaseline">
|
||||
{AK_P21_INTERIM_VISUAL_SCREENS.map((screen) => (
|
||||
<AkP21InterimVisualFixture key={screen} screen={screen} />
|
||||
))}
|
||||
</main>
|
||||
);
|
||||
|
||||
expect(container.querySelectorAll("[data-ui-id$='.page']")).toHaveLength(5);
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
// Guards how the loader's FilterablePropertyDto list becomes facets:
|
||||
// option-bearing properties become dropdowns, and a property without options
|
||||
// still shows up as a removable chip while it is active — otherwise a filter
|
||||
// arriving through a row link would be invisible and unclearable.
|
||||
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import type { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
||||
import { ApiFilterBar } from "./ApiFilterBar";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (s: string) => s, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
const METHOD: FilterablePropertyDto = {
|
||||
name: "method",
|
||||
title: "models.apiKeyLog.method",
|
||||
options: [
|
||||
{ name: "GET", value: "GET" },
|
||||
{ name: "POST", value: "POST" },
|
||||
],
|
||||
};
|
||||
|
||||
function renderBar(properties: FilterablePropertyDto[]) {
|
||||
const onToggleProperty = vi.fn();
|
||||
const onSearchChange = vi.fn();
|
||||
render(
|
||||
<ApiFilterBar
|
||||
uiId="ui.test.filter"
|
||||
properties={properties}
|
||||
search=""
|
||||
onSearchChange={onSearchChange}
|
||||
onToggleProperty={onToggleProperty}
|
||||
onReset={vi.fn()}
|
||||
/>
|
||||
);
|
||||
return { onToggleProperty, onSearchChange };
|
||||
}
|
||||
|
||||
describe("ApiFilterBar", () => {
|
||||
it("turns an option-bearing property into a facet button", () => {
|
||||
renderBar([{ ...METHOD }]);
|
||||
|
||||
// The options live in a Radix portal that only mounts once opened; the chip
|
||||
// test below covers the reporting path.
|
||||
expect(document.querySelector("[data-ui-id='ui.test.filter.method']")).not.toBeNull();
|
||||
expect(screen.getByText("models.apiKeyLog.method")).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("shows an active option-less filter as a removable chip", () => {
|
||||
const { onToggleProperty } = renderBar([{ name: "endpoint", title: "models.apiKeyLog.endpoint", value: "/api/kontakte" }]);
|
||||
|
||||
expect(screen.getByText("/api/kontakte")).toBeInTheDocument();
|
||||
fireEvent.click(document.querySelector("[data-ui-id='ui.test.filter.chip.endpoint./api/kontakte.remove']")!);
|
||||
expect(onToggleProperty).toHaveBeenCalledWith("endpoint", "/api/kontakte");
|
||||
});
|
||||
|
||||
it("leaves out an option-less property that is not filtering", () => {
|
||||
renderBar([{ name: "params", title: "models.apiKeyLog.params" }]);
|
||||
|
||||
expect(document.querySelector("[data-ui-id='ui.test.filter.params']")).toBeNull();
|
||||
});
|
||||
});
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
// The shared facet strip for the API tabs, driven by the loader's
|
||||
// FilterablePropertyDto list.
|
||||
//
|
||||
// The tabs used to carry the boilerplate InputSearchWithURL plus an InputFilters
|
||||
// popover button, which looked nothing like the bar every list screen wears. The
|
||||
// URL contract is untouched: the free-text box still writes `q`, and every facet
|
||||
// still writes its property name as a single query parameter, so the loader-side
|
||||
// filtering in ApiKeyLogService keeps working unchanged.
|
||||
//
|
||||
// Properties without a fixed option list (endpoint, params, status …) cannot be
|
||||
// offered as a dropdown, but they are still reachable — the row links write
|
||||
// their parameter. Whenever such a filter is active it renders as a one-option
|
||||
// facet so it appears as a removable chip rather than an invisible filter.
|
||||
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherFilter } from "@subframe/core";
|
||||
import type { ReactNode } from "react";
|
||||
import type { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
|
||||
import { FacetFilterBar, type ClientFacet } from "../shared/FacetFilterBar";
|
||||
|
||||
/** Chip colours, so two active filters are told apart at a glance. */
|
||||
const FACET_TONE = ["violet-subtle", "blue-subtle", "sky-subtle", "yellow-subtle", "neutral-subtle"] as const;
|
||||
|
||||
export type ApiFilterBarProps = {
|
||||
properties: readonly FilterablePropertyDto[];
|
||||
/** Current `q` value. */
|
||||
search: string;
|
||||
onSearchChange: (value: string) => void;
|
||||
/** Sets a property filter, or clears it when the active value is picked again. */
|
||||
onToggleProperty: (name: string, value: string) => void;
|
||||
onReset: () => void;
|
||||
uiId: string;
|
||||
hideSearch?: boolean;
|
||||
afterFacets?: ReactNode;
|
||||
};
|
||||
|
||||
export function ApiFilterBar({ properties, search, onSearchChange, onToggleProperty, onReset, uiId, hideSearch, afterFacets }: ApiFilterBarProps) {
|
||||
const { t } = useTranslation();
|
||||
|
||||
const facets: ClientFacet[] = properties
|
||||
.map((property, index): ClientFacet | null => {
|
||||
const active = property.value ?? null;
|
||||
const options = property.options?.length
|
||||
? property.options.map((option) => ({ value: option.value, label: option.name }))
|
||||
: active
|
||||
? [{ value: active, label: active }]
|
||||
: [];
|
||||
if (options.length === 0) return null;
|
||||
return {
|
||||
key: property.name,
|
||||
label: t(property.title),
|
||||
icon: <FeatherFilter />,
|
||||
tone: FACET_TONE[index % FACET_TONE.length],
|
||||
options,
|
||||
selected: new Set(active ? [active] : []),
|
||||
};
|
||||
})
|
||||
.filter((facet): facet is ClientFacet => facet !== null);
|
||||
|
||||
return (
|
||||
<FacetFilterBar
|
||||
variant="inline"
|
||||
uiId={uiId}
|
||||
facets={facets}
|
||||
onToggle={onToggleProperty}
|
||||
search={search}
|
||||
onSearchChange={onSearchChange}
|
||||
searchPlaceholder={t("shared.searchDot")}
|
||||
onReset={onReset}
|
||||
hideSearch={hideSearch}
|
||||
afterFacets={afterFacets}
|
||||
labels={{ reset: t("shared.reset"), removeChip: t("settings.members.filters.removeChip") }}
|
||||
/>
|
||||
);
|
||||
}
|
||||
+72
@@ -0,0 +1,72 @@
|
||||
// Guards the contract the edit route relies on after "Bearbeiten" moved from the
|
||||
// boilerplate ApiKeyForm onto the shared FormDialog: saving reports the trimmed
|
||||
// fields, and rotate and delete both ask before they run — the old FormGroup
|
||||
// wired its delete straight to a submit.
|
||||
|
||||
import { fireEvent, render, screen } from "@testing-library/react";
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { ApiKeyEditDialog, type ApiKeyEditData } from "./ApiKeyEditDialog";
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (s: string) => s, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
const DATA: ApiKeyEditData = {
|
||||
redactedKey: "hgd_demo…••••auth",
|
||||
alias: "Website Lead Intake",
|
||||
expires: "",
|
||||
active: true,
|
||||
canUpdate: true,
|
||||
canDelete: true,
|
||||
canRotate: true,
|
||||
};
|
||||
|
||||
function renderDialog(overrides: Partial<ApiKeyEditData> = {}) {
|
||||
const handlers = { onSave: vi.fn(), onRotate: vi.fn(), onDelete: vi.fn(), onClose: vi.fn() };
|
||||
render(<ApiKeyEditDialog data={{ ...DATA, ...overrides }} submitting={false} errorMessage={null} {...handlers} />);
|
||||
return handlers;
|
||||
}
|
||||
|
||||
const byId = (id: string) => document.querySelector(`[data-ui-id='${id}']`) as HTMLButtonElement;
|
||||
|
||||
describe("ApiKeyEditDialog", () => {
|
||||
it("prefills the key and reports the trimmed save", () => {
|
||||
const { onSave } = renderDialog({ expires: "2027-01-31" });
|
||||
expect(screen.getByLabelText("models.apiKey.alias")).toHaveValue("Website Lead Intake");
|
||||
|
||||
fireEvent.change(screen.getByLabelText("models.apiKey.alias"), { target: { value: " Intake " } });
|
||||
fireEvent.click(byId("ui.settings.apiKeys.editDialog.submit"));
|
||||
|
||||
expect(onSave).toHaveBeenCalledWith({ alias: "Intake", expires: "2027-01-31", active: true });
|
||||
});
|
||||
|
||||
it("asks before rotating and only then reports it", () => {
|
||||
const { onRotate } = renderDialog();
|
||||
fireEvent.click(byId("ui.settings.apiKeys.editDialog.rotate"));
|
||||
|
||||
expect(onRotate).not.toHaveBeenCalled();
|
||||
expect(screen.getByText("models.apiKey.rotateBody")).toBeInTheDocument();
|
||||
|
||||
fireEvent.click(byId("ui.settings.apiKeys.editDialog.rotateSubmit"));
|
||||
expect(onRotate).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("asks before deleting and only then reports it", () => {
|
||||
const { onDelete } = renderDialog();
|
||||
fireEvent.click(byId("ui.settings.apiKeys.editDialog.delete"));
|
||||
|
||||
expect(onDelete).not.toHaveBeenCalled();
|
||||
fireEvent.click(byId("ui.settings.apiKeys.editDialog.deleteSubmit"));
|
||||
expect(onDelete).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("hides the actions a viewer is not allowed to run", () => {
|
||||
renderDialog({ canDelete: false, canRotate: false, canUpdate: false });
|
||||
|
||||
expect(byId("ui.settings.apiKeys.editDialog.delete")).toBeNull();
|
||||
expect(byId("ui.settings.apiKeys.editDialog.rotate")).toBeNull();
|
||||
expect(byId("ui.settings.apiKeys.editDialog.submit")).toBeDisabled();
|
||||
expect(screen.getByLabelText("models.apiKey.alias")).toBeDisabled();
|
||||
});
|
||||
});
|
||||
+180
@@ -0,0 +1,180 @@
|
||||
// "API-Schluessel bearbeiten" on the shared FormDialog chrome.
|
||||
//
|
||||
// The edit route rendered the boilerplate ApiKeyForm inside an OpenModal, so it
|
||||
// wore the same odd popup shape the create route did — plus a FormGroup footer
|
||||
// whose delete button raised its own confirm. The fields are the same three the
|
||||
// action already accepts; rotate and delete sit in their own section below them,
|
||||
// because both are irreversible in a way that saving a new alias is not.
|
||||
//
|
||||
// Presentational: the route owns the submits. The admin API-key routes keep the
|
||||
// shared ApiKeyForm for now.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherRefreshCw, FeatherSave, FeatherTrash2 } from "@subframe/core";
|
||||
import { Alert } from "~/ui/components/Alert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { DateField } from "../tasks/DateField";
|
||||
import { FormDialog } from "../shared/FormDialog";
|
||||
|
||||
export type ApiKeyEditInput = {
|
||||
alias: string;
|
||||
/** ISO date (yyyy-mm-dd) or "" for a key that does not expire. */
|
||||
expires: string;
|
||||
active: boolean;
|
||||
};
|
||||
|
||||
export type ApiKeyEditData = {
|
||||
/** Redacted key (prefix…last four) — the raw secret never reaches the client. */
|
||||
redactedKey: string;
|
||||
alias: string;
|
||||
expires: string;
|
||||
active: boolean;
|
||||
canUpdate: boolean;
|
||||
canDelete: boolean;
|
||||
canRotate: boolean;
|
||||
};
|
||||
|
||||
export function ApiKeyEditDialog({
|
||||
data,
|
||||
submitting,
|
||||
errorMessage,
|
||||
onSave,
|
||||
onRotate,
|
||||
onDelete,
|
||||
onClose,
|
||||
}: {
|
||||
data: ApiKeyEditData;
|
||||
submitting: boolean;
|
||||
errorMessage: string | null;
|
||||
onSave: (input: ApiKeyEditInput) => void;
|
||||
onRotate: () => void;
|
||||
onDelete: () => void;
|
||||
onClose: () => void;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [alias, setAlias] = useState(data.alias);
|
||||
const [expires, setExpires] = useState(data.expires);
|
||||
const [active, setActive] = useState(data.active);
|
||||
const [confirm, setConfirm] = useState<"rotate" | "delete" | null>(null);
|
||||
|
||||
const disabled = !data.canUpdate;
|
||||
const canSubmit = !disabled && alias.trim().length > 0 && !submitting;
|
||||
|
||||
if (confirm) {
|
||||
const isDelete = confirm === "delete";
|
||||
return (
|
||||
<FormDialog
|
||||
open
|
||||
onOpenChange={(open: boolean) => (open ? undefined : setConfirm(null))}
|
||||
size="xs"
|
||||
uiId={`ui.settings.apiKeys.editDialog.${confirm}Confirm`}
|
||||
title={isDelete ? t("models.apiKey.deleteTitle") : t("models.apiKey.rotateTitle")}
|
||||
footer={
|
||||
<>
|
||||
<Button className="mobile:w-full" type="button" variant="tertiary" onClick={() => setConfirm(null)}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
className="mobile:w-full"
|
||||
variant={isDelete ? "destructive" : "primary"}
|
||||
icon={isDelete ? <FeatherTrash2 /> : <FeatherRefreshCw />}
|
||||
loading={submitting}
|
||||
disabled={submitting}
|
||||
onClick={() => (isDelete ? onDelete() : onRotate())}
|
||||
data-ui-id={`ui.settings.apiKeys.editDialog.${confirm}Submit`}
|
||||
>
|
||||
{isDelete ? t("shared.delete") : t("models.apiKey.rotate")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
<span className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary">
|
||||
{isDelete ? t("models.apiKey.deleteBody", { alias: data.alias }) : t("models.apiKey.rotateBody", { alias: data.alias })}
|
||||
</span>
|
||||
</FormDialog>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<FormDialog
|
||||
open
|
||||
onOpenChange={(open: boolean) => (open ? undefined : onClose())}
|
||||
title={t("models.apiKey.editTitle")}
|
||||
subtitle={data.redactedKey}
|
||||
uiId="ui.settings.apiKeys.editDialog"
|
||||
footer={
|
||||
<>
|
||||
<Button type="button" variant="tertiary" onClick={onClose} disabled={submitting}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button
|
||||
icon={<FeatherSave />}
|
||||
loading={submitting}
|
||||
disabled={!canSubmit}
|
||||
onClick={() => onSave({ alias: alias.trim(), expires, active })}
|
||||
data-ui-id="ui.settings.apiKeys.editDialog.submit"
|
||||
>
|
||||
{t("shared.save")}
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
>
|
||||
{errorMessage ? <Alert variant="error" title={errorMessage} /> : null}
|
||||
|
||||
<TextInput className="w-full max-w-full" label={t("models.apiKey.alias")} showLabel>
|
||||
<TextInput.Input
|
||||
value={alias}
|
||||
onChange={(event) => setAlias(event.target.value)}
|
||||
disabled={disabled}
|
||||
autoComplete="off"
|
||||
required
|
||||
data-ui-id="ui.settings.apiKeys.editDialog.alias"
|
||||
/>
|
||||
</TextInput>
|
||||
|
||||
<div className="flex w-full flex-col gap-1">
|
||||
<DateField label={t("models.apiKey.expires")} name="expires" value={expires} onChange={setExpires} />
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("models.apiKey.expiresHint")}</span>
|
||||
</div>
|
||||
|
||||
<Checkbox className="w-fit" label={t("models.apiKey.active")} checked={active} disabled={disabled} onCheckedChange={(checked: boolean) => setActive(checked)} />
|
||||
|
||||
{data.canRotate || data.canDelete ? (
|
||||
<div className="flex w-full flex-col gap-3 border-t border-solid border-border-default pt-4">
|
||||
{/* Both are irreversible in a way that renaming a key is not, so they
|
||||
stand apart from the save action and ask before they run. */}
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-tertiary">{t("models.apiKey.dangerSection")}</span>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{data.canRotate ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="secondary"
|
||||
icon={<FeatherRefreshCw />}
|
||||
disabled={submitting}
|
||||
onClick={() => setConfirm("rotate")}
|
||||
data-ui-id="ui.settings.apiKeys.editDialog.rotate"
|
||||
>
|
||||
{t("models.apiKey.rotate")}
|
||||
</Button>
|
||||
) : null}
|
||||
{data.canDelete ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="destructive"
|
||||
icon={<FeatherTrash2 />}
|
||||
disabled={submitting}
|
||||
onClick={() => setConfirm("delete")}
|
||||
data-ui-id="ui.settings.apiKeys.editDialog.delete"
|
||||
>
|
||||
{t("shared.delete")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</FormDialog>
|
||||
);
|
||||
}
|
||||
Loaded 100 of 5955 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user