import { FC } from "react";
import { useFormContext } from "react-hook-form";
import { Datepicker, InputField, Select } from "../forms/Inputs";
import { TSclientSchema } from "../forms/schema/client";

type props = {
  client: TSclientSchema;
};

const ConnectivityForm: FC<props> = ({ client }) => {
  const {
    setValue,
    formState: { errors },
  } = useFormContext();

  return (
    <div className="grid grid-cols-1 gap-6 sm:grid-cols-2">
      <div className="left">
        <div className="mt-1">
          <Select
            defaultValue={1}
            options={[
              { value: 1, label: "UTP" },
              { value: 2, label: "FIBER" },
            ]}
            labelText="Cable Type"
            name="cable_type"
            errors={errors}
          />
        </div>
        <div className="mt-1">
          <InputField
            labelText="Require Cable"
            name="cable_length"
            placeholder="ex: 200ft"
            errors={errors}
          />
        </div>
        <div className="mt-1">
          <Select
            defaultValue={1}
            options={[
              { value: 1, label: "Active" },
              { value: 0, label: "Inactive" },
            ]}
            labelText="Connection Mode"
            name="connection_mode"
            errors={errors}
          />
        </div>
        <div className="mt-1">
          <InputField
            labelText="MAC Address"
            name="mac_address"
            placeholder="MAC Address"
            errors={errors}
          />
        </div>
      </div>
      <div className="right">
        <div className="mt-1">
          <Select
            defaultValue={1}
            options={[
              { value: 1, label: "Home" },
              { value: 2, label: "Corporate" },
              { value: 3, label: "Others" },
            ]}
            labelText="Client Type"
            name="type"
            errors={errors}
          />
        </div>
        <div className="mt-2">
          <Select
            defaultValue={1}
            options={[
              { value: 1, label: "Shared" },
              { value: 2, label: "Dedicated" },
            ]}
            labelText="Connectivity Type"
            name="connection_type"
            errors={errors}
          />
        </div>
        <div className="mt-1">
          <Datepicker
            name="termination_date"
            labelText="Termination Date"
            defaultDate={client?.termination_date}
          />
        </div>
      </div>
    </div>
  );
};

export default ConnectivityForm;
