-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from AJD-Archive/feature/113
친구 신청&삭제 api 연결
- Loading branch information
Showing
15 changed files
with
332 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
import { FollowInfo } from '../../types/FriendType'; | ||
import * as S from './FriendStyled'; | ||
import CustomModal from '../CustomModal'; | ||
import useModal from '../../hooks/useModal'; | ||
import { useState } from 'react'; | ||
import { useDeleteFollow, usePostFollow } from '../../hooks/useFollowersList'; | ||
|
||
interface FriendProps { | ||
follower: FollowInfo; | ||
} | ||
|
||
const Friend = ({ follower }: FriendProps) => { | ||
const { isModalOpen, openModal, handleYesClick, handleNoClick } = useModal(); // 모달창 관련 훅 호출 | ||
const [isDelModalOpen, setIsDelModalOpen] = useState<boolean>(false); | ||
|
||
const { mutate: followMutate } = usePostFollow(follower.memberId!, follower.name!); | ||
const { mutate: unFollowMutate } = useDeleteFollow(follower.memberId!, follower.name!); | ||
|
||
const follow = async () => { | ||
followMutate(); | ||
}; | ||
|
||
const unFollow = async () => { | ||
unFollowMutate(); | ||
}; | ||
|
||
// 친구 삭제를 모달창으로 확인 | ||
const submitUnFollow = () => { | ||
setIsDelModalOpen(true); | ||
const handleModalClose = () => setIsDelModalOpen(false); | ||
openModal('yes', unFollow, handleModalClose); | ||
}; | ||
|
||
return ( | ||
<> | ||
<S.FriendLayout> | ||
<S.ProfileImageWrapper src={follower.profileImage} /> | ||
<S.FriendUserWrapper> | ||
<p className="name">{follower.name}</p> | ||
<p className="nickName">{follower.nickname}</p> | ||
</S.FriendUserWrapper> | ||
{follower.isFollow ? ( | ||
<S.FriendRequestButtonWrapper onClick={submitUnFollow}> | ||
<p>친구 삭제</p> | ||
</S.FriendRequestButtonWrapper> | ||
) : ( | ||
<S.FriendRequestButtonWrapper onClick={follow}> | ||
<p>친구 신청</p> | ||
</S.FriendRequestButtonWrapper> | ||
)} | ||
</S.FriendLayout> | ||
|
||
{isModalOpen && isDelModalOpen && ( | ||
<CustomModal | ||
title="친구를 삭제하시겠습니까?" | ||
subTitle="한 번 삭제된 친구는 다시 추가해야 합니다." | ||
onYesClick={handleYesClick} | ||
onNoClick={handleNoClick} | ||
/> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default Friend; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.