From 34c08df0160d468d147764ccadc12ce1ed4e44c3 Mon Sep 17 00:00:00 2001 From: Matheus Albino Brunhara Date: Sat, 28 May 2022 14:57:05 -0500 Subject: [PATCH] =?UTF-8?q?Mais=20atualiza=C3=A7=C3=B5es=20em=20CadastroVa?= =?UTF-8?q?n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/CadastroVan.tsx | 202 ++++++++++++++++++-------------------- 1 file changed, 93 insertions(+), 109 deletions(-) diff --git a/src/pages/CadastroVan.tsx b/src/pages/CadastroVan.tsx index 7c4bcc6..c6dd9f4 100644 --- a/src/pages/CadastroVan.tsx +++ b/src/pages/CadastroVan.tsx @@ -6,18 +6,22 @@ import { IonBackButton, IonButton, IonButtons, - IonCardTitle, IonContent, IonHeader, IonPage, IonToolbar, IonText, - IonRadioGroup, - IonRadio + IonTitle, + IonList, + IonCheckbox, + IonItemDivider, + IonListHeader, } from "@ionic/react"; import React, { useReducer, useState } from "react"; +import * as yup from 'yup'; + import { ApiClient } from "../services/api-client.service"; import "./CadastroVan.css"; @@ -44,12 +48,36 @@ const CadastroVan: React.FC = () => { } ); + // TODO, yup + let schema = yup.object().shape({ + carPlate: yup.string().required(), + carBrand: yup.string().required(), + carModel: yup.string().required(), + maxPassengers: yup.number().integer().min(1).max(100).required(), + isRented: yup.boolean().required(), + carRentalName: yup.string(), // .required(), + postalCode: yup.string(), // .required(), + street: yup.string(), // .required(), + number: yup.number().integer(), // .required(), + complement: yup.string(), // .required(), + city: yup.string(), // .required(), + state: yup.string(), // .required(), + + // name: yup.string().required(), + // age: yup.number().required().positive().integer(), + // email: yup.string().email(), + // website: yup.string().url(), + // createdOn: yup.date().default(function () { + // return new Date(); + // }), + }); + const vanForm = { carPlate: inputValues.carPlate, carBrand: inputValues.carBrand, carModel: inputValues.carModel, maxPassengers: inputValues.maxPassengers, - isRent: inputValues.isRent, + isRented: inputValues.isRented, carRentalName: inputValues.carRentalName, carRentalAddress: { postalCode: inputValues.postalCode, @@ -107,7 +135,7 @@ const CadastroVan: React.FC = () => { return false; } - if (vanForm.isRent) { + if (vanForm.isRented) { return validateRentalForm(); } else { clearRentalData(); @@ -173,18 +201,20 @@ const CadastroVan: React.FC = () => { + Cadastro de veículo - -
- Cadastro do Veículo - + + + + Informações do veículo + - Placa * + Placa { - Marca * + Marca { - Modelo * + Modelo { - Número Máximo de Passageiros * + Número Máximo de Passageiros { onIonInput={(e: any) => setInputValues({ maxPassengers: e.target.value })} /> + + + + + Informações do locador + - -
- Veículo alugado? -
-
- setInputValues({ isRent: e.target.value })} - > - - Sim - - - - - Não - - - -
-
+ O veículo é alugado? + setInputValues({ isRented: e.detail.checked })} />
- {inputValues.isRent && ( + {inputValues.isRented && (
- - Nome do Locador * - setInputValues({ carRentalName: e.target.value })} - /> - - -
- Endereço do Locador -
- - CEP* - setInputValues({ postalCode: e.target.value })} - /> - - - Logradouro* - setInputValues({ street: e.target.value })} - /> - + + + setInputValues({ carRentalName: e.target.value })} + /> - - Número* - setInputValues({ number: e.target.value })} - /> - - - - Complemento* - setInputValues({ complement: e.target.value })} - /> - - - - Cidade* - setInputValues({ city: e.target.value })} - /> - - - - Estado* - setInputValues({ state: e.target.value })} - /> - -
+ setInputValues({ postalCode: e.target.value })} + /> + setInputValues({ number: e.target.value })} + /> + setInputValues({ complement: e.target.value })} + /> + setInputValues({ city: e.target.value })} + /> + setInputValues({ state: e.target.value })} + /> +
)} @@ -337,7 +320,8 @@ const CadastroVan: React.FC = () => { Salvar - +
+