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
4 changes: 3 additions & 1 deletion src/components/card/my-homework-status-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ interface MyHomeworkStatusProps {
myHomework?: HomeworkDetailResponseDto;
isMissionClosed?: boolean;
onSelectHomework: (homeworkId: number) => void;
onRefetch?: () => void;
}

export default function MyHomeworkStatusCard({
missionId,
myHomework,
isMissionClosed = false,
onSelectHomework,
onRefetch,
}: MyHomeworkStatusProps) {
// 미제출 상태
if (!myHomework || myHomework.homeworkStatus === 'NOT_SUBMITTED') {
Expand All @@ -28,7 +30,7 @@ export default function MyHomeworkStatusCard({
<span className="text-text-subtlest font-designer-14r">
아직 과제를 제출하지 않았습니다.
</span>
<SubmitHomeworkModal missionId={missionId} />
<SubmitHomeworkModal missionId={missionId} onSuccess={onRefetch} />
</div>
</div>
);
Expand Down
21 changes: 13 additions & 8 deletions src/components/contents/homework-detail-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,17 @@ export default function HomeworkDetailContent({
const isLeader = useIsLeader(currentUserId);
const { data: homework, isLoading: isHomeworkLoading } =
useGetHomework(homeworkId);
const { data: mission, isLoading: isMissionLoading } =
useGetMission(missionId);
const {
data: mission,
isLoading: isMissionLoading,
refetch: refetchMission,
} = useGetMission(missionId);

const handleDeleteSuccess = () => {
const handleDeleteSuccess = async () => {
const params = new URLSearchParams(searchParams.toString());
params.delete('homeworkId');
router.push(`?${params.toString()}`);
await refetchMission();
};

if (isHomeworkLoading || !homework || isMissionLoading || !mission) {
Expand All @@ -59,8 +63,9 @@ export default function HomeworkDetailContent({
// 미션 제출 가능 기간이 지나지 않았는지 확인
const isMissionActive = mission.status !== 'ENDED';

// 삭제 가능 조건: 평가 전이면서 미션 제출 가능 기간이 지나지 않은 상태
const canDelete = !isEvaluated && isMissionActive;
// 수정/삭제 가능 조건: 본인 과제이면서 평가 전이면서 미션 제출 가능 기간이 지나지 않은 상태
const isMyHomework = homework.submitterId === currentUserId;
const canEditOrDelete = isMyHomework && !isEvaluated && isMissionActive;

const profileImageUrl =
homework.submitterProfileImage?.resizedImages?.[0]?.resizedImageUrl ??
Expand Down Expand Up @@ -91,8 +96,8 @@ export default function HomeworkDetailContent({
</div>
</div>

{/* 수정/삭제 버튼 - 평가 전이면서 미션 제출 가능 기간이 지나지 않은 경우에만 노출 */}
{canDelete && (
{/* 수정/삭제 버튼 - 본인 과제이면서 평가 전이면서 미션 제출 가능 기간이 지나지 않은 경우에만 노출 */}
{canEditOrDelete && (
<div className="flex items-center gap-100">
<EditHomeworkModal
homeworkId={homeworkId}
Expand Down Expand Up @@ -144,7 +149,7 @@ export default function HomeworkDetailContent({
homeworkId={homeworkId}
peerReviews={peerReviews ?? []}
isLeader={isLeader}
isMyHomework={homework.submitterId === currentUserId}
isMyHomework={isMyHomework}
/>
</div>
);
Expand Down
3 changes: 2 additions & 1 deletion src/components/contents/mission-detail-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function MissionDetailContent({
const memberId = useUserStore((state) => state.memberId);
const isLeader = useIsLeader(memberId);

const { data: mission, isLoading } = useGetMission(missionId);
const { data: mission, isLoading, refetch } = useGetMission(missionId);

// homeworks에서 내 과제 정보 찾기
const myHomework = useMemo(() => {
Expand Down Expand Up @@ -84,6 +84,7 @@ export default function MissionDetailContent({
myHomework={myHomework}
isMissionClosed={isMissionClosed}
onSelectHomework={handleSelectHomework}
onRefetch={refetch}
/>
)}

Expand Down
1 change: 0 additions & 1 deletion src/components/lists/group-study-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { GroupStudyListItemDto } from '@/api/openapi';
import { useAuth } from '@/hooks/common/use-auth';
import { hashValue } from '@/utils/hash';

import { GroupStudyData } from '../../features/study/group/api/group-study-types';
import StudyCard from '../card/study-card';

interface GroupStudyListProps {
Expand Down
11 changes: 10 additions & 1 deletion src/components/modals/submit-homework-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@ type SubmitHomeworkFormValues = z.infer<typeof SubmitHomeworkFormSchema>;

interface SubmitHomeworkModalProps {
missionId: number; // todo api response 타입 적용
onSuccess?: () => void;
}

// 과제 제출 모달
export default function SubmitHomeworkModal({
missionId,
onSuccess,
}: SubmitHomeworkModalProps) {
const [open, setOpen] = useState<boolean>(false);

Expand Down Expand Up @@ -54,6 +56,7 @@ export default function SubmitHomeworkModal({
<SubmitHomeworkForm
missionId={missionId}
onClose={() => setOpen(false)}
onSuccess={onSuccess}
/>
</Modal.Content>
</Modal.Portal>
Expand All @@ -64,9 +67,14 @@ export default function SubmitHomeworkModal({
interface SubmitHomeworkFormProps {
missionId: number;
onClose: () => void;
onSuccess?: () => void;
}

function SubmitHomeworkForm({ missionId, onClose }: SubmitHomeworkFormProps) {
function SubmitHomeworkForm({
missionId,
onClose,
onSuccess,
}: SubmitHomeworkFormProps) {
const methods = useForm<SubmitHomeworkFormValues>({
resolver: zodResolver(SubmitHomeworkFormSchema),
mode: 'onChange',
Expand All @@ -93,6 +101,7 @@ function SubmitHomeworkForm({ missionId, onClose }: SubmitHomeworkFormProps) {
onSuccess: async () => {
alert('과제가 성공적으로 제출되었습니다!');
onClose();
onSuccess?.();
},
onError: () => {
alert('과제 제출에 실패했습니다. 다시 시도해주세요.');
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/group-study-detail-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { STUDY_DETAIL_TABS, StudyTabValue } from '@/config/constants';
import { useGetGroupStudyMyStatus } from '@/hooks/queries/group-study-member-api';
import { useLeaderStore } from '@/stores/useLeaderStore';
import { Leader } from '../../features/study/group/api/group-study-types';
import ChannelSection from '../../features/study/group/channel/ui/channel-section';
import ChannelSection from '../../features/study/group/channel/ui/lounge-section';

import {
useCompleteGroupStudyMutation,
Expand Down Expand Up @@ -228,7 +228,7 @@ export default function StudyDetailPage({
)}

{active === 'mission' && <MissionSection groupStudyId={groupStudyId} />}
{active === 'channel' && (
{active === 'lounge' && (
<ChannelSection
groupStudyId={groupStudyId}
memberId={memberId}
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 @@ -12,7 +12,7 @@ import {
} from '@/features/study/group/api/group-study-types';
import { useGetGroupStudyMyStatus } from '@/hooks/queries/group-study-member-api';
import { useLeaderStore } from '@/stores/useLeaderStore';
import ChannelSection from '../../features/study/group/channel/ui/channel-section';
import ChannelSection from '../../features/study/group/channel/ui/lounge-section';
import {
useCompleteGroupStudyMutation,
useDeleteGroupStudyMutation,
Expand Down Expand Up @@ -234,7 +234,7 @@ export default function PremiumStudyDetailPage({
{activeTab === 'mission' && (
<MissionSection groupStudyId={groupStudyId} />
)}
{activeTab === 'channel' && (
{activeTab === 'lounge' && (
<ChannelSection
groupStudyId={groupStudyId}
memberId={memberId}
Expand Down
4 changes: 2 additions & 2 deletions src/components/pages/premium-study-list-page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default function PremiumStudyListPage() {
}

return (
<PageContainer className="py-600">
<div className="mx-auto w-[1280px] py-600">
{/* 헤더 */}
<div className="mb-400 flex items-center justify-between">
<h1 className="font-designer-24b text-text-default">
Expand Down Expand Up @@ -185,6 +185,6 @@ export default function PremiumStudyListPage() {
totalPages={totalPages}
/>
)}
</PageContainer>
</div>
);
}
9 changes: 3 additions & 6 deletions src/components/section/group-study-info-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ export default function StudyInfoSection({
groupStudyId,
status: 'APPROVED',
});

const applicants = [
...(approvedApplicants?.pages.flatMap(({ content }) => content) || []),
];
const applicants = approvedApplicants?.pages[0]?.content;

return (
// todo: 스터디 공지 모달 추가
Expand Down Expand Up @@ -103,7 +100,7 @@ export default function StudyInfoSection({
<div className="flex items-center justify-between">
<div className="font-designer-20b flex gap-100">
<span>실시간 신청자 목록</span>
<span className="text-[#A4A7AE]">{`${approvedApplicants?.pages.length}명`}</span>
<span className="text-[#A4A7AE]">{`${applicants?.length}명`}</span>
</div>
{isLeader && (
<Button
Expand All @@ -118,7 +115,7 @@ export default function StudyInfoSection({
</div>

<div className="grid grid-cols-2 grid-rows-2 gap-200">
{applicants.map((data) => {
{applicants?.map((data) => {
const temperPreset = getSincerityPresetByLevelName(
data.applicantInfo.sincerityTemp.levelName as string,
);
Expand Down
2 changes: 1 addition & 1 deletion src/config/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ export const STUDY_DETAIL_TABS = [
{ label: '스터디 소개', value: 'intro' },
{ label: '참가자', value: 'members' },
{ label: '미션', value: 'mission' },
{ label: '채널', value: 'channel' },
{ label: '라운지', value: 'lounge' },
] as const;

export type StudyTabValue = (typeof STUDY_DETAIL_TABS)[number]['value'];
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ChannelSectionProps {
myApplicationStatus?: GetGroupStudyMemberStatusResponseContent;
}

export default function ChannelSection({
export default function LoungeSection({
groupStudyId,
memberId,
myApplicationStatus,
Expand Down
2 changes: 1 addition & 1 deletion src/features/study/group/channel/ui/post-not-found.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from 'react';

export default function PostNotFound() {
return (
<div className="bg-background-alternative flex h-[640px]">
<div className="bg-background-alternative my-500 flex h-[640px] w-[1164px]">
<div className="m-auto flex flex-col items-center">
<Image
src="/images/post_not_found.png"
Expand Down
23 changes: 14 additions & 9 deletions src/features/study/group/channel/ui/post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ import dayjs from 'dayjs';
import UserAvatar from '@/components/ui/avatar';
import Button from '@/components/ui/button';
import UserProfileModal from '@/entities/user/ui/user-profile-modal';
import { useLeaderStore } from '@/stores/useLeaderStore';
import { useIsLeader, useLeaderStore } from '@/stores/useLeaderStore';
import { useUserStore } from '@/stores/useUserStore';
import GroupStudyNoticeModal from '../../ui/group-notice-modal';

interface PostProps {
Expand All @@ -15,6 +16,8 @@ interface PostProps {
}
export default function Post({ data }: PostProps) {
const leader = useLeaderStore((state) => state.leaderInfo);
const myMemberId = useUserStore((state) => state.memberId);
const isLeader = useIsLeader(myMemberId);

if (!leader) return null;

Expand All @@ -26,14 +29,16 @@ export default function Post({ data }: PostProps) {
{data?.noticeTitle}
</p>

<GroupStudyNoticeModal
trigger={<Button size="medium">공지 수정하기</Button>}
groupStudyId={data.groupStudyId}
defaultValues={{
noticeTitle: data.noticeTitle,
noticeContent: data.noticeContent,
}}
/>
{isLeader && (
<GroupStudyNoticeModal
trigger={<Button size="medium">공지 수정하기</Button>}
groupStudyId={data.groupStudyId}
defaultValues={{
noticeTitle: data.noticeTitle,
noticeContent: data.noticeContent,
}}
/>
)}
</div>

<div className="flex gap-150">
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/queries/peer-review-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const useCreatePeerReview = () => {
await queryClient.invalidateQueries({
queryKey: ['peerReviews', variables.homeworkId],
});
await queryClient.invalidateQueries({
queryKey: ['homework', variables.homeworkId],
});
},
});
};
Expand Down
3 changes: 3 additions & 0 deletions src/hooks/queries/study-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,8 @@ export const useGetStudies = ({
return data.content;
},
placeholderData: keepPreviousData,
staleTime: 0,
refetchOnMount: true,
refetchOnWindowFocus: true,
});
};
Loading
Loading