import { useContext, useState } from 'react'; import { Switch, Route, Redirect, useLocation } from 'react-router-dom'; import HeaderUserAndAuth from '../../components/HeaderUserAndAuth'; import { AccessoriesContext } from '../../context/AccessoriesContext'; import { Wrapper, ScreenWrapper } from './styles'; import { UserContext } from '../../context/UserContext'; import { roles } from '../../config/enums'; import Landing from '../../components/user/Landing'; // USER import MyProfile from '../../components/user/MyProfile'; // MapUsers - same as guest and auth but diffrent url USER import Session from '../../components/user/Session'; // USER and GUEST import Auth from '../../components/Auth'; // NOT AUTH import MapUsers from '../../components/user/MapUsers'; // TODO GUEST and NOT AUTH import { DndProvider } from 'react-dnd'; import { TouchBackend } from 'react-dnd-touch-backend'; const UserAndNotAuthScreen = () => { const { user } = useContext(UserContext); const location = useLocation(); const { isMobile } = useContext(AccessoriesContext); const [isUserParked, setIsUserParked] = useState(false); // TODO FETCH const asphaltBg = user && user.role === roles.user && location.pathname === '/'; const mapUrl = user && user.role === roles.user ? '/maps' : '/'; const options = { enableMouseEvents: true, }; const content = ( {!user ? ( // NOT AUTH ROUTES ) : ( <> {user.role === roles.user ? ( // USER ROUTES <> ( )} /> ) : null} {/* USER AND GUEST ROUTES */} )} {/* USER, GUEST AND NOT AUTH ROUTES */} ); return isMobile ? content : {content}; }; export default UserAndNotAuthScreen;