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

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

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

export default App;
