Skip to content

Commit

Permalink
test allBusinesses
Browse files Browse the repository at this point in the history
  • Loading branch information
ElyasMehraein committed Apr 30, 2024
1 parent 0beb6b5 commit 8bb2a53
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
22 changes: 10 additions & 12 deletions app/all/page.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
// import connectToDB from "@/configs/db";
// import BusinessModel from "@/models/Business";
// import AllBusinesses from "@/components/templates/allBusinesses/AllBusinesses";
import CreateBusiness from "@/components/templates/createBusiness/CreateBusiness";
import connectToDB from "@/configs/db";
import BusinessModel from "@/models/Business";
import AllBusinesses from "@/components/templates/allBusinesses/AllBusinesses";

export default async function page() {
// try {
// await connectToDB();
// const businesses = JSON.parse(JSON.stringify(await BusinessModel.find({}, "businessName bio businessBrand isAvatar")));
try {
await connectToDB();
const businesses = JSON.parse(JSON.stringify(await BusinessModel.find({}, "businessName bio businessBrand isAvatar")));


return (
// <AllBusinesses businesses={businesses} />
<AllBusinesses businesses={businesses} />
// <h1 className="inMiddle">تست</h1>
<CreateBusiness />

);
// } catch (err) {
} catch (err) {

// console.error('Error fetching businesses:', err);
// }
console.error('Error fetching businesses:', err);
}
}

9 changes: 7 additions & 2 deletions components/templates/allBusinesses/AllBusinesses.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client"
import { AppBar, Avatar, Box, Button, Container, List, ListItem, ListItemAvatar, ListItemButton, ListItemIcon, ListItemText, TextField, Toolbar, Typography } from '@mui/material'
import { useState } from 'react'
import { useEffect, useState } from 'react'
import { useRouter } from 'next/navigation'
import { AllBusinessesText, selectGuild } from '@/components/typoRepo';
import { Accordion, AccordionDetails, Chip } from "@mui/material";
Expand All @@ -14,11 +14,16 @@ import ItsAvatar from '@/components/modules/ItsAvatar'
export default function AllBusinesses({ businesses }) {
const router = useRouter()
const [expanded, setExpanded] = useState(false);
const [mounted, setMounted] = useState(false);
useEffect(() => {
setMounted(true)
}, [])

const goToIndex = () => {
router.push("/")
}
return (

return (mounted &&
<>
<Box sx={{ flexGrow: 1 }}>
<AppBar position="static">
Expand Down

0 comments on commit 8bb2a53

Please sign in to comment.