import { useColumns } from ".";
import { useLocation } from "react-router-dom";
import React from "react";
import { useGetAllHomework } from "../../../../../api/homework";
import DataTable from "../../../../../Layout/Dashboard/Table/DataTable";

const App: React.FC = () => {
  const [searchQuery, setSearchQuery] = React.useState<string>("");
  const location = useLocation();

  React.useEffect(() => {
    const searchParams = new URLSearchParams(location?.search);
    setSearchQuery(searchParams?.get("title_homework") || "");
    // console.log(searchQuery,"searchQuery");
  }, [location, searchQuery]);

  const response = useGetAllHomework({
    title: searchQuery,
    pagination: true,
  });

  return <DataTable response={response} useColumns={useColumns} />;
};

export default App;
