import {FC} from 'react';
import {context, pageContext, searchContext, useContextReducer} from './context';
import {PageProvider, SearchProvider} from '@components';
import {ChildrenFC} from '@utils';
import Filter from './filter';
import TableList from './table';

const MenuProvider: ChildrenFC = function({children}) {
  const state = useContextReducer();

  const {Provider} = context;

  return <Provider value={state}>{children}</Provider>;
};

const PdaMenu: FC = function() {
  return (
    <MenuProvider>
      <SearchProvider context={searchContext}>
        <PageProvider context={pageContext}>
          <main className='content-main'>
            <Filter />
            <TableList />
          </main>
        </PageProvider>
      </SearchProvider>
    </MenuProvider>
  );
};

export default PdaMenu;
