// pages/admin/categories/index.js
import { useState, useEffect } from "react";
import AdminLayout from "../../../components/layout/AdminLayout";
import { Row, Col, Typography, Form, Input, Button, Layout } from "antd";
import { EditOutlined } from "@ant-design/icons";

const { Content } = Layout;
const { Title } = Typography;

const Categories = () => {
  const [loading, setLoading] = useState(false);

  const onFinish = async (values) => {
    try {
      setLoading(true);
      setTimeout(() => {
        console.log(values);
        setLoading(false);
      }, 1000);
    } catch (err) {
      console.log(err);
      setLoading(false);
    }
  };

  return (
    <AdminLayout>
      <Row>
        <Col>
          <Title level={4}>Categories</Title>

          <Form onFinish={onFinish}>
            <Form.Item
              name="name"
              rules={[
                {
                  required: true,
                  message: "Please give it a name!",
                },
              ]}
              hasFeedback
            >
              <Input prefix={<EditOutlined />} placeholder="Name" />
            </Form.Item>

            <Form.Item>
              <Button type="primary" htmlType="submit" loading={loading}>
                Create
              </Button>
            </Form.Item>
          </Form>
        </Col>
      </Row>
    </AdminLayout>
  );
};

export default Categories;