import Table from "./TablePage";
import SearchField from "../../../../../Components/DataTable/SearchField";
import { useLocation, useNavigate } from "react-router-dom";
import EditHomeWorkModel from "./Model/EditModel";
import AddHomeWorkModel from "./Model/AddModel";
import DeleteHomeWorkModel from "./Model/Delete";

import type { DatePickerProps } from "antd";
import { DatePicker } from "antd";
import dayjs from "dayjs";
import { useObjectToEdit } from "../../../../../zustand/ObjectToEditState";
import { useTranslation } from "react-i18next";
import CustomDatePicker from "../../../../../Components/Ui/Custom/CustomDatePicker";

const TableHeader = () => {
  const { set_param_to_send, param_to_send } = useObjectToEdit();
  const navigate = useNavigate();
  const location = useLocation();

  const onChange: DatePickerProps["onChange"] = (date, dateString) => {
    const newObj = { ...param_to_send };
    newObj.date = dateString;
    set_param_to_send(newObj);
    navigate(
      `${location.pathname}?${param_to_send?.state ?? "all"}=${dateString}`,
    );
  };

  const Today = new Date() as any;
  const [t] = useTranslation();
  return (
    <div className="TableWithHeader">
      <header>
        <h6>{t("header.Follow_the_curriculum")}</h6>
        <div className="Selects">
        <CustomDatePicker/>
        </div>
      </header>
      <SearchField
        searchBy="session_name"
        placeholder={"practical.search_here"}
      />

      <Table />

      <AddHomeWorkModel />
      <EditHomeWorkModel />
      <DeleteHomeWorkModel />
    </div>
  );
};

export default TableHeader;
