import React from 'react';
import { Modal, Form } from 'antd';
import { TeamForm } from './TeamForm';

const CreateTeamModal = ({ open, onCancel, onSubmit, confirmLoading }) => {
  const [form] = Form.useForm();

  const handleSubmit = async () => {
    try {
      const values = await form.validateFields();
      await onSubmit(values);
      form.resetFields();
    } catch (error) {
      console.error('Validation failed:', error);
    }
  };

  return (
    <Modal
      title="新增团队"
      open={open}
      onCancel={onCancel}
      onOk={handleSubmit}
      confirmLoading={confirmLoading}
      width={600}
    >
      <TeamForm form={form} />
    </Modal>
  );
};

export default CreateTeamModal;