63 lines
2.3 KiB
TypeScript
63 lines
2.3 KiB
TypeScript
import { buildComposePrefill, buildEmailComposeVM, type EmailComposeVM } from "@hivegrid/view-models";
|
|
|
|
import { EmailComposePage } from "./EmailComposePage";
|
|
|
|
export const EMAIL_COMPOSE_INTERIM_VISUAL_SCREENS = ["blank", "reply", "no-mailbox"] as const;
|
|
|
|
export type EmailComposeInterimVisualScreen = (typeof EMAIL_COMPOSE_INTERIM_VISUAL_SCREENS)[number];
|
|
|
|
const MAILBOXES = [
|
|
{ id: "mailbox-1", emailAddress: "info@handwerk.test", provider: "gmail" as const, isDefaultForUser: true },
|
|
{ id: "mailbox-2", emailAddress: "office@handwerk.test", provider: "microsoft" as const, isDefaultForUser: false },
|
|
];
|
|
|
|
const TEMPLATES = [
|
|
{ id: "tpl-1", name: "Angebot Nachfassen", subject: "Ihr Angebot", htmlBody: "<p>Guten Tag, haben Sie unser Angebot erhalten?</p>" },
|
|
];
|
|
|
|
/** The original stays far in the past so the quoted block (which carries the
|
|
* ISO timestamp) never depends on the test run date. */
|
|
const ORIGINAL = {
|
|
id: "msg-1",
|
|
direction: "inbound" as const,
|
|
fromAddress: "erika@example.test",
|
|
fromName: "Erika Beispiel",
|
|
toSummary: "info@handwerk.test",
|
|
subject: "Angebot für Projekt Nordlicht",
|
|
sentAtIso: "2020-01-03T09:30:00.000Z",
|
|
safeBodyHtml: "<p>Vielen Dank, wir prüfen das Angebot.</p>",
|
|
};
|
|
|
|
export function createEmailComposeInterimVisualVMs(): Record<EmailComposeInterimVisualScreen, EmailComposeVM> {
|
|
const base = {
|
|
mailboxes: MAILBOXES,
|
|
defaultMailboxId: "mailbox-1",
|
|
templates: TEMPLATES,
|
|
backHref: "/acme/emails",
|
|
};
|
|
|
|
return {
|
|
blank: buildEmailComposeVM({ ...base, prefill: buildComposePrefill({ mode: "blank", original: null }) }),
|
|
reply: buildEmailComposeVM({
|
|
...base,
|
|
backHref: "/acme/emails/msg-1",
|
|
prefill: buildComposePrefill({ mode: "reply", original: ORIGINAL }),
|
|
}),
|
|
"no-mailbox": buildEmailComposeVM({
|
|
...base,
|
|
mailboxes: [],
|
|
defaultMailboxId: null,
|
|
templates: [],
|
|
prefill: buildComposePrefill({ mode: "blank", original: null }),
|
|
}),
|
|
};
|
|
}
|
|
|
|
const noOp = (): void => undefined;
|
|
|
|
/** Shared ready-state fixture for the AK-UI-03 interim markup baseline. */
|
|
export function EmailComposeInterimVisualFixture({ screen }: { screen: EmailComposeInterimVisualScreen }): React.JSX.Element {
|
|
const vms = createEmailComposeInterimVisualVMs();
|
|
return <EmailComposePage vm={vms[screen]} actions={{ onSend: noOp, onBack: noOp, onOpenSettings: noOp }} />;
|
|
}
|