-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b8391df
commit 7bf1545
Showing
3 changed files
with
51 additions
and
51 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,44 @@ | ||
import { Typography } from '@mui/material' | ||
import React from 'react' | ||
import MyIndex from '@/components/templates/index/MyIndex'; | ||
import { verifyToken } from "@/controllers/auth"; | ||
import connectToDB from '@/configs/db'; | ||
import UserModel from '@/models/User'; | ||
import { cookies } from "next/headers"; | ||
import BillModel from '@/models/Bill'; | ||
|
||
export default function page() { | ||
return ( | ||
<Typography sx={{ p: 5, height: "100vh", display: "flex", justifyContent: "center", alignContent: "center" }} className='inMiddle'> | ||
همون طور که میدونید تازه سایت راه اندازی شده و در مرحله تست هستیم حالا یه تعداد از باگ های سایت مشخص شده که حلش دو سه روز طول می کشه توی این مدت مجبوریم صبر کنیم😅 | ||
</Typography> | ||
) | ||
export default async function page() { | ||
const token = cookies().get("token")?.value; | ||
const tokenPayLoad = verifyToken(token); | ||
|
||
if (!tokenPayLoad) { | ||
return <MyIndex /> | ||
} | ||
connectToDB() | ||
const user = await JSON.parse(JSON.stringify(await UserModel.findOne( | ||
{ _id: tokenPayLoad.id }, | ||
).populate("businesses"))) | ||
|
||
const bills = await JSON.parse(JSON.stringify(await BillModel.find({ | ||
to: user?._id, isAccept: false | ||
}).populate("from"))) | ||
|
||
let distinctGuilds = [] | ||
await BillModel.find({ isAccept: true }) | ||
.then(docs => { | ||
if (docs.length > 0) { | ||
const guilds = docs.map(doc => doc.guild); | ||
distinctGuilds = [...new Set(guilds)]; | ||
|
||
} else { | ||
console.log('No guilds to show.'); | ||
} | ||
}) | ||
.catch(err => { | ||
console.error(err); | ||
}); | ||
return ( | ||
<MyIndex {...{ user, bills, token, distinctGuilds }} /> | ||
) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Typography } from '@mui/material' | ||
import React from 'react' | ||
|
||
export default function page() { | ||
return ( | ||
<Typography sx={{ p: 5, height: "100vh", display: "flex", justifyContent: "center", alignContent: "center" }} className='inMiddle'> | ||
همون طور که میدونید تازه سایت راه اندازی شده و در مرحله تست هستیم حالا یه تعداد از باگ های سایت مشخص شده که حلش دو سه روز طول می کشه توی این مدت مجبوریم صبر کنیم😅 | ||
</Typography> | ||
) | ||
} |