mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-07-09 06:58:06 +00:00
fix(fix api userDashboard): fix api userDashboard
This commit is contained in:
@@ -4,17 +4,26 @@ const get = async (req, res) => {
|
|||||||
const { preference, excludedId } = req.query;
|
const { preference, excludedId } = req.query;
|
||||||
const prisma = new PrismaClient();
|
const prisma = new PrismaClient();
|
||||||
// a terme mettre l'age, la distance
|
// a terme mettre l'age, la distance
|
||||||
const users = await prisma.user.findMany({
|
const users = await prisma.user
|
||||||
where: {
|
.findMany({
|
||||||
AND: [
|
where: {
|
||||||
{ gender: { equals: preference } },
|
AND: [
|
||||||
{ images: { isEmpty: false }, NOT: { id: { equals: excludedId } } },
|
{ gender: { equals: preference } },
|
||||||
],
|
{ images: { isEmpty: false }, NOT: { id: { equals: excludedId } } },
|
||||||
},
|
],
|
||||||
});
|
},
|
||||||
res.status(200).send(users);
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
if (!users) {
|
||||||
|
return res.status(500).send({ message: "Internal server error" });
|
||||||
|
}
|
||||||
|
return res.status(200).send({ users });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// faire une API pour ajouter un like / dislike
|
||||||
|
|
||||||
export default (req, res) => {
|
export default (req, res) => {
|
||||||
req.method === "GET"
|
req.method === "GET"
|
||||||
? get(req, res)
|
? get(req, res)
|
||||||
|
|||||||
@@ -93,10 +93,11 @@ export default function Dashboard() {
|
|||||||
<Box py={3}>
|
<Box py={3}>
|
||||||
{isLoadingListUsers ? (
|
{isLoadingListUsers ? (
|
||||||
<LoadingPage />
|
<LoadingPage />
|
||||||
) : listUsers.length === 0 && !isErrorListUsers ? (
|
) : listUsers.users.length === 0 && listUsers.users === null ? (
|
||||||
<SearchFailCard />
|
<SearchFailCard />
|
||||||
) : (
|
) : (
|
||||||
listUsers.map((user: any) => (
|
listUsers.users.map((user: any) => (
|
||||||
|
// dans cardUser, mettre une liste de user, utiliser le user[0] et quand like ou dislike, supprimer le user[0] de la liste
|
||||||
<CardUser
|
<CardUser
|
||||||
key={user.id}
|
key={user.id}
|
||||||
user={user}
|
user={user}
|
||||||
|
|||||||
Reference in New Issue
Block a user