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

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

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

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

export default Goods;
