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

[FE] Fix/permission 토픽 권한 수정 오류 해결 #419

Merged
merged 7 commits into from
Sep 20, 2023
2 changes: 1 addition & 1 deletion frontend/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ import { defineConfig } from 'cypress';
export default defineConfig({
e2e: {
baseUrl: 'http://localhost:3000',
defaultCommandTimeout: 10000,
defaultCommandTimeout: 20000,
},
});
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/mapbefine.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('토픽 상세 페이지', () => {
if (index === 0) $el.click();
});

cy.wait(3000);
cy.wait(5000);

cy.get('span').each(($el, index) => {
if (index === 6) $el.click();
Expand All @@ -87,7 +87,7 @@ describe('토픽 상세 페이지', () => {
if (index === 0) $el.click();
});

cy.wait(2000);
cy.wait(5000);

cy.get('span').each(($el, index) => {
if (index === 6) $el.click();
Expand Down
39 changes: 26 additions & 13 deletions frontend/src/components/AuthorityRadioContainer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import Text from '../common/Text';
import Space from '../common/Space';
import Flex from '../common/Flex';
import { useContext, useEffect, useState } from 'react';
import { TopicAuthorMember, TopicAuthorMemberWithId } from '../../types/Topic';
import {
TopicAuthorMember,
TopicAuthorMemberWithAuthorId,
} from '../../types/Topic';
import { ModalContext } from '../../context/ModalContext';
import Box from '../common/Box';
import Modal from '../Modal';
Expand All @@ -18,7 +21,7 @@ interface AuthorityRadioContainer {
setIsPrivate: React.Dispatch<React.SetStateAction<boolean>>;
setIsAll: React.Dispatch<React.SetStateAction<boolean>>;
setAuthorizedMemberIds: React.Dispatch<React.SetStateAction<number[]>>;
permissionedMembers?: TopicAuthorMemberWithId[];
permissionedMembers?: TopicAuthorMemberWithAuthorId[];
}

const AuthorityRadioContainer = ({
Expand Down Expand Up @@ -62,6 +65,10 @@ const AuthorityRadioContainer = ({
);
};

const whenViewingPreviousAuthorMember = () => {
return authorizedMemberIds.length === 0 && !isAll;
Copy link
Collaborator

Choose a reason for hiding this comment

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

원래 있던 로직에 &&!isAll 부분만 추가됬는데 어떤 차이가 있는지 이해가 잘 안되네여...😅
해설 부탁드립니다

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

저도 이 부분이 궁금합니다!!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 부분은 UI에 대한 부분입니다. '이전에 권한을 지정한 인원' 영역이 '모두' 또는 '혼자' 를 클릭할 때 마다 보여서요. '모두' 또는 '혼자'를 선택했었으면 권한을 선택한 인원이 없었는데 UI 상으로 '이전에 권한을 지정한 인원' 영역이 보이게 되면 사용자가 혼란을 겪을 수도 있어 위와 같이 변경하였습니다.

스크린샷으로 보여드리고 싶은데 토큰 이슈가 있어서 텍스트로만 답변드린 점 양해부탁드립니다~~

};

return (
<>
<Text color="black" $fontSize="default" $fontWeight="normal">
Expand Down Expand Up @@ -162,25 +169,31 @@ const AuthorityRadioContainer = ({
</>
)}

{authorizedMemberIds.length === 0 && permissionedMembers && (
{permissionedMembers && whenViewingPreviousAuthorMember() && (
Copy link
Collaborator

Choose a reason for hiding this comment

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

이 부분도 이렇게 변경된 이유 한번 설명해주실 수 있으실까요?! permissionedMembers는 이해가 됐는데 whenViewingPreviousAuthorMember() 이 부분이 이해가 안되서 그런 것 같아요!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

whenViewingPrevious~~ 함수는 true 또는 false를 반환하는 조건식입니다. 단순히 조건식을 바로 나열할 수도 있는데 && 연산자가 3번이나 쓰여서 가독성이 좋지 않을 것 같아서요. 그리고 조건식을 나열한 것만 봐서는 그 의미를 파악하기 힘들것 같아 함수로 빼버렸습니다.

<>
<Space size={5} />
<Space size={0} />
<Box>
<Text color="black" $fontSize="default" $fontWeight="normal">
기존에 선택한 친구들
이전에 권한을 부여한 친구들
</Text>
<Space size={1} />
{permissionedMembers.map((member) => (
<Text
color="black"
$fontSize="default"
$fontWeight="normal"
key={member.id}
>
• {member.memberResponse.nickName}
{permissionedMembers.length > 0 ? (
permissionedMembers.map((member) => (
<Text
color="black"
$fontSize="default"
$fontWeight="normal"
key={member.id}
>
• {member.memberResponse.nickName}
</Text>
))
) : (
<Text color="black" $fontSize="default" $fontWeight="normal">
• 없음
</Text>
))}
)}
</Box>
</>
)}
Expand Down
10 changes: 4 additions & 6 deletions frontend/src/components/TopicInfo/UpdatedTopicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const UpdatedTopicInfo = ({
publicity: isPrivate ? 'PRIVATE' : 'PUBLIC',
permissionType: isAll && !isPrivate ? 'ALL_MEMBERS' : 'GROUP_ONLY',
},
errorMessage: `'공개 ➡️ 비공개', '모두 ➡️ 친구들', '친구들 ➡️ 혼자' 로 변경할 수 없습니다.`,
errorMessage: `권한은 '공개 ➡️ 비공개', '모두 ➡️ 친구', '친구 ➡️ 혼자' 로 변경할 수 없습니다.`,
isThrow: true,
});

Expand All @@ -75,7 +75,7 @@ const UpdatedTopicInfo = ({
const updateTopicAuthority = async () => {
// topicAuthorInfo api 구조 이상으로 권한 설정 자체에 대한 id를 사용 (topicId 아님)
await fetchDelete({
url: `/permissions/${topicAuthorInfo?.permissionMembers[0].id}`,
url: `/permissions/${topicAuthorInfo?.permissionedMembers[0].id}`,
errorMessage: '권한 삭제에 실패했습니다.',
isThrow: true,
});
Expand Down Expand Up @@ -103,9 +103,7 @@ const UpdatedTopicInfo = ({
setTopicAuthorInfo(response);
setIsPrivate(response.publicity === 'PRIVATE');

if (topicAuthorInfo) {
setIsAll(topicAuthorInfo?.permissionMembers.length === 0);
}
setIsAll(response.permissionedMembers.length === 0);
},
);
}, []);
Expand Down Expand Up @@ -147,7 +145,7 @@ const UpdatedTopicInfo = ({
setIsPrivate={setIsPrivate}
setIsAll={setIsAll}
setAuthorizedMemberIds={setAuthorizedMemberIds}
permissionedMembers={topicAuthorInfo?.permissionMembers}
permissionedMembers={topicAuthorInfo?.permissionedMembers}
/>

<Space size={6} />
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/SelectedTopic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ const SelectedTopic = () => {
{topicDetails.map((topicDetail, idx) => (
<Fragment key={topicDetail.id}>
<PinsOfTopic
topicId={topicId}
topicId={topicId.split(',')[idx]}
idx={idx}
topicDetail={topicDetail}
setSelectedPinId={setSelectedPinId}
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/types/Topic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ export interface ModalTopicCardProps {

export interface TopicAuthorInfo {
publicity: 'PUBLIC' | 'PRIVATE';
permissionMembers: TopicAuthorMemberWithId[];
permissionedMembers: TopicAuthorMemberWithAuthorId[];
}

export interface TopicAuthorMemberWithId {
export interface TopicAuthorMemberWithAuthorId {
id: number;
memberResponse: TopicAuthorMember;
}
Expand Down
Loading