Skip to content
Snippets Groups Projects
Commit e9c664ce authored by Henrique Varella Ehrenfried's avatar Henrique Varella Ehrenfried :speech_balloon:
Browse files

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!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...,!39Update admin system,!34Fix search
...@@ -16,7 +16,7 @@ GNU Affero General Public License for more details. ...@@ -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 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/>.*/ 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 Card from '@material-ui/core/Card';
import CardContent from '@material-ui/core/CardContent'; import CardContent from '@material-ui/core/CardContent';
import noAvatar from "../img/default_profile.png"; import noAvatar from "../img/default_profile.png";
...@@ -26,27 +26,30 @@ import Options from './ContactCardOptions.js' ...@@ -26,27 +26,30 @@ import Options from './ContactCardOptions.js'
import FollowButton from './ContactButtons/FollowButton.js' import FollowButton from './ContactButtons/FollowButton.js'
import FollowingButton from './ContactButtons/FollowingButton.js' import FollowingButton from './ContactButtons/FollowingButton.js'
import FollowersCountButton from './ContactButtons/FollowersCountButton.js' import FollowersCountButton from './ContactButtons/FollowersCountButton.js'
import {Link} from 'react-router-dom'; import { Link } from 'react-router-dom';
export default function ImgMediaCard(props) { export default function ImgMediaCard(props) {
const [followedBoolean, setFollowedBoolean] = useState(props.followed) const [followedBoolean, setFollowedBoolean] = useState(props.followed)
const toggleFollowed = () => {setFollowedBoolean(!followedBoolean)} const toggleFollowed = () => { setFollowedBoolean(!followedBoolean) }
return ( const [avatar, setAvatar] = useState(props.avatar ? props.avatar : noAvatar);
return (
<StyledCard> <StyledCard>
<CardDiv> <CardDiv>
<CardAreaDiv> <CardAreaDiv>
{/*Top part of contat card (background image, number of followers and avatar)*/} {/*Top part of contat card (background image, number of followers and avatar)*/}
<Header> <Header>
<StyledCardMedia image={props.cover}> <StyledCardMedia image={props.cover}>
<div style = {{display : "flex", backgroundColor : "inherit", float : "right"}}> <div style={{ display: "flex", backgroundColor: "inherit", float: "right" }}>
<Link to={props.href}> <Link to={props.href}>
<FollowersCountButton followCount={props.follow_count}/> <FollowersCountButton followCount={props.follow_count} />
</Link> </Link>
<AvatarDiv> <AvatarDiv>
<img src={props.avatar ? props.avatar : noAvatar} alt='user avatar' <img src={avatar} alt='user avatar'
style={{height : "100%", width : "100%", borderRadius : "50%"}}/> style={{ height: "100%", width: "100%", borderRadius: "50%" }}
onError={() => setAvatar(noAvatar)}
/>
</AvatarDiv> </AvatarDiv>
</div> </div>
</StyledCardMedia> </StyledCardMedia>
...@@ -62,48 +65,48 @@ export default function ImgMediaCard(props) { ...@@ -62,48 +65,48 @@ export default function ImgMediaCard(props) {
</Link> </Link>
<Link to={props.href}> <Link to={props.href}>
<span style={{fontSize : "14px", fontWeight : "normal"}}> <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"} <b>{props.numCollections}</b> {props.numCollections !== 1 ? "Coleções" : "Coleção"} | <b>{props.numLearningObjects}</b> {props.numLearningObjects !== 1 ? "Recursos" : "Recurso"}
</span> </span>
</Link> </Link>
<div style={{display : "flex", justifyContent : "center"}}> <div style={{ display: "flex", justifyContent: "center" }}>
{ {
followedBoolean ? followedBoolean ?
( (
<React.Fragment> <React.Fragment>
<FollowingButton <FollowingButton
followedID={props.followerID ? props.followerID : props.followedID} followedID={props.followerID ? props.followerID : props.followedID}
toggleFollowed={toggleFollowed}/> toggleFollowed={toggleFollowed} />
<Options <Options
followableID={props.followerID ? props.followerID : props.followedID} followableID={props.followerID ? props.followerID : props.followedID}
followed={followedBoolean} followed={followedBoolean}
toggleFollowed={toggleFollowed}/> toggleFollowed={toggleFollowed} />
</React.Fragment> </React.Fragment>
) )
: :
( (
<React.Fragment> <React.Fragment>
<FollowButton <FollowButton
followerID={props.followedID ? props.followedID : props.followerID} followerID={props.followedID ? props.followedID : props.followerID}
toggleFollowed={toggleFollowed}/> toggleFollowed={toggleFollowed} />
<Options <Options
followableID={props.followedID ? props.followedID : props.followerID} followableID={props.followedID ? props.followedID : props.followerID}
followed={followedBoolean} followed={followedBoolean}
toggleFollowed={toggleFollowed}/> toggleFollowed={toggleFollowed} />
</React.Fragment> </React.Fragment>
) )
} }
</div> </div>
</UserInfo> </UserInfo>
</CardContent> </CardContent>
</CardAreaDiv> </CardAreaDiv>
</CardDiv> </CardDiv>
</StyledCard> </StyledCard>
); );
} }
/*Controls top part of Card*/ /*Controls top part of Card*/
...@@ -132,7 +135,7 @@ export const CardDiv = styled.div` ...@@ -132,7 +135,7 @@ export const CardDiv = styled.div`
/*Override Material UI styling -----------------------------------------------*/ /*Override Material UI styling -----------------------------------------------*/
const StyledCardMedia = styled(CardMedia) ` const StyledCardMedia = styled(CardMedia)`
height : 100%; height : 100%;
width : 100%; width : 100%;
background-size : cover; background-size : cover;
......
...@@ -27,7 +27,7 @@ import Snackbar from '@material-ui/core/Snackbar'; ...@@ -27,7 +27,7 @@ import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert from '@material-ui/lab/Alert'; import MuiAlert from '@material-ui/lab/Alert';
import { useLocation } from 'react-router-dom' import { useLocation } from 'react-router-dom'
import MenuBarMobile from './MenuBarMobile.js' import MenuBarMobile from './MenuBarMobile.js'
import {validateGoogleLoginToken} from './HelperFunctions/getAxiosConfig' import { validateGoogleLoginToken } from './HelperFunctions/getAxiosConfig'
//const StyledButton = styled(Button)` //const StyledButton = styled(Button)`
// background : #ffa54c !important; // background : #ffa54c !important;
...@@ -38,90 +38,82 @@ function Alert(props) { ...@@ -38,90 +38,82 @@ function Alert(props) {
} }
export default function Header(props){ export default function Header(props) {
const { state, dispatch } = useContext(Store) const { state, dispatch } = useContext(Store)
const [signUpOpen, setSignUp] = useState(false) const [signUpOpen, setSignUp] = useState(false)
const [loginOpen, setLogin] = useState(false) const [loginOpen, setLogin] = useState(false)
const [successfulLoginOpen, handleSuccessfulLogin] = useState(false) const [successfulLoginOpen, handleSuccessfulLogin] = useState(false)
const [modalColaborar, setModalColaborar] = useState(false) const [modalColaborar, setModalColaborar] = useState(false)
function handleSuccessValidateToken (data) { function handleSuccessValidateToken(data) {
dispatch ({ dispatch({
type: "USER_LOGGED_IN", type: "USER_LOGGED_IN",
userLoggedIn: !state.userIsLoggedIn, userLoggedIn: !state.userIsLoggedIn,
login: data.data login: data.data
} }
) )
} }
/* useEffect( () => { let loc = useLocation()
if (sessionStorage.getItem('@portalmec/auth_headers')) { useEffect(() => {
let config = { headers : JSON.parse(sessionStorage.getItem('@portalmec/auth_headers'))} let query = new URLSearchParams(loc.search)
validateToken(config, handleSuccessValidateToken, (error) => {console.log(error)}) if (query.get("auth_token")) {
} let config = {
}, [])*/ headers: {
"access-token": query.get("auth_token"),
let loc = useLocation() "client": query.get("client_id"),
useEffect(() => { "uid": query.get("uid"),
let query = new URLSearchParams(loc.search) "expiry": query.get("expiry"),
"token-type": 'Bearer'
if(query.get("auth_token")) { }
let config = { }
headers : { validateGoogleLoginToken(config, handleSuccessValidateToken, (error) => { console.log(error) })
"access-token" : query.get("auth_token"), redirect()
"client" : query.get("client_id"), }
"uid" : query.get("uid"), }, [loc])
"expiry" : query.get("expiry"),
"token-type" : 'Bearer' useEffect(() => {
} if (state.currentUser.askTeacherQuestion === true) {
} dispatch({
validateGoogleLoginToken(config, handleSuccessValidateToken, (error) => {console.log(error)}) type: "TOGGLE_MODAL_COLABORAR_PLATAFORMA",
redirect() modalColaborarPlataformaOpen: true
} });
}, [loc]) }
}, [state.currentUser.askTeacherQuestion])
useEffect ( () => {
if (state.currentUser.askTeacherQuestion === true) { const redirect = () => {
dispatch({ props.history.push('/')
type: "TOGGLE_MODAL_COLABORAR_PLATAFORMA", }
modalColaborarPlataformaOpen: true
}); const toggleSnackbar = (event, reason) => {
} if (reason === 'clickaway') {
}, [state.currentUser.askTeacherQuestion]) return;
}
const redirect = () => {
props.history.push('/') handleSuccessfulLogin(false);
} }
const toggleSnackbar = (event, reason) => { const handleSignUp = () => {
if (reason === 'clickaway') { setSignUp(!signUpOpen)
return; }
}
const handleLogin = () => {
handleSuccessfulLogin(false); setLogin(!loginOpen)
} }
const handleSignUp = () => { const handleClickSearch = (open) => {
setSignUp(!signUpOpen) dispatch({
} type: "HANDLE_SEARCH_BAR",
opened: !state.searchOpen
const handleLogin = () => { })
setLogin(!loginOpen) }
}
let windowWidth = window.innerWidth
const handleClickSearch = (open) => {
dispatch({ return (
type: "HANDLE_SEARCH_BAR", <React.Fragment>
opened: !state.searchOpen {/*
})
}
let windowWidth = window.innerWidth
return (
<React.Fragment>
{/*
windowWidth > 990 && windowWidth > 990 &&
<AcessibilityBar/> <AcessibilityBar/>
*/} */}
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment