From 4298a7fa6fb97102fc6e129e6eb520cf221c883d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jimena=20Hern=C3=A1ndez?= Date: Sun, 5 Nov 2023 14:32:51 -0600 Subject: [PATCH] searchBar admin --- .../src/pages/AdminStudent/AdminStudent.jsx | 35 ++++++++++++++++-- .../AdminStudent/AdminStudent.module.css | 30 ++++++++++++++++ .../pages/PricipalAdmin/PrincipalAdmin.jsx | 36 +++++++++++++++++-- .../PricipalAdmin/PrincipalAdmin.module.css | 34 +++++++++++++++++- 4 files changed, 129 insertions(+), 6 deletions(-) diff --git a/uniEmpleos/src/pages/AdminStudent/AdminStudent.jsx b/uniEmpleos/src/pages/AdminStudent/AdminStudent.jsx index e54445d8..8d556395 100644 --- a/uniEmpleos/src/pages/AdminStudent/AdminStudent.jsx +++ b/uniEmpleos/src/pages/AdminStudent/AdminStudent.jsx @@ -1,4 +1,5 @@ import React, { useEffect, useState } from "react" +import { IoSearchCircle } from "react-icons/io5" import Header from "../../components/Header/Header" import style from "./AdminStudent.module.css" import InfoStudent from "../../components/InfoStudent/InfoStudent" @@ -37,6 +38,20 @@ const ProfileAdminStudent = () => { obtainStudents() }, []) + const [searchTerm, setSearchTerm] = useState("") + + const [showSearch, setShowSearch] = useState(false) + + const handleSearchChange = (event) => { + setSearchTerm(event.target.value) + } + + const filteredStudents = studentsData.studets + ? studentsData.studets.filter((student) => + student.nombre.toLowerCase().includes(searchTerm.toLowerCase()) + ) + : [] + return (
@@ -46,12 +61,28 @@ const ProfileAdminStudent = () => { style={typeError} close={() => setWarning(false)} /> +
+ setShowSearch(!showSearch)} + /> + {showSearch && ( + + )} +
{loading ? ( ) : (
- {studentsData.studets ? ( - studentsData.studets.map((student) => { + {filteredStudents.length > 0 ? ( + filteredStudents.map((student) => { const pfpUrlEmisor = student.foto === "" ? "/images/pfp.svg" diff --git a/uniEmpleos/src/pages/AdminStudent/AdminStudent.module.css b/uniEmpleos/src/pages/AdminStudent/AdminStudent.module.css index d944b4ed..e77b6953 100644 --- a/uniEmpleos/src/pages/AdminStudent/AdminStudent.module.css +++ b/uniEmpleos/src/pages/AdminStudent/AdminStudent.module.css @@ -4,4 +4,34 @@ flex-wrap: wrap; } +.searchBar{ + padding: 10px; + width: 100%; + border: 2px solid #94bd0f; + color: #000; + font-size: 20px; + border-radius: 50px; + background-color: #fff; + font-size: 14px; +} + +input.searchBar::placeholder{ + color: #000; +} + +.searchBar:focus{ + outline: none; +} + +.searchContainer{ + display: flex; + align-items: center; + padding: 20px; + gap: 20px; +} + +.searchContainer svg{ + cursor: pointer; +} + diff --git a/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.jsx b/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.jsx index 2a3ac409..aec3852e 100644 --- a/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.jsx +++ b/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.jsx @@ -1,4 +1,5 @@ import React, { useEffect, useState } from "react" +import { IoSearchCircle } from "react-icons/io5" import style from "./PrincipalAdmin.module.css" import useApi from "../../Hooks/useApi" import Popup from "../../components/Popup/Popup" @@ -8,7 +9,6 @@ import API_URL from "../../api" import InfoStudent from "../../components/InfoStudent/InfoStudent" import { navigate } from "../../store" - const PrincipalAdmin = () => { const enterprisesApi = useApi() const [enterprises, setEnterprises] = useState([]) @@ -29,6 +29,20 @@ const PrincipalAdmin = () => { setLoading(false) } + const [searchTerm, setSearchTerm] = useState("") + + const [showSearch, setShowSearch] = useState(false) + + const handleSearchChange = (event) => { + setSearchTerm(event.target.value) + } + + const filteredEnterprises = enterprises.companies + ? enterprises.companies.filter((enterprise) => + enterprise.nombre.toLowerCase().includes(searchTerm.toLowerCase()) + ) + : [] + const handleClick = (e) => { navigate(`/publicProfileAdminEnterprise/${e}`) } @@ -46,12 +60,28 @@ const PrincipalAdmin = () => { style={typeError} close={() => setWarning(false)} /> +
+ setShowSearch(!showSearch)} + /> + {showSearch && ( + + )} +
{loading ? ( ) : (
- {enterprises.companies ? ( - enterprises.companies.map((enterprise) => { + {filteredEnterprises.length > 0 ? ( + filteredEnterprises.map((enterprise) => { const pfpUrlEmisor = enterprise.foto === "" ? "/images/pfp.svg" diff --git a/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.module.css b/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.module.css index 7af2b8ad..68841fb4 100644 --- a/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.module.css +++ b/uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.module.css @@ -2,4 +2,36 @@ width: 100%; display: flex; flex-wrap: wrap; -} \ No newline at end of file + padding-top: 20px; +} + +.searchBar{ + padding: 10px; + width: 100%; + border: 2px solid #94bd0f; + color: #000; + font-size: 20px; + border-radius: 50px; + background-color: #fff; + font-size: 14px; +} + +input.searchBar::placeholder{ + color: #000; +} + +.searchBar:focus{ + outline: none; +} + +.searchContainer{ + display: flex; + align-items: center; + padding: 20px; + gap: 20px; +} + +.searchContainer svg{ + cursor: pointer; +} +