Files
HiveGrid-Wireframes/hivegrid-cloud/packages/mail/src/templates-react/transactional/MagicLink.tsx
T

64 lines
1.9 KiB
TypeScript

import { TransactionalScaffold } from "./shared.js";
import { InfoBox } from "../_layout/InfoBox.js";
import type { MailBrand } from "../_layout/theme.js";
/**
* MagicLink email — passwordless sign-in flow.
* Includes a short expiry-warning InfoBox plus the standard CTA.
*/
export interface MagicLinkEmailProps {
readonly brand: MailBrand;
readonly recipientName?: string;
readonly actionUrl: string;
readonly expiresInMinutes?: number;
readonly subject?: string;
readonly previewText?: string;
readonly eyebrow?: string;
readonly title?: string;
readonly intro?: string;
readonly actionLabel?: string;
readonly outro?: string;
readonly expiresText?: string;
readonly unsubscribeUrl?: string;
readonly signoffThanks?: string;
}
export function MagicLinkEmail({
brand,
recipientName,
actionUrl,
expiresInMinutes = 15,
subject,
previewText,
eyebrow,
title,
intro,
actionLabel,
outro,
expiresText,
unsubscribeUrl,
signoffThanks,
}: MagicLinkEmailProps) {
const resolvedSubject = subject ?? `Your sign-in link for ${brand.productName}`;
const resolvedTitle = title ?? (recipientName ? `Hello, ${recipientName}!` : "Hello!");
return (
<TransactionalScaffold
brand={brand}
subject={resolvedSubject}
previewText={previewText ?? `Click to sign in to ${brand.productName}`}
eyebrow={eyebrow ?? "Magic link"}
title={resolvedTitle}
intro={intro ?? `Click the button below to sign in to your ${brand.productName} account. No password required.`}
actionUrl={actionUrl}
actionLabel={actionLabel ?? "Sign in"}
outro={outro ?? "If you didn't request this email, you can safely ignore it."}
unsubscribeUrl={unsubscribeUrl}
signoffThanks={signoffThanks}
>
<InfoBox brand={brand} tone="warning">
{expiresText ?? `This link expires in ${expiresInMinutes} minutes and can only be used once.`}
</InfoBox>
</TransactionalScaffold>
);
}