import React from "react";
import DataTable from "../../../Layout/Dashboard/Table/DataTable";
import { useColumns } from "./useTableColumns";
import useSearchQuery from "../../../api/utils/useSearchQuery";
import { useFilterState } from "../../../Components/Utils/Filter/FilterState";
import { useGetAllSales } from "../../../api/sales";
import { formatDate } from "../../../utils/formatDate";

const App: React.FC = () => {
  
  const [searchQuery] = useSearchQuery("name");
  const { filterState }:any = useFilterState();
  
  const response = useGetAllSales({
    name: searchQuery,
    pagination: true,
    ...filterState,
    activation_date:formatDate(filterState?.activation_date),
    expiration_date:formatDate(filterState?.expiration_date),
  });

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

export default App;
