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

Merge branch 'fix_remaining_bugs' into Develop

parents e9c664ce 23910b68
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,!35Fix remaining bugs
......@@ -54,6 +54,7 @@ export default function ColCardOwnerOptions (props) {
/>
<ModalEditarColecao id={props.id}
open={modalEditarOpen} handleClose={() => {toggleModalEditar(false)}}
changeColName={props.changeColName} changeColPrivacy={props.changeColPrivacy}
/>
<div style={{fontSize: "12px"}}>
......
......@@ -42,7 +42,6 @@ import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert from '@material-ui/lab/Alert';
export default function CollectionCardFunction(props) {
// console.log(props);
const { state } = useContext(Store)
// eslint-disable-next-line
......@@ -50,6 +49,12 @@ export default function CollectionCardFunction(props) {
const [userFollowingCol, toggleUserFollowingCol] = useState(props.followed ? props.followed : false)
const handleToggleUserFollowingCol = () => { toggleUserFollowingCol(!userFollowingCol) }
const [name, setName] = useState(props.name)
const changeColName = (newName) => {setName(newName)}
const [privacy, setPrivacy] = useState(props.privacy)
const changeColPrivacy = (newPrivacy) => {setPrivacy(newPrivacy)}
const [likesCount, setLikesCount] = useState(props.likeCount)
const [liked, toggleLiked] = useState(props.liked)
......@@ -88,49 +93,6 @@ export default function CollectionCardFunction(props) {
}
useEffect(() => {
// setTimeout(function () {
// if (state.currentUser.id) {
// const config = getAxiosConfig();
// axios({
// method: 'get',
// url: `${apiUrl}/users/${state.currentUser.id}/following/Collection`,
// headers: config.headers
// }).then(
// (response) => {
// const data = response.data
// for (let i = 0; i < data.length; i++)
// if (data[i].followable.id === props.id)
// toggleUserFollowingCol(true)
// saveHeaders(response)
// })
// }
// else {
// toggleLiked(false);
// toggleUserFollowingCol(false);
// }
// }, 1000);
// setTimeout(function () {
// if (state.currentUser.id) {
// const config = getAxiosConfig();
// axios({
// method: 'get',
// url: `${apiUrl}/users/${state.currentUser.id}/collections/liked`,
// headers: config.headers
// }).then(
// (response) => {
// const data = response.data
// for (let i = 0; i < data.length; i++)
// if (data[i].id === props.id)
// toggleLiked(true)
// saveHeaders(response)
// })
// }
// else {
// toggleLiked(false);
// toggleUserFollowingCol(false);
// }
// }, 2000);
if (!state.currentUser.id) {
toggleLiked(false);
toggleUserFollowingCol(false);
......@@ -240,7 +202,7 @@ export default function CollectionCardFunction(props) {
}} />
<UserAndTitle>
<span>{props.author}</span>
<span className={"col-name"}>{props.name}</span>
<span className={"col-name"}>{name}</span>
</UserAndTitle>
</UserInfo>
<StyledGrid container direction="row">
......@@ -291,13 +253,15 @@ export default function CollectionCardFunction(props) {
<Grid container>
<Grid item xs={6} style={{ display: "flex", justifyContent: "center" }}>
{
props.privacy === 'private' &&
privacy === 'private' &&
<LockIcon style={{ color: "#666" }} />
}
</Grid>
<Grid item xs={6} style={{ display: "flex", justifyContent: "flex-end" }}>
<ColCardOwnerOptions
id={props.id}
changeColName={changeColName}
changeColPrivacy={changeColPrivacy}
/>
</Grid>
</Grid>
......@@ -370,20 +334,6 @@ const UserAndTitle = styled.div`
}
`
// const AvatarDiv = styled.div`
// z-index : 5;
// overflow : hidden;
// img {
// border-radius : 50%;
// height : 70px;
// width : 70px;
// border : 2px solid #fff !important;
// background-color : #fff;
// box-shadow : 0 1px 3px rgba(0,0,0,.45);
// }
// `
const UserInfo = styled.div`
position : absolute;
display : flex;
......
......@@ -43,7 +43,7 @@ export default function EditarColecaoForm (props) {
const [value, setValue] = useState(-1);
/*values are set according to backend complaint id*/
const [options] = [
const options = [
{value : "pública", text :'Pública (Sua coleção estará disponível para todos)'},
{value : "privada", text : 'Privada (Somente você poderá visualizar esta coleção)'}
]
......@@ -69,7 +69,7 @@ export default function EditarColecaoForm (props) {
}
function handleSuccessfulSubmit (data) {
props.finalize(data.id)
props.finalize(data.name, data.privacy)
}
const formSubmit = (e) => {
e.preventDefault()
......
......@@ -25,7 +25,7 @@ import { Store } from '../Store';
import ColaborarModal from './ColaborarModal.js'
import Snackbar from '@material-ui/core/Snackbar';
import MuiAlert from '@material-ui/lab/Alert';
import { useLocation } from 'react-router-dom'
import { useLocation, useHistory } from 'react-router-dom'
import MenuBarMobile from './MenuBarMobile.js'
import { validateGoogleLoginToken } from './HelperFunctions/getAxiosConfig'
......@@ -54,8 +54,19 @@ export default function Header(props) {
)
}
/* 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()
let history = useHistory()
useEffect(() => {
const url = `/auth/validate_token/`
let query = new URLSearchParams(loc.search)
if(query.get("auth_token")) {
......@@ -68,8 +79,8 @@ export default function Header(props) {
"token-type" : 'Bearer'
}
}
validateGoogleLoginToken(config, handleSuccessValidateToken, (error) => { console.log(error) })
redirect()
validateGoogleLoginToken(url, config, handleSuccessValidateToken, (error) => {console.log(error)})
history.push("/")
}
}, [loc])
......@@ -82,10 +93,6 @@ export default function Header(props) {
}
}, [state.currentUser.askTeacherQuestion])
const redirect = () => {
props.history.push('/')
}
const toggleSnackbar = (event, reason) => {
if (reason === 'clickaway') {
return;
......
......@@ -92,7 +92,6 @@ export const getRequest = (url, onSuccess, onError) => {
})
})
.then(data => {
console.log(data)
onSuccess(data)
})
.catch(error => {
......@@ -114,7 +113,6 @@ export const deleteRequest = (url, onSuccess, onError) => {
})
})
.then(data => {
console.log(data)
onSuccess(data)
})
.catch(error => {
......@@ -124,10 +122,7 @@ export const deleteRequest = (url, onSuccess, onError) => {
export const putRequest = (url, payload, onSuccess, onError) => {
let newHeaders = fetchHeaders()
if (payload instanceof FormData) {
newHeaders.append('Content-Type', 'multipart/form-data')
}
else {
if (!(payload instanceof FormData)) {
newHeaders.append('Content-Type', 'application/json')
}
......@@ -145,7 +140,6 @@ export const putRequest = (url, payload, onSuccess, onError) => {
})
})
.then(data => {
console.log(data)
onSuccess(data)
})
.catch(error => {
......@@ -176,7 +170,6 @@ export const postRequest = (url, payload, onSuccess, onError) => {
})
})
.then(data => {
console.log(data)
onSuccess(data)
})
.catch(error => {
......@@ -189,9 +182,7 @@ export const fetchAllRequest = (urls, onSuccess, onError) => {
headers : fetchHeaders()
}))).then( (responses) => {
for(let res of responses) {
console.log(res)
if (res.headers.has('access-token') && res.status !== 304) {
console.log(res)
updateAccessToken(res.headers.get('access-token'))
}
}
......@@ -205,20 +196,36 @@ export const fetchAllRequest = (urls, onSuccess, onError) => {
})
}
export const validateGoogleLoginToken = (config, onSuccess, onError) => {
axios.get( (`${apiUrl}/auth/validate_token/`), config ).then(
(response) => {
export const validateGoogleLoginToken = (url, config, onSuccess, onError) => {
const newHeaders = new Headers(config.headers)
if ( response.headers['access-token'] ) {
updateHeaders(response.headers)
fetch((`${apiUrl}${url}`), {
method : 'GET',
headers : newHeaders
})
.then(response => {
const auth_headers = {
client: response.headers.get('client'),
"access-token": response.headers.get('access-token'),
uid: response.headers.get('uid'),
expiry: response.headers.get('expiry'),
"token-type": "Bearer"
}
onSuccess(response.data)
},
(error) => {
sessionStorage.setItem('@portalmec/auth_headers', JSON.stringify(auth_headers))
return response.json().catch(err => {
return {};
})
})
.then(data => {
console.log(data)
onSuccess(data)
})
.catch(error => {
onError(error)
}
)
})
}
export const authentication = (url, payload, onSuccess, onError) => {
......
......@@ -25,6 +25,12 @@ import CloseModalButton from './CloseModalButton'
import EditarColecaoForm from './EditarColecaoForm.js'
export default function ModalEditarColecao (props) {
function finalize (newName, newPrivacy) {
props.changeColName(newName)
props.changeColPrivacy(newPrivacy)
props.handleClose()
}
return (
<StyledModal
aria-labelledby="transition-modal-title"
......@@ -47,7 +53,7 @@ export default function ModalEditarColecao (props) {
<CloseModalButton handleClose={props.handleClose} id={props.id}/>
</Header>
<Content style={{paddingTop : "0"}}>
<EditarColecaoForm id={props.id} handleClose={props.handleClose} finalize={props.handleClose}/>
<EditarColecaoForm id={props.id} handleClose={props.handleClose} finalize={finalize}/>
</Content>
</Container>
</Fade>
......
......@@ -21,28 +21,10 @@ import Card from '@material-ui/core/Card';
import {apiDomain} from '../env';
import ResourceCardOptions from './ResourceCardOptions'
import noAvatar from "../img/default_profile.png";
// import { makeStyles } from '@material-ui/core/styles';
import Button from '@material-ui/core/Button';
import styled from 'styled-components'
// import animacao from "../img/laranja/ANIMACAO_SIMULACAO.jpg";
// import apresentacao from "../img/laranja/APRESENTACAO.jpg";
// import aplicativo from "../img/laranja/APP.jpg";
// import audio from "../img/laranja/AUDIO.jpg";
// import vazio from "../img/laranja/EMPTY.jpg";
// import imagem from "../img/laranja/IMAGEM.jpg";
// import grafico from "../img/laranja/INFOGRAFICO.jpg";
// import jogo from "../img/laranja/JOGO.jpg";
// import livro from "../img/laranja/LIVRO_DIGITAL.jpg";
// import mapa from "../img/laranja/MAPA.jpg";
// import outros from "../img/laranja/OUTROS.jpg";
// import software from "../img/laranja/SOFTWARE.jpg";
// import texto from "../img/laranja/TEXTO.jpg";
// import video from "../img/laranja/VIDEO.jpg";
import Rating from '@material-ui/lab/Rating';
import StarBorderIcon from '@material-ui/icons/StarBorder';
// import AddIcon from '@material-ui/icons/CreateNewFolder';
// import Video from '@material-ui/icons/OndemandVideo';
// import MoreIcon from '@material-ui/icons/More';
import FavoriteIcon from '@material-ui/icons/Favorite';
import ButtonGuardarColecao from './ButtonGuardarColecao.js'
import Slide from '@material-ui/core/Slide';
......@@ -108,7 +90,7 @@ export default function ResourceCardFunction(props) {
</HeaderContainer>
<TagContainer container direction="row">
{
props.tags.map((tag) =>
props.tags && props.tags.map((tag) =>
<Grid item key={tag.id}>
<span >{tag.name}</span>
</Grid>
......
......@@ -35,13 +35,10 @@ export default function Template(props) {
{
props.length === 0 ?
(
[
<NoContent text={props.noContentText} />
]
)
:
(
[
<React.Fragment>
<StyledGrid container spacing={1} style={{ paddingLeft: "30px", paddingRight: "15px" }}>
{
......@@ -75,7 +72,6 @@ export default function Template(props) {
showAll={() => props.showAll()}
/>
</React.Fragment>
]
)
}
......
......@@ -28,6 +28,7 @@ import FormInput from "../../FormInput.js"
import ValidateUserInput from '../../HelperFunctions/FormValidationFunction.js'
import {apiDomain} from '../../../env.js'
import ModalAlterarCover from '../../ModalAlterarCover/ModalAlterarCover.js'
import Profile from '../../../img/default_profile0.png'
export default function TabPanelEditarPerfil (props) {
// eslint-disable-next-line
......@@ -55,7 +56,6 @@ export default function TabPanelEditarPerfil (props) {
const updateCover = (selectorFiles) => {
const objectURL = URL.createObjectURL(selectorFiles[0])
console.log(objectURL)
setTempCover(objectURL)
controlModal()
}
......@@ -118,7 +118,7 @@ export default function TabPanelEditarPerfil (props) {
<div style={{padding:"0", display:"flex", flexDirection:"column"}}>
<HeaderContainer>
<div style={{position:"relative", height:"100%"}}>
<img src={`${apiDomain}` + state.currentUser.cover} alt="user cover avatar" style={{width:"100%", height:"100%", objectFit:"cover"}}/>
<img src={state.currentUser.cover ? `${apiDomain}` + state.currentUser.cover : null} alt="user cover avatar" style={{width:"100%", height:"100%", objectFit:"cover"}}/>
<input accept="image/*" style = {{display:"none"}} id="icon-button-file" type="file" onChange={(e) => updateCover(e.target.files)}/>
<label htmlFor="icon-button-file">
<Tooltip title={<span style={{fontSize:"14px", overflow:"hidden", transition:"all .5s ease"}}>ALTERAR CAPA</span>} placement="left">
......@@ -129,7 +129,7 @@ export default function TabPanelEditarPerfil (props) {
</label>
</div>
<ProfileAvatarDiv onMouseEnter={handleHoverAlterarFoto} onMouseLeave={handleHoverAlterarFoto}>
<img src={`${apiDomain}` + state.currentUser.avatar} alt = "user avatar" style={{border:"0", verticalAlign:"middle"}}/>
<img src={state.currentUser.avatar ? `${apiDomain}` + state.currentUser.avatar : Profile} alt = "user avatar" style={{border:"0", verticalAlign:"middle"}}/>
<ChangeAvatarDiv style={ {display : hoverAlterarFoto ? 'flex' : 'none'}}>
<span>Alterar Foto</span>
</ChangeAvatarDiv>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment