Initial commit - restaurant dashboard
This commit is contained in:
@@ -11,23 +11,23 @@ const Dashboard = () => {
|
||||
const theme = useTheme();
|
||||
const isMobile = useMediaQuery(theme.breakpoints.down('sm'));
|
||||
const [hasProducts, setHasProducts] = useState(false);
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
// const [isLoading, setIsLoading] = useState(true);
|
||||
const [sidebarOpen, setSidebarOpen] = useState(!isMobile);
|
||||
|
||||
// محاكاة التحقق من المنتجات
|
||||
|
||||
useEffect(() => {
|
||||
const checkProducts = async () => {
|
||||
setIsLoading(true);
|
||||
const productsExist = await checkIfProductsExist(); // استبدل بمنطقك
|
||||
// setIsLoading(true);
|
||||
const productsExist = await checkIfProductsExist();
|
||||
setHasProducts(productsExist);
|
||||
setIsLoading(false);
|
||||
// setIsLoading(false);
|
||||
};
|
||||
|
||||
checkProducts();
|
||||
}, []);
|
||||
|
||||
const checkIfProductsExist = async () => {
|
||||
return new Promise((resolve) => setTimeout(() => resolve(true), 1500)); // محاكاة تأخير
|
||||
return new Promise((resolve) => setTimeout(() => resolve(true), 1500));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
@@ -76,8 +76,8 @@ const Dashboard = () => {
|
||||
<Box sx={{
|
||||
flexGrow: 1,
|
||||
width: sidebarOpen ? 'calc(100% - 20px)' : '100%',
|
||||
pt: { xs: 0.5, sm: 1 },
|
||||
mt: { xs: 1, sm: 2 },
|
||||
// pt: { xs: 0.5, sm: 1 },
|
||||
// mt: { xs: 1, sm: 2 },
|
||||
overflowY: 'auto',
|
||||
pl: { xs: 0, sm: 2 },
|
||||
pr: { xs: 1, sm: 2 },
|
||||
@@ -89,15 +89,18 @@ const Dashboard = () => {
|
||||
duration: theme.transitions.duration.leavingScreen,
|
||||
}),
|
||||
}}>
|
||||
{isLoading ? (
|
||||
{/* {isLoading ? (
|
||||
<>
|
||||
<Skeleton variant="rectangular" height={50} sx={{ mb: 2 }} />
|
||||
<Skeleton variant="rectangular" height={200} sx={{ mb: 2 }} />
|
||||
<Skeleton variant="rectangular" height={300} sx={{ mb: 2 }} />
|
||||
</>
|
||||
) : (
|
||||
hasProducts ? <DashbordContect /> : <NoProdectDash />
|
||||
)}
|
||||
hasProducts ?
|
||||
<DashbordContect />
|
||||
: <NoProdectDash />
|
||||
)} */}
|
||||
<DashbordContect />
|
||||
</Box>
|
||||
</Box>
|
||||
</Box>
|
||||
|
||||
Reference in New Issue
Block a user