/**
 * 邮件模板配置表单
 */
import React from 'react';
import { Label } from '@/components/ui/label';
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
import type { TemplateConfigComponentProps } from '../template-config-strategies/types';

export const EmailTemplateConfigForm: React.FC<TemplateConfigComponentProps> = ({
  register,
  errors,
  setValue,
  configState,
}) => {
  const currentContentType = configState?.contentType || 'TEXT';
  const currentPriority = configState?.priority || 'NORMAL';
  
  return (
    <div className="space-y-4">
      <div>
        <Label htmlFor="contentType">内容类型</Label>
        <Select
          value={currentContentType}
          onValueChange={(value) => setValue('templateConfig.contentType', value)}
        >
          <SelectTrigger>
            <SelectValue placeholder="选择内容类型" />
          </SelectTrigger>
          <SelectContent>
            <SelectItem value="TEXT">纯文本</SelectItem>
            <SelectItem value="HTML">HTML格式</SelectItem>
          </SelectContent>
        </Select>
        {errors?.templateConfig?.contentType && (
          <p className="text-sm text-destructive mt-1">
            {errors.templateConfig.contentType.message}
          </p>
        )}
      </div>

      <div>
        <Label htmlFor="priority">优先级</Label>
        <Select
          value={currentPriority}
          onValueChange={(value) => setValue('templateConfig.priority', value)}
        >
          <SelectTrigger>
            <SelectValue placeholder="选择优先级" />
          </SelectTrigger>
          <SelectContent>
            <SelectItem value="LOW">低</SelectItem>
            <SelectItem value="NORMAL">普通</SelectItem>
            <SelectItem value="HIGH">高</SelectItem>
          </SelectContent>
        </Select>
        {errors?.templateConfig?.priority && (
          <p className="text-sm text-destructive mt-1">
            {errors.templateConfig.priority.message}
          </p>
        )}
      </div>
    </div>
  );
};
