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

const ContainerProvider: ChildrenFC = function({children}) {
  const {Provider} = context;
  const state = useContextReducer();

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

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

export default Container;
