| 1 |
import React from "react"; |
| 2 |
import { Eye, Mail } from "lucide-react"; |
| 3 |
import { Button } from "../ui/button"; |
| 4 |
import { Modal } from "../ui/modal"; |
| 5 |
import { __ } from "../../lib/i18n"; |
| 6 |
|
| 7 |
export type EmailPreviewModalProps = { |
| 8 |
open: boolean; |
| 9 |
onClose: () => void; |
| 10 |
subject: string; |
| 11 |
body: string; |
| 12 |
}; |
| 13 |
|
| 14 |
/** |
| 15 |
* Email preview: subject + HTML body in an iframe. |
| 16 |
* Uses the shared Yatra modal shell: {@link Modal} from `components/ui/modal` (`yatra-model-ui`). |
| 17 |
*/ |
| 18 |
export const EmailPreviewModal: React.FC<EmailPreviewModalProps> = ({ |
| 19 |
open, |
| 20 |
onClose, |
| 21 |
subject, |
| 22 |
body, |
| 23 |
}) => ( |
| 24 |
<Modal |
| 25 |
isOpen={open} |
| 26 |
onClose={onClose} |
| 27 |
title={ |
| 28 |
<span className="flex items-center gap-3"> |
| 29 |
<span |
| 30 |
className="flex h-10 w-10 flex-shrink-0 items-center justify-center rounded-full bg-blue-100 dark:bg-blue-900/30" |
| 31 |
aria-hidden |
| 32 |
> |
| 33 |
<Eye className="h-5 w-5 text-blue-600 dark:text-blue-400" /> |
| 34 |
</span> |
| 35 |
<span>{__("Email Preview", "yatra")}</span> |
| 36 |
</span> |
| 37 |
} |
| 38 |
description={__("Preview with sample data", "yatra")} |
| 39 |
maxWidthClassName="max-w-6xl w-[95vw]" |
| 40 |
panelClassName="yatra-model-ui flex flex-col max-h-[90vh]" |
| 41 |
bodyClassName="flex flex-1 min-h-0 flex-col px-0 py-0" |
| 42 |
bodyScrollClassName="flex min-h-0 flex-1 flex-col overflow-hidden" |
| 43 |
footer={ |
| 44 |
<div className="flex w-full justify-end"> |
| 45 |
<Button variant="outline" onClick={onClose} type="button"> |
| 46 |
{__("Close", "yatra")} |
| 47 |
</Button> |
| 48 |
</div> |
| 49 |
} |
| 50 |
> |
| 51 |
<div className="flex min-h-0 flex-1 flex-col"> |
| 52 |
<div className="flex-shrink-0 border-b border-gray-200 bg-white px-6 py-4 dark:border-gray-700 dark:bg-gray-900"> |
| 53 |
<div className="mb-1 flex items-center gap-2"> |
| 54 |
<Mail className="h-4 w-4 text-gray-400" aria-hidden /> |
| 55 |
<span className="text-xs font-medium uppercase tracking-wide text-gray-500 dark:text-gray-400"> |
| 56 |
{__("Subject", "yatra")} |
| 57 |
</span> |
| 58 |
</div> |
| 59 |
<p className="text-base font-medium text-gray-900 dark:text-white"> |
| 60 |
{subject} |
| 61 |
</p> |
| 62 |
</div> |
| 63 |
|
| 64 |
<div className="min-h-0 flex-1 bg-gray-100 px-6 py-4 dark:bg-gray-950"> |
| 65 |
<div className="flex h-full min-h-[min(500px,50vh)] flex-col overflow-hidden rounded-lg border border-gray-200 bg-white shadow-sm"> |
| 66 |
<iframe |
| 67 |
srcDoc={body} |
| 68 |
className="min-h-[min(500px,50vh)] w-full flex-1 border-0" |
| 69 |
title={__("Email Preview", "yatra")} |
| 70 |
sandbox="allow-same-origin" |
| 71 |
/> |
| 72 |
</div> |
| 73 |
</div> |
| 74 |
</div> |
| 75 |
</Modal> |
| 76 |
); |
| 77 |
|
| 78 |
export default EmailPreviewModal; |
| 79 |
|