From 7fc3f43dd14dc2d64d8b5a97b93c8d0d106dab07 Mon Sep 17 00:00:00 2001 From: aken-you Date: Mon, 5 Jan 2026 01:32:30 +0900 Subject: [PATCH] =?UTF-8?q?refactor:=20=EA=B7=B8=EB=A3=B9=EC=8A=A4?= =?UTF-8?q?=ED=84=B0=EB=94=94=20=ED=98=84=EC=9E=AC=20=EC=83=81=ED=83=9C=20?= =?UTF-8?q?=EC=A1=B0=ED=9A=8C=20openapi=EB=A1=9C=20=EB=A7=88=EC=9D=B4?= =?UTF-8?q?=EA=B7=B8=EB=A0=88=EC=9D=B4=EC=85=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/lists/study-member-list.tsx | 8 +++----- .../pages/group-study-detail-page.tsx | 5 +++-- .../pages/premium-study-detail-page.tsx | 4 ++-- src/components/summary/study-info-summary.tsx | 4 ++-- .../group/api/get-group-study-my-status.ts | 15 --------------- .../group/channel/ui/channel-section.tsx | 6 ++---- .../model/use-group-study-my-status-query.ts | 19 ------------------- src/hooks/queries/group-study-member-api.ts | 17 +++++++++++++---- 8 files changed, 25 insertions(+), 53 deletions(-) delete mode 100644 src/features/study/group/api/get-group-study-my-status.ts delete mode 100644 src/features/study/group/model/use-group-study-my-status-query.ts diff --git a/src/components/lists/study-member-list.tsx b/src/components/lists/study-member-list.tsx index f96eed8c..5caff2ae 100644 --- a/src/components/lists/study-member-list.tsx +++ b/src/components/lists/study-member-list.tsx @@ -2,20 +2,18 @@ import Image from 'next/image'; import { useState } from 'react'; +import { GetGroupStudyMemberStatusResponseContent } from '@/api/openapi'; import Pagination from '@/components/ui/pagination'; import { useGetGroupStudyMembers } from '@/hooks/queries/group-study-member-api'; import { useAuth } from '@/hooks/use-auth'; -import type { - GroupStudyMember, - GroupStudyMyStatusResponse, -} from '../../features/study/group/api/group-study-types'; +import type { GroupStudyMember } from '../../features/study/group/api/group-study-types'; import GroupStudyMemberItem from '../../features/study/group/ui/group-study-member-item'; import KickedReasonModal from '../../features/study/group/ui/kicked-reason-modal'; interface GroupStudyMemberListProps { groupStudyId: number; leaderId: number; - myApplicationStatus?: GroupStudyMyStatusResponse; + myApplicationStatus?: GetGroupStudyMemberStatusResponseContent; } export default function StudyMemberList({ diff --git a/src/components/pages/group-study-detail-page.tsx b/src/components/pages/group-study-detail-page.tsx index 91e93041..05efdda2 100644 --- a/src/components/pages/group-study-detail-page.tsx +++ b/src/components/pages/group-study-detail-page.tsx @@ -6,10 +6,11 @@ import { useState } from 'react'; import MoreMenu from '@/components/ui/dropdown/more-menu'; import Tabs from '@/components/ui/tabs'; import { STUDY_DETAIL_TABS, StudyTabValue } from '@/config/constants'; +import { useGetGroupStudyMyStatus } from '@/hooks/queries/group-study-member-api'; import { StudyLeaderProvider } from '@/providers/study-leader-context'; import { Leader } from '../../features/study/group/api/group-study-types'; import ChannelSection from '../../features/study/group/channel/ui/channel-section'; -import { useGroupStudyMyStatusQuery } from '../../features/study/group/model/use-group-study-my-status-query'; + import { useCompleteGroupStudyMutation, useDeleteGroupStudyMutation, @@ -49,7 +50,7 @@ export default function StudyDetailPage({ const [action, setAction] = useState(null); const [showStudyFormModal, setShowStudyFormModal] = useState(false); - const { data: myApplicationStatus } = useGroupStudyMyStatusQuery({ + const { data: myApplicationStatus } = useGetGroupStudyMyStatus({ groupStudyId, isLeader, }); diff --git a/src/components/pages/premium-study-detail-page.tsx b/src/components/pages/premium-study-detail-page.tsx index ea8edfa1..dd2cec12 100644 --- a/src/components/pages/premium-study-detail-page.tsx +++ b/src/components/pages/premium-study-detail-page.tsx @@ -10,9 +10,9 @@ import { GroupStudyFullResponse, Leader, } from '@/features/study/group/api/group-study-types'; +import { useGetGroupStudyMyStatus } from '@/hooks/queries/group-study-member-api'; import { StudyLeaderProvider } from '@/providers/study-leader-context'; import ChannelSection from '../../features/study/group/channel/ui/channel-section'; -import { useGroupStudyMyStatusQuery } from '../../features/study/group/model/use-group-study-my-status-query'; import { useCompleteGroupStudyMutation, useDeleteGroupStudyMutation, @@ -51,7 +51,7 @@ export default function PremiumStudyDetailPage({ const [action, setAction] = useState(null); const [showStudyFormModal, setShowStudyFormModal] = useState(false); - const { data: myApplicationStatus } = useGroupStudyMyStatusQuery({ + const { data: myApplicationStatus } = useGetGroupStudyMyStatus({ groupStudyId, isLeader, }); diff --git a/src/components/summary/study-info-summary.tsx b/src/components/summary/study-info-summary.tsx index c9cef101..0601f140 100644 --- a/src/components/summary/study-info-summary.tsx +++ b/src/components/summary/study-info-summary.tsx @@ -16,7 +16,7 @@ import { STUDY_STATUS_LABELS, STUDY_TYPE_LABELS, } from '../../features/study/group/const/group-study-const'; -import { useGroupStudyMyStatusQuery } from '../../features/study/group/model/use-group-study-my-status-query'; +import { useGetGroupStudyMyStatus } from '@/hooks/queries/group-study-member-api'; interface Props { data: GroupStudyFullResponse; @@ -49,7 +49,7 @@ export default function SummaryStudyInfo({ data }: Props) { const isLeader = leader?.memberId === memberId; - const { data: myApplicationStatus } = useGroupStudyMyStatusQuery({ + const { data: myApplicationStatus } = useGetGroupStudyMyStatus({ groupStudyId, isLeader, }); diff --git a/src/features/study/group/api/get-group-study-my-status.ts b/src/features/study/group/api/get-group-study-my-status.ts deleted file mode 100644 index 2f732638..00000000 --- a/src/features/study/group/api/get-group-study-my-status.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { axiosInstance } from '@/api/client/axios'; -import type { GroupStudyMyStatusResponse } from './group-study-types'; - -// 그룹 스터디 신청한 내 상태 조회 API -export const getGroupStudyMyStatus = async ({ - groupStudyId, -}: { - groupStudyId: number; -}): Promise => { - const res = await axiosInstance.get( - `/group-studies/${groupStudyId}/members/status`, - ); - - return res.data.content; -}; diff --git a/src/features/study/group/channel/ui/channel-section.tsx b/src/features/study/group/channel/ui/channel-section.tsx index 3e34f63c..0c974aa6 100644 --- a/src/features/study/group/channel/ui/channel-section.tsx +++ b/src/features/study/group/channel/ui/channel-section.tsx @@ -1,18 +1,16 @@ +import { GetGroupStudyMemberStatusResponseContent } from '@/api/openapi'; import { useLeaderStore } from '@/stores/useLeaderStore'; import Comments from './comment-section'; import CreatePost from './create-post'; import Post from './post'; import PostNotFound from './post-not-found'; - -import { GroupStudyMyStatusResponse } from '../../api/group-study-types'; import KickedReasonModal from '../../ui/kicked-reason-modal'; - import { usePostQuery } from '../model/use-channel-query'; interface ChannelSectionProps { groupStudyId: number; memberId: number; - myApplicationStatus?: GroupStudyMyStatusResponse; + myApplicationStatus?: GetGroupStudyMemberStatusResponseContent; } export default function ChannelSection({ diff --git a/src/features/study/group/model/use-group-study-my-status-query.ts b/src/features/study/group/model/use-group-study-my-status-query.ts deleted file mode 100644 index 19c1d7c9..00000000 --- a/src/features/study/group/model/use-group-study-my-status-query.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { useQuery } from '@tanstack/react-query'; -import { useAuth } from '@/hooks/use-auth'; -import { getGroupStudyMyStatus } from '../api/get-group-study-my-status'; - -export const useGroupStudyMyStatusQuery = ({ - groupStudyId, - isLeader, -}: { - groupStudyId: number; - isLeader: boolean; -}) => { - const { data } = useAuth(); - - return useQuery({ - queryKey: ['groupStudyMyStatus', groupStudyId], - queryFn: () => getGroupStudyMyStatus({ groupStudyId }), // 그룹스터디 멤버만 상태 조회 가능 (리더는 조회 x) - enabled: !!groupStudyId && !isLeader && data?.memberId !== undefined, - }); -}; diff --git a/src/hooks/queries/group-study-member-api.ts b/src/hooks/queries/group-study-member-api.ts index dc7ffc4b..fb881eac 100644 --- a/src/hooks/queries/group-study-member-api.ts +++ b/src/hooks/queries/group-study-member-api.ts @@ -7,6 +7,7 @@ import type { } from '@/api/openapi/models'; // TEMPORARY: Keep until OpenAPI types fixed import type { GroupStudyMembersResponse } from '@/features/study/group/api/group-study-types'; +import { useAuth } from '../use-auth'; const groupStudyMemberApi = createApiInstance(GroupStudyMemberApi); @@ -50,15 +51,23 @@ export const useGetMemberRole = (id: number) => { }); }; -export const useGetMemberStatus = (id: number) => { +export const useGetGroupStudyMyStatus = ({ + groupStudyId, + isLeader, +}: { + groupStudyId: number; + isLeader: boolean; +}) => { + const { data } = useAuth(); + return useQuery({ - queryKey: ['groupStudyMemberStatus', id], + queryKey: ['groupStudyMemberStatus', groupStudyId], queryFn: async () => { - const { data } = await groupStudyMemberApi.getMemberStatus(id); + const { data } = await groupStudyMemberApi.getMemberStatus(groupStudyId); return data.content; }, - enabled: !!id, + enabled: !!groupStudyId && !isLeader && data?.memberId !== undefined, }); };