import React, { useState, useEffect } from 'react'; import { Box, useTheme, useMediaQuery, Skeleton } from '@mui/material'; import KitchPlusAppBar from '../AppBar'; import Sidebar from '../SideHome'; import DashbordContect from './DashboardContcet'; import NoProdectDash from './NoProdectDash'; const drawerWidth = 230; const Dashboard = () => { const theme = useTheme(); const isMobile = useMediaQuery(theme.breakpoints.down('sm')); const [hasProducts, setHasProducts] = useState(false); // const [isLoading, setIsLoading] = useState(true); const [sidebarOpen, setSidebarOpen] = useState(!isMobile); useEffect(() => { const checkProducts = async () => { // setIsLoading(true); const productsExist = await checkIfProductsExist(); setHasProducts(productsExist); // setIsLoading(false); }; checkProducts(); }, []); const checkIfProductsExist = async () => { return new Promise((resolve) => setTimeout(() => resolve(true), 1500)); }; useEffect(() => { if (window.innerWidth >= theme.breakpoints.values.md) { setSidebarOpen(true); } else { setSidebarOpen(false); } }, [theme.breakpoints.values.md]); useEffect(() => { const handleResize = () => { if (window.innerWidth >= theme.breakpoints.values.md) { setSidebarOpen(true); } else { setSidebarOpen(false); } }; handleResize(); window.addEventListener('resize', handleResize); return () => window.removeEventListener('resize', handleResize); }, [theme.breakpoints.values.md]); const handleDrawerToggle = () => { setSidebarOpen(!sidebarOpen); }; return ( {/* {isLoading ? ( <> ) : ( hasProducts ? : )} */} ); }; export default Dashboard;