From 2d47e5787bbef8dccd106b3a03e5705cd0f0e3e5 Mon Sep 17 00:00:00 2001 From: Lucas Schoenfelder <les17@inf.ufpr.br> Date: Tue, 26 May 2020 12:04:59 -0300 Subject: [PATCH] added create collection modal --- .../TabPanels/UserPageTabs/PanelColecoes.js | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/Components/TabPanels/UserPageTabs/PanelColecoes.js b/src/Components/TabPanels/UserPageTabs/PanelColecoes.js index c99aa29b..f39a6752 100644 --- a/src/Components/TabPanels/UserPageTabs/PanelColecoes.js +++ b/src/Components/TabPanels/UserPageTabs/PanelColecoes.js @@ -31,7 +31,7 @@ import CreateNewFolderIcon from '@material-ui/icons/CreateNewFolder'; import Title from '../PanelComponents/PanelTitle.js' import CollectionCardFunction from '../../CollectionCardFunction.js' import {ButtonsAreaColecao} from '../PanelComponents/ButtonsArea' - +import CriarColecaoModal from '../../CriarColecaoModal.js' export default function TabPanelColecoes (props) { const [loading, handleLoading] = useState(true) @@ -42,14 +42,14 @@ export default function TabPanelColecoes (props) { const [followedCollections, setFollowedCollections] = useState([]) const [followedCollectionsSlice, setFollowedCollectionsSlice] = useState([]) - useEffect( () => { + const getInfo = () => { axios.all([ axios.get((`${apiUrl}/users/` + props.id + '/collections'), props.config), axios.get((`${apiUrl}/users/` + props.id + '/following/Collection'), props.config), ]) .then( (responseArr) => { console.log('responseArr Colecoes: ', responseArr) - if (responseArr[0].headers['access-token']) { + if (responseArr[1].headers['access-token']) { sessionStorage.setItem('@portalmec/accessToken', responseArr[0].headers['access-token']) } @@ -66,6 +66,10 @@ export default function TabPanelColecoes (props) { console.log('error while running axios all') } ) + } + + useEffect( () => { + getInfo() }, []) const showMoreUserCollections = () => { @@ -82,7 +86,6 @@ export default function TabPanelColecoes (props) { const showAllFollowedCollections = () => {setFollowedCollectionsSlice(followedCollections)} - return ( <> { @@ -116,6 +119,7 @@ export default function TabPanelColecoes (props) { showMore={showMoreUserCollections} showAll={showAllUserCollections} followed={false} + callback={getInfo} /> <PanelTemplateColecao @@ -136,9 +140,13 @@ export default function TabPanelColecoes (props) { } function Tentativa (props) { + const [modalOpen, toggleModal] = useState(false) + const handleModal = () => {toggleModal(!modalOpen)}; return ( <WhiteContainer> + <CriarColecaoModal open={modalOpen} handleClose={() => {handleModal(); props.callback()}}/> + <Title title={props.title} length={props.length} @@ -146,7 +154,7 @@ function Tentativa (props) { <StyledGrid container spacing={1} style={{paddingLeft : "30px", paddingRight : "15px"}}> <Grid item md={3} xs={12}> - <CardDiv> + <CardDiv onClick={()=>{handleModal()}}> <div style={{backgroundColor:"#673ab7", height:"250px", display:"flex", justifyContent:"center", alignItems:"center"}}> <CreateNewFolderIcon style={{color:"#fff", fontSize:"70px"}}/> <p style={{fontSize:"16px", margin:"0 0 10px", color : "#fff"}}> -- GitLab