From 51c0502af6d46e304bb4718429a86325980b67dc Mon Sep 17 00:00:00 2001 From: Rafael Date: Sun, 7 Mar 2021 20:21:45 +0100 Subject: [PATCH] Added steps content and send simulation --- src/App.tsx | 2 +- src/components/Central.tsx | 224 ++++++++++++++++++++++++++++++------- 2 files changed, 187 insertions(+), 39 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index 2acd2d4..8422425 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,7 +1,7 @@ import React from "react"; import "./App.css"; import { Provider } from "react-redux"; -import { createStore, Reducer, Action } from "redux"; +import { createStore, Reducer } from "redux"; import GlobalState, { initialState } from "./state/globalState"; import Header from "./styledComponents/Header"; import Central from "./styledComponents/Central"; diff --git a/src/components/Central.tsx b/src/components/Central.tsx index 8539bc5..60d6d79 100644 --- a/src/components/Central.tsx +++ b/src/components/Central.tsx @@ -4,8 +4,14 @@ import Step from "@material-ui/core/Step"; import StepLabel from "@material-ui/core/StepLabel"; import Button from "@material-ui/core/Button"; import Typography from "@material-ui/core/Typography"; -import { FormControl, Grid, InputLabel, MenuItem, Select } from "@material-ui/core"; - +import { + FormControl, + Grid, + InputLabel, + MenuItem, + Select, +} from "@material-ui/core"; +import TextField from "@material-ui/core/TextField"; /* function Central(props: any) { return ( @@ -168,22 +174,19 @@ interface Form { oficina?: string; area?: string; - nie?: string; - nombre?: string; - apellidos?: string; - email?: string; - - - rnie?: string; - rnombre?: string; - rapellidos?: string; - remail?: string; - + nie?: string; + nombre?: string; + apellidos?: string; + email?: string; - telefono?: number; - expediente?: string; - matricula?: string; + rnie?: string; + rnombre?: string; + rapellidos?: string; + remail?: string; + telefono?: number; + expediente?: string; + matricula?: string; } interface ICentralProps { @@ -192,7 +195,7 @@ interface ICentralProps { } interface ICentralState { - formulario: Form + formulario: Form; } class Centrals extends React.Component { @@ -203,8 +206,18 @@ class Centrals extends React.Component { "Datos del representante", "Otros datos", ]; - oficinas = [{id: 0, name:'Alicante'},{id: 1, name:'Sevilla'},{id: 2, name:'Madrid'},{id: 3, name:'Constantina'}] - areas = ['Conductores', 'Vehículos', 'Sanciones', 'Otros'] + oficinas = [ + { id: 0, name: "Alicante" }, + { id: 1, name: "Sevilla" }, + { id: 2, name: "Madrid" }, + { id: 3, name: "Constantina" }, + ]; + areas = [ + { id: 0, name: "Conductores" }, + { id: 1, name: "Vehículos" }, + { id: 2, name: "Sanciones" }, + { id: 3, name: "Otros" }, + ]; constructor(props: ICentralProps) { super(props); @@ -212,13 +225,13 @@ class Centrals extends React.Component { } onValueChange = (event: React.ChangeEvent) => { - const key = event.target.name - const val = event.target.value + const key = event.target.name; + const val = event.target.value; const formGroup = { ...this.state.formulario }; formGroup[key] = val; this.setState({ formulario: formGroup }); - console.log(this.state) - } + console.log(this.state); + }; isStepOptional(step: number) { return step === 3; @@ -226,7 +239,12 @@ class Centrals extends React.Component { handleNext = () => { console.log(this.props); - this.props.setActiveStep(this.props.current + 1); + if(this.props.current < this.steps.length-1){ + this.props.setActiveStep(this.props.current + 1); + }else{ + alert("Formulario enviado") + } + console.log(this.props.current); }; @@ -239,15 +257,13 @@ class Centrals extends React.Component { return ( - - Oficina - + Oficina + {this.areas.map((area) => ( + + {area.name} + + ))} + + + + ); case 2: - return "This is the bit I really care about!"; + return ( + + + + + + + + + + + + + + + + + + + ); case 3: - return "3!"; + return ( + + + + + + + + + + + + + + + + + + + ); case 4: - return "4!"; + return ( + + + + + + + + + + + + + + + + ); default: return "Unknown step"; } @@ -277,7 +419,9 @@ class Centrals extends React.Component { const labelProps: { optional?: React.ReactNode } = {}; if (this.isStepOptional(index)) { labelProps.optional = ( - Opcional + + Opcional + ); } return ( @@ -290,11 +434,15 @@ class Centrals extends React.Component {
{this.props.current === this.steps.length ? (
- Has completado todos los pasos + + Has completado todos los pasos +
) : (
- {this.getStepContent(this.props.current)} + + {this.getStepContent(this.props.current)} +