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/#365 스터디페이지에 학습자료 추가 버튼 구현 #367

Merged
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
57 changes: 39 additions & 18 deletions src/app/team/[teamId]/study/[studyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ import { useAtomValue } from 'jotai';
import NextLink from 'next/link';
import { useRouter } from 'next/navigation';
import { useEffect, useState } from 'react';
import { BsPlus } from 'react-icons/bs';
import { MdOutlineArrowForwardIos } from 'react-icons/md';

import { getDocumentList } from '@/app/api/document';
import { getStudy, getStudyMembers } from '@/app/api/study';
import { myTeamAtom } from '@/atom';
import DocumentCard from '@/components/DocumentCard';
import Title from '@/components/Title';
import CreateDocumentModal from '@/containers/study/CreateDocumentModal';
import { CreateDocument } from '@/containers/study/CreateDocumentModal/type';
import CurriculumCard from '@/containers/study/CurriculumCard';
import DeleteStudyModal from '@/containers/study/Modal/DeleteStudyModal';
import StudyModal from '@/containers/study/Modal/StudyModal';
Expand All @@ -30,6 +33,8 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
const [isDeleteModalOpen, setIsDeleteModalOpen] = useState<boolean>(false);
const [isTerminateModalOpen, setIsTerminateModalOpen] = useState<boolean>(false);
const [documentArray, setDocumentArray] = useState<DocumentList[]>([]);
const [isCreateDocumentModalOpen, setIsCreateDocumentModalOpen] = useState<boolean>(false);
const categoryData: CreateDocument = { groupId: params.studyId, groupType: 'studies' };

const router = useRouter();
const user = useGetUser();
Expand Down Expand Up @@ -58,7 +63,7 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
setDocumentArray(res.body.content);
}
});
}, [params.studyId, isEditModalOpen]);
}, [params.studyId, isEditModalOpen, isCreateDocumentModalOpen]);

useEffect(() => {
if (!isTerminateModalOpen) {
Expand Down Expand Up @@ -108,25 +113,34 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
/>
)}

<Flex align="right" direction="column" rowGap="3" w="100%">
<Link
as={NextLink}
gap="3"
display="flex"
w="fit-content"
ml="auto"
href={`/team/${params.teamId}/study/${params.studyId}/document`}
>
<Flex direction="column" rowGap="3" w="100%">
<Flex align="center" justify="space-between">
<Link
as={NextLink}
gap="3"
display="flex"
w="fit-content"
href={`/team/${params.teamId}/study/${params.studyId}/document`}
>
<IconButton
fontSize="16px"
aria-label=""
icon={<MdOutlineArrowForwardIos />}
isRound
size="icon_sm"
variant="icon_orange"
/>
<Text>전체 보기</Text>
</Link>
<IconButton
fontSize="16px"
shadow="base"
aria-label=""
icon={<MdOutlineArrowForwardIos />}
isRound
size="icon_sm"
variant="icon_orange"
icon={<BsPlus />}
onClick={() => setIsCreateDocumentModalOpen(true)}
size="icon_md"
variant="icon_orange_dark"
/>
<Text>전체 보기</Text>
</Link>
</Flex>
{documentArray && documentArray.length > 0 ? (
<Grid gap="2" templateColumns={{ base: 'repeat(2, 1fr)', lg: 'repeat(4, 1fr)' }}>
{documentArray.map((data) => (
Expand Down Expand Up @@ -162,7 +176,7 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
refetchMembers={handleRefetchMembers}
/>
)}
<Participant participantInfos={participantData || []} />
{participantData && <Participant participantInfos={participantData} />}
</Flex>
</Flex>
</Grid>
Expand All @@ -186,6 +200,13 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
isOpen={isDeleteModalOpen}
setIsOpen={setIsDeleteModalOpen}
/>

<CreateDocumentModal
isOpen={isCreateDocumentModalOpen}
onClose={() => setIsCreateDocumentModalOpen(false)}
categoryData={categoryData}
category="create"
/>
</>
);
};
Expand Down