diff --git a/src/ContenedorHorarios/CursosElem.tsx b/src/ContenedorHorarios/CursosElem.tsx index 78032bf..bb57baa 100755 --- a/src/ContenedorHorarios/CursosElem.tsx +++ b/src/ContenedorHorarios/CursosElem.tsx @@ -1,5 +1,5 @@ import { Cursos, CursoRaw, DatosGrupo, ListaCursosUsuario, Curso } from "../types/DatosHorario"; -import { createEffect, createMemo, For } from "solid-js"; +import { createEffect, createMemo, For, SetStateFunction } from "solid-js"; import { StyleSheet, css } from "aphrodite"; import { estilosGlobales } from "../Estilos"; @@ -35,28 +35,53 @@ interface Props { listaCursosUsuario: ListaCursosUsuario, idHover: () => string, setIdHover: (v: string) => string, - esCursoMiHorario: boolean + esCursoMiHorario: boolean, + setCursosUsuarios: SetStateFunction } -function IndicadorGrupo(props: { nombre: string, esLab: boolean, idParcial: string, setIdHover: (v: string) => string }) { +type FnSetCursosUsuarios = SetStateFunction; + +interface PropsIndicadorGrupo { + nombre: string, + esLab: boolean, + idParcial: string, + setIdHover: (v: string) => string, + onClick: () => void +} + +function IndicadorGrupo(props: PropsIndicadorGrupo) { const id = `${props.idParcial}_${props.esLab ? 'L' : 'T'}_${props.nombre}`; return props.setIdHover(id)} onMouseLeave={() => props.setIdHover("")} + onClick={props.onClick} > {props.esLab ? "L" : ""}{props.nombre} } -const agruparProfesores = (datos: { [k: string]: DatosGrupo }) => { - const profesores: { [k: string]: string[] } = {}; +const agruparProfesores = (datos: { [k: string]: DatosGrupo }, indiceCurso: number, esLab: boolean, setCursosUsuarios: FnSetCursosUsuarios) => { + const profesores: { [k: string]: [string, () => void][] } = {}; for (const [grupo, datosGrupo] of Object.entries(datos)) { const nombreProfesor = datosGrupo.Docente; if (!profesores[nombreProfesor]) { profesores[nombreProfesor] = []; } - profesores[nombreProfesor].push(grupo); + profesores[nombreProfesor].push([ + grupo, + () => { + setCursosUsuarios( + "cursos", + indiceCurso, + esLab ? "Laboratorio" : "Teoria", + /// @ts-ignore + grupo, + "seleccionado", + x => !x + ); + } + ]); } return profesores; }; @@ -79,7 +104,7 @@ export function CursosElem(props: Props) { return <> - {([_, datosCurso]) => { + {([indiceCurso, datosCurso]) => { const idCurso = `${anio()}_${datosCurso.abreviado}`; @@ -105,8 +130,18 @@ export function CursosElem(props: Props) { : claseCursoNoAgregado }); - const profesoresTeoria = createMemo(() => agruparProfesores(datosCurso.Teoria)); - const profesoresLab = createMemo(() => agruparProfesores(datosCurso.Laboratorio ?? {})); + const profesoresTeoria = createMemo(() => agruparProfesores( + datosCurso.Teoria, + parseInt(indiceCurso), + false, + props.setCursosUsuarios + )); + const profesoresLab = createMemo(() => agruparProfesores( + datosCurso.Laboratorio ?? {}, + parseInt(indiceCurso), + true, + props.setCursosUsuarios + )); return
- {x => + {([x, fnOnClick]) => } @@ -146,11 +182,12 @@ export function CursosElem(props: Props) { {profesor}  - {x => + {([x, fnOnClick]) => } @@ -168,6 +205,6 @@ export function CursosElem(props: Props) {
}} - - ; - } + + ; +} diff --git a/src/ContenedorHorarios/Horarios.tsx b/src/ContenedorHorarios/Horarios.tsx index 494a409..9ef822c 100755 --- a/src/ContenedorHorarios/Horarios.tsx +++ b/src/ContenedorHorarios/Horarios.tsx @@ -108,6 +108,7 @@ export function Horarios(props: HorariosProps) { idHover={idHover} setIdHover={setIdHover} esCursoMiHorario={false} + setCursosUsuarios={setListaCursos} />
diff --git a/src/ContenedorHorarios/MiHorario.tsx b/src/ContenedorHorarios/MiHorario.tsx index c5f6068..dd88efe 100755 --- a/src/ContenedorHorarios/MiHorario.tsx +++ b/src/ContenedorHorarios/MiHorario.tsx @@ -119,6 +119,7 @@ export function MiHorario(props: MiHorarioProps) { idHover={idHover} setIdHover={setIdHover} esCursoMiHorario={true} + setCursosUsuarios={props.setCursosUsuarios} />