import React, { useState } from 'react';
import { TableHeaderProps } from './types';

type ColumnSettingType = { header: TableHeaderProps['children']; isNote: boolean };

type TableContextType = {
  columnSettings: ColumnSettingType[];
  setColumnSettings: React.Dispatch<React.SetStateAction<ColumnSettingType[]>>;
};

export const TableContext = React.createContext<TableContextType>({
  columnSettings: [],
  setColumnSettings: () => {},
});

export const useInitTableContext = (): TableContextType => {
  const [columnSettings, setColumnSettings] = useState<TableContextType['columnSettings']>([]);

  return { columnSettings, setColumnSettings };
};
