Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
SeungJL committed Nov 16, 2024
1 parent 644fedb commit 6db94b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
19 changes: 12 additions & 7 deletions hooks/groupStudy/queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,26 @@ export const useGroupQuery = (
},
options,
);
export const useGroupsMineQuery = (
all: true | null,
status: "pending" | "end",
options?: QueryOptions<IGroup[]>,
) =>
export const useGroupsMineQuery = (status: "pending" | "all", options?: QueryOptions<IGroup[]>) =>
useQuery<IGroup[], AxiosError, IGroup[]>(
[GROUP_STUDY, all, status],
[GROUP_STUDY, status],
async () => {
const res = await axios.get<IGroup[]>(`${SERVER_URI}/groupStudy/mine`, {
params: { all, status },
params: { status },
});
return res.data;
},
options,
);
export const useGroupsTitleQuery = (userId: string, options?: QueryOptions<string[]>) =>
useQuery<string[], AxiosError, string[]>(
[GROUP_STUDY, userId],
async () => {
const res = await axios.get<string[]>(`${SERVER_URI}/groupStudy/profile/${userId}`, {});
return res.data;
},
options,
);

export const useGroupIdQuery = (groupStudyId?: string, options?: QueryOptions<IGroup>) =>
useQuery<IGroup, AxiosError, IGroup>(
Expand Down
4 changes: 3 additions & 1 deletion pageTemplates/group/GroupMine.tsx
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);

Expand Down
8 changes: 7 additions & 1 deletion pages/profile/[uid].tsx → pages/profile/[userId].tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
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";

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";
Expand Down Expand Up @@ -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]);
Expand Down

0 comments on commit 6db94b6

Please sign in to comment.