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
196d7dac
Commit
196d7dac
authored
4 years ago
by
Raul Almeida
Browse files
Options
Downloads
Patches
Plain Diff
WIP Collection Page
parent
db88fb37
No related branches found
No related tags found
5 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
,
!23
Tela de coleção
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Components/CollectionDescription.js
+4
-4
4 additions, 4 deletions
src/Components/CollectionDescription.js
src/Components/FollowCollectionButton.js
+56
-17
56 additions, 17 deletions
src/Components/FollowCollectionButton.js
src/Pages/CollectionPage.js
+1
-1
1 addition, 1 deletion
src/Pages/CollectionPage.js
with
61 additions
and
22 deletions
src/Components/CollectionDescription.js
+
4
−
4
View file @
196d7dac
...
...
@@ -54,7 +54,7 @@ export default function CollectionDescription(props) {
<
/DownloadButton
>
<
/Grid
>
<
Grid
item
>
<
FollowCollectionButton
user_id
=
{
state
.
currentUser
.
id
}
/
>
<
FollowCollectionButton
user_id
=
{
state
.
currentUser
.
id
}
collection_id
=
{
props
.
collection_id
}
/
>
<
/Grid
>
<
/Grid
>
<
/Grid
>
...
...
@@ -73,7 +73,7 @@ const ButtonText=styled.span`
font-size: 1.2em;
`
const
DownloadButton
=
styled
(
Button
)
`
padding-left: 10
,
padding-right: 10
,
width: 2
10,
padding-left: 10
;
padding-right: 10
;
width: 2
50px;
`
This diff is collapsed.
Click to expand it.
src/Components/FollowCollectionButton.js
+
56
−
17
View file @
196d7dac
...
...
@@ -16,33 +16,70 @@ GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Plataforma Integrada MEC. If not, see <http://www.gnu.org/licenses/>.*/
import
React
,
{
useState
}
from
'
react
'
;
import
React
,
{
useState
,
useEffect
}
from
'
react
'
;
import
Button
from
'
@material-ui/core/Button
'
;
import
CheckIcon
from
'
@material-ui/icons/Check
'
;
import
AddIcon
from
'
@material-ui/icons/Add
'
;
import
styled
from
'
styled-components
'
;
import
SignUpModal
from
'
./SignUpModal.js
'
;
import
axios
from
'
axios
'
;
import
{
apiUrl
}
from
'
../env
'
;
export
default
function
FollowCollectionButton
(
props
)
{
const
[
icon
,
setIcon
]
=
useState
(
<
AddIcon
fontSize
=
"
large
"
/>
);
const
[
button_text
,
setButtonText
]
=
useState
(
"
Seguir Coleção
"
);
const
[
variant
,
setVariant
]
=
useState
(
"
outlined
"
);
const
[
sign_up_open
,
setSignUpOpen
]
=
useState
(
false
);
const
[
following
,
setFollowing
]
=
useState
(
false
);
//user following collection
const
handleClick
=
()
=>
{
//aqui tem que ter:
//se o usuário não está logado, abre a tela de criar conta
//setSignUpOpen(true);
useEffect
(()
=>
{
axios
.
get
(
apiUrl
+
'
/users/
'
+
props
.
user_id
+
'
/following/Collection
'
)
.
then
(
res
=>
{
for
(
const
element
in
res
.
body
)
if
(
element
.
id
==
props
.
collection_id
)
setFollowing
(
true
);
});
},
[])
//se o usuário já segue a coleção,deixa de seguir
//handleMouse{Enter, Leave} only do anything when user follows given collection:
const
handleMouseEnter
=
()
=>
{
if
(
following
)
{
setVariant
(
"
outlined
"
);
setButtonText
(
"
Deixar de seguir
"
);
setIcon
(
null
);
}
}
const
handleMouseLeave
=
()
=>
{
if
(
following
)
{
setVariant
(
"
contained
"
);
setButtonText
(
"
Seguindo
"
);
setIcon
(
<
CheckIcon
fontSize
=
"
large
"
/>
);
}
}
//setButtonText("Seguir Coleção");
//se o usuário não segue a coleção, muda o visual por alguns instantes e depois mostra o "deixa de seguir"
setVariant
(
"
contained
"
);
setButtonText
(
"
Seguindo
"
);
setIcon
(
<
CheckIcon
fontSize
=
"
large
"
/>
)
const
handleClick
=
()
=>
{
if
(
!
props
.
user_id
)
setSignUpOpen
(
true
);
else
if
(
!
following
)
{
setVariant
(
"
contained
"
);
setButtonText
(
"
Seguindo
"
);
setIcon
(
<
CheckIcon
fontSize
=
"
large
"
/>
)
axios
.
post
(
apiUrl
+
'
/Collection/
'
+
props
.
collection_id
+
'
/follow
'
)
.
then
(
res
=>
{
if
(
Number
(
res
.
status
)
==
201
)
setFollowing
(
true
);
});
}
else
{
setVariant
(
"
outlined
"
);
setButtonText
(
"
Deixar de seguir
"
);
setIcon
(
<
AddIcon
fontSize
=
"
large
"
/>
);
axios
.
delete
(
apiUrl
+
'
/Collection/
'
+
props
.
collection_id
+
'
/follow
'
)
.
then
(
res
=>
{
if
(
Number
(
res
.
status
)
==
200
)
setFollowing
(
false
);
});
}
};
return
(
...
...
@@ -52,7 +89,9 @@ export default function FollowCollectionButton(props) {
color
=
"
primary
"
startIcon
=
{
icon
}
size
=
"
large
"
onClick
=
{()
=>
handleClick
()}
onMouseEnter
=
{
handleMouseEnter
}
onMouseLeave
=
{
handleMouseLeave
}
onClick
=
{
handleClick
}
>
<
ButtonText
>
{
button_text
}
<
/ButtonText
>
<
/FollowButton
>
...
...
@@ -71,7 +110,7 @@ const ButtonText=styled.span`
font-size: 1.2em;
`
const
FollowButton
=
styled
(
Button
)
`
padding-left: 10
,
padding-right: 10
,
width: 2
10,
padding-left: 10
;
padding-right: 10
;
width: 2
50px;
`
This diff is collapsed.
Click to expand it.
src/Pages/CollectionPage.js
+
1
−
1
View file @
196d7dac
...
...
@@ -39,7 +39,7 @@ export default function CollectionPage() {
<
VerticalRuler
width
=
{
1
}
height
=
{
300
}
color
=
"
rgb(238, 238, 238)
"
/>
<
Grid
item
xs
=
{
10
}
md
=
{
6
}
>
<
CollectionDescription
title
=
"
Linguagem de Programacao
"
/>
<
CollectionDescription
title
=
"
Linguagem de Programacao
"
collection_id
=
"
9868
"
/>
<
/Grid>
<
Grid
container
item
direction
=
"
row
"
justify
=
"
center
"
alignItems
=
"
center
"
style
=
{{
backgroundColor
:
'
#f4f4f4
'
}}
>
...
...
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