'use client'; /* IMPORT */ import { ArrowLeft, Edit, List, Settings } from 'lucide-react'; import { Badge } from '@/components/ui/badge'; import { Button } from '@/components/ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle, } from '@/components/ui/card'; import { getCategoryDisplayName } from '../validations'; import Link from 'next/link'; import { Separator } from '@/components/ui/separator'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { TemplateContentEditor } from './template-content-editor'; import { TemplateSettings } from './template-settings'; import { TemplateVariableManager } from './template-variable-manager'; import { type TemplateWithVariables } from '@/db/schema'; import { useState } from 'react'; // ---------------------------------------------------------------------------------------------------- /* TYPES */ interface TemplateEditorProps { templateSlug: string; initialTemplate: TemplateWithVariables; } export function TemplateEditor({ templateSlug, initialTemplate }: TemplateEditorProps) { const [template, setTemplate] = useState(initialTemplate); return (
{/* 헤더 */}

{template.name}

v{template.version} {template.category && ( {getCategoryDisplayName(template.category)} )}

{template.description || '템플릿 편집'}

{/* 헤더 액션 버튼들 */} {/*
*/}
{/* 메인 편집 영역 - 3개 탭으로 간소화 */} 편집 & 미리보기 변수 관리 설정 {/* 편집 & 미리보기 탭 (통합) */} 템플릿 편집 & 미리보기 왼쪽에서 이메일 제목과 내용을 편집하고, 오른쪽에서 실시간 미리보기를 확인하세요. {/* 변수 관리 탭 */} 변수 관리 템플릿에서 사용할 변수를 추가하고 관리하세요. 추가되는 변수는 실제 코드에서 정의가 되어있지 않으면 템플릿에 있더라도 나타나지 않습니다. {/* 설정 탭 */} 템플릿 설정 템플릿의 기본 정보와 설정을 관리하세요. {/* 추가 정보 */}

💡 편집 팁

  • • 자동 미리보기를 켜두면 편집하면서 바로 확인 가능
  • • 변수 배지를 클릭하면 커서 위치에 바로 삽입
  • • Ctrl+S로 빠른 저장

📊 템플릿 상태

  • • 변수: {template.variables.length}개
  • • 필수 변수: {template.variables.filter(v => v.isRequired).length}개
  • • 최종 수정: {new Date(template.updatedAt).toLocaleDateString('ko-KR')}

🚀 다음 단계

  • • 변수 관리에서 필요한 변수 추가
  • • 설정에서 카테고리 및 설명 수정
) }