Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

searchBar admin #230

Merged
merged 1 commit into from
Nov 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 33 additions & 2 deletions uniEmpleos/src/pages/AdminStudent/AdminStudent.jsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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 (
<div className={style.mainContainer}>
<Header />
Expand All @@ -46,12 +61,28 @@ const ProfileAdminStudent = () => {
style={typeError}
close={() => setWarning(false)}
/>
<div className={style.searchContainer}>
<IoSearchCircle
size={40}
color="#94bd0f"
onClick={() => setShowSearch(!showSearch)}
/>
{showSearch && (
<input
className={style.searchBar}
type="text"
placeholder="Buscar"
value={searchTerm}
onChange={handleSearchChange}
/>
)}
</div>
{loading ? (
<Loader size={100} />
) : (
<div className={style.studentsContainer}>
{studentsData.studets ? (
studentsData.studets.map((student) => {
{filteredStudents.length > 0 ? (
filteredStudents.map((student) => {
const pfpUrlEmisor =
student.foto === ""
? "/images/pfp.svg"
Expand Down
30 changes: 30 additions & 0 deletions uniEmpleos/src/pages/AdminStudent/AdminStudent.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}


36 changes: 33 additions & 3 deletions uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.jsx
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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([])
Expand All @@ -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}`)
}
Expand All @@ -46,12 +60,28 @@ const PrincipalAdmin = () => {
style={typeError}
close={() => setWarning(false)}
/>
<div className={style.searchContainer}>
<IoSearchCircle
size={40}
color="#94bd0f"
onClick={() => setShowSearch(!showSearch)}
/>
{showSearch && (
<input
className={style.searchBar}
type="text"
placeholder="Buscar"
value={searchTerm}
onChange={handleSearchChange}
/>
)}
</div>
{loading ? (
<Loader size={100} />
) : (
<div className={style.enterprisesContainer}>
{enterprises.companies ? (
enterprises.companies.map((enterprise) => {
{filteredEnterprises.length > 0 ? (
filteredEnterprises.map((enterprise) => {
const pfpUrlEmisor =
enterprise.foto === ""
? "/images/pfp.svg"
Expand Down
34 changes: 33 additions & 1 deletion uniEmpleos/src/pages/PricipalAdmin/PrincipalAdmin.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,36 @@
width: 100%;
display: flex;
flex-wrap: wrap;
}
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;
}

Loading