diff --git a/src/Pages/SearchOld.js b/src/Pages/SearchOld.js deleted file mode 100644 index 7034aed72f391535efb709255d3d97070d8bcf18..0000000000000000000000000000000000000000 --- a/src/Pages/SearchOld.js +++ /dev/null @@ -1,94 +0,0 @@ -/*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, { useEffect, useState, useContext } from 'react'; -import axios from 'axios'; - -// import ResourceCard from '../Components/ResourceCard' -// import CollectionCard from '../Components/CollectionCard' -// import UserCard from '../Components/UserCard' - -import {apiUrl} from '../env'; -import './Styles/Home.css'; -import { Store } from '../Store'; - -export default function Search(props){ - - const { state, dispatch } = useContext(Store) - const [ results, setResults ] = useState([]) - const [ page, ] = useState(0) - const [ resultsPerPage, ] = useState(12) - const [ order, ] = useState('score') - - useEffect(()=>{ - dispatch({ - type: 'HANDLE_SEARCH_BAR', - opened: true - }) - - const urlParams = new URLSearchParams(window.location.search) - const query = urlParams.get('query') - const searchClass = urlParams.get('search_class') - - if(state.search.query !== query || state.search.class !== searchClass){ - dispatch({ - type: 'SAVE_SEARCH', - newSearch: { - query: query, - class: searchClass - } - }) - } - - return () => dispatch({ - type: 'HANDLE_SEARCH_BAR', - opened: false - }) - },[]) - - useEffect(()=>{ - axios.get(`${apiUrl}/search?page=${page}&results_per_page=${resultsPerPage}&order=${order}&query=${state.search.query}&search_class=${state.search.class}`) - .then( res => { - setResults(res.data) - }) - - },[state.search]) - - - return ( - <React.Fragment> - <h1>Search for {state.search.query!=='*'?state.search.query:'all'} in {state.search.class}</h1> - { - state.search.class === 'LearningObject' && - <ul> - {results.map((res)=><li key={res.id}> {res.name} </li>)} - </ul> - } - {state.search.class === 'Collection' && - <ul> - {results.map((res)=><li key={res.id}> {res.name} </li>)} - </ul> - } - {state.search.class === 'User' && - <ul> - {results.map((res)=><li key={res.id}> {res.name} </li>)} - </ul> - } - </React.Fragment> - ) -}