import React, { createContext, useContext, useState } from "react";
import {
  GridManagerContextProps,
  GridManagerProviderProps,
} from "@app/models/components";

const GridManagerContext = createContext<GridManagerContextProps>(
  {} as GridManagerContextProps
);

export const GridManagerProvider: React.FC<GridManagerProviderProps> = ({
  children,
}) => {
  const [filters, setFilters] = useState({
    media_type: "",
    link_status: "",
  });

  return (
    <GridManagerContext.Provider
      value={{
        filters,
        setFilters,
      }}
    >
      {children}
    </GridManagerContext.Provider>
  );
};

export const useGridManager = () => {
  return useContext(GridManagerContext);
};
