Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/components/lists/study-member-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
5 changes: 3 additions & 2 deletions src/components/pages/group-study-detail-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -49,7 +50,7 @@ export default function StudyDetailPage({
const [action, setAction] = useState<ActionKey | null>(null);
const [showStudyFormModal, setShowStudyFormModal] = useState<boolean>(false);

const { data: myApplicationStatus } = useGroupStudyMyStatusQuery({
const { data: myApplicationStatus } = useGetGroupStudyMyStatus({
groupStudyId,
isLeader,
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/premium-study-detail-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -51,7 +51,7 @@ export default function PremiumStudyDetailPage({
const [action, setAction] = useState<ActionKey | null>(null);
const [showStudyFormModal, setShowStudyFormModal] = useState<boolean>(false);

const { data: myApplicationStatus } = useGroupStudyMyStatusQuery({
const { data: myApplicationStatus } = useGetGroupStudyMyStatus({
groupStudyId,
isLeader,
});
Expand Down
4 changes: 2 additions & 2 deletions src/components/summary/study-info-summary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
});
Expand Down
15 changes: 0 additions & 15 deletions src/features/study/group/api/get-group-study-my-status.ts

This file was deleted.

6 changes: 2 additions & 4 deletions src/features/study/group/channel/ui/channel-section.tsx
Original file line number Diff line number Diff line change
@@ -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({
Expand Down
19 changes: 0 additions & 19 deletions src/features/study/group/model/use-group-study-my-status-query.ts

This file was deleted.

17 changes: 13 additions & 4 deletions src/hooks/queries/group-study-member-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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,
});
};

Expand Down
Loading