-
Notifications
You must be signed in to change notification settings - Fork 0
그룹스터디 후기 기능 추가 및 스터디 수정 모달 관련 로직 수정 #444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
73071c5
fix : 온점 추가
HA-SEUNG-JEONG d9f2d6b
feat : 1:1 스터디 리뷰 평가 통계·후기 목록 추가 및 그룹 스터디 수정 폼 스키마 분리
HA-SEUNG-JEONG ed241ab
fix : 스키마 수정
HA-SEUNG-JEONG 5c7f55a
delete : 불필요 파일 삭제
HA-SEUNG-JEONG 9708ef2
feat : 새 컴포넌트 추가
HA-SEUNG-JEONG 81219ee
delete : studyTypeName prop 제거
HA-SEUNG-JEONG ffd41cd
refactor : 중복 로직 리팩토링
HA-SEUNG-JEONG 4c78796
fix : fallback 처리
HA-SEUNG-JEONG 2306981
fix : 스터디 수정 모드에서 기존 시작일 유지 시 유효성 오류 수정
HA-SEUNG-JEONG a0b89e7
feat : 메인 반영
HA-SEUNG-JEONG 7536842
fix : typecheck 수정
HA-SEUNG-JEONG dae80cb
fix : typecheck 수정
HA-SEUNG-JEONG 3c2fc24
fix : 패키지 업데이트
HA-SEUNG-JEONG b3f92f8
feat : 미작성 후기 모달 띄우기
HA-SEUNG-JEONG 45b0d7c
feat : 훅 추가
HA-SEUNG-JEONG 404f555
feat : 새 컴포넌트 추가(툴바)
HA-SEUNG-JEONG 0e6b8b2
fix : 워딩 및 잔재 버그 수정
HA-SEUNG-JEONG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
249 changes: 249 additions & 0 deletions
249
src/app/(service)/(my)/my-study-review/_components/completed-study-review-page.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,249 @@ | ||
| 'use client'; | ||
|
|
||
| import { useQueries } from '@tanstack/react-query'; | ||
| import dayjs from 'dayjs'; | ||
| import dynamic from 'next/dynamic'; | ||
| import { useMemo, useState } from 'react'; | ||
| import { axiosInstance } from '@/api/client/axios'; | ||
| import GroupStudyReviewModal from '@/components/common/modals/group-study-review-modal'; | ||
| import Pagination from '@/components/common/ui/pagination'; | ||
| import { useAuthReady } from '@/hooks/common/use-auth'; | ||
| import { useMemberStudyListQuery } from '@/hooks/queries/use-member-study-list-query'; | ||
| import { useToastStore } from '@/stores/use-toast-store'; | ||
| import type { MemberStudyItem } from '@/types/api/group-study.types'; | ||
| import StudyReviewTabNav from './study-review-tab-nav'; | ||
| import MemberStudyCard from '../group/_components/member-study-card'; | ||
|
|
||
| const StudyCompletionModal = dynamic( | ||
| () => import('@/components/common/modals/study-completion-modal'), | ||
| { ssr: false }, | ||
| ); | ||
|
|
||
| const StudyReviewModal = dynamic( | ||
| () => import('@/components/common/modals/study-review-modal'), | ||
| { ssr: false }, | ||
| ); | ||
|
|
||
| interface CompletedStudyReviewPageProps { | ||
| basePath: string; | ||
| studyType: 'GROUP_STUDY' | 'PREMIUM_STUDY' | 'ONE_ON_ONE_STUDY'; | ||
| studyTypeName: string; | ||
| hideTabNav?: boolean; | ||
| hideEmptyMessage?: boolean; | ||
| } | ||
|
|
||
| interface StudyRoleSectionProps { | ||
| title: string; | ||
| studies: MemberStudyItem[]; | ||
| basePath: string; | ||
| emptyMessage: string; | ||
| onMemberClick?: (study: MemberStudyItem) => void; | ||
| } | ||
|
|
||
| function StudyRoleSection({ | ||
| title, | ||
| studies, | ||
| basePath, | ||
| emptyMessage, | ||
| onMemberClick, | ||
| }: StudyRoleSectionProps) { | ||
| return ( | ||
| <section className="flex flex-col gap-200"> | ||
| <div className="flex items-center gap-100"> | ||
| <h2 className="font-designer-20b text-text-default">{title}</h2> | ||
| </div> | ||
|
|
||
| {studies.length > 0 ? ( | ||
| <ul className="grid grid-cols-1 gap-300 sm:grid-cols-2 lg:grid-cols-3"> | ||
| {studies.map((study, index) => ( | ||
| <MemberStudyCard | ||
| key={study.studyId ?? index} | ||
| study={study} | ||
| basePath={basePath} | ||
| onMemberClick={onMemberClick} | ||
| /> | ||
| ))} | ||
| </ul> | ||
| ) : ( | ||
| <div className="font-designer-14r text-text-subtle flex h-200 items-center justify-center rounded-100 border border-border-subtle text-center"> | ||
| {emptyMessage} | ||
| </div> | ||
| )} | ||
| </section> | ||
| ); | ||
| } | ||
|
|
||
| export default function CompletedStudyReviewPage({ | ||
| basePath, | ||
| studyType, | ||
| studyTypeName, | ||
| hideTabNav = false, | ||
| hideEmptyMessage = false, | ||
| }: CompletedStudyReviewPageProps) { | ||
| const [page, setPage] = useState(1); | ||
| const [reviewStudy, setReviewStudy] = useState<MemberStudyItem | null>(null); | ||
| const [submittedStudyIds, setSubmittedStudyIds] = useState<number[]>([]); | ||
| const [showCompletionModal, setShowCompletionModal] = useState(false); | ||
|
|
||
| const { memberId } = useAuthReady(); | ||
| const showToast = useToastStore((state) => state.showToast); | ||
|
|
||
| const { data: completedStudyResponse } = useMemberStudyListQuery({ | ||
| memberId: memberId ?? 0, | ||
| studyType, | ||
| studyStatus: 'COMPLETED', | ||
| completedPage: page, | ||
| completedPageSize: 6, | ||
| }); | ||
|
|
||
| const completedStudies = useMemo( | ||
| () => completedStudyResponse?.completed.content ?? [], | ||
| [completedStudyResponse?.completed.content], | ||
| ); | ||
| const participantStudies = completedStudies.filter( | ||
| (study) => study.studyRole === 'PARTICIPANT', | ||
| ); | ||
| const leaderStudies = completedStudies.filter( | ||
| (study) => study.studyRole === 'LEADER', | ||
| ); | ||
|
|
||
| const writtenResults = useQueries({ | ||
| queries: participantStudies.map((study) => ({ | ||
| queryKey: ['study-review', 'written', studyType, study.studyId], | ||
| queryFn: async () => { | ||
| const url = | ||
| studyType === 'ONE_ON_ONE_STUDY' | ||
| ? `/study-spaces/${study.studyId}/reviews/written` | ||
| : `/group-studies/${study.studyId}/reviews/written`; | ||
| const { data } = await axiosInstance.get<{ content: boolean }>(url); | ||
|
|
||
| return data.content; | ||
| }, | ||
| enabled: !!study.studyId, | ||
| staleTime: 60_000, | ||
| })), | ||
| }); | ||
|
|
||
| const reviewWrittenByStudyId = new Map<number, boolean | undefined>(); | ||
|
|
||
| participantStudies.forEach((study, index) => { | ||
| const writtenResult = writtenResults[index]; | ||
| const isRecentlySubmitted = submittedStudyIds.includes(study.studyId); | ||
|
|
||
| reviewWrittenByStudyId.set( | ||
| study.studyId, | ||
| isRecentlySubmitted || writtenResult?.data === true | ||
| ? true | ||
| : writtenResult?.data, | ||
| ); | ||
| }); | ||
|
|
||
| const handleParticipantStudyClick = (study: MemberStudyItem) => { | ||
| const reviewWritten = reviewWrittenByStudyId.get(study.studyId); | ||
|
|
||
| if (reviewWritten === true) { | ||
| showToast('이미 후기를 작성한 스터디입니다.', 'info'); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| if (reviewWritten === undefined) { | ||
| showToast( | ||
| '후기 작성 가능 여부를 확인하는 중입니다. 잠시 후 다시 시도해주세요.', | ||
| 'info', | ||
| ); | ||
|
|
||
| return; | ||
| } | ||
|
|
||
| setReviewStudy(study); | ||
| }; | ||
|
|
||
| const activeReviewStudyId = reviewStudy?.studyId; | ||
|
|
||
| const handleSubmitSuccess = () => { | ||
| if (activeReviewStudyId === undefined) return; | ||
| setSubmittedStudyIds((prev) => | ||
| prev.includes(activeReviewStudyId) | ||
| ? prev | ||
| : [...prev, activeReviewStudyId], | ||
| ); | ||
| setTimeout(() => setShowCompletionModal(true), 300); | ||
| }; | ||
|
|
||
| const emptyParticipatedMessage = `아직 참여한 ${studyTypeName}가 없습니다.`; | ||
| const emptyLedMessage = `아직 개설한 ${studyTypeName}가 없습니다.`; | ||
|
|
||
| return ( | ||
| <div className="flex flex-col gap-400"> | ||
| {!hideTabNav && <StudyReviewTabNav />} | ||
|
|
||
| {completedStudies.length === 0 ? ( | ||
| !hideEmptyMessage && ( | ||
| <div className="font-designer-14r text-text-subtle flex h-200 items-center justify-center text-center"> | ||
| {emptyParticipatedMessage} | ||
| </div> | ||
| ) | ||
| ) : ( | ||
| <> | ||
| <StudyRoleSection | ||
| title="참여한 스터디" | ||
| studies={participantStudies} | ||
| basePath={basePath} | ||
| emptyMessage={emptyParticipatedMessage} | ||
| onMemberClick={handleParticipantStudyClick} | ||
| /> | ||
|
|
||
| <StudyRoleSection | ||
| title="운영한 스터디" | ||
| studies={leaderStudies} | ||
| basePath={basePath} | ||
| emptyMessage={emptyLedMessage} | ||
| /> | ||
|
|
||
| <Pagination | ||
| page={page} | ||
| onChangePage={setPage} | ||
| totalPages={completedStudyResponse?.completed.totalPages ?? 1} | ||
| /> | ||
| </> | ||
| )} | ||
|
|
||
| {activeReviewStudyId !== undefined && | ||
| reviewStudy && | ||
| (studyType === 'ONE_ON_ONE_STUDY' ? ( | ||
| <StudyReviewModal | ||
| open={!!reviewStudy} | ||
| onOpenChange={(open) => { | ||
| if (!open) { | ||
| setReviewStudy(null); | ||
| } | ||
| }} | ||
| targetStudySpaceId={activeReviewStudyId} | ||
| onSubmitSuccess={handleSubmitSuccess} | ||
| /> | ||
| ) : ( | ||
| <GroupStudyReviewModal | ||
| open={!!reviewStudy} | ||
| onOpenChange={(open) => { | ||
| if (!open) { | ||
| setReviewStudy(null); | ||
| } | ||
| }} | ||
| groupStudyId={activeReviewStudyId} | ||
| detailInfo={{ title: reviewStudy.title }} | ||
| basicInfo={{ | ||
| startDate: dayjs(reviewStudy.startTime).format('YYYY.MM.DD'), | ||
| endDate: dayjs(reviewStudy.endTime).format('YYYY.MM.DD'), | ||
| }} | ||
| onSubmitSuccess={handleSubmitSuccess} | ||
| /> | ||
| ))} | ||
|
|
||
| <StudyCompletionModal | ||
| open={showCompletionModal} | ||
| onOpenChange={setShowCompletionModal} | ||
| /> | ||
| </div> | ||
| ); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 3699
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 64
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 64
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 64
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 364
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 97
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 64
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 6007
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 64
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 64
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 167
🏁 Script executed:
Repository: code-zero-to-one/study-platform-client
Length of output: 317
Tailwind 임의 값 사용이 코딩 가이드라인을 위반합니다.
pb-[100px]와max-w-[780px]는 임의 값(arbitrary values)을 사용하고 있습니다. 프로젝트 커스텀 디자인 토큰만 사용해야 합니다. 예를 들어,px-400과pt-400,pt-500은 올바르게global.css에 정의된 spacing 토큰을 사용하고 있습니다. 비슷하게pb-와max-w-도 정의된 토큰 또는 새로운 utility 클래스를 사용해 주세요.🤖 Prompt for AI Agents