mirror of
https://github.com/LucasVbr/meeting-app.git
synced 2026-12-05 17:30:50 +00:00
Merge remote-tracking branch 'origin/dev' into dev
# Conflicts: # src/pages/graphique.tsx # src/pages/map.tsx
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
Box,
|
||||
Button,
|
||||
Button, Container,
|
||||
FormControl,
|
||||
FormErrorMessage,
|
||||
FormLabel,
|
||||
@@ -60,7 +60,7 @@ export default function settings() {
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<Container>
|
||||
<Box as="form" id="form_passion" width={'80%'}
|
||||
onSubmit={handleSubmit(savePassion)}>
|
||||
<FormControl isInvalid={errors.name as boolean | undefined}>
|
||||
@@ -77,7 +77,7 @@ export default function settings() {
|
||||
Submit
|
||||
</Button>
|
||||
</Box>
|
||||
</>
|
||||
</Container>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import {
|
||||
Box,
|
||||
Box, Button,
|
||||
Container,
|
||||
Flex,
|
||||
FormControl,
|
||||
IconButton,
|
||||
Input,
|
||||
Text
|
||||
} from '@chakra-ui/react';
|
||||
import Head from 'next/head';
|
||||
import {websiteName} from '@/lib/constants';
|
||||
@@ -19,7 +18,8 @@ import {io, Socket} from 'socket.io-client';
|
||||
import {Chat, Message, User} from '@prisma/client';
|
||||
import LoadingPage from '@/components/LoadingPage';
|
||||
import Navbar from '@/components/Navbar';
|
||||
import {ArrowForwardIcon, CalendarIcon} from '@chakra-ui/icons';
|
||||
|
||||
import {ArrowForwardIcon} from '@chakra-ui/icons';
|
||||
import {FaMapMarkedAlt} from 'react-icons/fa';
|
||||
|
||||
export default function ChatId() {
|
||||
@@ -84,8 +84,8 @@ export default function ChatId() {
|
||||
|
||||
<Navbar/>
|
||||
|
||||
<Container pt={20} bgColor={'white'}>
|
||||
<MessageList user={session.user as User} messages={messages}/>
|
||||
<Container maxW={'container.md'} pt={20} bgColor={'white'}>
|
||||
<MessageList chat={chatInfo} user={session.user as User} messages={messages}/>
|
||||
|
||||
<form onSubmit={handleSubmit}>
|
||||
<FormControl>
|
||||
@@ -103,6 +103,8 @@ export default function ChatId() {
|
||||
</form>
|
||||
<AlwaysScrollToBottom/>
|
||||
</Container>
|
||||
|
||||
<Button m={3} position={'fixed'} bottom={0} onClick={() => router.push("/dashboard")}>Tableau de bord</Button>
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
+105
-86
@@ -3,32 +3,36 @@ import {
|
||||
GridItem,
|
||||
Box,
|
||||
useToast,
|
||||
useDisclosure,
|
||||
Card, CardBody, CardHeader, Heading,
|
||||
} from '@chakra-ui/react';
|
||||
import {useSession} from 'next-auth/react';
|
||||
import {useRouter} from 'next/router';
|
||||
Card,
|
||||
CardBody,
|
||||
CardHeader,
|
||||
Heading,
|
||||
} from "@chakra-ui/react";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
import type {Session} from '@/models/auth/Session';
|
||||
import CardUser from '../components/layout/dashboard/card_user/CardUser';
|
||||
import SearchFailCard
|
||||
from '../components/layout/dashboard/card_user/SearchFailCard';
|
||||
import type { Session } from "@/models/auth/Session";
|
||||
import CardUser from "../components/layout/dashboard/card_user/CardUser";
|
||||
import SearchFailCard from "../components/layout/dashboard/card_user/SearchFailCard";
|
||||
|
||||
import LeftPanel from '../components/layout/dashboard/left_panel/LeftPanel';
|
||||
import ModalMatch
|
||||
from '@/components/layout/dashboard/match_notification/ModalMatch';
|
||||
import Head from 'next/head';
|
||||
import {websiteName} from '@/lib/constants';
|
||||
import {useQuery} from '@tanstack/react-query';
|
||||
import LoadingPage from '@/components/LoadingPage';
|
||||
import {Notification, NotificationType, User} from '@prisma/client';
|
||||
import ChatList from '@/components/chat/ChatList';
|
||||
import LeftPanel from "../components/layout/dashboard/left_panel/LeftPanel";
|
||||
import ModalMatch from "@/components/layout/dashboard/match_notification/ModalMatch";
|
||||
import Head from "next/head";
|
||||
import { websiteName } from "@/lib/constants";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import LoadingPage from "@/components/LoadingPage";
|
||||
import { Notification, NotificationType, User } from "@prisma/client";
|
||||
import ChatList from "@/components/chat/ChatList";
|
||||
|
||||
export default function Dashboard() {
|
||||
const router = useRouter();
|
||||
const toast = useToast({position: 'top', isClosable: true});
|
||||
const toast = useToast({ position: "top", isClosable: true });
|
||||
|
||||
const {data: session, status} = useSession({required: true});
|
||||
const { data: session, status } = useSession({ required: true });
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
queryClient.invalidateQueries({ queryKey: ["ListUsers"] });
|
||||
|
||||
const {
|
||||
isLoading,
|
||||
@@ -37,18 +41,18 @@ export default function Dashboard() {
|
||||
error,
|
||||
refetch: refetchLoggedUser,
|
||||
} = useQuery({
|
||||
queryKey: ['LoggedUser'],
|
||||
enabled: status === 'authenticated',
|
||||
queryKey: ["LoggedUser"],
|
||||
enabled: status === "authenticated",
|
||||
queryFn: async () => {
|
||||
const {user} = session as unknown as Session;
|
||||
const { user } = session as unknown as Session;
|
||||
|
||||
return fetch(`/api/users/${user.id}?include=Notification`)
|
||||
.then((res) => {
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
return err;
|
||||
});
|
||||
.then((res) => {
|
||||
return res.json();
|
||||
})
|
||||
.catch((err) => {
|
||||
return err;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
@@ -58,89 +62,104 @@ export default function Dashboard() {
|
||||
isLoading: isLoadingListUsers,
|
||||
error: errorListUsers,
|
||||
} = useQuery({
|
||||
queryKey: ['ListUsers'],
|
||||
enabled: status === 'authenticated' && !isLoading,
|
||||
queryKey: ["ListUsers"],
|
||||
enabled: status === "authenticated" && !isLoading,
|
||||
queryFn: async () => {
|
||||
return fetch(
|
||||
`/api/user/userDashboard?userID=${loggedUser.id}`) //exclure les profils déjà like ou dislike
|
||||
.then((res) => res.json())
|
||||
.catch((err) => {
|
||||
return err;
|
||||
});
|
||||
return fetch(`/api/user/userDashboard?userID=${loggedUser.id}`) //exclure les profils déjà like ou dislike
|
||||
.then((res) => res.json())
|
||||
.catch((err) => {
|
||||
return err;
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
if (isLoading) {
|
||||
if (status === 'unauthenticated') router.push('/login');
|
||||
return <LoadingPage/>;
|
||||
if (status === "unauthenticated") router.push("/login");
|
||||
return <LoadingPage />;
|
||||
}
|
||||
|
||||
if (isError) {
|
||||
toast({
|
||||
title: `Erreur lors de la récupération des données du profil`,
|
||||
status: 'error',
|
||||
position: 'top',
|
||||
status: "error",
|
||||
position: "top",
|
||||
});
|
||||
if (status === 'unauthenticated') router.push('/');
|
||||
if (status === "unauthenticated") router.push("/");
|
||||
}
|
||||
|
||||
let modal;
|
||||
|
||||
if (loggedUser?.Notification?.length > 0) {
|
||||
const matchNotification = loggedUser.Notification.filter(
|
||||
(notif: Notification) =>
|
||||
notif.type === NotificationType.NEW_MATCH &&
|
||||
notif.hasBeenConsulted === false,
|
||||
(notif: Notification) =>
|
||||
notif.type === NotificationType.NEW_MATCH &&
|
||||
notif.hasBeenConsulted === false
|
||||
);
|
||||
modal = matchNotification.map((notif: Notification) => {
|
||||
return (
|
||||
<ModalMatch notif={notif} key={notif.id} loggedUser={loggedUser}/>
|
||||
<ModalMatch notif={notif} key={notif.id} loggedUser={loggedUser} />
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
if (status === 'loading') return <LoadingPage/>;
|
||||
if (status === "loading") return <LoadingPage />;
|
||||
return (
|
||||
<>
|
||||
{modal}
|
||||
<>
|
||||
{modal}
|
||||
|
||||
<Head>
|
||||
<title>{websiteName} | Dashboard</title>
|
||||
</Head>
|
||||
<Head>
|
||||
<title>{websiteName} | Dashboard</title>
|
||||
</Head>
|
||||
|
||||
<Grid templateColumns={'repeat(5, 1fr)'}
|
||||
templateRows={'repeat(2, 1fr)'}
|
||||
gap={5}
|
||||
minH={'100vh'}>
|
||||
<GridItem area={'1 / 1 / 3 / 2'}>
|
||||
<LeftPanel user={loggedUser}/>
|
||||
</GridItem>
|
||||
<GridItem area={'1 / 2 / 3 / 4'}>
|
||||
<Box py={3}>
|
||||
{isLoadingListUsers
|
||||
? (<LoadingPage/>)
|
||||
: (isErrorListUsers || !listUsers || !listUsers.users ||
|
||||
listUsers.users.length === 0)
|
||||
? <SearchFailCard/>
|
||||
: <CardUser users={listUsers.users} loggedUser={loggedUser}
|
||||
refetchLoggedUser={refetchLoggedUser}/>
|
||||
}
|
||||
</Box>
|
||||
</GridItem>
|
||||
<GridItem area={'1 / 4 / 2 / 6'}>
|
||||
<Box py={3} pr={3}>
|
||||
<Card w={"100%"} h={"100%"} borderRadius={"1rem"}>
|
||||
<CardHeader>
|
||||
<Heading cursor={"pointer"} size='md' onClick={() => {router.push('/chat')}}>Conversations</Heading>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<ChatList user={session?.user as User}/>
|
||||
</CardBody>
|
||||
</Card>
|
||||
</Box>
|
||||
</GridItem>
|
||||
<GridItem area={'2 / 4 / 3 / 6'}>{/*Right Bottom*/}</GridItem>
|
||||
</Grid>
|
||||
</>
|
||||
<Grid
|
||||
templateColumns={"repeat(5, 1fr)"}
|
||||
templateRows={"repeat(2, 1fr)"}
|
||||
gap={5}
|
||||
minH={"100vh"}
|
||||
>
|
||||
<GridItem area={"1 / 1 / 3 / 2"}>
|
||||
<LeftPanel user={loggedUser} />
|
||||
</GridItem>
|
||||
<GridItem area={"1 / 2 / 3 / 4"}>
|
||||
<Box py={3}>
|
||||
{isLoadingListUsers ? (
|
||||
<LoadingPage />
|
||||
) : isErrorListUsers ||
|
||||
!listUsers ||
|
||||
!listUsers.users ||
|
||||
listUsers.users.length === 0 ? (
|
||||
<SearchFailCard />
|
||||
) : (
|
||||
<CardUser
|
||||
users={listUsers.users}
|
||||
loggedUser={loggedUser}
|
||||
refetchLoggedUser={refetchLoggedUser}
|
||||
/>
|
||||
)}
|
||||
</Box>
|
||||
</GridItem>
|
||||
<GridItem area={"1 / 4 / 2 / 6"}>
|
||||
<Box py={3} pr={3}>
|
||||
<Card w={"100%"} h={"100%"} borderRadius={"1rem"}>
|
||||
<CardHeader>
|
||||
<Heading
|
||||
cursor={"pointer"}
|
||||
size="md"
|
||||
onClick={() => {
|
||||
router.push("/chat");
|
||||
}}
|
||||
>
|
||||
Conversations
|
||||
</Heading>
|
||||
</CardHeader>
|
||||
<CardBody>
|
||||
<ChatList user={session?.user as User} />
|
||||
</CardBody>
|
||||
</Card>
|
||||
</Box>
|
||||
</GridItem>
|
||||
<GridItem area={"2 / 4 / 3 / 6"}>{/*Right Bottom*/}</GridItem>
|
||||
</Grid>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
+4
-3
@@ -37,7 +37,7 @@ export default function Map() {
|
||||
enabled: status === "authenticated",
|
||||
queryFn: async () => {
|
||||
const { user } = session as unknown as Session;
|
||||
console.log(loggedUser.location.length);
|
||||
|
||||
return fetch(`/api/users/${user.id}`)
|
||||
.then((res) => {
|
||||
return res.json();
|
||||
@@ -56,8 +56,9 @@ export default function Map() {
|
||||
} = useQuery({
|
||||
queryKey: ["listBars"],
|
||||
refetchOnWindowFocus: false,
|
||||
|
||||
enabled: Boolean(loggedUser) && loggedUser.location.length > 0,
|
||||
enabled:
|
||||
Boolean(loggedUser) &&
|
||||
(loggedUser.location?.length > 0 || location[0] !== null),
|
||||
queryFn: async () => {
|
||||
///Utiliser api de noratim
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ import CustomSlider from "@/components/layout/profile/CustomSlider";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
|
||||
export default function UserProfile() {
|
||||
const router = useRouter();
|
||||
@@ -45,6 +45,8 @@ export default function UserProfile() {
|
||||
const [showTooltipDistance, setShowTooltipDistance] = useState(false);
|
||||
const [sliderDistanceValue, setSliderDistanceValue] = useState<number>(0);
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const {
|
||||
handleSubmit,
|
||||
control,
|
||||
@@ -147,6 +149,7 @@ export default function UserProfile() {
|
||||
status: "success",
|
||||
isClosable: true,
|
||||
});
|
||||
queryClient.invalidateQueries({ queryKey: ["user"] });
|
||||
})
|
||||
.catch((err) => {
|
||||
setCurrentlyLoading(false);
|
||||
|
||||
Reference in New Issue
Block a user