'use client';

import React, { createContext, useContext, useState } from 'react';

type ShowTableContextType = {
  showTable: boolean;
  setShowTable: React.Dispatch<React.SetStateAction<boolean>>;
};

const ShowTableContext = createContext<ShowTableContextType | undefined>(undefined);

export const ShowTableProvider = ({ children }: { children: React.ReactNode }) => {
  const [showTable, setShowTable] = useState(false);

  return (
    <ShowTableContext.Provider value={{ showTable, setShowTable }}>
      {children}
    </ShowTableContext.Provider>
  );
};

export const useShowTable = () => {
  const context = useContext(ShowTableContext);
  if (context === undefined) {
    throw new Error('useShowTable must be used within a ShowTableProvider');
  }
  return context;
};
