/**
 * 模板配置表单工厂
 */
import React from 'react';
import { NotificationChannelType } from '../../../../NotificationChannel/List/types';
import type { TemplateConfigComponentProps } from '../template-config-strategies/types';
import { WeworkTemplateConfigForm } from './WeworkTemplateConfigForm';
import { EmailTemplateConfigForm } from './EmailTemplateConfigForm';

export class TemplateConfigFormFactory {
  static createConfigForm(
    type: NotificationChannelType,
    props: TemplateConfigComponentProps
  ): React.ReactElement | null {
    switch (type) {
      case NotificationChannelType.WEWORK:
        return <WeworkTemplateConfigForm {...props} />;
      
      case NotificationChannelType.EMAIL:
        return <EmailTemplateConfigForm {...props} />;
      
      default:
        return null;
    }
  }

  static getSupportedTypes(): NotificationChannelType[] {
    return [
      NotificationChannelType.WEWORK,
      NotificationChannelType.EMAIL,
    ];
  }

  static getDefaultConfig(type: NotificationChannelType): any {
    switch (type) {
      case NotificationChannelType.WEWORK:
        return { channelType: NotificationChannelType.WEWORK, messageType: 'TEXT' };
      
      case NotificationChannelType.EMAIL:
        return { channelType: NotificationChannelType.EMAIL, contentType: 'TEXT', priority: 'NORMAL' };
      
      default:
        return {};
    }
  }
}
