for images and videos make them inside home : import React, { useContext, useState }…
- User
for images and videos make them inside home : import React, { useContext, useState } from 'react'; import { Outlet, Navigate, Link, useNavigate } from 'react-router-dom'; import UserContext from '../hooks/userContext'; import { AppBar, Box, CssBaseline, Drawer, IconButton, List, ListItem, ListItemIcon, ListItemText, Toolbar, Typography, Button, Collapse, } from '@mui/material'; import MenuIcon from '@mui/icons-material/Menu'; import HomeIcon from '@mui/icons-material/Home'; import PersonIcon from '@mui/icons-material/Person'; import SettingsIcon from '@mui/icons-material/Settings'; import ExpandLess from '@mui/icons-material/ExpandLess'; import ExpandMore from '@mui/icons-material/ExpandMore'; import WebIcon from '@mui/icons-material/Web'; import WelcomeIcon from '@mui/icons-material/EmojiPeople'; import { Dashboard, Image as ImageIcon, VideoLibrary, AddPhotoAlternate, Add as AddIcon, PhotoLibrary, OndemandVideo } from '@mui/icons-material'; import axios from 'axios';
const drawerWidth = 240;
function PrivateRoute() { const { user, isLoading, setUser } = useContext(UserContext); const [mobileOpen, setMobileOpen] = useState(false); const [openHome, setOpenHome] = useState(false); const [openImages, setOpenImages] = useState(false); const [openVideos, setOpenVideos] = useState(false);
const navigate = useNavigate();
const handleDrawerToggle = () => { setMobileOpen(!mobileOpen); };
const handleHomeClick = () => { setOpenHome(!openHome); };
const handleImagesClick = () => { setOpenImages(!openImages); };
const handleVideosClick = () => { setOpenVideos(!openVideos); };
const handleLogout = async () => { try { localStorage.removeItem('token'); setUser({}); await axios.get('http://127.0.0.1:8000/logout', {}, { headers: { 'Authorization': Bearer ${localStorage.getItem('token')}, }, }); navigate('/login'); } catch (err) { if (err.response && err.response.status === 401) { console.log('Unauthorized access, redirecting to login...'); } else { console.log(err); } navigate('/login'); } };
const menuItems = [ { text: 'Users', icon: , path: '/users' }, { text: 'Settings', icon: , path: '/settings' }, ];
const drawer = ( {/* Dashboard */} <ListItem button component={Link} to={'/'} key={'Dashboard'} > <ListItemText primary={'Dashboard'} />
code - Assistant