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
+113
@@ -0,0 +1,113 @@
|
||||
// R-P7 Interim-UI (AD-28) — "Neuer Lead" as a modal on the lead inbox, mirroring
|
||||
// the automation list pattern ("Neue Automation starten"). Presentational only: the
|
||||
// form posts to the create route (`createHref`) with the same field contract as the
|
||||
// standalone LeadNewPage, so the route action stays untouched. No useLoaderData /
|
||||
// useFetcher (DoD A.5). Final Subframe optics = tracked design-nachzug.
|
||||
|
||||
import { useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import { FeatherPlus, FeatherX } from "@subframe/core";
|
||||
import type { LeadQuelle } from "~/utils/integrations/leads/leadListQuery";
|
||||
import { Button } from "~/ui/components/Button";
|
||||
import { Dialog } from "~/ui/components/Dialog";
|
||||
import { IconButton } from "~/ui/components/IconButton";
|
||||
import { Select } from "~/ui/components/Select";
|
||||
import { TextArea } from "~/ui/components/TextArea";
|
||||
import { TextInput } from "~/ui/components/TextInput";
|
||||
|
||||
const QUELLEN: readonly LeadQuelle[] = ["form", "email", "aircall", "manual", "custom"];
|
||||
|
||||
export type LeadNewDialogProps = {
|
||||
open: boolean;
|
||||
onOpenChange: (open: boolean) => void;
|
||||
/** Route that owns the create action (the standalone /leads/new route). */
|
||||
createHref: string;
|
||||
};
|
||||
|
||||
export function LeadNewDialog({ open, onOpenChange, createHref }: LeadNewDialogProps) {
|
||||
const { t } = useTranslation();
|
||||
const [quelle, setQuelle] = useState<string>("manual");
|
||||
// A lead needs at least one identifying detail — same rule as the standalone page.
|
||||
const [hasIdentity, setHasIdentity] = useState(false);
|
||||
|
||||
function checkIdentity(event: React.FormEvent<HTMLFormElement>) {
|
||||
const form = event.currentTarget;
|
||||
const filled = ["vorname", "nachname", "email", "telefon", "message"].some((name) => {
|
||||
const field = form.elements.namedItem(name);
|
||||
return field instanceof HTMLInputElement || field instanceof HTMLTextAreaElement ? field.value.trim().length > 0 : false;
|
||||
});
|
||||
setHasIdentity(filled);
|
||||
}
|
||||
|
||||
return (
|
||||
<Dialog open={open} onOpenChange={onOpenChange}>
|
||||
<Dialog.Content className="w-[560px] max-w-[92vw] p-0">
|
||||
<form method="post" action={createHref} className="flex w-full flex-col" onInput={checkIdentity} data-ui-id="ui.leads.new.dialog">
|
||||
<div className="flex w-full items-start justify-between gap-3 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex flex-col items-start gap-1">
|
||||
<span className="text-heading- font-heading- text-text-neutral-primary">{t("leads.new.title")}</span>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("leads.new.subtitle")}</span>
|
||||
</div>
|
||||
<IconButton
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="small"
|
||||
icon={<FeatherX />}
|
||||
aria-label={t("shared.cancel")}
|
||||
onClick={() => onOpenChange(false)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full flex-col gap-4 px-6 py-5 max-h-[65vh] overflow-y-auto mobile:px-4">
|
||||
<Select
|
||||
className="max-w-[240px]"
|
||||
name="quelle"
|
||||
label={t("leads.field.quelle")}
|
||||
showLabel
|
||||
value={quelle}
|
||||
onValueChange={(value: string) => setQuelle(value)}
|
||||
>
|
||||
{QUELLEN.map((q) => (
|
||||
<Select.Item key={q} value={q}>
|
||||
{t(`leads.quelle.${q}`)}
|
||||
</Select.Item>
|
||||
))}
|
||||
</Select>
|
||||
<div className="grid w-full gap-4 sm:grid-cols-2">
|
||||
<TextInput label={t("leads.field.vorname")} showLabel>
|
||||
<TextInput.Input name="vorname" autoFocus data-ui-id="ui.leads.new.dialog.vorname" />
|
||||
</TextInput>
|
||||
<TextInput label={t("leads.field.nachname")} showLabel>
|
||||
<TextInput.Input name="nachname" />
|
||||
</TextInput>
|
||||
<TextInput label={t("leads.field.email")} showLabel>
|
||||
<TextInput.Input name="email" type="email" data-ui-id="ui.leads.new.dialog.email" />
|
||||
</TextInput>
|
||||
<TextInput label={t("leads.field.telefon")} showLabel>
|
||||
<TextInput.Input name="telefon" />
|
||||
</TextInput>
|
||||
</div>
|
||||
<TextArea label={t("leads.field.message")} showLabel className="max-w-none">
|
||||
<TextArea.Input name="message" />
|
||||
</TextArea>
|
||||
</div>
|
||||
|
||||
<div className="flex w-full items-center justify-end gap-2 border-t border-solid border-border-default bg-surface-neutral-secondary px-6 py-4 mobile:flex-col-reverse mobile:items-stretch mobile:px-4">
|
||||
<Button
|
||||
type="button"
|
||||
className="mobile:w-full"
|
||||
variant="tertiary"
|
||||
onClick={() => onOpenChange(false)}
|
||||
data-ui-id="ui.leads.new.dialog.cancel"
|
||||
>
|
||||
{t("shared.cancel")}
|
||||
</Button>
|
||||
<Button type="submit" className="mobile:w-full" icon={<FeatherPlus />} disabled={!hasIdentity} data-ui-id="ui.leads.new.dialog.submit">
|
||||
{t("leads.actions.create")}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</Dialog.Content>
|
||||
</Dialog>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user