From 0ff15727a2cc151569ddfdf0eb51b8fb17354bfe Mon Sep 17 00:00:00 2001
From: Lucas Schoenfelder <les17@inf.ufpr.br>
Date: Fri, 22 May 2020 13:33:33 -0300
Subject: [PATCH] missing share button and save to collection button
 functionalities

---
 src/Pages/ResourcePage.js | 57 ++++++++++++++++++++++++++++++++++++++-
 1 file changed, 56 insertions(+), 1 deletion(-)

diff --git a/src/Pages/ResourcePage.js b/src/Pages/ResourcePage.js
index 4d9780a5..24135d87 100644
--- a/src/Pages/ResourcePage.js
+++ b/src/Pages/ResourcePage.js
@@ -24,7 +24,14 @@ import Grid from '@material-ui/core/Grid';
 import TextoObjeto from '../Components/ResourcePageComponents/TextoObjeto.js'
 import Footer from '../Components/ResourcePageComponents/Footer.js'
 import Sobre from '../Components/ResourcePageComponents/Sobre.js'
+import CommentsArea from '../Components/ResourcePageComponents/CommentsArea.js'
 import noAvatar from "../img/default_profile.png";
+import Snackbar from '@material-ui/core/Snackbar';
+import MuiAlert from '@material-ui/lab/Alert';
+
+export function Alert(props) {
+  return <MuiAlert elevation={6} variant="filled" {...props} />;
+}
 
 export default function LearningObjectPage (props){
     const id = props.match.params.recursoId
@@ -34,13 +41,35 @@ export default function LearningObjectPage (props){
     useEffect( () => {
         axios.get( (`${apiUrl}/learning_objects/` + id )
     ).then( (response) => {
+        if ( response.headers['access-token'] ) {
+            sessionStorage.setItem('@portalmec/accessToken', response.headers['access-token'])
+        }
         console.log(response)
         setRecurso(response.data)
         toggle(false)
     }, (error) => {console.log(error)})
     }, [])
 
+    const [snackbarOpen, toggleSnackbar] = useState(false)
+    const handleSnackbar = (index) => {setIndex(index); toggleSnackbar(true)}
+    const snackbarText = [
+        "Baixando o Recurso... Lembre-se de relatar sua experiência após o uso do Recurso!",
+        "Seu comentário foi publicado com sucesso!",
+        "Comentário editado com sucesso.",
+        "Comentário deletado com sucesso. "
+    ]
+    const [snackbarIndex, setIndex] = useState(0)
+
     return (
+        <React.Fragment>
+        <Snackbar open={snackbarOpen} autoHideDuration={1000} onClose={toggleSnackbar}
+        anchorOrigin = {{ vertical:'top', horizontal:'right' }}
+        >
+            <Alert severity="info" style={{backgroundColor:"#00acc1"}}>
+                {snackbarText[snackbarIndex]}
+            </Alert>
+        </Snackbar>
+
         <Background>
             {
                 carregando ?
@@ -59,6 +88,8 @@ export default function LearningObjectPage (props){
                                     }
 
                                     {/*adicionar opcoes caso o usuario seja o publisher*/}
+                                    {/*adicionar links para os botoes de editar/deletar*/}
+                                    {/*implementar checkUserRole('publisher')*/}
                                     <TextoObjeto
                                         name={recurso.name}
                                         rating={recurso.rating}
@@ -69,16 +100,28 @@ export default function LearningObjectPage (props){
                                         educationalStages={recurso.educational_stages}
                                         viewCount={recurso.views_count}
                                         downloadCount={recurso.downloads_count}
+                                        id={recurso.publisher.id}
+                                        stateRecurso={recurso.state}
                                         />
                                     </div>
                                     {/*adicionar funcionalidade nos botoes do footer*/}
-                                    <Footer/>
+                                    {/*"Você já reportou esse recurso"*/}
+                                    <Footer
+                                        recursoId={id}
+                                        downloadableLink = {recurso.default_attachment_location}
+                                        handleSnackbar={handleSnackbar}
+                                        title={recurso.name}
+                                        thumb={recurso.thumbnail}
+                                        link={window.location.href}
+                                        />
                                 </Card>
                             </Grid>
 
                             <Grid item xs={12}>
                                 <Card>
                                     {/*add option to MoreVertIcon*/}
+                                    {/*change file size display*/}
+                                    {/*change render method on additional item info*/}
                                     <Sobre
                                         avatar={recurso.publisher.avatar ? (apiDomain + recurso.publisher.avatar) : noAvatar}
                                         publisher={recurso.publisher.name}
@@ -95,12 +138,24 @@ export default function LearningObjectPage (props){
                                         />
                                 </Card>
                             </Grid>
+
+                            <Grid item xs={12}>
+                                <Card>
+                                    {/*adicionar funcionalidade ao botao de entrar*/}
+                                    <CommentsArea
+                                        recursoId = {id}
+                                        handleSnackbar={handleSnackbar}
+
+                                        />
+                                </Card>
+                            </Grid>
                         </Grid>
                     ]
                 )
             }
 
         </Background>
+        </React.Fragment>
     )
 }
 
-- 
GitLab