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
+622
@@ -0,0 +1,622 @@
|
||||
import { FeatherArchive, FeatherArrowLeft, FeatherRotateCcw, FeatherSave, FeatherSend } from "@subframe/core";
|
||||
import type { AdminLeadDetailVM } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadDetailPageProps = {
|
||||
readonly vm: AdminLeadDetailVM;
|
||||
readonly csrf: string;
|
||||
readonly submitting: boolean;
|
||||
readonly feedback?: { readonly success?: string; readonly error?: string };
|
||||
readonly actions: {
|
||||
readonly onBack: () => void;
|
||||
readonly onSubmit: PlatformLeadFormAction;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S03: platform lead detail and attributable activity timeline. */
|
||||
export function AdminPlatformLeadDetailPage({ vm, csrf, submitting, feedback, actions }: AdminPlatformLeadDetailPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.detail" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start gap-3 border-b border-solid px-6 py-5">
|
||||
<Breadcrumbs>
|
||||
<Link to={adminPath("leads", { mode: "host-aware" })}>
|
||||
<Breadcrumbs.Item>{t("admin.platformLeads.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{vm.displayName || t("shared.notSet")}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="mobile:flex-col flex w-full items-start gap-4">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{vm.displayName || t("shared.notSet")}</h1>
|
||||
<BadgeFeedback farbe={vm.statusTone}>{t(vm.statusLabelKey)}</BadgeFeedback>
|
||||
{vm.archivedAt ? <BadgeFeedback farbe="subtle-neutral">{t("admin.platformLeads.archive.archived")}</BadgeFeedback> : null}
|
||||
</div>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.platformLeads.detailDescription")}</p>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" icon={<FeatherArrowLeft />} onClick={actions.onBack}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{feedback?.success ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{feedback.success}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{feedback?.error ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{feedback.error}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{vm.duplicateHintOfLeadId ? (
|
||||
<BannerAlert type="warning" fillContainer>
|
||||
<span className="font-body-default-semibold-0">{t("admin.platformLeads.detail.duplicateHint")}</span>
|
||||
<span>{t("admin.platformLeads.detail.duplicateHintBody")}</span>
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{vm.archivedAt ? (
|
||||
<BannerAlert type="information" fillContainer>
|
||||
{t("admin.platformLeads.detail.archived")}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-[minmax(0,1fr)_minmax(320px,0.7fr)] gap-4">
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.contact")} />
|
||||
<DefinitionGrid
|
||||
rows={[
|
||||
[t("admin.platformLeads.fields.firstName"), vm.firstName],
|
||||
[t("admin.platformLeads.fields.lastName"), vm.lastName],
|
||||
[t("admin.platformLeads.fields.company"), vm.company],
|
||||
[t("admin.platformLeads.fields.email"), vm.email],
|
||||
[t("admin.platformLeads.fields.phone"), vm.phone],
|
||||
[t("admin.platformLeads.fields.source"), vm.sourceDisplayName],
|
||||
[t("admin.platformLeads.fields.externalId"), vm.externalId],
|
||||
[t("admin.platformLeads.fields.capturedAt"), formatters.dateTime(vm.capturedAt)],
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.qualification.title")} />
|
||||
<DefinitionGrid
|
||||
rows={[
|
||||
[
|
||||
t("admin.platformLeads.qualification.score"),
|
||||
vm.qualification ? String(vm.qualification.score) : null,
|
||||
],
|
||||
[
|
||||
t("admin.platformLeads.qualification.band"),
|
||||
vm.qualification
|
||||
? t(`admin.platformLeads.qualification.bands.${vm.qualification.scoreBand}`)
|
||||
: null,
|
||||
],
|
||||
[
|
||||
t("admin.platformLeads.qualification.enrichmentStatus"),
|
||||
vm.qualification
|
||||
? t(
|
||||
`admin.platformLeads.qualification.enrichment.${vm.qualification.enrichmentStatus}`
|
||||
)
|
||||
: null,
|
||||
],
|
||||
[
|
||||
t("admin.platformLeads.qualification.provider"),
|
||||
vm.qualification?.enrichmentProvider ?? null,
|
||||
],
|
||||
]}
|
||||
/>
|
||||
{vm.enrichmentRows.length > 0 ? (
|
||||
<div className="border-border-default grid w-full grid-cols-2 gap-3 border-t border-solid pt-4">
|
||||
{vm.enrichmentRows.map((row) => (
|
||||
<div key={row.key} className="flex min-w-0 flex-col items-start gap-1">
|
||||
<span className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">
|
||||
{t(`admin.platformLeads.qualification.fields.${row.key}`, {
|
||||
defaultValue: row.key,
|
||||
})}
|
||||
</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary break-words">
|
||||
{row.value}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.message")} />
|
||||
<p className="text-body-default-regular-150 font-body-default-regular-150 text-text-neutral-secondary whitespace-pre-wrap">
|
||||
{vm.message || t("shared.notSet")}
|
||||
</p>
|
||||
</Card>
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.attribution")} />
|
||||
<DefinitionGrid
|
||||
rows={[
|
||||
[t("admin.platformLeads.fields.utmSource"), vm.attribution.utmSource],
|
||||
[t("admin.platformLeads.fields.utmMedium"), vm.attribution.utmMedium],
|
||||
[t("admin.platformLeads.fields.utmCampaign"), vm.attribution.utmCampaign],
|
||||
[t("admin.platformLeads.fields.utmTerm"), vm.attribution.utmTerm],
|
||||
[t("admin.platformLeads.fields.utmContent"), vm.attribution.utmContent],
|
||||
[t("admin.platformLeads.fields.referrer"), vm.attribution.referrer],
|
||||
[t("admin.platformLeads.fields.landingPage"), vm.attribution.landingPage],
|
||||
]}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.qualification.actionsTitle")} />
|
||||
{vm.permissions.canWrite ? (
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
<div className="flex w-full flex-wrap gap-2">
|
||||
<QuickLeadAction
|
||||
csrf={csrf}
|
||||
intent="score"
|
||||
reason={t("admin.platformLeads.qualification.reasons.score")}
|
||||
label={t("admin.platformLeads.qualification.actions.score")}
|
||||
submitting={submitting}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
{vm.permissions.canAssign ? (
|
||||
<QuickLeadAction
|
||||
csrf={csrf}
|
||||
intent="auto-assign"
|
||||
reason={t("admin.platformLeads.qualification.reasons.assign")}
|
||||
label={t("admin.platformLeads.qualification.actions.assign")}
|
||||
submitting={submitting}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
) : null}
|
||||
<QuickLeadAction
|
||||
csrf={csrf}
|
||||
intent="detect-duplicates"
|
||||
reason={t("admin.platformLeads.qualification.reasons.duplicates")}
|
||||
label={t("admin.platformLeads.qualification.actions.duplicates")}
|
||||
submitting={submitting}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form
|
||||
onSubmit={platformLeadFormHandler(actions.onSubmit)}
|
||||
className="flex w-full flex-col items-start gap-3"
|
||||
>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="enrich" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.qualification.reasons.enrich")}
|
||||
/>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.provider")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input
|
||||
name="provider"
|
||||
required
|
||||
defaultValue={vm.qualification?.enrichmentProvider ?? "provider-webhook"}
|
||||
/>
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.company")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="companyName" defaultValue={vm.company ?? ""} />
|
||||
</TextInput>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-3">
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.domain")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="domain" />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.region")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="region" />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.countryCode")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="countryCode" maxLength={2} />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.qualification.fields.industry")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="industry" />
|
||||
</TextInput>
|
||||
</div>
|
||||
<Button type="submit" variant="secondary" loading={submitting}>
|
||||
{t("admin.platformLeads.qualification.actions.enrich")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
) : (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.platformLeads.qualification.actionsTitle")}
|
||||
body={t("admin.platformLeads.errors.noWritePermission")}
|
||||
/>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.duplicates.title")} />
|
||||
{vm.duplicates.length === 0 ? (
|
||||
<EmptyState
|
||||
outlined
|
||||
title={t("admin.platformLeads.duplicates.empty")}
|
||||
body={t("admin.platformLeads.duplicates.emptyBody")}
|
||||
/>
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
{vm.duplicates.map((candidate) => (
|
||||
<div
|
||||
key={candidate.id}
|
||||
className="border-border-default flex w-full flex-col items-start gap-3 rounded-md border border-solid p-3"
|
||||
>
|
||||
<div className="flex w-full items-start justify-between gap-3">
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<Link
|
||||
className="text-body-default-medium-0 font-body-default-medium-0 text-text-brand-primary"
|
||||
to={adminPath(`leads/${candidate.candidateLeadId}`, {
|
||||
mode: "host-aware",
|
||||
})}
|
||||
>
|
||||
{candidate.candidateLeadId}
|
||||
</Link>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{candidate.matchKeys.join(", ")}
|
||||
</span>
|
||||
</div>
|
||||
<BadgeFeedback farbe="subtle-warning">
|
||||
{candidate.confidencePercent} %
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
{vm.permissions.canMerge ? (
|
||||
<div className="flex flex-wrap gap-2">
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="merge" />
|
||||
<input type="hidden" name="candidateId" value={candidate.id} />
|
||||
<input
|
||||
type="hidden"
|
||||
name="survivorLeadId"
|
||||
value={candidate.primaryLeadId}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
name="mergedLeadId"
|
||||
value={candidate.duplicateLeadId}
|
||||
/>
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.duplicates.reasons.merge")}
|
||||
/>
|
||||
<Button type="submit" size="small" loading={submitting}>
|
||||
{t("admin.platformLeads.duplicates.actions.merge")}
|
||||
</Button>
|
||||
</form>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input
|
||||
type="hidden"
|
||||
name="intent"
|
||||
value="dismiss-duplicate"
|
||||
/>
|
||||
<input type="hidden" name="candidateId" value={candidate.id} />
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.duplicates.reasons.dismiss")}
|
||||
/>
|
||||
<Button
|
||||
type="submit"
|
||||
size="small"
|
||||
variant="tertiary"
|
||||
loading={submitting}
|
||||
>
|
||||
{t("admin.platformLeads.duplicates.actions.dismiss")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
|
||||
{vm.status === "qualified" && !vm.converted && vm.permissions.canWrite ? (
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.conversion.title")} />
|
||||
<form
|
||||
onSubmit={platformLeadFormHandler(actions.onSubmit)}
|
||||
className="flex w-full flex-col items-start gap-3"
|
||||
>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="convert" />
|
||||
<input
|
||||
type="hidden"
|
||||
name="reason"
|
||||
value={t("admin.platformLeads.conversion.reason")}
|
||||
/>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.company")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="companyName" required defaultValue={vm.company ?? ""} />
|
||||
</TextInput>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-3">
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.firstName")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="firstName" required defaultValue={vm.firstName ?? ""} />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.lastName")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="lastName" required defaultValue={vm.lastName ?? ""} />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.conversion.dealTitle")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input
|
||||
name="dealTitle"
|
||||
required
|
||||
defaultValue={t("admin.platformLeads.conversion.defaultDealTitle", {
|
||||
name: vm.company || vm.displayName,
|
||||
})}
|
||||
/>
|
||||
</TextInput>
|
||||
<Select
|
||||
name="ownerAdminUserId"
|
||||
defaultValue={vm.assignedToAdminUserId ?? vm.assigneeOptions[0]?.id}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
>
|
||||
{vm.assigneeOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.conversion.amount")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="amountCents" type="number" min={0} />
|
||||
</TextInput>
|
||||
<TextInput
|
||||
showLabel
|
||||
label={t("admin.platformLeads.conversion.nextStep")}
|
||||
fillContainer
|
||||
>
|
||||
<TextInput.Input name="nextStep" />
|
||||
</TextInput>
|
||||
<Button type="submit" loading={submitting}>
|
||||
{t("admin.platformLeads.conversion.action")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{vm.converted ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{t("admin.platformLeads.conversion.complete")}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.processing")} />
|
||||
{vm.permissions.canWrite ? (
|
||||
<>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="status" />
|
||||
<Select
|
||||
name="status"
|
||||
defaultValue={vm.status}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.status")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.status")}
|
||||
highContrastText
|
||||
>
|
||||
{(["new", "contacted", "qualified", "disqualified"] as const).map((status) => (
|
||||
<Select.Item key={status} value={status}>
|
||||
{t(`admin.platformLeads.status.${status}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.reason")} fillContainer>
|
||||
<TextInput.Input name="reason" required minLength={5} />
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary" loading={submitting} icon={<FeatherSave />}>
|
||||
{t("admin.platformLeads.actions.save")}
|
||||
</Button>
|
||||
</form>
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="assign" />
|
||||
<Select
|
||||
name="assignedToAdminUserId"
|
||||
defaultValue={vm.assignedToAdminUserId ?? "unassigned"}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{vm.assigneeOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.reason")} fillContainer>
|
||||
<TextInput.Input name="reason" required minLength={5} />
|
||||
</TextInput>
|
||||
<Button type="submit" variant="secondary" loading={submitting} icon={<FeatherSave />}>
|
||||
{t("admin.platformLeads.actions.save")}
|
||||
</Button>
|
||||
</form>
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="note" />
|
||||
<TextArea showLabel label={t("admin.platformLeads.fields.note")} className="max-w-none">
|
||||
<TextArea.Input name="note" required maxLength={8000} />
|
||||
</TextArea>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherSend />}>
|
||||
{t("admin.platformLeads.actions.addNote")}
|
||||
</Button>
|
||||
</form>
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value={vm.archivedAt ? "restore" : "archive"} />
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.reason")} fillContainer>
|
||||
<TextInput.Input name="reason" required minLength={5} />
|
||||
</TextInput>
|
||||
<Button
|
||||
type="submit"
|
||||
variant={vm.archivedAt ? "secondary" : "destructive"}
|
||||
loading={submitting}
|
||||
icon={vm.archivedAt ? <FeatherRotateCcw /> : <FeatherArchive />}
|
||||
>
|
||||
{t(vm.archivedAt ? "admin.platformLeads.actions.restore" : "admin.platformLeads.actions.archive")}
|
||||
</Button>
|
||||
</form>
|
||||
</>
|
||||
) : (
|
||||
<EmptyState outlined title={t("admin.platformLeads.detail.processing")} body={t("admin.platformLeads.errors.noWritePermission")} />
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<SectionTitle title={t("admin.platformLeads.detail.activity")} />
|
||||
{vm.activities.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.empty.activities")} body={t("admin.platformLeads.detailDescription")} />
|
||||
) : (
|
||||
<div className="flex w-full flex-col items-start gap-3">
|
||||
{vm.activities.map((activity) => (
|
||||
<div
|
||||
key={activity.id}
|
||||
className="border-border-default bg-surface-neutral-primary mobile:flex-col flex w-full items-start justify-between gap-4 rounded-md border border-solid px-4 py-4"
|
||||
>
|
||||
<div className="flex min-w-0 flex-col items-start gap-1">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-primary">{t(activity.labelKey)}</span>
|
||||
{activity.note ? (
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary whitespace-pre-wrap">
|
||||
{activity.note}
|
||||
</span>
|
||||
) : null}
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">
|
||||
{activity.actorLabel || t("admin.platformLeads.activity.system")}
|
||||
</span>
|
||||
</div>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatters.dateTime(activity.createdAt)}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionTitle({ title }: { title: string }): React.JSX.Element {
|
||||
return <span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{title}</span>;
|
||||
}
|
||||
|
||||
function DefinitionGrid({ rows }: { rows: readonly (readonly [string, string | null])[] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<dl className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
{rows.map(([label, value]) => (
|
||||
<div key={label} className="flex min-w-0 flex-col items-start gap-1">
|
||||
<dt className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 text-text-neutral-secondary">{label}</dt>
|
||||
<dd className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary max-w-full break-words">
|
||||
{value || t("shared.notSet")}
|
||||
</dd>
|
||||
</div>
|
||||
))}
|
||||
</dl>
|
||||
);
|
||||
}
|
||||
|
||||
function QuickLeadAction({
|
||||
csrf,
|
||||
intent,
|
||||
reason,
|
||||
label,
|
||||
submitting,
|
||||
onSubmit,
|
||||
}: {
|
||||
readonly csrf: string;
|
||||
readonly intent: "score" | "auto-assign" | "detect-duplicates";
|
||||
readonly reason: string;
|
||||
readonly label: string;
|
||||
readonly submitting: boolean;
|
||||
readonly onSubmit: PlatformLeadFormAction;
|
||||
}): React.JSX.Element {
|
||||
return (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value={intent} />
|
||||
<input type="hidden" name="reason" value={reason} />
|
||||
<Button type="submit" size="small" variant="secondary" loading={submitting}>
|
||||
{label}
|
||||
</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
+134
@@ -0,0 +1,134 @@
|
||||
import { FeatherArrowLeft, FeatherPlus } from "@subframe/core";
|
||||
import type { AdminLeadOption } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadNewPageProps = {
|
||||
readonly sourceOptions: readonly AdminLeadOption[];
|
||||
readonly assigneeOptions: readonly AdminLeadOption[];
|
||||
readonly csrf: string;
|
||||
readonly submitting: boolean;
|
||||
readonly error?: string;
|
||||
readonly actions: {
|
||||
readonly onBack: () => void;
|
||||
readonly onCreate: PlatformLeadFormAction;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S02: manual lead intake through the shared domain service. */
|
||||
export function AdminPlatformLeadNewPage({
|
||||
sourceOptions,
|
||||
assigneeOptions,
|
||||
csrf,
|
||||
submitting,
|
||||
error,
|
||||
actions,
|
||||
}: AdminPlatformLeadNewPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.new" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start gap-3 border-b border-solid px-6 py-5">
|
||||
<Breadcrumbs>
|
||||
<Link to={adminPath("leads", { mode: "host-aware" })}>
|
||||
<Breadcrumbs.Item>{t("admin.platformLeads.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{t("admin.platformLeads.actions.new")}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="flex w-full items-start gap-4">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.platformLeads.newTitle")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.platformLeads.newDescription")}</p>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" icon={<FeatherArrowLeft />} onClick={actions.onBack}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mobile:px-4 flex w-full max-w-[960px] flex-col items-start gap-6 px-6 py-6">
|
||||
{error ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{error}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
<Card>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onCreate)} className="flex w-full flex-col items-start gap-6">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-2 gap-4">
|
||||
<Select
|
||||
name="sourceId"
|
||||
required
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.source")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.source")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.fields.source")}
|
||||
>
|
||||
{sourceOptions.map((source) => (
|
||||
<Select.Item key={source.id} value={source.id}>
|
||||
{source.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="assignedToAdminUserId"
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.unassigned")}
|
||||
>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{assigneeOptions.map((assignee) => (
|
||||
<Select.Item key={assignee.id} value={assignee.id}>
|
||||
{assignee.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.firstName")} fillContainer>
|
||||
<TextInput.Input name="firstName" autoComplete="given-name" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.lastName")} fillContainer>
|
||||
<TextInput.Input name="lastName" autoComplete="family-name" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.email")} fillContainer>
|
||||
<TextInput.Input name="email" type="email" autoComplete="email" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.phone")} fillContainer>
|
||||
<TextInput.Input name="phone" type="tel" autoComplete="tel" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.company")} fillContainer>
|
||||
<TextInput.Input name="company" autoComplete="organization" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.sourceDetail")} fillContainer>
|
||||
<TextInput.Input name="sourceDetail" />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextArea showLabel label={t("admin.platformLeads.fields.message")} className="max-w-none">
|
||||
<TextArea.Input name="message" />
|
||||
</TextArea>
|
||||
<div className="flex w-full justify-end gap-2">
|
||||
<Button type="button" variant="ghost" onClick={actions.onBack}>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherPlus />}>
|
||||
{t("admin.platformLeads.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+305
@@ -0,0 +1,305 @@
|
||||
import { FeatherArrowLeft, FeatherKey, FeatherPlus, FeatherRefreshCw, FeatherSave, FeatherSlash } from "@subframe/core";
|
||||
import type { AdminLeadOption, AdminLeadSourcesVM } from "@hivegrid/view-models";
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Breadcrumbs } from "~/ui/components/Breadcrumbs";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { Checkbox } from "~/ui/components/Checkbox";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadSourcesPageProps = {
|
||||
readonly vm: AdminLeadSourcesVM;
|
||||
readonly csrf: string;
|
||||
readonly submitting: boolean;
|
||||
readonly feedback?: { readonly success?: string; readonly error?: string };
|
||||
readonly actions: {
|
||||
readonly onBack: () => void;
|
||||
readonly onSubmit: PlatformLeadFormAction;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S04: source routing and one-time credential administration. */
|
||||
export function AdminPlatformLeadSourcesPage({ vm, csrf, submitting, feedback, actions }: AdminPlatformLeadSourcesPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.sources" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full flex-col items-start gap-3 border-b border-solid px-6 py-5">
|
||||
<Breadcrumbs>
|
||||
<Link to={adminPath("leads", { mode: "host-aware" })}>
|
||||
<Breadcrumbs.Item>{t("admin.platformLeads.title")}</Breadcrumbs.Item>
|
||||
</Link>
|
||||
<Breadcrumbs.Divider />
|
||||
<Breadcrumbs.Item active>{t("admin.platformLeads.sources.title")}</Breadcrumbs.Item>
|
||||
</Breadcrumbs>
|
||||
<div className="flex w-full items-start gap-4">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.platformLeads.sources.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.platformLeads.sources.description")}</p>
|
||||
</div>
|
||||
<Button type="button" variant="tertiary" icon={<FeatherArrowLeft />} onClick={actions.onBack}>
|
||||
{t("shared.back")}
|
||||
</Button>
|
||||
</div>
|
||||
</header>
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{feedback?.success ? (
|
||||
<BannerAlert type="success" fillContainer>
|
||||
{feedback.success}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{feedback?.error ? (
|
||||
<BannerAlert type="error" fillContainer>
|
||||
{feedback.error}
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
{vm.revealedCredential ? (
|
||||
<BannerAlert type="warning" fillContainer>
|
||||
<span className="font-body-default-semibold-0">{t("admin.platformLeads.sources.revealedTitle")}</span>
|
||||
<span>{t("admin.platformLeads.sources.revealedBody")}</span>
|
||||
<TextInput fillContainer>
|
||||
<TextInput.Input value={vm.revealedCredential.plaintext} readOnly aria-label={t("admin.platformLeads.fields.sourceKey")} />
|
||||
</TextInput>
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
|
||||
{vm.canAdmin ? (
|
||||
<Card>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{t("admin.platformLeads.actions.createSource")}</span>
|
||||
<form onSubmit={platformLeadFormHandler(actions.onSubmit)} className="mobile:grid-cols-1 grid w-full grid-cols-4 items-end gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="create-source" />
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.sourceKey")} fillContainer>
|
||||
<TextInput.Input name="key" required pattern="[a-z0-9]+(?:-[a-z0-9]+)*" />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.sourceName")} fillContainer>
|
||||
<TextInput.Input name="displayName" required />
|
||||
</TextInput>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.rateLimit")} fillContainer>
|
||||
<TextInput.Input name="rateLimitPerMinute" type="number" min={1} max={10000} defaultValue="60" required />
|
||||
</TextInput>
|
||||
<Button type="submit" loading={submitting} icon={<FeatherPlus />}>
|
||||
{t("admin.platformLeads.actions.createSource")}
|
||||
</Button>
|
||||
</form>
|
||||
</Card>
|
||||
) : null}
|
||||
|
||||
{vm.rows.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.empty.sourcesTitle")} body={t("admin.platformLeads.empty.sourcesBody")} />
|
||||
) : (
|
||||
vm.rows.map((source) => (
|
||||
<SourceCard
|
||||
key={source.id}
|
||||
source={source}
|
||||
assignees={vm.assigneeOptions}
|
||||
csrf={csrf}
|
||||
submitting={submitting}
|
||||
canAdmin={vm.canAdmin}
|
||||
onSubmit={actions.onSubmit}
|
||||
/>
|
||||
))
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SourceCard({
|
||||
source,
|
||||
assignees,
|
||||
csrf,
|
||||
submitting,
|
||||
canAdmin,
|
||||
onSubmit,
|
||||
}: {
|
||||
source: AdminLeadSourcesVM["rows"][number];
|
||||
assignees: readonly AdminLeadOption[];
|
||||
csrf: string;
|
||||
submitting: boolean;
|
||||
canAdmin: boolean;
|
||||
onSubmit: PlatformLeadFormAction;
|
||||
}): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
return (
|
||||
<Card>
|
||||
<div className="mobile:flex-col flex w-full items-start justify-between gap-4">
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{source.displayName}</span>
|
||||
<BadgeFeedback farbe={source.enabled ? "subtle-positive" : "subtle-neutral"}>
|
||||
{t(source.enabled ? "admin.platformLeads.sources.enabled" : "admin.platformLeads.sources.disabled")}
|
||||
</BadgeFeedback>
|
||||
</div>
|
||||
<span className="font-monospace-body text-body-small-regular-0 text-text-neutral-tertiary">{source.key}</span>
|
||||
</div>
|
||||
{canAdmin ? (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="set-enabled" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="enabled" value={source.enabled ? "false" : "true"} />
|
||||
<input type="hidden" name="reason" value={source.enabled ? "Platform lead source disabled" : "Platform lead source enabled"} />
|
||||
<Button type="submit" variant={source.enabled ? "destructive" : "secondary"} loading={submitting} icon={<FeatherSlash />}>
|
||||
{t(source.enabled ? "admin.platformLeads.actions.disable" : "admin.platformLeads.actions.enable")}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-3 gap-4">
|
||||
<Metric label={t("admin.platformLeads.sources.leadCount")} value={String(source.leadCount)} />
|
||||
<Metric label={t("admin.platformLeads.sources.activeCredentials")} value={String(source.activeCredentialCount)} />
|
||||
<Metric label={t("admin.platformLeads.fields.rateLimit")} value={String(source.rateLimitPerMinute)} />
|
||||
</div>
|
||||
{canAdmin ? (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)} className="flex w-full flex-col items-start gap-4">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="update-routing" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source routing updated" />
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-3 gap-4">
|
||||
<Select
|
||||
name="defaultAssigneeAdminUserId"
|
||||
defaultValue={source.defaultAssigneeAdminUserId ?? "unassigned"}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{assignees.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<TextInput showLabel label={t("admin.platformLeads.fields.rateLimit")} fillContainer>
|
||||
<TextInput.Input name="rateLimitPerMinute" type="number" min={1} max={10000} defaultValue={String(source.rateLimitPerMinute)} required />
|
||||
</TextInput>
|
||||
<RecipientCheckboxes options={assignees} initial={source.notifyAdminUserIds} />
|
||||
</div>
|
||||
<Button type="submit" variant="secondary" loading={submitting} icon={<FeatherSave />}>
|
||||
{t("admin.platformLeads.actions.updateRouting")}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
<div className="border-border-default w-full border-t border-solid" />
|
||||
<div className="flex w-full items-center justify-between gap-4">
|
||||
<span className="text-body-default-semibold-0 font-body-default-semibold-0 text-text-neutral-primary">
|
||||
{t("admin.platformLeads.sources.credentials")}
|
||||
</span>
|
||||
{canAdmin ? (
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="create-credential" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source credential created" />
|
||||
<Button type="submit" size="small" loading={submitting} icon={<FeatherKey />}>
|
||||
{t("admin.platformLeads.actions.createCredential")}
|
||||
</Button>
|
||||
</form>
|
||||
) : null}
|
||||
</div>
|
||||
{source.credentials.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.sources.credentials")} body={t("admin.platformLeads.empty.sourcesBody")} />
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.sources.prefix")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.sources.expiresAt")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.sources.lastUsedAt")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("shared.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell />
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{source.credentials.map((credential) => (
|
||||
<Table.Row key={credential.id}>
|
||||
<Table.Cell>{credential.keyPrefix}</Table.Cell>
|
||||
<Table.Cell>{credential.expiresAt ? formatters.dateTime(credential.expiresAt) : t("shared.notSet")}</Table.Cell>
|
||||
<Table.Cell>{credential.lastUsedAt ? formatters.dateTime(credential.lastUsedAt) : t("admin.platformLeads.sources.neverUsed")}</Table.Cell>
|
||||
<Table.Cell>
|
||||
<BadgeFeedback farbe={credential.revokedAt ? "subtle-negative" : "subtle-positive"} size="small">
|
||||
{credential.revokedAt ? t("admin.platformLeads.sources.revokedAt") : t("admin.platformLeads.sources.enabled")}
|
||||
</BadgeFeedback>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
{canAdmin && !credential.revokedAt ? (
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="rotate-credential" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="credentialId" value={credential.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source credential rotated" />
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting} icon={<FeatherRefreshCw />}>
|
||||
{t("admin.platformLeads.actions.rotateCredential")}
|
||||
</Button>
|
||||
</form>
|
||||
<form onSubmit={platformLeadFormHandler(onSubmit)}>
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="intent" value="revoke-credential" />
|
||||
<input type="hidden" name="sourceId" value={source.id} />
|
||||
<input type="hidden" name="credentialId" value={credential.id} />
|
||||
<input type="hidden" name="reason" value="Platform lead source credential revoked" />
|
||||
<Button type="submit" variant="destructive" size="small" loading={submitting}>
|
||||
{t("admin.platformLeads.actions.revokeCredential")}
|
||||
</Button>
|
||||
</form>
|
||||
</div>
|
||||
) : null}
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function RecipientCheckboxes({ options, initial }: { options: readonly AdminLeadOption[]; initial: readonly string[] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const [selected, setSelected] = useState<readonly string[]>(initial);
|
||||
return (
|
||||
<div className="flex w-full flex-col items-start gap-2">
|
||||
<span className="text-body-default-medium-0 font-body-default-medium-0 text-text-neutral-secondary">{t("admin.platformLeads.fields.notifyUsers")}</span>
|
||||
{selected.map((id) => (
|
||||
<input key={id} type="hidden" name="notifyAdminUserIds" value={id} />
|
||||
))}
|
||||
<div className="flex flex-wrap gap-3">
|
||||
{options.map((option) => (
|
||||
<Checkbox
|
||||
key={option.id}
|
||||
checked={selected.includes(option.id)}
|
||||
onCheckedChange={(checked) =>
|
||||
setSelected((current) => (checked ? [...new Set([...current, option.id])] : current.filter((id) => id !== option.id)))
|
||||
}
|
||||
label={option.label}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Metric({ label, value }: { label: string; value: string }): React.JSX.Element {
|
||||
return (
|
||||
<div className="border-border-default bg-surface-neutral-primary flex flex-col items-start gap-1 rounded-md border border-solid px-4 py-3">
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary">{label}</span>
|
||||
<span className="text-body-large-0 font-body-large-0 text-text-neutral-primary">{value}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
+299
@@ -0,0 +1,299 @@
|
||||
import { useEffect, useRef } from "react";
|
||||
import { FeatherArchive, FeatherCheckCircle, FeatherInbox, FeatherPlus, FeatherSettings, FeatherUserX } from "@subframe/core";
|
||||
import type { AdminLeadListVM, AdminLeadStatus } from "@hivegrid/view-models";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { Link } from "react-router";
|
||||
|
||||
import { useLocaleFormatters } from "~/locale/format";
|
||||
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
|
||||
import { BannerAlert } from "~/ui/components/BannerAlert";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Card } from "~/ui/components/Card";
|
||||
import { EmptyState } from "~/ui/components/EmptyState";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { StatsCard } from "~/ui/components/StatsCard";
|
||||
import { Table } from "~/ui/components/Table";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
|
||||
import { LIVE_FILTER_DEBOUNCE_MS } from "~/hooks/use-live-filter";
|
||||
|
||||
import { platformLeadFormHandler, type PlatformLeadFormAction } from "./platformLeadForm";
|
||||
|
||||
export type AdminPlatformLeadsPageProps = {
|
||||
readonly vm: AdminLeadListVM;
|
||||
readonly loading?: boolean;
|
||||
readonly actions: {
|
||||
readonly onApplyFilters: PlatformLeadFormAction;
|
||||
readonly onFirstPage: () => void;
|
||||
readonly onNew: () => void;
|
||||
readonly onNextPage: (cursor: string) => void;
|
||||
readonly onReset: () => void;
|
||||
readonly onSources: () => void;
|
||||
};
|
||||
};
|
||||
|
||||
/** R-LEADS / D-P28 S01: app-chrome-free platform lead inbox interim screen. */
|
||||
export function AdminPlatformLeadsPage({ vm, loading = false, actions }: AdminPlatformLeadsPageProps): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
const formatters = useLocaleFormatters();
|
||||
|
||||
// Live filter on the uncontrolled form: selects resubmit immediately (next
|
||||
// tick, so the hidden native select carries the fresh value), the search
|
||||
// input debounced.
|
||||
const filterFormRef = useRef<HTMLFormElement | null>(null);
|
||||
const filterDebounceRef = useRef<number | null>(null);
|
||||
useEffect(() => {
|
||||
return () => {
|
||||
if (filterDebounceRef.current) window.clearTimeout(filterDebounceRef.current);
|
||||
};
|
||||
}, []);
|
||||
function scheduleFilterSubmit(delayMs: number): void {
|
||||
if (filterDebounceRef.current) window.clearTimeout(filterDebounceRef.current);
|
||||
filterDebounceRef.current = window.setTimeout(() => filterFormRef.current?.requestSubmit(), delayMs);
|
||||
}
|
||||
|
||||
return (
|
||||
<div data-ui-id="ui.admin.platformLeads.list" className="bg-surface-neutral-primary flex w-full flex-col items-start">
|
||||
<header className="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full items-start gap-4 border-b border-solid px-6 py-5">
|
||||
<div className="flex shrink-0 grow basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.platformLeads.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{t("admin.platformLeads.description")}</p>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
{vm.permissions.canAdminSources ? (
|
||||
<Button type="button" variant="tertiary" icon={<FeatherSettings />} onClick={actions.onSources}>
|
||||
{t("admin.platformLeads.actions.sources")}
|
||||
</Button>
|
||||
) : null}
|
||||
{vm.permissions.canCreate ? (
|
||||
<Button type="button" icon={<FeatherPlus />} onClick={actions.onNew}>
|
||||
{t("admin.platformLeads.actions.new")}
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<div className="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6">
|
||||
{loading ? (
|
||||
<BannerAlert type="information" fillContainer>
|
||||
<span aria-live="polite">{t("admin.platformLeads.loading")}</span>
|
||||
</BannerAlert>
|
||||
) : null}
|
||||
<div className="mobile:grid-cols-1 grid w-full grid-cols-5 gap-4">
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.total")}
|
||||
value={vm.summary.total}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherInbox />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.new")}
|
||||
value={vm.summary.newCount}
|
||||
trend={vm.summary.newCount ? "negative" : "positive"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherInbox />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.qualified")}
|
||||
value={vm.summary.qualifiedCount}
|
||||
trend="positive"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherCheckCircle />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.unassigned")}
|
||||
value={vm.summary.unassignedCount}
|
||||
trend={vm.summary.unassignedCount ? "negative" : "positive"}
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherUserX />}
|
||||
/>
|
||||
<StatsCard
|
||||
label={t("admin.platformLeads.metrics.archived")}
|
||||
value={vm.summary.archivedCount}
|
||||
trend="neutral"
|
||||
percentage=""
|
||||
comparisonText=""
|
||||
icon={<FeatherArchive />}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<Card>
|
||||
<form ref={filterFormRef} onSubmit={platformLeadFormHandler(actions.onApplyFilters)} className="flex w-full flex-wrap items-end gap-4">
|
||||
<TextInput type="search" showLabel label={t("admin.platformLeads.fields.search")}>
|
||||
<TextInput.Input
|
||||
name="q"
|
||||
type="search"
|
||||
defaultValue={vm.filters.query}
|
||||
placeholder={t("admin.platformLeads.fields.searchPlaceholder")}
|
||||
onChange={() => scheduleFilterSubmit(LIVE_FILTER_DEBOUNCE_MS)}
|
||||
/>
|
||||
</TextInput>
|
||||
<Select
|
||||
name="status"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.status}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.status")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.status")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.all")}
|
||||
variant="filled"
|
||||
>
|
||||
<Select.Item value="all">{t("admin.platformLeads.filters.all")}</Select.Item>
|
||||
{(["new", "contacted", "qualified", "disqualified"] as const).map((status) => (
|
||||
<Select.Item key={status} value={status}>
|
||||
{t(`admin.platformLeads.status.${status}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="sourceId"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.sourceId}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.source")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.source")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.all")}
|
||||
variant="filled"
|
||||
>
|
||||
<Select.Item value="all">{t("admin.platformLeads.filters.all")}</Select.Item>
|
||||
{vm.sourceOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="assignee"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.assignedToAdminUserId}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.assignee")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.assignee")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.filters.all")}
|
||||
variant="filled"
|
||||
>
|
||||
<Select.Item value="all">{t("admin.platformLeads.filters.all")}</Select.Item>
|
||||
<Select.Item value="unassigned">{t("admin.platformLeads.filters.unassigned")}</Select.Item>
|
||||
{vm.assigneeOptions.map((option) => (
|
||||
<Select.Item key={option.id} value={option.id}>
|
||||
{option.label}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<Select
|
||||
name="archive"
|
||||
onValueChange={() => scheduleFilterSubmit(0)}
|
||||
defaultValue={vm.filters.archive}
|
||||
showLabel
|
||||
label={t("admin.platformLeads.fields.archive")}
|
||||
triggerAriaLabel={t("admin.platformLeads.fields.archive")}
|
||||
highContrastText
|
||||
placeholder={t("admin.platformLeads.archive.active")}
|
||||
variant="filled"
|
||||
>
|
||||
{(["active", "archived", "all"] as const).map((archive) => (
|
||||
<Select.Item key={archive} value={archive}>
|
||||
{t(`admin.platformLeads.archive.${archive}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button type="button" variant="ghost" onClick={actions.onReset}>
|
||||
{t("admin.platformLeads.actions.reset")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Card>
|
||||
|
||||
<Card>
|
||||
{vm.rows.length === 0 ? (
|
||||
<EmptyState outlined title={t("admin.platformLeads.empty.title")} body={t("admin.platformLeads.empty.body")} />
|
||||
) : (
|
||||
<Table
|
||||
header={
|
||||
<Table.HeaderRow>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.lead")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.source")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.status")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.assignee")}</Table.HeaderCell>
|
||||
<Table.HeaderCell>{t("admin.platformLeads.table.capturedAt")}</Table.HeaderCell>
|
||||
</Table.HeaderRow>
|
||||
}
|
||||
>
|
||||
{vm.rows.map((lead) => (
|
||||
<Table.Row key={lead.id}>
|
||||
<Table.Cell>
|
||||
<Link className="flex min-w-0 flex-col items-start" to={adminPath(`leads/${lead.id}`, { mode: "host-aware" })}>
|
||||
<span className="text-body-small-medium-0 font-body-small-medium-0 text-text-neutral-primary max-w-80 truncate">
|
||||
{lead.displayName || t("shared.notSet")}
|
||||
</span>
|
||||
<span className="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-text-neutral-tertiary max-w-80 truncate">
|
||||
{[lead.company, lead.contactLine].filter(Boolean).join(" · ") || t("shared.notSet")}
|
||||
</span>
|
||||
</Link>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">{lead.sourceDisplayName}</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<BadgeFeedback farbe={lead.statusTone} size="small">
|
||||
{t(lead.statusLabelKey)}
|
||||
</BadgeFeedback>
|
||||
{lead.archivedAt ? (
|
||||
<BadgeFeedback farbe="subtle-neutral" size="small">
|
||||
{t("admin.platformLeads.archive.archived")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
{lead.duplicateHintOfLeadId ? (
|
||||
<BadgeFeedback farbe="subtle-warning" size="small">
|
||||
{t("admin.platformLeads.detail.duplicateHint")}
|
||||
</BadgeFeedback>
|
||||
) : null}
|
||||
</div>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">
|
||||
{lead.assigneeLabel || t("admin.platformLeads.filters.unassigned")}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
<Table.Cell>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">
|
||||
{formatters.dateTime(lead.capturedAt)}
|
||||
</span>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
))}
|
||||
</Table>
|
||||
)}
|
||||
</Card>
|
||||
{vm.pagination.hasPrevious || vm.pagination.nextCursor ? (
|
||||
<nav className="flex w-full items-center justify-end gap-2" aria-label={t("admin.platformLeads.pagination.label")}>
|
||||
{vm.pagination.hasPrevious ? (
|
||||
<Button type="button" variant="ghost" onClick={actions.onFirstPage}>
|
||||
{t("admin.platformLeads.pagination.first")}
|
||||
</Button>
|
||||
) : null}
|
||||
{vm.pagination.nextCursor ? (
|
||||
<Button type="button" variant="secondary" onClick={() => actions.onNextPage(vm.pagination.nextCursor!)}>
|
||||
{t("admin.platformLeads.pagination.next")}
|
||||
</Button>
|
||||
) : null}
|
||||
</nav>
|
||||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export function isAdminLeadStatus(value: string): value is AdminLeadStatus {
|
||||
return ["new", "contacted", "qualified", "disqualified"].includes(value);
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
|
||||
|
||||
exports[`R-LEADS interim visual baseline > renders list, manual intake, detail and source administration from VM props 1`] = `"<main data-ui-id="ui.admin.platformLeads.interim.visualBaseline"><div data-ui-id="ui.admin.platformLeads.list" class="bg-surface-neutral-primary flex w-full flex-col items-start"><header class="border-border-default bg-surface-neutral-secondary mobile:px-4 flex w-full items-start gap-4 border-b border-solid px-6 py-5"><div class="flex shrink-0 grow basis-0 flex-col items-start"><h1 class="text-subtitle font-subtitle text-text-neutral-primary">admin.platformLeads.title</h1><p class="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-secondary">admin.platformLeads.description</p></div><div class="flex flex-wrap items-center justify-end gap-2"><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md px-4 py-2.5 text-left focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled border border-solid border-border-default bg-surface-neutral-primary hover:border hover:border-solid hover:border-border-strong hover:bg-surface-neutral-secondary active:bg-surface-neutral-tertiary" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled text-icon-neutral-on-subtle loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 group-disabled/3b777358:text-text-neutral-disabled text-text-neutral-primary">admin.platformLeads.actions.sources</span></button><button class="group/3b777358 flex h-9 cursor-pointer items-center justify-center gap-3 rounded-md border-none bg-brand-brand-surface-solid-default px-4 py-2.5 text-left hover:bg-brand-brand-surface-solid-hover active:bg-brand-brand-surface-solid-active focus-within:shadow-focus disabled:cursor-default disabled:bg-surface-neutral-disabled disabled:pointer-events-none hover:disabled:cursor-default hover:disabled:bg-surface-neutral-disabled active:disabled:cursor-default active:disabled:bg-surface-neutral-disabled" type="button"><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span><div class="hidden h-4 w-4 flex-none items-center justify-center gap-2"><div class="text-body-extra-small-regular-150 font-body-extra-small-regular-150 text-icon-neutral-on-solid group-disabled/3b777358:text-icon-neutral-disabled group-hover/3b777358:group-disabled/3b777358:text-icon-neutral-on-solid group-active/3b777358:group-disabled/3b777358:text-icon-neutral-disabled loader-module_root__-0Kak"></div></div><span class="whitespace-nowrap text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-on-solid group-disabled/3b777358:text-text-neutral-disabled">admin.platformLeads.actions.new</span></button></div></header><div class="mobile:px-4 flex w-full flex-col items-start gap-6 px-6 py-6"><div class="mobile:grid-cols-1 grid w-full grid-cols-5 gap-4"><div class="group/63f809c7 flex w-full cursor-pointer flex-col items-start gap-3 rounded-md border border-solid border-border-default bg-surface-neutral-primary px-4 py-4 hover:shadow-lg"><div class="flex w-full flex-col items-start gap-5"><div class="flex w-full items-center justify-between"><span class="text-body-default-regular-0 font-body-default-regular-0 text-text-neutral-secondary">admin.platformLeads.metrics.total</span><span class="text-body-default-regular-0 font-body-default-regular-0 text-icon-neutral-tertiary icon-wrapper-module_root__-l6uP"><span class="icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span></span></div><span class="text-subtitle-0 font-subtitle-0 text-text-neutral-primary">1</span><div class="flex items-center gap-1"><div class="flex items-center gap-2"><span class="hidden text-body-large-0 font-body-large-0 text-icon-feedback-negative icon-wrapper-module_root__-l6uP"><svg data-visual-icon="true"></svg></span><span class="text-body-large-0 font-body-large-0 text-icon-neutral-tertiary inline-flex icon-wrapper-module_root__-l6uP"><svg data-visLine truncated
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
import { buildAdminLeadListVM } from "@hivegrid/view-models";
|
||||
import { createInstance } from "i18next";
|
||||
import { I18nextProvider, initReactI18next } from "react-i18next";
|
||||
import { MemoryRouter } from "react-router";
|
||||
|
||||
import deTranslations from "../../../../../public/locales/de/translations.json";
|
||||
|
||||
import { AdminPlatformLeadsPage } from "./AdminPlatformLeadsPage";
|
||||
|
||||
const visualI18n = createInstance();
|
||||
void visualI18n.use(initReactI18next).init({
|
||||
lng: "de",
|
||||
fallbackLng: "de",
|
||||
defaultNS: "translation",
|
||||
resources: { de: { translation: deTranslations } },
|
||||
interpolation: { escapeValue: false },
|
||||
initImmediate: false,
|
||||
});
|
||||
|
||||
export function createPlatformLeadsInterimVisualVM() {
|
||||
return buildAdminLeadListVM({
|
||||
rows: [
|
||||
{
|
||||
id: "lead_visual_1",
|
||||
firstName: "Petra",
|
||||
lastName: "Muster",
|
||||
email: "petra@example.test",
|
||||
phone: "+49 30 123456",
|
||||
company: "Muster SHK GmbH",
|
||||
status: "new",
|
||||
sourceId: "source_hivegrid",
|
||||
sourceDisplayName: "HiveGrid Website",
|
||||
assignedToAdminUserId: "operator_haris",
|
||||
assigneeLabel: "Haris Vertrieb",
|
||||
duplicateHintOfLeadId: null,
|
||||
capturedAt: "2026-07-16T06:00:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
{
|
||||
id: "lead_visual_2",
|
||||
firstName: "Noah",
|
||||
lastName: "Geerkens",
|
||||
email: "noah@example.test",
|
||||
phone: null,
|
||||
company: "Geerkens GmbH",
|
||||
status: "qualified",
|
||||
sourceId: "source_partner",
|
||||
sourceDisplayName: "Partner-Empfehlung",
|
||||
assignedToAdminUserId: null,
|
||||
assigneeLabel: null,
|
||||
duplicateHintOfLeadId: "lead_visual_duplicate",
|
||||
capturedAt: "2026-07-15T14:30:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
],
|
||||
sourceOptions: [
|
||||
{ id: "source_hivegrid", label: "HiveGrid Website" },
|
||||
{ id: "source_partner", label: "Partner-Empfehlung" },
|
||||
],
|
||||
assigneeOptions: [{ id: "operator_haris", label: "Haris Vertrieb" }],
|
||||
filters: {
|
||||
query: "",
|
||||
status: "all",
|
||||
sourceId: "all",
|
||||
assignedToAdminUserId: "all",
|
||||
archive: "active",
|
||||
},
|
||||
summary: { total: 31, newCount: 12, qualifiedCount: 8, unassignedCount: 5, archivedCount: 3 },
|
||||
pagination: { hasPrevious: false, nextCursor: "lead_visual_next" },
|
||||
permissions: { canCreate: true, canWrite: true, canAdminSources: true },
|
||||
});
|
||||
}
|
||||
|
||||
const noOp = (): void => undefined;
|
||||
|
||||
/** Shared AD-28 fixture for the R-LEADS Chromium pixel baseline. */
|
||||
export function PlatformLeadsInterimVisualFixture(): React.JSX.Element {
|
||||
return (
|
||||
<I18nextProvider i18n={visualI18n}>
|
||||
<MemoryRouter initialEntries={["/leads"]}>
|
||||
<AdminPlatformLeadsPage
|
||||
vm={createPlatformLeadsInterimVisualVM()}
|
||||
actions={{
|
||||
onApplyFilters: noOp,
|
||||
onFirstPage: noOp,
|
||||
onNew: noOp,
|
||||
onNextPage: noOp,
|
||||
onReset: noOp,
|
||||
onSources: noOp,
|
||||
}}
|
||||
/>
|
||||
</MemoryRouter>
|
||||
</I18nextProvider>
|
||||
);
|
||||
}
|
||||
+192
@@ -0,0 +1,192 @@
|
||||
// @vitest-environment jsdom
|
||||
import "@testing-library/jest-dom/vitest";
|
||||
import { render } from "@testing-library/react";
|
||||
import { buildAdminLeadDetailVM, buildAdminLeadListVM, buildAdminLeadSourcesVM } from "@hivegrid/view-models";
|
||||
import { createMemoryRouter, RouterProvider } from "react-router";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { AdminPlatformLeadDetailPage } from "./AdminPlatformLeadDetailPage";
|
||||
import { AdminPlatformLeadNewPage } from "./AdminPlatformLeadNewPage";
|
||||
import { AdminPlatformLeadsPage } from "./AdminPlatformLeadsPage";
|
||||
import { AdminPlatformLeadSourcesPage } from "./AdminPlatformLeadSourcesPage";
|
||||
|
||||
vi.stubGlobal(
|
||||
"ResizeObserver",
|
||||
class ResizeObserverMock {
|
||||
observe() {}
|
||||
unobserve() {}
|
||||
disconnect() {}
|
||||
}
|
||||
);
|
||||
|
||||
vi.mock("react-i18next", () => ({
|
||||
useTranslation: () => ({ t: (key: string) => key, i18n: { language: "de" } }),
|
||||
}));
|
||||
|
||||
vi.mock("~/locale/format", () => ({
|
||||
useLocaleFormatters: () => ({ dateTime: (value: string | Date) => String(value) }),
|
||||
}));
|
||||
|
||||
const assignees = [{ id: "operator_haris", label: "Haris Vertrieb" }];
|
||||
const sources = [{ id: "source_hivegrid", label: "HiveGrid Website" }];
|
||||
|
||||
describe("R-LEADS interim visual baseline", () => {
|
||||
it("renders list, manual intake, detail and source administration from VM props", () => {
|
||||
const listVm = buildAdminLeadListVM({
|
||||
rows: [
|
||||
{
|
||||
id: "lead_1",
|
||||
firstName: "Petra",
|
||||
lastName: "Muster",
|
||||
email: "petra@example.test",
|
||||
phone: "+49 30 123456",
|
||||
company: "Muster SHK GmbH",
|
||||
status: "new",
|
||||
sourceId: "source_hivegrid",
|
||||
sourceDisplayName: "HiveGrid Website",
|
||||
assignedToAdminUserId: "operator_haris",
|
||||
assigneeLabel: "Haris Vertrieb",
|
||||
duplicateHintOfLeadId: null,
|
||||
capturedAt: "2026-07-16T06:00:00.000Z",
|
||||
archivedAt: null,
|
||||
},
|
||||
],
|
||||
sourceOptions: sources,
|
||||
assigneeOptions: assignees,
|
||||
permissions: { canCreate: true, canWrite: true, canAdminSources: true },
|
||||
});
|
||||
const detailVm = buildAdminLeadDetailVM({
|
||||
lead: {
|
||||
id: "lead_1",
|
||||
firstName: "Petra",
|
||||
lastName: "Muster",
|
||||
email: "petra@example.test",
|
||||
phone: "+49 30 123456",
|
||||
company: "Muster SHK GmbH",
|
||||
message: "Wir interessieren uns für HiveGrid.",
|
||||
status: "new",
|
||||
sourceId: "source_hivegrid",
|
||||
sourceDisplayName: "HiveGrid Website",
|
||||
sourceDetail: "Kontaktformular",
|
||||
externalId: "submission_1",
|
||||
assignedToAdminUserId: "operator_haris",
|
||||
assigneeLabel: "Haris Vertrieb",
|
||||
duplicateHintOfLeadId: null,
|
||||
capturedAt: "2026-07-16T06:00:00.000Z",
|
||||
createdAt: "2026-07-16T06:00:00.000Z",
|
||||
updatedAt: "2026-07-16T06:00:00.000Z",
|
||||
archivedAt: null,
|
||||
attribution: {
|
||||
utmSource: "messe",
|
||||
utmMedium: "qr",
|
||||
utmCampaign: "mhk-berlin",
|
||||
utmTerm: null,
|
||||
utmContent: null,
|
||||
referrer: "https://example.test/",
|
||||
landingPage: "https://hivegrid.de/demo",
|
||||
},
|
||||
qualification: {
|
||||
score: 70,
|
||||
scoreBand: "hot",
|
||||
scoreVersion: 1,
|
||||
enrichmentStatus: "complete",
|
||||
enrichmentProvider: "fixture",
|
||||
enrichmentData: { industry: "SHK", region: "DACH" },
|
||||
enrichedAt: "2026-07-16T06:10:00.000Z",
|
||||
},
|
||||
duplicateCandidates: [],
|
||||
conversion: { companyId: null, contactId: null, dealId: null },
|
||||
activities: [
|
||||
{
|
||||
id: "activity_1",
|
||||
type: "captured",
|
||||
actorAdminUserId: null,
|
||||
actorLabel: null,
|
||||
note: null,
|
||||
createdAt: "2026-07-16T06:00:00.000Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
assigneeOptions: assignees,
|
||||
permissions: { canWrite: true, canAssign: true, canMerge: true },
|
||||
});
|
||||
const sourceVm = buildAdminLeadSourcesVM({
|
||||
rows: [
|
||||
{
|
||||
id: "source_hivegrid",
|
||||
key: "hivegrid-website",
|
||||
displayName: "HiveGrid Website",
|
||||
enabled: true,
|
||||
defaultAssigneeAdminUserId: "operator_haris",
|
||||
defaultAssigneeLabel: "Haris Vertrieb",
|
||||
notifyAdminUserIds: ["operator_haris"],
|
||||
notifyAdminUserLabels: ["Haris Vertrieb"],
|
||||
rateLimitPerMinute: 60,
|
||||
leadCount: 30,
|
||||
credentials: [
|
||||
{
|
||||
id: "credential_1",
|
||||
keyPrefix: "hgpls_demo",
|
||||
createdAt: "2026-07-16T06:00:00.000Z",
|
||||
expiresAt: null,
|
||||
revokedAt: null,
|
||||
lastUsedAt: "2026-07-16T06:05:00.000Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
assigneeOptions: assignees,
|
||||
canAdmin: true,
|
||||
now: "2026-07-16T12:00:00.000Z",
|
||||
revealedCredential: { sourceId: "source_hivegrid", plaintext: "shown-exactly-once" },
|
||||
});
|
||||
|
||||
const router = createMemoryRouter(
|
||||
[
|
||||
{
|
||||
path: "*",
|
||||
element: (
|
||||
<main data-ui-id="ui.admin.platformLeads.interim.visualBaseline">
|
||||
<AdminPlatformLeadsPage
|
||||
vm={listVm}
|
||||
actions={{
|
||||
onApplyFilters: () => undefined,
|
||||
onFirstPage: () => undefined,
|
||||
onNew: () => undefined,
|
||||
onNextPage: () => undefined,
|
||||
onReset: () => undefined,
|
||||
onSources: () => undefined,
|
||||
}}
|
||||
/>
|
||||
<AdminPlatformLeadNewPage
|
||||
sourceOptions={sources}
|
||||
assigneeOptions={assignees}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
actions={{ onBack: () => undefined, onCreate: () => undefined }}
|
||||
/>
|
||||
<AdminPlatformLeadDetailPage
|
||||
vm={detailVm}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
actions={{ onBack: () => undefined, onSubmit: () => undefined }}
|
||||
/>
|
||||
<AdminPlatformLeadSourcesPage
|
||||
vm={sourceVm}
|
||||
csrf="csrf"
|
||||
submitting={false}
|
||||
actions={{ onBack: () => undefined, onSubmit: () => undefined }}
|
||||
/>
|
||||
</main>
|
||||
),
|
||||
},
|
||||
],
|
||||
{ initialEntries: ["/leads"] }
|
||||
);
|
||||
const { container } = render(<RouterProvider router={router} />);
|
||||
|
||||
expect(container.querySelectorAll("[data-ui-id^='ui.admin.platformLeads.']")).toHaveLength(5);
|
||||
const stableMarkup = container.innerHTML.replace(/<svg\b[^>]*>[\s\S]*?<\/svg>/gu, '<svg data-visual-icon="true"></svg>');
|
||||
expect(stableMarkup).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
import { platformLeadFormHandler } from "./platformLeadForm";
|
||||
|
||||
describe("platformLeadFormHandler", () => {
|
||||
it("hands the complete form payload to the route-owned action callback", () => {
|
||||
const action = vi.fn();
|
||||
const { container } = render(
|
||||
<form onSubmit={platformLeadFormHandler(action)}>
|
||||
<input name="intent" value="status" readOnly />
|
||||
<input name="reason" value="verified reason" readOnly />
|
||||
</form>
|
||||
);
|
||||
|
||||
const form = container.querySelector("form");
|
||||
expect(form).not.toBeNull();
|
||||
fireEvent.submit(form!);
|
||||
|
||||
expect(action).toHaveBeenCalledOnce();
|
||||
expect(Object.fromEntries((action.mock.calls[0]?.[0] as FormData).entries())).toEqual({ intent: "status", reason: "verified reason" });
|
||||
});
|
||||
});
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import type { FormEventHandler } from "react";
|
||||
|
||||
export type PlatformLeadFormAction = (input: FormData) => void;
|
||||
|
||||
/** Keeps React Router submission inside the route while screens stay presentational. */
|
||||
export function platformLeadFormHandler(action: PlatformLeadFormAction): FormEventHandler<HTMLFormElement> {
|
||||
return (event) => {
|
||||
event.preventDefault();
|
||||
action(new FormData(event.currentTarget));
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user