diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 831955a..8e17ae6 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -24,6 +24,8 @@ export default function Navbar({ variant = "fixed" }: Props) { Tableau de bord Profil Carte + Statistiques + ); diff --git a/src/components/layout/dashboard/left_panel/LeftPanel.tsx b/src/components/layout/dashboard/left_panel/LeftPanel.tsx index f81a929..ca13e57 100644 --- a/src/components/layout/dashboard/left_panel/LeftPanel.tsx +++ b/src/components/layout/dashboard/left_panel/LeftPanel.tsx @@ -11,6 +11,7 @@ import { useRouter } from "next/router"; import { AiFillMessage } from "react-icons/ai"; import { BsFillPersonFill } from "react-icons/bs"; +import { BsGraphUp } from "react-icons/bs"; import { BiLogOut } from "react-icons/bi"; import { FaMapMarkedAlt } from "react-icons/fa"; @@ -71,6 +72,13 @@ export default function LeftPanel(props) { onClickHandler={() => router.push("/profile")}> Profil + + } + onClickHandler={() => router.push("/graphique")}> + Statistiques + + } diff --git a/src/pages/graphique.tsx b/src/pages/graphique.tsx index 0678a54..9ee3267 100644 --- a/src/pages/graphique.tsx +++ b/src/pages/graphique.tsx @@ -5,32 +5,170 @@ import BarChart from "@/components/graph/BarChart"; import PieChart from "@/components/graph/PieChart"; import LineChart from "@/components/graph/LineChart"; -import { Box } from "@chakra-ui/react"; +import { Box, + Flex, + Grid, + GridItem, + Item, + Stat, + Text, + StatLabel, + StatNumber, + StatHelpText, + StatArrow, + StatGroup, +} from "@chakra-ui/react"; +import LeftPanelButton from "@/components/layout/dashboard/left_panel/LeftPanelButton"; +import { AiFillMessage } from "react-icons/ai"; +import { BsFillPersonFill } from "react-icons/bs"; +import { AiFillHome } from "react-icons/ai"; +import { BiLogOut } from "react-icons/bi"; +import { FaMapMarkedAlt } from "react-icons/fa"; + +import { useRouter } from "next/router"; + import { websiteName } from "@/lib/constants"; + import { useRef, useEffect } from "react"; import { useSession } from "next-auth/react"; +import { useQuery } from "@tanstack/react-query"; import type { Session } from "@/models/auth/Session"; import { Role } from "@prisma/client"; export default function Graphique() { const { data: session, status } = useSession({ required: true }); - const { user } = session as unknown as Session; + const router = useRouter(); + const { + isLoading, + isError, + data: userData, + error, + } = useQuery({ + queryKey: ["user"], + enabled: status === "authenticated", + queryFn: async () => { + const { user } = session as unknown as Session; + + return fetch(`/api/users/${user.id}`) + .then((res) => res.json()) + .catch((err) => { + return err; + }); + }, + }); + return ( <> - - {websiteName} - - {user.role === Role.ADMIN ? ( - - - - - - ) : ( - // pour récupérer les notifs d'un user - //fetch(`/api/users/${user.id}?include=Notification`) - <> - )} + + + + + + + } + onClickHandler={() => router.push("/dashboard")}> + Accueil + + + } + onClickHandler={() => router.push("/map")}> + Carte + + + } + onClickHandler={() => router.push("/profile")}> + Profil + + + } + onClickHandler={() => signOut({ callbackUrl: "/" })}> + Déconnexion + + + + + + + + + Bénéfices + + + + Recette dus aux abonnements + 0.00€ + Mai 2022 - Mai 2023 + + + + + Infos des échanges + + + + + Messages envoyés + 345,670 + + + 23.36% + + + + Matchs + 45 + + + 9.05% + + + + + + + Date de création des comptes depuis l'ouverture. + + + + + + + + + + Proportion du genre des utilisateurs. + + + + + + + ); } diff --git a/src/pages/map.tsx b/src/pages/map.tsx index 7e82cb2..805f0d4 100644 --- a/src/pages/map.tsx +++ b/src/pages/map.tsx @@ -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,6 +56,7 @@ export default function Map() { } = useQuery({ queryKey: ["listBars"], refetchOnWindowFocus: false, + enabled: Boolean(loggedUser) && loggedUser.location.length > 0, queryFn: async () => { ///Utiliser api de noratim diff --git a/yarn.lock b/yarn.lock index 562420a..440768b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1073,10 +1073,10 @@ dependencies: glob "7.1.7" -"@next/swc-darwin-arm64@13.2.3": +"@next/swc-win32-x64-msvc@13.2.3": version "13.2.3" - resolved "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-13.2.3.tgz" - integrity sha512-TXOubiFdLpMfMtaRu1K5d1I9ipKbW5iS2BNbu8zJhoqrhk3Kp7aRKTxqFfWrbliAHhWVE/3fQZUYZOWSXVQi1w== + resolved "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-13.2.3.tgz" + integrity sha512-aLG2MaFs4y7IwaMTosz2r4mVbqRyCnMoFqOcmfTi7/mAS+G4IMH0vJp4oLdbshqiVoiVuKrAfqtXj55/m7Qu1Q== "@nodelib/fs.scandir@2.1.5": version "2.1.5"