From 44d19d97d13d31b99f1542d1c874ec006bb175d9 Mon Sep 17 00:00:00 2001 From: Araozu Date: Fri, 14 Oct 2022 09:57:44 -0500 Subject: [PATCH] Desplazar de pantalla SeleccionCursos.tsx a SistemasMovil.tsx --- src/Views/SeleccionCursos.tsx | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/src/Views/SeleccionCursos.tsx b/src/Views/SeleccionCursos.tsx index f960712..b1460d4 100644 --- a/src/Views/SeleccionCursos.tsx +++ b/src/Views/SeleccionCursos.tsx @@ -20,6 +20,7 @@ const s = StyleSheet.create({ export function SeleccionCursos() { const [cursos, setCursos] = createSignal({}); + const [msjErr, setMsjError] = createSignal(false); // Recuperar cursos de back (async() => setCursos(await getAllListaCursosMock()))(); @@ -29,14 +30,24 @@ export function SeleccionCursos() { const form = ev.target as HTMLFormElement; // Los checkboxes const elements = form.elements; - const idsAEnviar: Array = []; + const idsAEnviar: Array = []; for (let i = 0; i < elements.length; i += 1) { const inputBox = elements[i] as HTMLInputElement; if (inputBox.checked) { - idsAEnviar.push(parseInt(inputBox.value, 10)); + idsAEnviar.push(inputBox.value); } } - console.log(idsAEnviar); + + if (idsAEnviar.length === 0) { + setMsjError(true); + setTimeout(() => setMsjError(false), 2500); + return; + } + + // Almacenar en localStorage + localStorage.setItem("cursos-seleccionados", JSON.stringify(idsAEnviar)); + // Ir a sig pantalla + window.location.href = "#/sistemas-movil/"; }; return ( @@ -69,6 +80,8 @@ export function SeleccionCursos() { )}
+ Selecciona al menos 1 curso +