import React from 'react';
import { Form, Input, Row, Col, Typography, Switch } from 'antd';

const { Text } = Typography;

const BrandForm = ({ form, formData, onValuesChange, isEdit = false }) => {
    return (
        <Form
            layout="vertical"
            form={form}
            onValuesChange={onValuesChange}
            initialValues={formData}
        >
            <Form.Item label="Status">
                <div style={{ display: 'flex', alignItems: 'center' }}>
                    <Form.Item name="is_active" valuePropName="checked" noStyle>
                        <Switch
                            checked={formData.is_active}
                            style={{ backgroundColor: formData.is_active ? '#23A55A' : '#bfbfbf' }}
                        />
                    </Form.Item>
                    <Text style={{ marginLeft: 8 }}>
                        {formData.is_active ? 'Running' : 'Offline'}
                    </Text>
                </div>
            </Form.Item>

            <Form.Item label="Brand Code" name="brand_code">
                <Input
                    placeholder={isEdit ? 'Brand Code Auto Fill' : 'Brand Code'}
                    disabled={isEdit}
                    style={{
                        backgroundColor: isEdit ? '#f5f5f5' : 'white',
                        cursor: isEdit ? 'not-allowed' : 'text'
                    }}
                />
            </Form.Item>

            <Row gutter={16}>
                <Col span={12}>
                    <Form.Item
                        label="Brand Name"
                        name="brand_name"
                        rules={[{ required: true, message: 'Brand Name wajib diisi!' }]}
                    >
                        <Input />
                    </Form.Item>
                </Col>
                <Col span={12}>
                    <Form.Item
                        label="Manufacturer"
                        name="brand_manufacture"
                        rules={[{ required: true, message: 'Manufacturer wajib diisi!' }]}
                    >
                        <Input placeholder="Enter Manufacturer" />
                    </Form.Item>
                </Col>
            </Row>

            <Row gutter={16}>
                <Col span={12}>
                    <Form.Item label="Brand Type" name="brand_type">
                        <Input placeholder="Enter Brand Type (Optional)" />
                    </Form.Item>
                </Col>
                <Col span={12}>
                    <Form.Item label="Model" name="brand_model">
                        <Input placeholder="Enter Model (Optional)" />
                    </Form.Item>
                </Col>
            </Row>
        </Form>
    );
};

export default BrandForm;