Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
PortalMEC-React
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PortalMEC
PortalMEC-React
Commits
1c46d363
Commit
1c46d363
authored
4 years ago
by
Lucas Eduardo Schoenfelder
Browse files
Options
Downloads
Patches
Plain Diff
added follow/unfollow collection functionality
parent
2af6d585
No related branches found
No related tags found
4 merge requests
!57
Merge of develop into master
,
!56
Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
,
!39
Update admin system
,
!32
Homologa
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Components/CollectionCardFunction.js
+21
-4
21 additions, 4 deletions
src/Components/CollectionCardFunction.js
with
21 additions
and
4 deletions
src/Components/CollectionCardFunction.js
+
21
−
4
View file @
1c46d363
...
@@ -39,11 +39,15 @@ import LockIcon from '@material-ui/icons/Lock';
...
@@ -39,11 +39,15 @@ import LockIcon from '@material-ui/icons/Lock';
import
ColCardOwnerOptions
from
'
./ColCardOwnerOptions.js
'
import
ColCardOwnerOptions
from
'
./ColCardOwnerOptions.js
'
import
ColCardPublicOptions
from
'
./ColCardPublicOptions
'
import
ColCardPublicOptions
from
'
./ColCardPublicOptions
'
import
{
Link
}
from
'
react-router-dom
'
;
import
{
Link
}
from
'
react-router-dom
'
;
import
axios
from
'
axios
'
import
{
getAxiosConfig
}
from
'
../Components/HelperFunctions/getAxiosConfig
'
export
default
function
CollectionCardFunction
(
props
)
{
export
default
function
CollectionCardFunction
(
props
)
{
const
{
state
}
=
useContext
(
Store
)
const
{
state
}
=
useContext
(
Store
)
const
[
userAvatar
,
setUserAvatar
]
=
useState
(
props
.
avatar
?
(
`
${
apiDomain
}
`
+
props
.
avatar
)
:
noAvatar
)
const
[
userAvatar
,
setUserAvatar
]
=
useState
(
props
.
avatar
?
(
`
${
apiDomain
}
`
+
props
.
avatar
)
:
noAvatar
)
const
[
userFollowingCol
,
toggleUserFollowingCol
]
=
useState
(
props
.
followed
)
const
handleToggleUserFollowingCol
=
()
=>
{
toggleUserFollowingCol
(
!
userFollowingCol
)}
const
[
followingHover
,
handleFollowingHover
]
=
useState
(
false
)
const
[
followingHover
,
handleFollowingHover
]
=
useState
(
false
)
const
toggleFollowingHover
=
(
value
)
=>
{
handleFollowingHover
(
value
)}
const
toggleFollowingHover
=
(
value
)
=>
{
handleFollowingHover
(
value
)}
...
@@ -51,9 +55,22 @@ export default function CollectionCardFunction (props) {
...
@@ -51,9 +55,22 @@ export default function CollectionCardFunction (props) {
const
[
slideIn
,
setSlide
]
=
useState
(
false
)
const
[
slideIn
,
setSlide
]
=
useState
(
false
)
const
controlSlide
=
()
=>
{
setSlide
(
!
slideIn
)}
const
controlSlide
=
()
=>
{
setSlide
(
!
slideIn
)}
const
handleFollow
=
()
=>
{
let
config
=
getAxiosConfig
()
let
payload
=
{}
axios
.
put
(
(
`
${
apiUrl
}
/collections/`
+
props
.
id
+
'
/follow
'
),
payload
,
config
).
then
(
(
response
)
=>
{
console
.
log
(
response
.
data
)
handleToggleUserFollowingCol
()
},
(
error
)
=>
{
console
.
log
(
error
)}
)
}
const
RenderFollowButton
=
()
=>
{
const
RenderFollowButton
=
()
=>
{
return
(
return
(
<
FollowButton
onClick
=
{
()
=>
{
console
.
log
(
"
fazer
"
)}
}
>
<
FollowButton
onClick
=
{
handleFollow
}
>
<
AddIcon
/><
span
>
SEGUIR
<
/span
>
<
AddIcon
/><
span
>
SEGUIR
<
/span
>
<
/FollowButton
>
<
/FollowButton
>
)
)
...
@@ -62,7 +79,7 @@ export default function CollectionCardFunction (props) {
...
@@ -62,7 +79,7 @@ export default function CollectionCardFunction (props) {
const
RenderFollowingButton
=
()
=>
{
const
RenderFollowingButton
=
()
=>
{
return
(
return
(
<
FollowingButton
onMouseOver
=
{()
=>
toggleFollowingHover
(
true
)}
<
FollowingButton
onMouseOver
=
{()
=>
toggleFollowingHover
(
true
)}
onMouseLeave
=
{()
=>
toggleFollowingHover
(
false
)}
onClick
=
{
()
=>
{
console
.
log
(
'
fazer
'
)}
}
>
onMouseLeave
=
{()
=>
toggleFollowingHover
(
false
)}
onClick
=
{
handleFollow
}
>
{
{
followingHover
?
followingHover
?
(
(
...
@@ -204,7 +221,7 @@ export default function CollectionCardFunction (props) {
...
@@ -204,7 +221,7 @@ export default function CollectionCardFunction (props) {
(
(
<
CardReaFooter
>
{
/*renders following/unfollow and follow button*/
}
<
CardReaFooter
>
{
/*renders following/unfollow and follow button*/
}
{
{
props
.
followed
?
userFollowingCol
?
(
(
[
[
RenderFollowingButton
()
RenderFollowingButton
()
...
@@ -233,7 +250,7 @@ const SlideAvatarDiv = styled.div`
...
@@ -233,7 +250,7 @@ const SlideAvatarDiv = styled.div`
vertical-align : middle;
vertical-align : middle;
border : 0;
border : 0;
img {
img {
height : 40px !important;
height : 40px !important;
width : 40px !important;
width : 40px !important;
border : 0;
border : 0;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment