Skip to content
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

Feature/#315 스터디원 목록 api 연결 #319

Merged
merged 3 commits into from
Sep 27, 2024
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
18 changes: 14 additions & 4 deletions src/app/team/[teamId]/study/[studyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useEffect, useState } from 'react';
import { MdOutlineArrowForwardIos } from 'react-icons/md';

import { getDocumentList } from '@/app/api/document';
import { getStudy } from '@/app/api/study';
import { getStudy, getStudyMembers } from '@/app/api/study';
import DocumentCard from '@/components/DocumentCard';
import Title from '@/components/Title';
import CurriculumCard from '@/containers/study/CurriculumCard';
Expand All @@ -18,8 +18,8 @@ import Participant from '@/containers/study/Participant';
import StudyControlPanel from '@/containers/study/StudyControlPanel';
import StudyInfoCard from '@/containers/study/StudyInfoCard';
import StudyParticipantMenu from '@/containers/study/StudyParticipantMenu';
import participantData from '@/mocks/participant';
import { DocumentList, Study } from '@/types';
import { useGetFetchWithToken } from '@/hooks/useFetchWithToken';
import { DocumentList, ParticipantType, Study, StudyMember } from '@/types';

const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
const [studyData, setStudyData] = useState<Study>();
Expand All @@ -28,6 +28,16 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
const [isTerminateModalOpen, setIsTerminateModalOpen] = useState<boolean>(false);
const [documentArray, setDocumentArray] = useState<DocumentList[]>([]);

const participantData = useGetFetchWithToken(getStudyMembers, [params?.studyId])?.map(
(data: StudyMember) =>
({
id: data.memberId,
name: data.name,
status: data.memberId === studyData?.studyLeaderId ? '스터디장' : '스터디원',
profileImg: data.imageUrl,
}) as ParticipantType,
);

useEffect(() => {
getStudy(params.studyId).then((data) => {
setStudyData(data.body);
Expand Down Expand Up @@ -111,7 +121,7 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
leaderId={studyData?.studyLeaderId}
/>
)}
<Participant participantInfos={participantData} />
<Participant participantInfos={participantData || []} />
</Flex>
</Flex>
</Grid>
Expand Down
36 changes: 21 additions & 15 deletions src/containers/study/Participant/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,27 @@ const Participant = ({ participantInfos }: ParticipantProps) => {
// Feed 없을때 임시로 maxH="45vh"로 설정 원래는 maxH="30vh"
return (
<Card className="scroll" overflowY="auto" w="100%" h="100%" maxH="45vh" borderRadius="2xl" shadow="lg">
<Grid templateColumns="repeat(3, 1fr)" px="5" pt="5" pb="2">
{[
{ data: leader, color: colors.orange_dark },
...otherParticipants.map((data) => ({ data, color: 'inherit' })),
].map(({ data, color }) => (
<Flex key={data.id} justify="center" mb="3">
<Avatar size="sm" src={data.profileImg} />
<Link href={data.myPageUrl}>
<Text textStyle="bold_sm" ml="2" color={color}>
{data.name}
</Text>
</Link>
</Flex>
))}
</Grid>
{participantInfos.length > 0 ? (
<Grid templateColumns="repeat(3, 1fr)" px="5" pt="5" pb="2">
{[
{ data: leader, color: colors.orange_dark },
...otherParticipants.map((data) => ({ data, color: 'inherit' })),
].map(({ data, color }) => (
<Flex key={data.id} justify="center" mb="3">
<Avatar size="sm" src={data.profileImg} />
<Link href={data.myPageUrl}>
<Text textStyle="bold_sm" ml="2" color={color}>
{data.name}
</Text>
</Link>
</Flex>
))}
</Grid>
) : (
<Flex align="center" justify="center" my="10">
<Text textStyle="bold_sm">참여자가 없습니다.</Text>
</Flex>
)}
</Card>
);
};
Expand Down