Skip to content
Snippets Groups Projects
Commit 16d97572 authored by Lucas Eduardo Schoenfelder's avatar Lucas Eduardo Schoenfelder
Browse files

centralized follow/unfollow logic in contact card to improve feedback when the...

centralized follow/unfollow logic in contact card to improve feedback when the user performs any of those actions
parent 8d3576b1
No related branches found
No related tags found
6 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!39Update admin system,!32Homologa,!31Fix console error,!30Centraliza axios
......@@ -71,18 +71,32 @@ export default function ImgMediaCard(props) {
{
followedBoolean ?
(
[
<FollowingButton followedID={props.followerID} toggleFollowed={toggleFollowed}/>
]
<React.Fragment>
<FollowingButton
followedID={props.followerID ? props.followerID : props.followedID}
toggleFollowed={toggleFollowed}/>
<Options
followableID={props.followerID ? props.followerID : props.followedID}
followed={followedBoolean}
toggleFollowed={toggleFollowed}/>
</React.Fragment>
)
:
(
[
<FollowButton followerID={props.followerID} toggleFollowed={toggleFollowed}/>
]
<React.Fragment>
<FollowButton
followerID={props.followedID ? props.followedID : props.followerID}
toggleFollowed={toggleFollowed}/>
<Options
followableID={props.followedID ? props.followedID : props.followerID}
followed={followedBoolean}
toggleFollowed={toggleFollowed}/>
</React.Fragment>
)
}
<Options followableID={props.followerID} followed={followedBoolean}/>
</div>
</UserInfo>
</CardContent>
......
......@@ -41,9 +41,15 @@ export default function SimpleMenu(props) {
function handleClose() {
setAnchorEl(null);
}
const handleFollow = (followerID) => {
putRequest(`/users/${followerID}/follow`, {}, (data) => {console.log(data)}, (error) => {console.log(error)})
putRequest(`/users/${followerID}/follow`, {}, (data) => {
console.log(data);
props.toggleFollowed()
}, (error) => {console.log(error)})
handleClose();
}
const [reportModal, toggleReportModal] = useState(false)
......@@ -80,13 +86,13 @@ export default function SimpleMenu(props) {
{
props.followed ?
(
<StyledMenuItem onClick={() => {handleFollow(props.followableID);handleClose()}}>
<StyledMenuItem onClick={() => {handleFollow(props.followableID)}}>
<ListItemIcon><ReportIcon /></ListItemIcon>Deixar de Seguir
</StyledMenuItem>
)
:
(
<StyledMenuItem onClick={() => {handleFollow(props.followableID);handleClose()}}>
<StyledMenuItem onClick={() => {handleFollow(props.followableID)}}>
<ListItemIcon><PersonAddIcon /></ListItemIcon>Seguir
</StyledMenuItem>
)
......
......@@ -88,7 +88,6 @@ export default function TabPanelRede (props) {
)
:
(
[
<React.Fragment>
<PanelTemplateRede
title={followersList.length === 1 ? "Seguidor" : "Seguidores"}
......@@ -111,7 +110,6 @@ export default function TabPanelRede (props) {
/>
</React.Fragment>
]
)
}
</>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment