From e3f0993daf98839dfef8e9b4b05df5f7c29da288 Mon Sep 17 00:00:00 2001
From: Luis Felipe Risch <lfr20@inf.ufpr.br>
Date: Sat, 13 Feb 2021 11:22:15 -0300
Subject: [PATCH] added links and removed verifications if its published

---
 src/Components/ResourceCardFunction.js | 113 ++++++++++---------------
 1 file changed, 43 insertions(+), 70 deletions(-)

diff --git a/src/Components/ResourceCardFunction.js b/src/Components/ResourceCardFunction.js
index 08d07b61..ff9e12fb 100644
--- a/src/Components/ResourceCardFunction.js
+++ b/src/Components/ResourceCardFunction.js
@@ -18,31 +18,13 @@ along with Plataforma Integrada MEC.  If not, see <http://www.gnu.org/licenses/>
 
 import React, { useState, useEffect } from 'react';
 import Card from '@material-ui/core/Card';
-import {apiDomain} from '../env';
+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';
@@ -51,7 +33,7 @@ import { Link } from 'react-router-dom';
 import { getDefaultThumbnail } from './HelperFunctions/getDefaultThumbnail'
 import GetIconByName from './UploadPageComponents/GetIconByName'
 import "./ResourceCard.css";
-import {putRequest} from './HelperFunctions/getAxiosConfig'
+import { putRequest } from './HelperFunctions/getAxiosConfig'
 
 export default function ResourceCardFunction(props) {
     const [thumbnail, setThumbnail] = useState(null)
@@ -81,7 +63,7 @@ export default function ResourceCardFunction(props) {
 
     }, [])
 
-    function handleSuccessLike (data) {
+    function handleSuccessLike(data) {
         toggleLiked(!liked)
         setLikesCount(data.count)
     }
@@ -89,32 +71,35 @@ export default function ResourceCardFunction(props) {
     const handleLike = () => {
         const url = `/learning_objects/${props.id}/like/`
 
-        putRequest(url, {}, handleSuccessLike, (error) => {console.log(error)})
+        putRequest(url, {}, handleSuccessLike, (error) => { console.log(error) })
     }
 
     const SlideAnimationContent = () => {
         return (
             <SlideContentDiv>
-                <div style={{padding : 7}}>
+                <div style={{ padding: 7 }}>
                     <HeaderContainer container="row" justify="flex-start" alignItems="center" >{/*marginBottom:10px*/}
                         <AvatarDiv item xs={2}>
                             <img className="img" src={userAvatar} alt="user avatar" />
                         </AvatarDiv>
                         <EnviadoPor item xs={10}>
                             Enviado por:
-                        <br />
                             <p>{props.author}</p>
                         </EnviadoPor>
                     </HeaderContainer>
-                    <TagContainer container direction="row">
-                        {
-                            props.tags.map((tag) =>
-                                <Grid item key={tag.id}>
-                                    <span >{tag.name}</span>
-                                </Grid>
-                            )
-                        }
-                    </TagContainer>
+                    {
+                        props.tags ?
+                            <TagContainer container direction="row">
+                                {
+                                    props.tags.map((tag) =>
+                                        <Grid item key={tag.id}>
+                                            <span >{tag.name}</span>
+                                        </Grid>
+                                    )
+                                }
+                            </TagContainer> :
+                            null
+                    }
                 </div>
             </SlideContentDiv>
         )
@@ -135,9 +120,7 @@ export default function ResourceCardFunction(props) {
                             </Slide >
                         }
                         <div className={`slideContentLinkBeforeActive${slideIn}`} style={{ height: '100%' }}>
-                            <Link to={props.href}>
-                                <img className="img-cover" src={thumbnail} alt="learning object thumbnail" style={{ width: "272.5px" }} />
-                            </Link>
+                            <img className="img-cover" src={thumbnail} alt="learning object thumbnail" style={{ width: "272.5px" }} />
                         </div>
                     </Header>
                     <Description>
@@ -146,49 +129,39 @@ export default function ResourceCardFunction(props) {
                                 {props.title}
                             </Title>
                         </Link>
-                        {
-                            props.published &&
-                            <Rating
-                                name="customized-empty"
-                                value={props.rating}
-                                readOnly
-                                style={{ color: "#666" }}
-                                emptyIcon={<StarBorderIcon fontSize="inherit" />}
-                            />
-                        }
+                        <Rating
+                            name="customized-empty"
+                            value={props.rating}
+                            readOnly
+                            style={{ color: "#666" }}
+                            emptyIcon={<StarBorderIcon fontSize="inherit" />}
+                        />
                         <Footer>
                             <Type>
                                 {GetIconByName(label)}
                                 <span>{label}</span>
                             </Type>
-                            {
-                                props.published &&
-                                <LikeCounter>
-                                    <span>{likesCount}</span>
-                                    <ButtonNoWidth onClick={handleLike}>
-                                        <FavoriteIcon style={{ color: liked ? "red" : "#666" }} />
-                                    </ButtonNoWidth>
-                                </LikeCounter>
-                            }
+                            <LikeCounter>
+                                <span>{likesCount}</span>
+                                <ButtonNoWidth onClick={handleLike}>
+                                    <FavoriteIcon style={{ color: liked ? "red" : "#666" }} />
+                                </ButtonNoWidth>
+                            </LikeCounter>
                         </Footer>
                     </Description>
                 </CardReaDiv>
-
-                {
-                    props.published &&
-                    <CardReaFooter>
-                        <div style={{ display: "flex", height: "100%" }}>
-                            <ButtonGuardarColecao thumb={props.thumbnail} title={props.title} recursoId={props.id}
-                            />
-                        </div>
-                        <ResourceCardOptions
-                            learningObjectId={props.id}
-                            downloadableLink={props.downloadableLink}
-                            thumb={props.thumbnail}
-                            title={props.title}
+                <CardReaFooter>
+                    <div style={{ display: "flex", height: "100%" }}>
+                        <ButtonGuardarColecao thumb={props.thumbnail} title={props.title} recursoId={props.id}
                         />
-                    </CardReaFooter>
-                }
+                    </div>
+                    <ResourceCardOptions
+                        learningObjectId={props.id}
+                        downloadableLink={props.downloadableLink}
+                        thumb={props.thumbnail}
+                        title={props.title}
+                    />
+                </CardReaFooter>
             </CardDiv>
         </StyledCard>
     )
-- 
GitLab