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/#305 스터디페이지 권한 수정 #307

Merged
merged 7 commits into from
Sep 27, 2024
15 changes: 10 additions & 5 deletions src/app/team/[teamId]/study/[studyId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ 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 useGetUser from '@/hooks/useGetUser';
import participantData from '@/mocks/participant';
import { DocumentList, Study } from '@/types';

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

const user = useGetUser();

useEffect(() => {
getStudy(params.studyId).then((data) => {
setStudyData(data.body);
Expand All @@ -54,11 +57,13 @@ const Page = ({ params }: { params: { teamId: number; studyId: number } }) => {
</>
)}
</Flex>
<StudyControlPanel
editModalOpen={setIsEditModalOpen}
terminateModalOpen={setIsTerminateModalOpen}
deleteModalOpen={setIsDeleteModalOpen}
/>
{user?.memberId === studyData?.studyLeaderId && (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 부분 user가 null 이고 studyData도 null 이라면 True로 판단될 수 있을 듯 합니다.
studyData && user?.memberId === studyData.studyLeaderId && 로 고치는 것도 좋아보입니다.

<StudyControlPanel
editModalOpen={setIsEditModalOpen}
terminateModalOpen={setIsTerminateModalOpen}
deleteModalOpen={setIsDeleteModalOpen}
/>
)}
<Grid gap="4" templateColumns={{ base: '', xl: '2fr 1fr' }} w="100%">
<Flex direction="column" rowGap={{ base: '6', '2xl': '12' }}>
{studyData && (
Expand Down