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
+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>'
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user