Skip to content
Snippets Groups Projects
Commit 9d5fe011 authored by Lucas Eduardo Schoenfelder's avatar Lucas Eduardo Schoenfelder
Browse files

added xtotalcount to fetchAll

parent 4c226d11
No related branches found
No related tags found
2 merge requests!57Merge of develop into master,!56Fixed buttons reportar, seguir, compartilhar, guardar and entrar (in comments...
......@@ -197,17 +197,21 @@ export async function fetchAllRequest (urls, onSuccess, onError) {
})))
console.log(responses)
var data = []
var headers = []
for (let res of responses) {
if (res.headers.has('access-token') && res.status !== 304) {
updateAccessToken(res.headers.get('access-token'))
}
let json = await res.json().catch(err => {
return {};
})
data.push(json)
headers.push(res.headers)
}
let data = await Promise.all(responses.map( (response) => response.json().catch(err => {
return {};
})))
onSuccess(data)
onSuccess(data, headers)
// await Promise.all( urls.map( url => fetch(`${apiUrl}${url}`, {
// headers : fetchHeaders()
......
......@@ -16,20 +16,18 @@ 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, { useContext } from 'react'
import React from 'react'
import MenuIcon from '@material-ui/icons/Menu';
import styled from 'styled-components'
import { Button } from '@material-ui/core'
import logo from '../img/logo_small.svg'
import { Link } from 'react-router-dom'
import MobileDrawerMenu from './MobileDrawerMenu';
import { Store } from '../Store';
export default function MenuBarMobile(props) {
const [drawerOpen, setDrawerStatus] = React.useState(false);
const { state, dispatch } = useContext(Store)
const toggleDrawer = (open) => (event) => {
......@@ -51,7 +49,7 @@ export default function MenuBarMobile(props) {
</Button>
<DrawerButtonDiv>
<Link to={"/"}>
<img src={logo} style={{ border: "0", verticalAlign: "middle" }} />
<img src={logo} alt="logo" style={{ border: "0", verticalAlign: "middle" }} />
</Link>
</DrawerButtonDiv>
</OuterDiv>
......@@ -63,8 +61,8 @@ const OuterDiv = styled.div`
height : 48px;
width : 100%;
${'' /* position : relative; */}
display : flex;
direction : row;
display : flex;
direction : row;
align-items : center;
img {
......@@ -80,4 +78,4 @@ const DrawerButtonDiv = styled.div`
right:0;
margin-left:auto;
margin-right:auto;
`
\ No newline at end of file
`
......@@ -84,7 +84,6 @@ export default function PanelTemplateColecao(props) {
:
(
<React.Fragment>
<StyledGrid container spacing={1} style={{ paddingLeft: "30px", paddingRight: "15px" }}>
{
props.sliceArr.map((card) =>
......@@ -102,7 +101,8 @@ export default function PanelTemplateColecao(props) {
sliceLength={props.sliceArr.length}
length={props.length}
showMore={props.showMore}
end={props.end}
total={props.end}
end={String(props.sliceArr.length) === props.end}
/>
}
</React.Fragment>
......
......@@ -76,8 +76,8 @@ export default function Template(props) {
sliceLength={props.sliceArr.length}
length={props.length}
showMore={props.showMore}
end={props.end}
total={props.total}
end={String(props.sliceArr.length) === props.end}
total={props.end}
/>
}
......
......@@ -74,7 +74,8 @@ export default function Template(props) {
sliceLength={props.slice.length}
length={props.length}
showMore={props.showMore}
end={props.end}
total={props.end}
end={String(props.slice.length) === props.end}
/>
}
......
......@@ -38,10 +38,16 @@ export default function TabPanelFavoritos(props) {
const [endOfColl, setEndoffColl] = useState(false)
function handleSuccess(responseArr) {
function handleSuccess(responseArr, headersArr) {
setlikedLearnObjs(responseArr[0])
setlikedCollections(responseArr[1])
if (headersArr[0].has('X-Total-Count')) {
setEndofLearndObj(headersArr[0].get('X-Total-Count'));
}
if (headersArr[1].has('X-Total-Count')) {
setEndoffColl(headersArr[1].get('X-Total-Count'));
}
handleLoading(false)
}
......@@ -112,7 +118,7 @@ export default function TabPanelFavoritos(props) {
[
<React.Fragment>
<Template
length={likedLearnObjs.length}
length={endOfLearnObj}
titleText={"Recursos Favoritados"}
noContentText={<p style={{ fontFamily: "Roboto", fontSize: "16px" }}>Quando você favorita um recurso ele aparece nesta seção. Além disso, você
<br />
......@@ -128,7 +134,7 @@ export default function TabPanelFavoritos(props) {
<PanelTemplateColecao
title={"Coleções favoritadas"}
length={likedCollections.length}
length={endOfColl}
noContentText={"Você ainda não curtiu nenhuma coleção."}
sliceArr={likedCollections}
showMore={showMoreLikedCollections}
......
......@@ -33,22 +33,32 @@ export default function TabPanelAtividades(props) {
const [currLimitDrafts, setcurrLimitDrafts] = useState(4);
const [currLimitCurating, setcurrLimitCurating] = useState(4);
const [endOfLearnObj, setEndofLearndObj] = useState(false);
const [endOfDrafts, setEndofDrafts] = useState(false);
const [endOfCurating, setEndofCurating] = useState(false);
const [endOfLearnObj, setEndofLearndObj] = useState(0);
const [endOfDrafts, setEndofDrafts] = useState(0);
const [endOfCurating, setEndofCurating] = useState(0);
const [learningObjects, setLearningObjects] = useState([]);
const [drafts, setDrafts] = useState([]);
const [curating, setCurating] = useState([]);
function handleSuccess(responseArr) {
function handleSuccess(responseArr, headersArr) {
setLearningObjects(responseArr[0])
if (headersArr[0].has('X-Total-Count')) {
setEndofLearndObj(headersArr[0].get('X-Total-Count'));
}
setDrafts(responseArr[1])
if (headersArr[1].has('X-Total-Count')) {
setEndofDrafts(headersArr[1].get('X-Total-Count'));
}
setCurating(responseArr[2])
if (headersArr[2].has('X-Total-Count')) {
setEndofCurating(headersArr[2].get('X-Total-Count'));
}
handleLoading(false)
}
useEffect(() => {
......
......@@ -23,7 +23,6 @@ export default function UserInfo(props) {
const { state } = useContext(Store);
const user = state.currentUser.name;
const education = state.currentUser.education;
return (
<UserProfileInfoDiv>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment