Skip to content

Commit

Permalink
issue #138 refactor: change accessLevel data, group feed isloading
Browse files Browse the repository at this point in the history
  • Loading branch information
sikkzz committed Feb 26, 2024
1 parent 4092e94 commit 92f1197
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
13 changes: 12 additions & 1 deletion src/components/Group/GroupFeed/GroupFeed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,15 @@ const GroupFeed = ({ groupId, leaderName }) => {
const [optionMenuOpenedFeedIndex, setOptionMenuOpenedFeedIndex] =
useState(null);

const [isLoading, setIsLoading] = useState(true);

const groupPostFetching = async () => {
await dispatch(getGroupAllPosts(groupId));
setIsLoading(false);
};

useEffect(() => {
dispatch(getGroupAllPosts(groupId));
groupPostFetching();
}, []);

const handleOnView = () => {
Expand All @@ -28,6 +35,10 @@ const GroupFeed = ({ groupId, leaderName }) => {
}
};

if (isLoading) {
return <div>로딩중</div>;
}

if (allGroupPosts.length === 0) {
return <EmptyFeed />;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,12 @@ const GroupMemberManagement = ({ groupId, memberList }) => {
memberInfo.accessLevel === data.accessLevel && (
<span key={data.accessLevel}>
{data.icon}
{data.accessLevel}
{memberInfo.accessLevel}
<AccessArrowIcon />
</span>
),
)}

{isAccessChangeOpenIndex === memberInfo.member.userId && (
<AccessLevelUl>
{ACCESS_LEVEL_DATA.map((data) => (
Expand Down
21 changes: 17 additions & 4 deletions src/features/group/group-slice.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,23 @@ const groupSlice = createSlice({
state.isMemberListLoading = false;
state.groupMemberList = payload;
})
.addCase(changeAccessLevel.fulfilled, (state) => {
state.isLoading = false;
toast.success("그룹원 권한이 변경되었습니다.");
})
.addCase(
changeAccessLevel.fulfilled,
(
state,
{
meta: {
arg: { userId, accessLevel },
},
},
) => {
state.isLoading = false;
toast.success("그룹원 권한이 변경되었습니다.");
state.groupMemberList[
state.groupMemberList.findIndex((el) => el.member.userId === userId)
].accessLevel = accessLevel;
},
)
.addCase(withdrawalGroup.fulfilled, (state) => {
state.isLoading = false;
toast.error("그룹 탈퇴에 성공하였습니다");
Expand Down

0 comments on commit 92f1197

Please sign in to comment.