From ffae41237e55d24e649ded870ef9abdac47514e6 Mon Sep 17 00:00:00 2001 From: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Date: Wed, 15 Apr 2026 08:24:48 +0200 Subject: [PATCH] refactor(admin): split email-templates page.tsx into colocated components Extract tabs nav, templates grid, editor split view, settings form, logs table, and data-loading/actions hook into _components/ and _hooks/. page.tsx reduced from 816 to 88 LOC. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../email-templates/_components/EditorTab.tsx | 131 +++ .../email-templates/_components/LogsTab.tsx | 55 ++ .../_components/SettingsTab.tsx | 143 ++++ .../email-templates/_components/TabNav.tsx | 43 + .../_components/TemplateCard.tsx | 49 ++ .../_components/TemplatesTab.tsx | 64 ++ .../_hooks/useEmailTemplates.ts | 227 +++++ .../app/sdk/email-templates/_types.ts | 84 ++ .../app/sdk/email-templates/page.tsx | 776 +----------------- 9 files changed, 820 insertions(+), 752 deletions(-) create mode 100644 admin-compliance/app/sdk/email-templates/_components/EditorTab.tsx create mode 100644 admin-compliance/app/sdk/email-templates/_components/LogsTab.tsx create mode 100644 admin-compliance/app/sdk/email-templates/_components/SettingsTab.tsx create mode 100644 admin-compliance/app/sdk/email-templates/_components/TabNav.tsx create mode 100644 admin-compliance/app/sdk/email-templates/_components/TemplateCard.tsx create mode 100644 admin-compliance/app/sdk/email-templates/_components/TemplatesTab.tsx create mode 100644 admin-compliance/app/sdk/email-templates/_hooks/useEmailTemplates.ts create mode 100644 admin-compliance/app/sdk/email-templates/_types.ts diff --git a/admin-compliance/app/sdk/email-templates/_components/EditorTab.tsx b/admin-compliance/app/sdk/email-templates/_components/EditorTab.tsx new file mode 100644 index 0000000..441d0cc --- /dev/null +++ b/admin-compliance/app/sdk/email-templates/_components/EditorTab.tsx @@ -0,0 +1,131 @@ +'use client' + +import { CATEGORIES, EmailTemplate, STATUS_BADGE, TemplateVersion } from '../_types' + +interface EditorTabProps { + template: EmailTemplate | null + version: TemplateVersion | null + subject: string + html: string + previewHtml: string | null + saving: boolean + onSubjectChange: (v: string) => void + onHtmlChange: (v: string) => void + onSave: () => void + onPublish: () => void + onPreview: () => void + onBack: () => void +} + +export function EditorTab({ + template, version, subject, html, previewHtml, saving, + onSubjectChange, onHtmlChange, onSave, onPublish, onPreview, onBack, +}: EditorTabProps) { + if (!template) { + return ( +
+ Waehlen Sie ein Template aus der Liste. +
+ +
+ ) + } + + const cat = CATEGORIES[template.category] || CATEGORIES.general + + return ( +
+
+
+ +

{template.name}

+ {cat.label} + {version && ( + + {(STATUS_BADGE[version.status] || STATUS_BADGE.draft).label} + + )} +
+
+ + {version && version.status !== 'published' && ( + + )} + {version && ( + + )} +
+
+ + {/* Variables */} +
+ Variablen: + {(template.variables || []).map(v => ( + + ))} +
+ + {/* Split View */} +
+ {/* Editor */} +
+
+ + onSubjectChange(e.target.value)} + className="w-full px-3 py-2 border border-gray-300 rounded-lg text-sm focus:ring-2 focus:ring-purple-500 focus:border-transparent" + placeholder="E-Mail Betreff..." + /> +
+
+ +