diff --git a/src/components/admin/EmailTemplatePreview.tsx b/src/components/admin/EmailTemplatePreview.tsx index 59035e3..25aa838 100644 --- a/src/components/admin/EmailTemplatePreview.tsx +++ b/src/components/admin/EmailTemplatePreview.tsx @@ -3,8 +3,16 @@ import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Alert, AlertDescription } from '@/components/ui/alert'; +import { + Dialog, + DialogContent, + DialogHeader, + DialogTitle, + DialogDescription, + DialogFooter, +} from '@/components/ui/dialog'; import { toast } from '@/hooks/use-toast'; -import { Eye, Send, Mail } from 'lucide-react'; +import { Eye, Send, Mail, X } from 'lucide-react'; import { EmailTemplateRenderer, ShortcodeProcessor } from '@/lib/email-templates/master-template'; interface NotificationTemplate { @@ -22,9 +30,17 @@ interface EmailTemplatePreviewProps { template: NotificationTemplate; onTest?: (template: NotificationTemplate) => void; isTestSending?: boolean; + open: boolean; + onClose: () => void; } -export function EmailTemplatePreview({ template, onTest, isTestSending = false }: EmailTemplatePreviewProps) { +export function EmailTemplatePreview({ + template, + onTest, + isTestSending = false, + open, + onClose +}: EmailTemplatePreviewProps) { const [previewMode, setPreviewMode] = useState<'master' | 'content'>('master'); const [testEmail, setTestEmail] = useState(''); const [showTestForm, setShowTestForm] = useState(false); @@ -60,109 +76,154 @@ export function EmailTemplatePreview({ template, onTest, isTestSending = false } const previewHtml = generatePreview(); return ( -
- {/* Preview Controls */} -
-
- - -
- -
+ + + + + + Preview: {template.name} + + + Preview template email dengan master styling + -
-
+ - {/* Test Email Form */} - {showTestForm && ( -
-
- -
- setTestEmail(e.target.value)} - placeholder="test@example.com" - className="flex-1" - /> -
-

- This will send a test email with dummy data for all available shortcodes. -

-
- )} - {/* Preview Info */} - - - - {previewMode === 'master' - ? 'Showing complete email template with header, footer, and styling applied.' - : 'Showing only the content section without master template styling.' - } - - + {/* Test Email Form */} + {showTestForm && ( +
+
+ +
+ setTestEmail(e.target.value)} + placeholder="test@example.com" + className="flex-1" + /> + +
+

+ This will send a test email with dummy data for all available shortcodes. +

+
+
+ )} - {/* Email Preview */} -
-
- - {previewMode === 'master' ? 'Full Email Preview' : 'Content Preview'} - -
-
-