From 1b9b214570beab508c3c496e40d03698bcd2f3ae Mon Sep 17 00:00:00 2001
From: Lucas Schoenfelder <les17@inf.ufpr.br>
Date: Mon, 25 Jan 2021 12:33:51 -0300
Subject: [PATCH] switched manual axios call to centralized axios request
 handler

---
 package-lock.json                             |  15 +-
 package.json                                  |   2 +-
 src/Components/AboutResource.js               | 264 ------------------
 src/Components/AcessibilityBar.js             |  60 ----
 src/Components/AreasSubPages.js               |  13 +-
 src/Components/Button.js                      |  75 -----
 src/Components/Card.js                        | 105 -------
 src/Components/ColCardPublicOptions.js        |  16 +-
 src/Components/CollectionCardFunction.js      |  42 +--
 src/Components/CollectionCommentSection.js    |  12 +-
 src/Components/Coment.js                      |  27 --
 src/Components/Header.js                      |   5 +
 .../HelperFunctions/getAxiosConfig.js         |  73 +++++
 src/Components/Notifications.js               |  37 +--
 14 files changed, 129 insertions(+), 617 deletions(-)
 delete mode 100644 src/Components/AboutResource.js
 delete mode 100644 src/Components/AcessibilityBar.js
 delete mode 100644 src/Components/Button.js
 delete mode 100644 src/Components/Card.js
 delete mode 100644 src/Components/Coment.js

diff --git a/package-lock.json b/package-lock.json
index a8fb0106..cb6f2099 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -2538,11 +2538,18 @@
       "integrity": "sha512-3YDiu347mtVtjpyV3u5kVqQLP242c06zwDOgpeRnybmXlYYsLbtTrUBUm8i8srONt+FWobl5aibnU1030PeeuA=="
     },
     "axios": {
-      "version": "0.19.2",
-      "resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
-      "integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
+      "version": "0.21.1",
+      "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.1.tgz",
+      "integrity": "sha512-dKQiRHxGD9PPRIUNIWvZhPTPpl1rf/OxTYKsqKUDjBwYylTvV7SjSHJb9ratfyzM6wCdLCOYLzs73qpg5c4iGA==",
       "requires": {
-        "follow-redirects": "1.5.10"
+        "follow-redirects": "^1.10.0"
+      },
+      "dependencies": {
+        "follow-redirects": {
+          "version": "1.13.1",
+          "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.13.1.tgz",
+          "integrity": "sha512-SSG5xmZh1mkPGyKzjZP8zLjltIfpW32Y5QpdNJyjcfGxK3qo3NDDkZOZSFiGn1A6SclQxY9GzEwAHQ3dmYRWpg=="
+        }
       }
     },
     "axobject-query": {
diff --git a/package.json b/package.json
index 95bdc57a..22c837b4 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
     "@material-ui/lab": "^4.0.0-alpha.57",
     "@material-ui/styles": "^4.11.2",
     "@syncfusion/ej2-react-inputs": "^18.3.52",
-    "axios": "^0.19.2",
+    "axios": "^0.21.1",
     "base64-img": "^1.0.4",
     "binary-extensions": "^2.1.0",
     "build": "^0.1.4",
diff --git a/src/Components/AboutResource.js b/src/Components/AboutResource.js
deleted file mode 100644
index 87a0949e..00000000
--- a/src/Components/AboutResource.js
+++ /dev/null
@@ -1,264 +0,0 @@
-/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
-Departamento de Informatica - Universidade Federal do Parana
-
-This file is part of Plataforma Integrada MEC.
-
-Plataforma Integrada MEC is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Plataforma Integrada MEC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-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 from 'react';
-import axios from 'axios';
-import {apiUrl} from '../env';
-import {Col,Row} from 'react-grid-system';
-import Paper from '@material-ui/core/Paper';
-import Typography from '@material-ui/core/Typography';
-import CardContent from '@material-ui/core/CardContent';
-import Collapse from '@material-ui/core/Collapse';
-import CardMedia from '@material-ui/core/CardMedia';
-import CardActions from '@material-ui/core/CardActions';
-import Coment from './Coment';
-import Rating from '@material-ui/lab/Rating';
-import Tag from './Tags';
-import { Hidden } from '@material-ui/core';
-import Button from '@material-ui/core/Button';
-import IconButton from '@material-ui/core/IconButton';
-import Menu from '@material-ui/core/Menu';
-import ListItemIcon from '@material-ui/core/ListItemIcon';
-import MenuItem from '@material-ui/core/MenuItem';
-import MoreVertIcon from '@material-ui/icons/MoreVert';
-/*imagens e icones*/
-import ExpandMoreIcon from '@material-ui/icons/ExpandMore';
-import ShareIcon from '@material-ui/icons/Share';
-import ReportIcon from '@material-ui/icons/Error';
-import AddIcon from '@material-ui/icons/CreateNewFolder';
-import FavoriteIcon from '@material-ui/icons/Favorite';
-import GetAppIcon from '@material-ui/icons/GetApp';
-import StarBorderIcon from '@material-ui/icons/StarBorder';
-import RateReviewIcon from '@material-ui/icons/RateReview';
-import VisibilityIcon from '@material-ui/icons/Visibility';
-import SdCardIcon from '@material-ui/icons/SdCard';
-import TranslateIcon from '@material-ui/icons/Translate';
-import InsertDriveFileIcon from '@material-ui/icons/InsertDriveFile';
-import DateRangeIcon from '@material-ui/icons/DateRange';
-import UpdateIcon from '@material-ui/icons/Update';
-import AssignmentOutlinedIcon from '@material-ui/icons/AssignmentOutlined';
-import OpenIcon from '@material-ui/icons/CallMade';
-import { TextField, FormControl } from '@material-ui/core';
-
-import noAvatar from "../img/default_profile.png";
-import styled from 'styled-components'
-
-
-
-const TypographyStyled = styled(Typography)`
-  padding: 5px;
-`
-
-const CardActionsStyled = styled(CardActions)`
-  padding:0px 0px 10px 0px;
-  align-items: center;
-`
-
-const PaperStyled = styled(Paper)`
-  margin: 2em 0em 2em 0em;
-  padding: 2em 2em 0em 2em;
-  @media only screen and (min-width :500px ) {
-    margin: 2em 10% 2em 10%;
-  }
-`
-const elevateStyle = 3;
-
-const Overlay = styled.div`
-  display: inline;
-  background: linear-gradient(transparent,transparent,#fff),transparent;
-  bottom: 0;
-  cursor: pointer;
-  left: 0;
-  opacity: .8;
-  filter: alpha(opacity=80);
-  position: absolute;
-  right: 0;
-  top: 0;
-  height: inherit;
-
-`
-async function getResource(id){
-  let res = await axios.get(`${apiUrl}/learning_objects/${id}`);
-  let data = res.data;
-  return(data);
-}
-
-export default function AboutResource() {
-
-  var display = getResource(19133);
-  console.log(display);
-  const [anchorEl, setAnchorEl] = React.useState(null);
-
-  function handleClick(event) {
-    setAnchorEl(event.currentTarget);
-  }
-
-  function handleClose() {
-    setAnchorEl(null);
-  }
-  return (
-    <div style={{backgroundColor: "#f4f4f4", padding: "2em 0em 2em 0em"}}>
-      <PaperStyled elevation={elevateStyle}>
-        <CardMedia image={noAvatar}/>
-        <CardContent style={{padding: "0em"}}>
-          <Typography variant="h5" color="textSecondary" component="h3">
-          {display.name}
-          </Typography>
-          <CardActionsStyled >
-            <IconButton style={{padding: "0px"}}aria-label="Favoritar">
-              <FavoriteIcon />
-            </IconButton>
-            <Rating
-              name="customized-empty"
-              value={2}
-              precision={0.5}
-              emptyIcon={<StarBorderIcon fontSize="inherit" />}
-            />
-            <Hidden smDown>
-              <IconButton aria-label="Relatar">
-                <RateReviewIcon/>
-              </IconButton>
-              RELATAR
-            </Hidden>
-            </CardActionsStyled>
-            <CardContent style={{padding: "0em"}}>
-              <TypographyStyled component="p" color="textSecondary">
-              Tipo de Recurso:
-              </TypographyStyled>
-              <TypographyStyled component="p" color="textSecondary">
-              Componentes Curriculares:
-              </TypographyStyled>
-              <TypographyStyled component="p" color="textSecondary">
-              Outras Temáticas:
-              </TypographyStyled>
-              <TypographyStyled component="p" color="textSecondary">
-              Etapas de Ensino:
-              </TypographyStyled>
-            </CardContent>
-          <Row >
-            <Col md={4} sm={12}><VisibilityIcon style={{verticalAlign: "middle"}}/>Visualizações:</Col>
-            <Col md={5} sm={12}><GetAppIcon style={{verticalAlign: "middle"}}/>Baixados/Acessados:</Col>
-          </Row>
-          <CardActions disableSpacing style={{fontSize: "0.7rem", borderRadius: "2px", justifyContent: "space-between", paddingTop: "2em"}}>
-            <Hidden smDown>
-              <Button  aria-label="Reportar" size="small">
-              <ReportIcon />     REPORTAR ABUSO OU ERRO        </Button>
-              <Button aria-label="Compartilhar">
-              <ShareIcon />   COMPARTILHAR          </Button>
-            </Hidden>
-            <Button aria-label="Guardar">
-            <AddIcon />   GUARDAR          </Button>
-            <Button variant="contained" color="secondary">
-            <OpenIcon/> Abrir Recurso </Button>
-            <Hidden mdUp>
-            <Button aria-controls="simple-menu" aria-haspopup="true" onClick={handleClick}>
-              <MoreVertIcon/>
-            </Button>
-            <Menu
-              id="simple-menu"
-              anchorEl={anchorEl}
-              keepMounted
-              open={Boolean(anchorEl)}
-              onClose={handleClose}
-            >
-              <MenuItem onClick={handleClose}>
-              <ListItemIcon>
-                <ShareIcon />
-              </ListItemIcon>
-              Compartilhar</MenuItem>
-              <MenuItem onClick={handleClose}>
-              <ListItemIcon>
-                <ReportIcon />
-              </ListItemIcon>
-              Reportar</MenuItem>
-            </Menu>
-            </Hidden>
-          </CardActions>
-    </CardContent>
-      </PaperStyled>
-      <PaperStyled elevation={elevateStyle}>
-        <Row style={{padding: "15px"}}>
-          <Col md={8} sm={12}>
-            <Typography variant="h5" color="textSecondary" component="h3">
-            Sobre o Recurso
-            </Typography>
-            <Typography component="p" color="textSecondary">
-            Paper can be used to build surface or other elements for your application.
-            </Typography>
-            <div style={{paddingTop: "4em"}}>
-            <Typography variant="h5" color="textSecondary" component="h3">
-            Informações Adicionais</Typography>
-            <Tag name="teste"/>
-            <Typography component="p" color="textSecondary">
-            <SdCardIcon/>Tamanho:
-            </Typography>
-            <Typography component="p" color="textSecondary">
-            <TranslateIcon/>Idioma:
-            </Typography>
-            <Typography component="p" color="textSecondary">
-            <InsertDriveFileIcon/>Formato:
-            </Typography>
-            <Typography component="p" color="textSecondary">
-            <DateRangeIcon/>Data de Envio:
-            </Typography>
-            <Typography component="p" color="textSecondary">
-            <UpdateIcon/>Modificado em:
-            </Typography>
-            <Typography component="p" color="textSecondary">
-            <AssignmentOutlinedIcon/>Tipo de Licença:
-            </Typography>
-            </div>
-          </Col>
-          <Col md={4}  sm={12}>
-            <div style={{borderLeft:"1px solid #e5e5e5"}}>
-              <Typography>
-                Enviado por:
-              </Typography><br/>
-              <img style={{padding: "2em" }} alt="Avatar" src={noAvatar} height="100em"/>
-            </div>
-          </Col>
-      </Row>
-
-
-      </PaperStyled>
-      <PaperStyled elevation={elevateStyle}>
-        <CardContent>
-            Conte sua experiência com o Recurso
-            <Rating
-              name="customized-color"
-              value={0}
-              precision={0.5}
-            />
-            <Row>
-              <Col md={10} sm={12}>
-                <TextField fullWidth="true" multiline="true" required="true" placeholder="Escreva aqui sua experiência com o recurso *"/>
-              </Col>
-              <Col>
-                <Button variant="contained" color="primary">submit </Button>
-              </Col>
-            </Row>
-
-        </CardContent>
-        <CardContent>
-          <Typography variant="h5" component="p" color="textSecondary">Relatos sobre o uso do Recurso</Typography>
-          <Coment author="jorginho" coment="muito bom gostei mto bom msm"/>
-        </CardContent>
-      </PaperStyled>
-    </div>
-  );
-}
diff --git a/src/Components/AcessibilityBar.js b/src/Components/AcessibilityBar.js
deleted file mode 100644
index 7546ea2f..00000000
--- a/src/Components/AcessibilityBar.js
+++ /dev/null
@@ -1,60 +0,0 @@
-/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
-Departamento de Informatica - Universidade Federal do Parana
-
-This file is part of Plataforma Integrada MEC.
-
-Plataforma Integrada MEC is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Plataforma Integrada MEC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-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, {Component} from 'react';
-import {Row, Col, Container} from 'react-grid-system';
-import Bt from './Button.js'
-
-const acessibilityBar ={
-  width: '100%',
-  color: 'gray',
-  fontFamily: '"Roboto", Sans-Serif',
-  whiteSpace: 'nowrap',
-  fontSize: '0.7vw',
-  textAlign: 'right'
-
-}
-
-class AcessibilityBar extends Component{
-  renderBt(name, link=undefined){
-    return <Bt name={name} link={link}/>
-  }
-  render(){
-    return(
-    <Container fluid={true}>
-      <Row style={acessibilityBar}>
-        <Col md={6} xs={6} lg={6} style={{textAlign: 'left'}}>
-          {this.renderBt("Ir para conteúdo 1", "texto1")}
-          {this.renderBt("Ir para menu 2", "texto2")}
-          {this.renderBt("Ir para menu 3", "texto3")}
-          {this.renderBt("Ir para rodapé 4", "texto4")}
-        </Col>
-        <Col md={6} xs={6} lg={6} style={{textAlign: 'right'}}>
-          Tamanho do Texto: {this.renderBt("A+")}
-          {this.renderBt("A-")}
-          {this.renderBt("A")}
-          {this.renderBt("Contraste")}
-          {this.renderBt("Acessibilidade")}
-          {this.renderBt("Mapa do Site")}
-        </Col>
-      </Row>
-    </Container>
-  );
-  }
-}
-export default AcessibilityBar;
diff --git a/src/Components/AreasSubPages.js b/src/Components/AreasSubPages.js
index f6b59bb2..fb21567d 100644
--- a/src/Components/AreasSubPages.js
+++ b/src/Components/AreasSubPages.js
@@ -30,6 +30,7 @@ import colecoes from "../img/ilustra_colecoes.png";
 import Grid from "@material-ui/core/Grid";
 import ResourceCardFunction from "./ResourceCardFunction.js";
 import CollectionCardFunction from "./CollectionCardFunction.js";
+import {makeAxiosGetRequest} from './HelperFunctions/getAxiosConfig.js'
 
 const areaStyle = {
   paddingTop: "5px",
@@ -49,14 +50,10 @@ class ReqResources extends Component {
       resources: [],
     };
   }
-  componentDidMount() {
-    axios
-      .get(`${apiUrl}/learning_objects?limit=12&sort=["published_at", "desc"]`)
-      .then((res) => {
-        this.setState({ resources: res.data });
-        console.log(res.data);
-      });
-  }
+
+componentDidMount() {
+    makeAxiosGetRequest(`/learning_objects?limit=12&sort=["published_at", "desc"]`, (data) => {this.setState({ resources: data })}, () => {console.log('error AreasSubPages')})
+}
   render() {
     var row1 = this.state.resources.slice(0, 4);
     var row2 = this.state.resources.slice(4, 8);
diff --git a/src/Components/Button.js b/src/Components/Button.js
deleted file mode 100644
index afe4acad..00000000
--- a/src/Components/Button.js
+++ /dev/null
@@ -1,75 +0,0 @@
-/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
-Departamento de Informatica - Universidade Federal do Parana
-
-This file is part of Plataforma Integrada MEC.
-
-Plataforma Integrada MEC is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Plataforma Integrada MEC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-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, {Component} from 'react';
-
-class Bt extends Component{
-  constructor(props){
-    super(props);
-
-    this.state ={
-      color: "white",
-      hover: "#F0F0F0",
-      iddle: "white"
-    };
-  }
-  componentWillMount(){
-    if (this.props.backhover){
-      this.setState({hover: this.props.backhover})
-    }
-    if (this.props.iddle){
-      this.setState({color:this.props.background,
-                      iddle: this.props.background})
-    }
-  }
-  onHover(){
-    this.setState({color: this.state.hover})
-  }
-  onIddle(){
-    this.setState({color: this.state.iddle})
-  }
-  onClick(){
-    if(this.props.link === undefined){
-    }
-    if(this.props.method !== undefined ){
-      console.log(this.props.parameter)
-       this.props.method(this.props.parameter)
-    }
-    else {
-      alert(`goto ${this.props.link}`)
-    }
-  }
-
-  render(){
-    const acessibilityBt = {
-      borderStyle: 'none',
-      padding: '10px',
-      textAlign: 'center',
-      display: 'inline-block',
-      backgroundColor: this.state.color,
-      color: "#ababab"
-    };
-    return(
-      <span id={this.props.name +"-Button"} style={acessibilityBt} onMouseEnter={this.onHover.bind(this)} onMouseOut={this.onIddle.bind(this)} onClick={this.onClick.bind(this)}>
-        {this.props.name}
-      </span>
-    );
-  }
-}
-
-export default Bt;
diff --git a/src/Components/Card.js b/src/Components/Card.js
deleted file mode 100644
index e721b550..00000000
--- a/src/Components/Card.js
+++ /dev/null
@@ -1,105 +0,0 @@
-/*Copyright (C) 2019 Centro de Computacao Cientifica e Software Livre
-Departamento de Informatica - Universidade Federal do Parana
-
-This file is part of Plataforma Integrada MEC.
-
-Plataforma Integrada MEC is free software: you can redistribute it and/or modify
-it under the terms of the GNU Affero General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-Plataforma Integrada MEC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-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, {Component} from 'react';
-import {Container} from 'react-grid-system';
-import Card from '@material-ui/core/Card';
-import CardContent from '@material-ui/core/CardContent';
-import CardActions from '@material-ui/core/CardActions';
-import IconButton from '@material-ui/core/IconButton';
-import Typography from '@material-ui/core/Typography';
-import FavoriteIcon from '@material-ui/icons/Favorite';
-import StarRatings from 'react-star-ratings';
-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 AddIcon from '@material-ui/icons/CreateNewFolder';
-import Options from './CardOptions'
-import Video from '@material-ui/icons/OndemandVideo';
-
-var types = [{label: "Animação", thumb: animacao}, {label: "Apresentação", thumb: apresentacao},
-{label: "Aplicativo" , thumb: aplicativo}, {label: "Áudio", thumb: audio}, {label: "Vazio", thumb: vazio}, {label: "Imagem", thumb: imagem}, {label: "Gráfico", thumb: grafico}, {label: "Jogo", thumb: jogo}, {label: "Livro", thumb: livro}, {label: "Mapa", thumb: mapa}, {label: "Outros", thumb: outros}, {label: "Software", thumb:software}, {label: "Texto", thumb:texto}, {label: "Vídeo", thumb:video}]
-class ResourceCard extends Component{
-  constructor(props){
-    super(props);
-    this.state = {
-      hover: false,
-      thumbnail: null,
-      isVideo: false,
-    };
- };
- decide(){
-   var aux = this.props.thumbnail;
-   if (!aux) {
-     aux = types.find(function(element){ return element.label === (this.props.type)});
-   }
-   this.setState({thumbnail: aux.thumb});
-   console.log(this.state.thumbnail);
-   (this.props.type === "Vídeo")? this.setState({isvideo:true}) : this.setState({isvideo:false});
-};
- render(){
-   {this.decide()}
-  return (
-    <Card>
-      <img src={this.state.thumbnail} alt="thumbnail do recurso"/>
-      <CardContent style={{height: "60%", textAlign: "left", paddingBottom: "0px"}}>
-        <Typography variant="body2" color="textSecondary" component="p" style={{height:"45px", overflow: "hidden", fontSize: "0.8em"}}>
-          {this.props.name}
-        </Typography>
-      </CardContent>
-      <Container style={{textAlign: "left"}}>
-        <StarRatings
-        rating={this.props.rating*100}
-        starRatedColor="ff7f00"
-        starDimension="20px"
-        starSpacing="2px"
-        starHoverColor="red"
-        />
-      </Container>
-      <CardActions style={{justifyContent: "space-between"}}>
-      { this.state.isVideo
-        ? <Video style={{color:"#ff7f00"}} />
-      : <br/>}
-        <IconButton  aria-label="Favoritar" size="small">
-          <FavoriteIcon />
-        </IconButton>
-      </CardActions>
-      <CardActions style={{borderTop:"1px solid #e5e5e5", justifyContent: "space-between"}}>
-
-      <IconButton aria-label="Guardar" size="small">
-        <AddIcon />
-      </IconButton>
-      <Options/>
-      </CardActions>
-    </Card>
-  );}
-}
-
-export default ResourceCard;
diff --git a/src/Components/ColCardPublicOptions.js b/src/Components/ColCardPublicOptions.js
index 53c8e8a3..9538aa24 100644
--- a/src/Components/ColCardPublicOptions.js
+++ b/src/Components/ColCardPublicOptions.js
@@ -27,9 +27,7 @@ import MoreVertIcon from '@material-ui/icons/MoreVert';
 import styled from 'styled-components'
 import ErrorIcon from '@material-ui/icons/Error';
 import ReportModal from './ReportModal.js'
-import {getAxiosConfig} from '../Components/HelperFunctions/getAxiosConfig'
-import axios from 'axios'
-import {apiUrl} from '../env';
+import {makeAxiosDeleteRequest} from '../Components/HelperFunctions/getAxiosConfig'
 
 export default function ColCardPublicOptions (props) {
   const [anchorEl, setAnchorEl] = React.useState(null);
@@ -46,16 +44,8 @@ export default function ColCardPublicOptions (props) {
   const handleReportModal = (value) => {toggleReportModal(value)}
 
   const handleUnfollow = () => {
-      let config = getAxiosConfig()
-      let payload = {}
-
-      axios.put( (`${apiUrl}/collections/` + props.id + '/follow'),payload, config).then(
-          (response) => {
-              console.log(response.data)
-              if ( response.headers['access-token'] ) {
-                  sessionStorage.setItem('@portalmec/accessToken', response.headers['access-token'])
-              }
-          }, (error) => {console.log(error)})
+
+      makeAxiosDeleteRequest(`/collections/${props.id}/follow`, (data) => {console.log(data)}, (error) => {console.log(error)})
   }
 
   return (
diff --git a/src/Components/CollectionCardFunction.js b/src/Components/CollectionCardFunction.js
index 5b015705..a0b1107e 100644
--- a/src/Components/CollectionCardFunction.js
+++ b/src/Components/CollectionCardFunction.js
@@ -18,7 +18,7 @@ along with Plataforma Integrada MEC.  If not, see <http://www.gnu.org/licenses/>
 
 import React, {useState, useContext} from 'react';
 import {Store} from '../Store.js'
-import {apiDomain, apiUrl} from '../env';
+import {apiDomain} from '../env';
 import noAvatar from "../img/default_profile.png";
 import Button from '@material-ui/core/Button';
 import styled from 'styled-components'
@@ -35,8 +35,7 @@ import LockIcon from '@material-ui/icons/Lock';
 import ColCardOwnerOptions from './ColCardOwnerOptions.js'
 import ColCardPublicOptions from './ColCardPublicOptions'
 import {Link} from 'react-router-dom';
-import axios from 'axios'
-import {getAxiosConfig} from '../Components/HelperFunctions/getAxiosConfig'
+import {makeAxiosPutRequest} from '../Components/HelperFunctions/getAxiosConfig'
 
 export default function CollectionCardFunction (props) {
     const {state} = useContext(Store)
@@ -48,21 +47,13 @@ export default function CollectionCardFunction (props) {
 
     const [likesCount, setLikesCount] = useState(props.likeCount)
     const [liked, toggleLiked] = useState(props.liked)
+
+    function handleSuccessLike (data) {
+        toggleLiked(!liked)
+        setLikesCount(data.count)
+    }
     const handleLike = () => {
-        let payload = {}
-        let config = getAxiosConfig()
-
-        axios.put( (`${apiUrl}/collections/` + props.id + '/like'),payload, config
-        ).then(
-            (response) => {
-                if ( response.headers['access-token'] ) {
-                    sessionStorage.setItem('@portalmec/accessToken', response.headers['access-token'])
-                }
-                toggleLiked(!liked)
-                setLikesCount(response.data.count)
-            },
-            (error) => {console.log(error)}
-        )
+        makeAxiosPutRequest(`/collections/${props.id}/like`, {}, handleSuccessLike, (error) => {console.log(error)})
     }
 
     const [followingHover, handleFollowingHover] = useState(false)
@@ -71,20 +62,11 @@ export default function CollectionCardFunction (props) {
     const [slideIn, setSlide] = useState(false)
     const controlSlide = () => {setSlide(!slideIn)}
 
+    function handleSuccessFollow (data) {
+        handleToggleUserFollowingCol()
+    }
     const handleFollow = () => {
-        let config = getAxiosConfig()
-        let payload = {}
-
-        axios.put( (`${apiUrl}/collections/` + props.id + '/follow'),payload, config).then(
-            (response) => {
-                if ( response.headers['access-token'] ) {
-                    sessionStorage.setItem('@portalmec/accessToken', response.headers['access-token'])
-                }
-                console.log(response.data)
-                handleToggleUserFollowingCol()
-            },
-            (error) => {console.log(error)}
-        )
+        makeAxiosPutRequest(`/collections/${props.id}/follow`, {}, handleSuccessFollow, (error) => {console.log(error)})
     }
 
     const RenderFollowButton = () => {
diff --git a/src/Components/CollectionCommentSection.js b/src/Components/CollectionCommentSection.js
index 9351596e..95ea693a 100644
--- a/src/Components/CollectionCommentSection.js
+++ b/src/Components/CollectionCommentSection.js
@@ -22,13 +22,12 @@ import Card from '@material-ui/core/Card';
 import Button from '@material-ui/core/Button';
 import EditIcon from '@material-ui/icons/Edit';
 import styled from 'styled-components';
-import axios from 'axios';
-import { apiUrl } from '../env';
 import CommentForm from './ResourcePageComponents/CommentForm.js';
 import Comment from './Comment.js';
 import Snackbar from '@material-ui/core/Snackbar';
 import MuiAlert from '@material-ui/lab/Alert';
 import Comentario from '../img/comentarios.png';
+import {makeAxiosGetRequest} from '../Components/HelperFunctions/getAxiosConfig'
 
 export default function CollectionCommentSection(props) {
 	const [post_snack_open, setPostSnackOpen] = useState(false);
@@ -36,9 +35,9 @@ export default function CollectionCommentSection(props) {
 	const [render_state, setRenderState] = useState(false);
 	const [reviews, setReviews] = useState([]);
 	const comment_ref = useRef(null);
-	
+
 	const forceUpdate = () => { setRenderState(!render_state); }
-	
+
 	const handlePostSnackbar = () => {
 		setPostSnackOpen(!post_snack_open);
 	}
@@ -114,10 +113,7 @@ export default function CollectionCommentSection(props) {
 	}
 
 	useEffect(() => {
-		axios.get(apiUrl+'/collections/'+props.id+'/reviews')
-			.then(res => {
-				setReviews(res.data);
-			});
+        makeAxiosGetRequest(`/collections/${props.id}/reviews`, (data) => {setReviews(data)}, (error) => {console.log(error)})
 	}, [render_state]);
 
 	return (
diff --git a/src/Components/Coment.js b/src/Components/Coment.js
deleted file mode 100644
index f76cbf7f..00000000
--- a/src/Components/Coment.js
+++ /dev/null
@@ -1,27 +0,0 @@
-import React, {Component} from 'react';
-import CardContent from '@material-ui/core/CardContent';
-import Typography from '@material-ui/core/Typography';
-import StarRatings from 'react-star-ratings';
-
-
-class Coment extends Component {
-  constructor(props) {
-    super(props);
-
-  }
-render(){
-  return(
-    <CardContent>
-    <StarRatings
-         rating={2}
-         starRatedColor="ff7f00"
-         starDimension="20px"
-         starSpacing="2px"
-         />
-      <Typography component="p" varitant="srOnly" style={{color: "orange"}}> {this.props.author}:{this.props.coment}</Typography>
-    </CardContent>
-  );
-}
-
-}
-export default Coment;
diff --git a/src/Components/Header.js b/src/Components/Header.js
index 14025e28..25edfdee 100644
--- a/src/Components/Header.js
+++ b/src/Components/Header.js
@@ -83,7 +83,12 @@ export default function Header(props){
   useEffect( () => {
       if (sessionStorage.getItem('@portalmec/auth_headers')) {
           let config = { headers : JSON.parse(sessionStorage.getItem('@portalmec/auth_headers'))}
+          console.log(config)
+          console.log(sessionStorage.getItem('@portalmec/accessToken'))
 
+          if (config.headers['access-token'] !== sessionStorage.getItem('@portalmec/accessToken')){
+              console.log('erro tokens diferentes')
+          }
           validateToken(config)
       }
   }, [])
diff --git a/src/Components/HelperFunctions/getAxiosConfig.js b/src/Components/HelperFunctions/getAxiosConfig.js
index 63a4ff6e..7ef9c62d 100644
--- a/src/Components/HelperFunctions/getAxiosConfig.js
+++ b/src/Components/HelperFunctions/getAxiosConfig.js
@@ -1,3 +1,5 @@
+import {apiUrl} from '../../env.js'
+import axios from 'axios'
 
 export const getAxiosConfig = () => {
     let config = {
@@ -12,3 +14,74 @@ export const getAxiosConfig = () => {
 
     return config
 }
+
+function getAxiosConfigFromJSON () {
+    let config = {
+        headers : JSON.parse(sessionStorage.getItem('@portalmec/auth_headers'))
+    }
+    return config
+}
+
+function updateHeaders (newAccessToken) {
+    sessionStorage.setItem('@portalmec/accessToken', newAccessToken)
+
+    let auth_headers = JSON.parse(sessionStorage.getItem('@portalmec/auth_headers'))
+    auth_headers['access-token'] = newAccessToken
+
+    sessionStorage.setItem('@portalmec/auth_headers', JSON.stringify(auth_headers))
+}
+
+export const makeAxiosGetRequest = (url, onSuccess, onError) => {
+    let config = getAxiosConfigFromJSON()
+
+    axios.get( (`${apiUrl}${url}`), config ).then(
+        (response) => {
+
+            if ( response.headers['access-token'] ) {
+                updateHeaders(response.headers['access-token'])
+            }
+
+            onSuccess(response.data)
+        },
+        (error) => {
+            onError(error)
+        }
+    )
+}
+
+export const makeAxiosDeleteRequest = (url, onSuccess, onError) => {
+    let config = getAxiosConfigFromJSON()
+
+    axios.delete( (`${apiUrl}${url}`), config ).then(
+        (response) => {
+
+            if ( response.headers['access-token'] ) {
+                updateHeaders(response.headers['access-token'])
+            }
+
+            onSuccess(response.data)
+        },
+        (error) => {
+            onError(error)
+        }
+    )
+}
+
+
+export const makeAxiosPutRequest = (url, payload, onSuccess, onError) => {
+    let config = getAxiosConfigFromJSON()
+
+    axios.put( (`${apiUrl}${url}`), payload, config ).then(
+        (response) => {
+
+            if ( response.headers['access-token'] ) {
+                updateHeaders(response.headers['access-token'])
+            }
+
+            onSuccess(response.data)
+        },
+        (error) => {
+            onError(error)
+        }
+    )
+}
diff --git a/src/Components/Notifications.js b/src/Components/Notifications.js
index d8df9e70..298e706a 100644
--- a/src/Components/Notifications.js
+++ b/src/Components/Notifications.js
@@ -21,10 +21,9 @@ import { Button } from '@material-ui/core';
 import Badge from '@material-ui/core/Badge';
 import styled from 'styled-components'
 import Menu from '@material-ui/core/Menu';
-import {apiDomain, apiUrl} from '../env.js'
-import axios from 'axios'
+import {apiDomain} from '../env.js'
 import ActivityListItem from './ActivityListItem.js'
-import {getAxiosConfig} from './HelperFunctions/getAxiosConfig.js'
+import {makeAxiosGetRequest} from './HelperFunctions/getAxiosConfig.js'
 import { withStyles } from '@material-ui/core/styles';
 import {Link} from 'react-router-dom'
 
@@ -77,27 +76,21 @@ export default function Notification (props) {
     const [notifications, setNotifications] = useState([]);
     // eslint-disable-next-line
     const [notificatonsLength, setLength] = useState(0);
-    useEffect(() => {
-
-        setTimeout(() => {
-            let config = getAxiosConfig()
-            axios.get(`${apiUrl}/feed?offset=0&limit=30`, config)
-            .then( (response) => {
-                if ( response.headers['access-token'] ) {
-                    sessionStorage.setItem('@portalmec/accessToken', response.headers['access-token'])
-                }
 
-                console.log('atividades response: ', response)
-                setNotifications(response.data)
-                setLength(response.data.length)
+    function handleAxiosSuccess (data) {
+        setNotifications(data)
+        setLength(data.length)
+    }
+
+    function handleAxiosError (error) {
+        console.log('error getNotifications')
+        console.log(error)
+    }
+
+    {/*setTimeout(() => {
+        makeAxiosGetRequest('/feed?offset=0&limit=30', handleAxiosSuccess, handleAxiosError)
+    }, 60000)*/}
 
-                },
-                (error) => {
-                    console.log('error while running getNotifications')
-                }
-            )
-        }, 1000);
-    }, [sessionStorage.getItem('@portalmec/uid')])
     function handleClick(event) {
         console.log('event.currentTarget: ', event.currentTarget)
         setAnchorEl(event.currentTarget);
-- 
GitLab