Skip to content

Commit

Permalink
Postulaciones
Browse files Browse the repository at this point in the history
Solo muestra las ofertas laborales que sean compatibles con la carrera del estudiante
  • Loading branch information
angelcast2002 committed Sep 26, 2023
1 parent da2696d commit 1b4a5b2
Show file tree
Hide file tree
Showing 3 changed files with 1,270 additions and 1,168 deletions.
2 changes: 1 addition & 1 deletion uniEmpleos/src/pages/ChatPage/ChatPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ const ChatPage = () => {

// console.log(apiMessages.data)
// console.log(user.id_user)
// console.log(apiLastChats.data)
console.log(apiLastChats.data)

return (
<div className={style.container}>
Expand Down
42 changes: 33 additions & 9 deletions uniEmpleos/src/pages/PrincipalStudent/PrincipalStudent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { navigate } from "../../store"
import { Header } from "../../components/Header/Header"
import useConfig from "../../Hooks/Useconfig"
import API_URL from "../../api"
import useApi from "../../Hooks/useApi"

const schema = Joi.object({
token: Joi.string().required(),
Expand All @@ -14,6 +15,10 @@ const schema = Joi.object({
})

const PrincipalStudent = () => {
const api = useApi()
const apiCareers = useApi()
const [carrera, setCarrera] = useState("")

const form = useConfig(schema, {
token: "a",
idoffert: "a",
Expand All @@ -32,9 +37,22 @@ const PrincipalStudent = () => {
const datos = await response.json()
setData(datos)
}
console.log(dataa)
useEffect(() => {
if (api.data && apiCareers.data) {
const carreraID = api.data.usuario.carrera
for (const i of apiCareers.data.careers) {
if (i.id_carrera === carreraID) {
setCarrera(i.nombre)
}
}
}
}, [api.data, apiCareers.data])

useEffect(() => {
configureData()
api.handleRequest("GET", "/users/")
apiCareers.handleRequest("GET", "/careers")
}, [])

const saveidlocalstorage = (id) => {
Expand All @@ -51,15 +69,21 @@ const PrincipalStudent = () => {
<Header userperson="student" />
{dataa.status === 200 ? (
<div className={styles.containerinfomain}>
{dataa.data.postulations.map((postulation) => (
<InfoTab
title={postulation.puesto}
salary={`Q.${postulation.salario}.00`}
company={postulation.nombre_empresa}
labelbutton="Postularme"
onClick={() => saveidlocalstorage(postulation.id_oferta)}
/>
))}
{dataa.data.postulations.map((postulation) => {
const regex = new RegExp(carrera)
if (regex.test(postulation.nombre_carreras) && carrera !== "") {
return (
<InfoTab
key={postulation.id_oferta} // Asegúrate de proporcionar una clave única en elementos de lista
title={postulation.puesto}
salary={`Q.${postulation.salario}.00`}
company={postulation.nombre_empresa}
labelbutton="Postularme"
onClick={() => saveidlocalstorage(postulation.id_oferta)}
/>
)
}
})}
</div>
) : (
<div className={styles.containerinfomain}>
Expand Down
Loading

0 comments on commit 1b4a5b2

Please sign in to comment.