import React, { useState, useEffect, createContext } from 'react';
import PropTypes from 'prop-types';

import DashboardMain from '../components/dashboard/JKDashboardMain';
import UserAuth from '../context/UserAuth';
import { BrowserQueryProvider } from '../context/BrowserQuery';

const DashboardLayout = ({ location }) => {
  useEffect(() => {
    window.scrollTo(0, 0);
  }, [location.pathname]);

  return (
    <UserAuth path={location.pathname}>
      <BrowserQueryProvider>
        <DashboardMain />
      </BrowserQueryProvider>
    </UserAuth>
  );
};

DashboardLayout.propTypes = { location: PropTypes.object.isRequired };

export default DashboardLayout;
