Files
hackFront/src/components/form.vue
T

517 lines
15 KiB
Vue
Raw Normal View History

2020-07-05 23:02:00 -05:00
<template>
<div class="registro-general">
2020-07-06 01:07:55 -05:00
<form class="pure-form pure-form-stacked" v-if="!cargando">
2020-07-05 23:02:00 -05:00
<fieldset>
<legend>Datos Generales <br /></legend>
<div class="pure-u-1 pure-u-md-2-2">
<label for="nombre-equipo">Nombre del equipo</label>
<input
type="text"
id="nombre-equipo"
class="pure-u-23-24"
v-model="nombreEquipo"
onkeypress="return ( (event.charCode >= 48 && event.charCode <= 57) || (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-1-3 ma">
<label for="des">Desafío</label>
<select
id="des"
name="desafio"
class="form-control"
v-model="desafio"
>
<option value="Salud">Salud</option>
<option value="Educación">Educación</option>
<option value="Economía">Economía</option>
<option value="Transporte">Transporte</option>
</select>
</div>
<div class="pure-u-1 pure-u-md-1-3 ma">
<label for="cam">Campus</label>
<select id="cam" name="Campus" class="form-control" v-model="campus">
<option value="Acatlán">Acatlán</option>
<option value="CU">CU</option>
<option value="Aragón">Aragón</option>
</select>
</div>
<div class="pure-u-1 pure-u-md-1-4 ">
<label for="noInt">Numero de integrantes </label>
<select
id="noInt"
name="integrantes"
class="form-control"
v-model="noIntegrantes"
@change="updateInte($event)"
>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
</select>
</div>
<legend>Datos del lider del equipo <br /></legend>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-3">
<label for="nombre">Nombre</label>
<input
type="text"
id="nombreLider"
class="pure-u-23-24"
v-model="nombreLider"
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-1-3">
<label for="apellidoPaLider">Apellido Paterno</label>
<input
type="text"
id="apellidoPaLider"
class="pure-u-23-24"
v-model="apellidoPaLider"
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-1-3">
<label for="apellidoMaLider">Apellido Materno</label>
<input
type="text"
id="apellidoMaLider"
class="pure-u-23-24"
v-model="apellidoMaLider"
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-1-2">
<label for="correoLider">Correo</label>
<input
type="email"
id="correoLider"
class="pure-u-23-24"
v-model="correoLider"
/>
</div>
<div class="pure-u-1 pure-u-md-1-2">
<label for="carrera">Carrera</label>
<input
type="text"
id="carrera"
class="pure-u-23-24"
v-model="carrera"
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
2020-07-06 21:35:11 -05:00
<div class="pure-u-1 pure-u-md-2-2">
<div class="form-check">
<input
type="checkbox"
2020-08-03 23:17:51 -05:00
class="form-check-input "
2020-07-06 21:35:11 -05:00
id="exampleCheck1"
v-model="confirmacion"
/>
<label class="form-check-label" for="exampleCheck1"
>Acepto ser el lider del Equipo</label
>
</div>
</div>
2020-07-05 23:02:00 -05:00
</div>
<div v-if="noIntegrantes > 1">
<legend>Datos de los integrantes del equipo<br /></legend>
<div v-for="item in integrantes" :key="item.id">
<h4 class="title">Integrante {{ item.id + 1 }}</h4>
<div class="pure-g">
<div class="pure-u-1 pure-u-md-1-3">
<label for="item.nombre">Nombre</label>
<input
type="text"
id="item.nombre"
class="pure-u-23-24"
v-model="item.nombre"
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-1-3">
2020-07-06 02:07:58 -05:00
<label for="item.apellidoPa">Apellido Paterno</label>
2020-07-05 23:02:00 -05:00
<input
type="text"
2020-07-06 02:07:58 -05:00
id="item.apellidoPa"
2020-07-05 23:02:00 -05:00
class="pure-u-23-24"
2020-07-06 01:58:35 -05:00
v-model="item.apellidoPa"
2020-07-05 23:02:00 -05:00
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-7-24">
2020-07-06 02:07:58 -05:00
<label for="item.apellidoMa">Apellido Materno</label>
2020-07-05 23:02:00 -05:00
<input
type="text"
2020-07-06 02:07:58 -05:00
id="item.apellidoMa"
2020-07-05 23:02:00 -05:00
class="pure-u-23-24"
2020-07-06 01:58:35 -05:00
v-model="item.apellidoMa"
2020-07-05 23:02:00 -05:00
onkeypress="return ( (event.charCode >= 32 && event.charCode <= 32) ||(event.charCode >= 65 && event.charCode <= 90) ||(event.charCode >= 97))"
/>
</div>
<div class="pure-u-1 pure-u-md-1">
<label for="item.correo">Correo</label>
<input
type="text"
id="item.correo"
class="pure-u-23-24"
v-model="item.correo"
/>
</div>
</div>
</div>
</div>
2020-07-06 21:35:11 -05:00
<div class="pure-g espacio" v-if="checkSize()">
2020-07-05 23:02:00 -05:00
<div class="pure-u-1 pure-u-md-1-2">
2020-07-06 01:07:55 -05:00
<button class="button_salir " @click="salir()">Salir</button>
2020-07-05 23:02:00 -05:00
</div>
<div class="pure-u-1 pure-u-md-1-2">
<button class="button " v-if="checkFull()" @click="registrar()">
2020-07-06 21:35:11 -05:00
Registrar
2020-07-05 23:02:00 -05:00
</button>
2020-07-06 21:35:11 -05:00
<p class="botton_falso" v-else>Registrar</p>
</div>
</div>
<div class="pure-g espacio" v-else>
<div class="pure-u-1 pure-u-md-1-2">
<button class="button " v-if="checkFull()" @click="registrar()">
Registrar
</button>
<p class="botton_falso" v-else>Registrar</p>
</div>
<div class="pure-u-1 pure-u-md-1-2">
<button class="button_salir " @click="salir()">Salir</button>
2020-07-05 23:02:00 -05:00
</div>
</div>
</fieldset>
</form>
2020-07-06 01:07:55 -05:00
<div v-else class="text-center">
<div
class="spinner-grow"
role="status"
style="width: 10rem; height: 10rem;"
>
<span class="sr-only">Loading...</span>
</div>
</div>
2020-07-05 23:02:00 -05:00
</div>
</template>
<script>
import axios from "axios";
import config from "../config/config.js";
2020-07-06 01:07:55 -05:00
import Swal from "sweetalert2";
2020-07-05 23:02:00 -05:00
export default {
data() {
return {
nombreEquipo: "",
campus: "",
desafio: "",
nombreLider: "",
apellidoPaLider: "",
apellidoMaLider: "",
correoLider: "",
carrera: "",
noIntegrantes: 1,
2020-07-06 01:07:55 -05:00
integrantes: [],
2020-07-06 21:35:11 -05:00
cargando: false,
2020-08-03 23:17:51 -05:00
confirmacion: false
2020-07-05 23:02:00 -05:00
};
},
methods: {
2020-07-06 21:35:11 -05:00
checkSize() {
if (window.screen.width > 500) {
return true;
} else {
return false;
}
},
2020-07-05 23:02:00 -05:00
updateInte(event) {
this.integrantes = [];
for (let i = 1; i < event.target.value; i++) {
this.integrantes.push({
id: i,
nombre: "",
apellidoPa: "",
apellidoMa: "",
2020-08-03 23:17:51 -05:00
correo: ""
2020-07-05 23:02:00 -05:00
});
}
},
checkFull() {
2020-07-06 21:35:11 -05:00
if (!this.confirmacion) return false;
2020-07-05 23:02:00 -05:00
if (this.nombreEquipo.trim() === "") {
return false;
}
if (this.campus.trim() === "") {
return false;
}
if (this.desafio.trim() === "") {
return false;
}
if (this.nombreLider.trim() === "") {
return false;
}
if (this.apellidoPaLider.trim() === "") {
return false;
}
if (this.apellidoMaLider.trim() === "") {
return false;
}
if (this.correoLider.trim() === "") {
return false;
}
if (this.carrera.trim() === "") {
return false;
}
for (let i = 1; i < this.noIntegrantes; i++) {
if (
this.integrantes[i - 1].nombre.trim() === "" ||
2020-07-06 02:07:58 -05:00
this.integrantes[i - 1].apellidoPa.trim() === "" ||
this.integrantes[i - 1].apellidoMa.trim() === "" ||
2020-07-05 23:02:00 -05:00
this.integrantes[i - 1].correo.trim() === ""
) {
return false;
}
}
return true;
},
2020-07-06 01:07:55 -05:00
async salir() {
await Swal.fire({
title: "¿Seguro que quieres salir?",
icon: "warning",
showCancelButton: true,
confirmButtonColor: "#3085d6",
cancelButtonColor: "#d33",
2020-08-03 23:17:51 -05:00
confirmButtonText: "Si"
}).then(result => {
2020-07-06 01:07:55 -05:00
if (result.value) {
2020-08-03 23:17:51 -05:00
window.location.href = "http://aws.unam.mx/";
2020-07-06 01:07:55 -05:00
}
});
},
2020-07-05 23:02:00 -05:00
async registrar() {
2020-07-06 01:07:55 -05:00
this.cargando = true;
2020-07-05 23:02:00 -05:00
const data = {
nombreEqui: this.nombreEquipo,
desafio: this.desafio,
campus: this.campus,
2020-07-06 01:07:55 -05:00
numeroIntegrantes: this.noIntegrantes,
nombreLider: this.nombreLider,
2020-07-05 23:02:00 -05:00
apellidoPaLider: this.apellidoPaLider,
apellidoMaLider: this.apellidoMaLider,
correoLider: this.correoLider,
carreraLider: this.carrera,
2020-08-03 23:17:51 -05:00
integrantes: this.integrantes
2020-07-05 23:02:00 -05:00
};
axios
.post(`${config.api}/registro`, data)
2020-08-03 23:17:51 -05:00
.then(async respose => {
2020-07-06 01:07:55 -05:00
this.cargando = false;
2020-07-05 23:02:00 -05:00
console.log(respose.data.msj);
2020-07-06 01:07:55 -05:00
await Swal.fire("Has sido registrado", "", "success");
2020-08-03 23:17:51 -05:00
window.location.href = "http://aws.unam.mx/";
return;
2020-07-05 23:02:00 -05:00
})
2020-08-03 23:17:51 -05:00
.catch(async error => {
2020-07-06 01:07:55 -05:00
this.cargando = false;
console.log(error.response.data.msj);
await Swal.fire(
"Ocurrio un error",
`${error.response.data.msj}`,
"error"
2020-08-03 23:17:51 -05:00
);
window.location.href = "http://aws.unam.mx/";
2020-07-05 23:02:00 -05:00
});
2020-08-03 23:17:51 -05:00
}
}
2020-07-05 23:02:00 -05:00
};
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
2020-07-06 21:35:11 -05:00
.form-check-label {
margin-left: 1.3rem;
margin-top: 1rem;
padding-top: 0.4rem;
2020-08-03 23:17:51 -05:00
display: flex;
2020-07-06 21:35:11 -05:00
}
.form-check-input {
width: 1.5rem;
height: 1.5rem;
2020-08-03 23:17:51 -05:00
display: flex;
2020-07-06 21:35:11 -05:00
}
2020-07-05 23:02:00 -05:00
.espacio {
margin-bottom: 3rem;
}
.botton_falso {
background-color: #ccc; /* Green */
border: none;
color: white;
height: 4.5rem;
width: 15rem;
padding: 1rem 4rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 1.5rem;
border-radius: 1rem;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-left: 2rem;
margin-right: 2rem;
margin-bottom: 2rem;
margin-top: 2rem;
}
.button_salir {
background-color: #1b3d70; /* Green */
border: none;
color: white;
height: 4.5rem;
width: 15rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 1.5rem;
border-radius: 1rem;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-left: 2rem;
margin-right: 2rem;
margin-bottom: 2rem;
margin-top: 2rem;
}
.button_salir:hover {
background-color: rgb(170, 4, 4);
color: white;
}
.button {
background-color: #1b3d70; /* Green */
border: none;
color: white;
height: 4.5rem;
width: 15rem;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 1.5rem;
border-radius: 1rem;
-webkit-transition-duration: 0.4s; /* Safari */
transition-duration: 0.4s;
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
margin-left: 2rem;
margin-right: 2rem;
margin-bottom: 2rem;
margin-top: 2rem;
}
.button:hover {
background-color: #46c200;
color: white;
}
.general {
max-width: 1280px;
height: auto;
margin: 0 auto;
}
.ma {
margin-right: 1.5rem;
}
.title {
color: white;
margin-top: 1rem;
}
2020-07-06 21:35:11 -05:00
@media screen and (max-width: 500px) {
.botton_falso {
margin-left: 4rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 3rem;
}
.button_salir {
margin-left: 4rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 1rem;
}
.button {
margin-left: 4rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 3rem;
}
}
@media screen and (max-width: 380px) {
.botton_falso {
margin-left: 3rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 3rem;
}
.button_salir {
margin-left: 3rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 1rem;
}
.button {
margin-left: 3rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 3rem;
}
}
@media screen and (max-width: 325px) {
.botton_falso {
margin-left: 1.5rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 3rem;
}
.button_salir {
margin-left: 1.5rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 1rem;
}
.button {
margin-left: 1.5rem;
margin-right: 0rem;
margin-bottom: 2rem;
margin-top: 3rem;
}
}
2020-07-05 23:02:00 -05:00
</style>