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

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

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

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

export default User;
