import axios from "axios";
import { Button, Card, Form } from "react-bootstrap";

const UpdateEmployee = () => {
  const handleUpdateEmployee = async (
    event: React.FormEvent<HTMLFormElement>
  ) => {
    event.preventDefault();
    const data = new FormData(event.currentTarget);
    let emp_id = data.get("emp_id");
    let name = data.get("name");
    let email = data.get("email");
    let password = data.get("password");
    console.log(emp_id, name, email, password);
    const response: any = await axios.post(
      `/api/user/create_emp?emp_id=${emp_id}&name=${name}&email=${email}&password=${password}`
    );
    console.log("response: ", response.data);
  };
  return (
    <>
      <Card className="my-2">
        <Card.Body>
          <Form className="p-3" onSubmit={handleUpdateEmployee}>
            <div className="my-3 text-center">
              <h5>Create Account</h5>
              <h6>Fill the details to create an account</h6>
            </div>
            <Form.Group className="mb-3">
              <Form.Label>Employee ID</Form.Label>
              <Form.Control type="text" name="emp_id" placeholder="Enter EID" />
            </Form.Group>

            <Form.Group className="mb-3">
              <Form.Label>Name</Form.Label>
              <Form.Control type="text" name="name" placeholder="Enter Name" />
            </Form.Group>

            <Form.Group className="mb-3">
              <Form.Label>Email</Form.Label>
              <Form.Control
                type="email"
                name="email"
                placeholder="Enter Email"
              />
            </Form.Group>

            <Form.Group className="mb-3">
              <Form.Label>Password</Form.Label>
              <Form.Control
                type="password"
                name="password"
                placeholder="Password"
              />
            </Form.Group>

            <Form.Group className="mb-3">
              <Form.Label>Confirm Password</Form.Label>
              <Form.Control type="password" placeholder="Confirm Password" />
            </Form.Group>

            <Button
              variant="outline-dark"
              size="lg"
              className="w-100"
              type="submit"
            >
              Submit
            </Button>
          </Form>
        </Card.Body>
      </Card>
    </>
  );
};

export default UpdateEmployee;
