// PrivateRoute.js
import PropTypes from 'prop-types'
import { useContext } from 'react'
import { AuthContext } from './Dashboard/context/AuthContext'

const PrivateRoute = ({ component: Component }) => {
  const { authenticated, showSessionExpiredModal } = useContext(AuthContext)

  // Redirect to login if not authenticated
  return (
    <>
      {authenticated || showSessionExpiredModal ? <Component /> : <Component />}
    </>
  )
}

PrivateRoute.propTypes = {
  component: PropTypes.func.isRequired
}

export default PrivateRoute
