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.
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;
......
......@@ -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.
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