From 6db94b6684995ca431ae3015f922ff6f71c36ded Mon Sep 17 00:00:00 2001 From: LSJ Date: Sat, 16 Nov 2024 18:21:24 +0900 Subject: [PATCH] . --- hooks/groupStudy/queries.ts | 19 ++++++++++++------- pageTemplates/group/GroupMine.tsx | 4 +++- pages/profile/{[uid].tsx => [userId].tsx} | 8 +++++++- 3 files changed, 22 insertions(+), 9 deletions(-) rename pages/profile/{[uid].tsx => [userId].tsx} (93%) diff --git a/hooks/groupStudy/queries.ts b/hooks/groupStudy/queries.ts index 691e7e4b2..eb57f9d62 100644 --- a/hooks/groupStudy/queries.ts +++ b/hooks/groupStudy/queries.ts @@ -45,21 +45,26 @@ export const useGroupQuery = ( }, options, ); -export const useGroupsMineQuery = ( - all: true | null, - status: "pending" | "end", - options?: QueryOptions, -) => +export const useGroupsMineQuery = (status: "pending" | "all", options?: QueryOptions) => useQuery( - [GROUP_STUDY, all, status], + [GROUP_STUDY, status], async () => { const res = await axios.get(`${SERVER_URI}/groupStudy/mine`, { - params: { all, status }, + params: { status }, }); return res.data; }, options, ); +export const useGroupsTitleQuery = (userId: string, options?: QueryOptions) => + useQuery( + [GROUP_STUDY, userId], + async () => { + const res = await axios.get(`${SERVER_URI}/groupStudy/profile/${userId}`, {}); + return res.data; + }, + options, + ); export const useGroupIdQuery = (groupStudyId?: string, options?: QueryOptions) => useQuery( diff --git a/pageTemplates/group/GroupMine.tsx b/pageTemplates/group/GroupMine.tsx index 42cdf6e94..1d2ec7050 100644 --- a/pageTemplates/group/GroupMine.tsx +++ b/pageTemplates/group/GroupMine.tsx @@ -1,4 +1,5 @@ import { Box, Button, Flex } from "@chakra-ui/react"; +import { useSession } from "next-auth/react"; import Link from "next/link"; import { useMemo } from "react"; import { useSetRecoilState } from "recoil"; @@ -10,7 +11,8 @@ import { transferGroupDataState } from "../../recoils/transferRecoils"; import { getRandomImage } from "../../utils/imageUtils"; function GroupMine() { - const { data } = useGroupsMineQuery(true, "pending"); + const { data: session } = useSession(); + const { data } = useGroupsMineQuery("pending"); const setGroup = useSetRecoilState(transferGroupDataState); diff --git a/pages/profile/[uid].tsx b/pages/profile/[userId].tsx similarity index 93% rename from pages/profile/[uid].tsx rename to pages/profile/[userId].tsx index 063c5ab79..ff316c5ae 100644 --- a/pages/profile/[uid].tsx +++ b/pages/profile/[userId].tsx @@ -1,7 +1,7 @@ import { Button } from "@chakra-ui/react"; +import { useSession } from "next-auth/react"; import { useParams, useSearchParams } from "next/navigation"; import { useRouter } from "next/router"; -import { useSession } from "next-auth/react"; import { useEffect, useState } from "react"; import { useRecoilValue, useSetRecoilState } from "recoil"; import styled from "styled-components"; @@ -9,6 +9,7 @@ import styled from "styled-components"; import Header from "../../components/layouts/Header"; import Slide from "../../components/layouts/PageSlide"; import { useTypeToast } from "../../hooks/custom/CustomToast"; +import { useGroupsTitleQuery } from "../../hooks/groupStudy/queries"; import { useUidToUserInfoQuery } from "../../hooks/user/queries"; import BottomDrawer from "../../pageTemplates/profile/BottomDrawer"; import DeclareDrawer from "../../pageTemplates/profile/DeclareDrawer"; @@ -39,6 +40,11 @@ function ProfilePage() { enabled: !!uid, }); + const { data: data2 } = useGroupsTitleQuery(session?.user.id, { + enabled: !!session?.user.id, + }); + console.log(4, session?.user.id, data2); + useEffect(() => { if (user) setTransferUserName(user.name); }, [user]);