2021-03-26 02:39:34 +00:00
|
|
|
import { estilosGlobales } from "../Estilos"
|
|
|
|
import { StyleSheet, css } from "aphrodite"
|
|
|
|
import { Tabla } from "./Tabla"
|
|
|
|
import { EstadoLayout } from "./ContenedorHorarios"
|
2021-03-27 00:19:09 +00:00
|
|
|
import { Switch, Match, createMemo, SetStateFunction } from "solid-js"
|
2021-03-26 02:39:34 +00:00
|
|
|
import { BotonMaxMin } from "./BotonMaxMin"
|
|
|
|
import { BotonIcono } from "./BotonIcono"
|
|
|
|
import { Curso, Cursos, ListaCursosUsuario } from "../types/DatosHorario"
|
|
|
|
import { CursosElem } from "./CursosElem"
|
2021-03-27 00:19:09 +00:00
|
|
|
import { TablaObserver } from "./TablaObserver"
|
2021-01-14 23:24:55 +00:00
|
|
|
|
2021-03-04 13:02:33 +00:00
|
|
|
interface MiHorarioProps {
|
|
|
|
estadoLayout: EstadoLayout,
|
2021-03-11 13:52:21 +00:00
|
|
|
setEstadoLayout: (v: EstadoLayout) => EstadoLayout,
|
2021-03-18 00:03:10 +00:00
|
|
|
cursosUsuario: ListaCursosUsuario,
|
|
|
|
fnAgregarCurso: (c: Curso) => void,
|
2021-03-19 00:51:35 +00:00
|
|
|
setCursosUsuarios: SetStateFunction<ListaCursosUsuario>
|
2021-03-11 13:52:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
const e = StyleSheet.create({
|
|
|
|
horario: {},
|
|
|
|
boton: {
|
|
|
|
textDecoration: "none",
|
|
|
|
// paddingRight: "0.5rem",
|
|
|
|
"::before": {
|
|
|
|
fontSize: "1rem",
|
|
|
|
// transform: "translateY(0.2rem)",
|
2021-03-26 02:39:34 +00:00
|
|
|
textDecoration: "none",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
2021-03-11 13:52:21 +00:00
|
|
|
|
|
|
|
export function MiHorario(props: MiHorarioProps) {
|
2021-03-27 00:19:09 +00:00
|
|
|
const tablaObserver = new TablaObserver()
|
2021-03-11 13:52:21 +00:00
|
|
|
|
|
|
|
const datosMiHorario = createMemo(() => {
|
2021-03-26 02:39:34 +00:00
|
|
|
const obj: Cursos = {}
|
2021-03-24 17:29:03 +00:00
|
|
|
props.cursosUsuario.cursos.forEach((x, i) => {
|
2021-03-26 02:39:34 +00:00
|
|
|
obj[i] = x
|
|
|
|
})
|
|
|
|
return obj
|
|
|
|
})
|
2021-01-14 23:24:55 +00:00
|
|
|
|
2021-03-26 02:39:34 +00:00
|
|
|
const fnMaximizar = () => props.setEstadoLayout("MaxPersonal")
|
|
|
|
const fnMinimizar = () => props.setEstadoLayout("Normal")
|
|
|
|
const estadoActualLayout = () => props.estadoLayout
|
2021-03-03 14:56:22 +00:00
|
|
|
|
2021-03-16 18:33:12 +00:00
|
|
|
/* TODO: En barra superior colocar todos los horarios. En barra inferior el horario
|
|
|
|
actual.
|
|
|
|
Al hacer click en un horario de la barra superior, llevarlo al inicio de la lista.
|
2021-03-27 00:19:09 +00:00
|
|
|
*/
|
2021-03-26 02:39:34 +00:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Switch>
|
|
|
|
<Match when={props.estadoLayout === "Normal" || props.estadoLayout === "MaxPersonal"}>
|
2021-03-11 16:25:02 +00:00
|
|
|
|
2021-03-26 02:39:34 +00:00
|
|
|
<div>
|
|
|
|
<div className={css(
|
|
|
|
estilosGlobales.inlineBlock,
|
|
|
|
estilosGlobales.contenedor,
|
|
|
|
)}
|
|
|
|
>
|
2021-03-11 16:25:02 +00:00
|
|
|
Mi horario
|
2021-03-26 02:39:34 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div>
|
|
|
|
<div className={css(
|
|
|
|
estilosGlobales.inlineBlock,
|
|
|
|
estilosGlobales.contenedor,
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
Mi horario
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
<BotonIcono
|
|
|
|
titulo={"Nuevo horario en blanco"}
|
|
|
|
icono={"ph-plus"}
|
|
|
|
onClick={() => {}}
|
|
|
|
/>
|
|
|
|
<BotonIcono
|
|
|
|
titulo={"Reiniciar horario"}
|
|
|
|
icono={"ph-arrow-counter-clockwise"}
|
|
|
|
onClick={() => {}}
|
|
|
|
/>
|
|
|
|
<BotonIcono
|
|
|
|
titulo={"Duplicar horario"}
|
|
|
|
icono={"ph-copy"}
|
|
|
|
onClick={() => {}}
|
|
|
|
/>
|
|
|
|
<BotonIcono titulo={"Eliminar horario"}
|
|
|
|
icono={"ph-trash"}
|
|
|
|
onClick={() => {}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
<BotonMaxMin
|
|
|
|
fnMaximizar={fnMaximizar}
|
|
|
|
fnMinimizar={fnMinimizar}
|
|
|
|
estadoActualLayout={estadoActualLayout}
|
|
|
|
estadoLayoutMax={"MaxPersonal"}
|
|
|
|
/>
|
2021-03-11 16:25:02 +00:00
|
|
|
</div>
|
|
|
|
|
2021-03-03 14:56:22 +00:00
|
|
|
<div className={css(
|
2021-03-26 02:39:34 +00:00
|
|
|
e.horario,
|
|
|
|
estilosGlobales.contenedor,
|
|
|
|
)}
|
|
|
|
>
|
|
|
|
<Tabla
|
|
|
|
data={datosMiHorario()}
|
|
|
|
anio={"Mi horario"}
|
|
|
|
version={1}
|
|
|
|
setCursosUsuarios={props.setCursosUsuarios}
|
2021-03-27 00:19:09 +00:00
|
|
|
tablaObserver={tablaObserver}
|
2021-03-26 02:39:34 +00:00
|
|
|
/>
|
2021-03-03 14:56:22 +00:00
|
|
|
</div>
|
2021-03-26 02:39:34 +00:00
|
|
|
|
|
|
|
<CursosElem
|
2021-03-27 00:19:09 +00:00
|
|
|
version={Number(Math.random() * 1_000_000)}
|
2021-03-26 02:39:34 +00:00
|
|
|
anioActual={() => "Mi horario"}
|
|
|
|
dataAnio={datosMiHorario()}
|
|
|
|
fnAgregarCurso={props.fnAgregarCurso}
|
|
|
|
listaCursosUsuario={props.cursosUsuario}
|
|
|
|
esCursoMiHorario
|
|
|
|
setCursosUsuarios={props.setCursosUsuarios}
|
2021-03-27 00:19:09 +00:00
|
|
|
tablaObserver={tablaObserver}
|
2021-03-17 23:24:36 +00:00
|
|
|
/>
|
2021-03-26 02:39:34 +00:00
|
|
|
</Match>
|
|
|
|
<Match when={props.estadoLayout === "MaxHorarios"}>
|
2021-03-04 13:02:33 +00:00
|
|
|
<BotonMaxMin
|
|
|
|
fnMaximizar={fnMaximizar}
|
|
|
|
fnMinimizar={fnMinimizar}
|
|
|
|
estadoActualLayout={estadoActualLayout}
|
|
|
|
estadoLayoutMax={"MaxPersonal"}
|
|
|
|
/>
|
2021-03-26 02:39:34 +00:00
|
|
|
</Match>
|
|
|
|
</Switch>
|
|
|
|
</div>
|
|
|
|
)
|
2021-01-14 23:24:55 +00:00
|
|
|
}
|