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
e9c664ce
Commit
e9c664ce
authored
4 years ago
by
Henrique Varella Ehrenfried
Browse files
Options
Downloads
Plain Diff
Merge branch 'Fix_Search' into 'Develop'
Fix search See merge request
!34
parents
bc0694db
25f158a4
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
,
!34
Fix search
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Components/ContactCard.js
+48
-45
48 additions, 45 deletions
src/Components/ContactCard.js
src/Components/Header.js
+77
-85
77 additions, 85 deletions
src/Components/Header.js
src/Pages/Search.js
+334
-318
334 additions, 318 deletions
src/Pages/Search.js
with
459 additions
and
448 deletions
src/Components/ContactCard.js
+
48
−
45
View file @
e9c664ce
...
...
@@ -16,7 +16,7 @@ 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
Card
from
'
@material-ui/core/Card
'
;
import
CardContent
from
'
@material-ui/core/CardContent
'
;
import
noAvatar
from
"
../img/default_profile.png
"
;
...
...
@@ -26,27 +26,30 @@ import Options from './ContactCardOptions.js'
import
FollowButton
from
'
./ContactButtons/FollowButton.js
'
import
FollowingButton
from
'
./ContactButtons/FollowingButton.js
'
import
FollowersCountButton
from
'
./ContactButtons/FollowersCountButton.js
'
import
{
Link
}
from
'
react-router-dom
'
;
import
{
Link
}
from
'
react-router-dom
'
;
export
default
function
ImgMediaCard
(
props
)
{
const
[
followedBoolean
,
setFollowedBoolean
]
=
useState
(
props
.
followed
)
const
toggleFollowed
=
()
=>
{
setFollowedBoolean
(
!
followedBoolean
)}
return
(
const
[
followedBoolean
,
setFollowedBoolean
]
=
useState
(
props
.
followed
)
const
toggleFollowed
=
()
=>
{
setFollowedBoolean
(
!
followedBoolean
)
}
const
[
avatar
,
setAvatar
]
=
useState
(
props
.
avatar
?
props
.
avatar
:
noAvatar
);
return
(
<
StyledCard
>
<
CardDiv
>
<
CardAreaDiv
>
{
/*Top part of contat card (background image, number of followers and avatar)*/
}
<
Header
>
<
StyledCardMedia
image
=
{
props
.
cover
}
>
<
div
style
=
{{
display
:
"
flex
"
,
backgroundColor
:
"
inherit
"
,
float
:
"
right
"
}}
>
<
div
style
=
{{
display
:
"
flex
"
,
backgroundColor
:
"
inherit
"
,
float
:
"
right
"
}}
>
<
Link
to
=
{
props
.
href
}
>
<
FollowersCountButton
followCount
=
{
props
.
follow_count
}
/
>
<
FollowersCountButton
followCount
=
{
props
.
follow_count
}
/
>
<
/Link
>
<
AvatarDiv
>
<
img
src
=
{
props
.
avatar
?
props
.
avatar
:
noAvatar
}
alt
=
'
user avatar
'
style
=
{{
height
:
"
100%
"
,
width
:
"
100%
"
,
borderRadius
:
"
50%
"
}}
/
>
<
img
src
=
{
avatar
}
alt
=
'
user avatar
'
style
=
{{
height
:
"
100%
"
,
width
:
"
100%
"
,
borderRadius
:
"
50%
"
}}
onError
=
{()
=>
setAvatar
(
noAvatar
)}
/
>
<
/AvatarDiv
>
<
/div
>
<
/StyledCardMedia
>
...
...
@@ -62,48 +65,48 @@ export default function ImgMediaCard(props) {
<
/Link
>
<
Link
to
=
{
props
.
href
}
>
<
span
style
=
{{
fontSize
:
"
14px
"
,
fontWeight
:
"
normal
"
}}
>
<
b
>
{
props
.
numCollections
}
<
/b> {props.numCollections !== 1
?
"Coleções" : "Coleção"} | <b>{props.numLearningObjects}</
b
>
{
props
.
numLearningObjects
!==
1
?
"
Recursos
"
:
"
Recurso
"
}
<
span
style
=
{{
fontSize
:
"
14px
"
,
fontWeight
:
"
normal
"
}}
>
<
b
>
{
props
.
numCollections
}
<
/b> {props.numCollections !== 1
?
"Coleções" : "Coleção"} | <b>{props.numLearningObjects}</
b
>
{
props
.
numLearningObjects
!==
1
?
"
Recursos
"
:
"
Recurso
"
}
<
/span
>
<
/Link
>
<
div
style
=
{{
display
:
"
flex
"
,
justifyContent
:
"
center
"
}}
>
<
div
style
=
{{
display
:
"
flex
"
,
justifyContent
:
"
center
"
}}
>
{
followedBoolean
?
(
<
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
>
)
:
(
<
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
>
)
(
<
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
>
)
:
(
<
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
>
)
}
<
/div
>
<
/UserInfo
>
<
/CardContent
>
<
/CardAreaDiv
>
<
/CardDiv
>
<
/StyledCard
>
);
<
/UserInfo
>
<
/CardContent
>
<
/CardAreaDiv
>
<
/CardDiv
>
<
/StyledCard
>
);
}
/*Controls top part of Card*/
...
...
@@ -132,7 +135,7 @@ export const CardDiv = styled.div`
/*Override Material UI styling -----------------------------------------------*/
const
StyledCardMedia
=
styled
(
CardMedia
)
`
const
StyledCardMedia
=
styled
(
CardMedia
)
`
height : 100%;
width : 100%;
background-size : cover;
...
...
This diff is collapsed.
Click to expand it.
src/Components/Header.js
+
77
−
85
View file @
e9c664ce
...
...
@@ -27,7 +27,7 @@ import Snackbar from '@material-ui/core/Snackbar';
import
MuiAlert
from
'
@material-ui/lab/Alert
'
;
import
{
useLocation
}
from
'
react-router-dom
'
import
MenuBarMobile
from
'
./MenuBarMobile.js
'
import
{
validateGoogleLoginToken
}
from
'
./HelperFunctions/getAxiosConfig
'
import
{
validateGoogleLoginToken
}
from
'
./HelperFunctions/getAxiosConfig
'
//const StyledButton = styled(Button)`
// background : #ffa54c !important;
...
...
@@ -38,90 +38,82 @@ function Alert(props) {
}
export
default
function
Header
(
props
){
const
{
state
,
dispatch
}
=
useContext
(
Store
)
const
[
signUpOpen
,
setSignUp
]
=
useState
(
false
)
const
[
loginOpen
,
setLogin
]
=
useState
(
false
)
const
[
successfulLoginOpen
,
handleSuccessfulLogin
]
=
useState
(
false
)
const
[
modalColaborar
,
setModalColaborar
]
=
useState
(
false
)
function
handleSuccessValidateToken
(
data
)
{
dispatch
({
type
:
"
USER_LOGGED_IN
"
,
userLoggedIn
:
!
state
.
userIsLoggedIn
,
login
:
data
.
data
}
)
}
/* useEffect( () => {
if (sessionStorage.getItem('@portalmec/auth_headers')) {
let config = { headers : JSON.parse(sessionStorage.getItem('@portalmec/auth_headers'))}
validateToken(config, handleSuccessValidateToken, (error) => {console.log(error)})
}
}, [])*/
let
loc
=
useLocation
()
useEffect
(()
=>
{
let
query
=
new
URLSearchParams
(
loc
.
search
)
if
(
query
.
get
(
"
auth_token
"
))
{
let
config
=
{
headers
:
{
"
access-token
"
:
query
.
get
(
"
auth_token
"
),
"
client
"
:
query
.
get
(
"
client_id
"
),
"
uid
"
:
query
.
get
(
"
uid
"
),
"
expiry
"
:
query
.
get
(
"
expiry
"
),
"
token-type
"
:
'
Bearer
'
}
}
validateGoogleLoginToken
(
config
,
handleSuccessValidateToken
,
(
error
)
=>
{
console
.
log
(
error
)})
redirect
()
}
},
[
loc
])
useEffect
(
()
=>
{
if
(
state
.
currentUser
.
askTeacherQuestion
===
true
)
{
dispatch
({
type
:
"
TOGGLE_MODAL_COLABORAR_PLATAFORMA
"
,
modalColaborarPlataformaOpen
:
true
});
}
},
[
state
.
currentUser
.
askTeacherQuestion
])
const
redirect
=
()
=>
{
props
.
history
.
push
(
'
/
'
)
}
const
toggleSnackbar
=
(
event
,
reason
)
=>
{
if
(
reason
===
'
clickaway
'
)
{
return
;
}
handleSuccessfulLogin
(
false
);
}
const
handleSignUp
=
()
=>
{
setSignUp
(
!
signUpOpen
)
}
const
handleLogin
=
()
=>
{
setLogin
(
!
loginOpen
)
}
const
handleClickSearch
=
(
open
)
=>
{
dispatch
({
type
:
"
HANDLE_SEARCH_BAR
"
,
opened
:
!
state
.
searchOpen
})
}
let
windowWidth
=
window
.
innerWidth
return
(
<
React
.
Fragment
>
{
/*
export
default
function
Header
(
props
)
{
const
{
state
,
dispatch
}
=
useContext
(
Store
)
const
[
signUpOpen
,
setSignUp
]
=
useState
(
false
)
const
[
loginOpen
,
setLogin
]
=
useState
(
false
)
const
[
successfulLoginOpen
,
handleSuccessfulLogin
]
=
useState
(
false
)
const
[
modalColaborar
,
setModalColaborar
]
=
useState
(
false
)
function
handleSuccessValidateToken
(
data
)
{
dispatch
({
type
:
"
USER_LOGGED_IN
"
,
userLoggedIn
:
!
state
.
userIsLoggedIn
,
login
:
data
.
data
}
)
}
let
loc
=
useLocation
()
useEffect
(()
=>
{
let
query
=
new
URLSearchParams
(
loc
.
search
)
if
(
query
.
get
(
"
auth_token
"
))
{
let
config
=
{
headers
:
{
"
access-token
"
:
query
.
get
(
"
auth_token
"
),
"
client
"
:
query
.
get
(
"
client_id
"
),
"
uid
"
:
query
.
get
(
"
uid
"
),
"
expiry
"
:
query
.
get
(
"
expiry
"
),
"
token-type
"
:
'
Bearer
'
}
}
validateGoogleLoginToken
(
config
,
handleSuccessValidateToken
,
(
error
)
=>
{
console
.
log
(
error
)
})
redirect
()
}
},
[
loc
])
useEffect
(()
=>
{
if
(
state
.
currentUser
.
askTeacherQuestion
===
true
)
{
dispatch
({
type
:
"
TOGGLE_MODAL_COLABORAR_PLATAFORMA
"
,
modalColaborarPlataformaOpen
:
true
});
}
},
[
state
.
currentUser
.
askTeacherQuestion
])
const
redirect
=
()
=>
{
props
.
history
.
push
(
'
/
'
)
}
const
toggleSnackbar
=
(
event
,
reason
)
=>
{
if
(
reason
===
'
clickaway
'
)
{
return
;
}
handleSuccessfulLogin
(
false
);
}
const
handleSignUp
=
()
=>
{
setSignUp
(
!
signUpOpen
)
}
const
handleLogin
=
()
=>
{
setLogin
(
!
loginOpen
)
}
const
handleClickSearch
=
(
open
)
=>
{
dispatch
({
type
:
"
HANDLE_SEARCH_BAR
"
,
opened
:
!
state
.
searchOpen
})
}
let
windowWidth
=
window
.
innerWidth
return
(
<
React
.
Fragment
>
{
/*
windowWidth > 990 &&
<AcessibilityBar/>
*/
}
...
...
This diff is collapsed.
Click to expand it.
src/Pages/Search.js
+
334
−
318
View file @
e9c664ce
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