Skip to content
Snippets Groups Projects
AreasSubPagesFunction.js 13.92 KiB
/*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, { useState, useEffect } from "react";
import "./carousel.css";
import { Col, Row, Container, Hidden, Visible } from "react-grid-system";
import styled from 'styled-components'
import MaterialCard from "./MaterialCard";
import "react-responsive-carousel/lib/styles/carousel.min.css";
import { Carousel } from "react-responsive-carousel";
import recursos from "../img/ilustra_recursos_digitais.png";
import materiais from "../img/ilustra_materiais.png";
import colecoes from "../img/ilustra_colecoes.png";
import ResourceCardFunction from "./ResourceCardFunction.js";
import CollectionCardFunction from "./CollectionCardFunction.js";
import colecoes_obj from './FormationMaterialsResources/formationMaterials';
import ExpandedMaterial from './ExpandedMaterials';
import {getRequest} from './HelperFunctions/getAxiosConfig.js'
import Grid from '@material-ui/core/Grid';


function objectsPerPage () {
    var pageWidth = window.innerWidth
    if (pageWidth >= 1200) {
        return 3
    }
    else {
        if (pageWidth > 766) {
            return 2
        }
        else {
            return 1
        }
    }
}

function ReqResources () {
    const [rows, setRows] = useState([])

    function onSuccessfulGet (data) {
        var aux = []
        var resources_per_page = objectsPerPage()
        for (let i = 0; i < 12 / resources_per_page; i++) {
          aux.push(data.slice(i * resources_per_page, resources_per_page * (i + 1)))
        }
        setRows(aux)
    }

    useEffect(() => {
        const url = `/learning_objects?limit=12&sort=["published_at", "desc"]`

        getRequest(url, (data) => onSuccessfulGet(data), (error) => {console.log(error)})
    }, [])

    return (