Skip to content
Open
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
1 change: 0 additions & 1 deletion front/src/component/follow/FollowList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ const FollowListContainer = styled.div`
`;

function FollowList({ myFollowing }) {
console.log(myFollowing.boards);
return (
<FollowListContainer>
<FollowUserCard myFollowing={myFollowing} />
Expand Down
18 changes: 14 additions & 4 deletions front/src/component/follow/FollowUserCard.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useState } from 'react';
import styled from 'styled-components';
import { Link } from 'react-router-dom';
import { useSelector, useDispatch } from 'react-redux';
Expand Down Expand Up @@ -118,15 +118,25 @@ const FollowListLeftSide = styled.div`
`;

function FollowUserCard({ myFollowing }) {
const [isFollow, setIsFollow] = useState(!!myFollowing.follow);
const dispatch = useDispatch();
const isLogin = useSelector(state => state.login.isLogin);
const cookieAccountId = Number(localStorage.getItem('accountId'));
console.log(cookieAccountId, myFollowing.id);

const followHandler = () => {
if (isLogin) {
postDetailFollowApi(myFollowing.id);
window.location.reload();
postDetailFollowApi(myFollowing.id)
.then(res => {
if (res === 'SUCCESS') {
setIsFollow(true);
} else {
setIsFollow(false);
}
})
.catch(err => {
console.log(err);
});
} else {
dispatch(loginModalActions.openLoginModal());
}
Expand All @@ -148,7 +158,7 @@ function FollowUserCard({ myFollowing }) {
<li className="followList__button">
{cookieAccountId === myFollowing.id ? (
<div />
) : !myFollowing.follow ? (
) : !isFollow ? (
<DefaultButton width="9rem" height="3rem" onClick={followHandler}>
팔로우
</DefaultButton>
Expand Down