import { useColumns } from ".";
import { useLocation } from "react-router-dom";
import React from "react";
import { useGetAllSessionContent } from "../../../../../api/sessionContent";
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("session_name") || "");
  }, [location, searchQuery]);

  const response = useGetAllSessionContent({
    content: searchQuery,
    pagination: true,
  });

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

export default App;
