Cadastro de veículo
-
-
+
+
@@ -235,46 +245,62 @@ const CadastroVan: React.FC = () => {
Informações do veículo
- Placa
+ Placa
setInputValues({ carPlate: e.target.value })}
+ placeholder="Digite a Placa do Veículo"
+ onIonChange={(e: any) =>
+ setInputValues({ carPlate: e.target.value })
+ }
/>
{/* TODO, problema de setState para valores vindos de um evento sendo triggerado por um ion-select */}
Marca
- { setInputValues({ carBrand: e.detail.value }) }}>
- { carModels ? carModels.map((carModel, index) => {
- return ({carModel.name})
- }) : <>> }
+ {
+ setInputValues({ carBrand: e.detail.value });
+ }}
+ >
+ {carModels ? (
+ carModels.map((carModel, index) => {
+ return (
+
+ {carModel.name}
+
+ );
+ })
+ ) : (
+ <>>
+ )}
- Modelo
+ Modelo
setInputValues({ carModel: e.target.value })}
+ placeholder="Digite o Modelo do Veículo"
+ onIonChange={(e: any) =>
+ setInputValues({ carModel: e.target.value })
+ }
/>
-
- Número de assentos
-
+ Número de assentos
setInputValues({ seats_number: e.target.value })}
+ placeholder="podem ser ocupados por passageiros"
+ onIonChange={(e: any) =>
+ setInputValues({ seats_number: e.target.value })
+ }
/>
@@ -286,52 +312,67 @@ const CadastroVan: React.FC = () => {
O veículo é alugado?
- setInputValues({ isRented: e.detail.checked })} />
+
+ setInputValues({ isRented: e.detail.checked })
+ }
+ />
{inputValues.isRented && (
-
-
- setInputValues({ locator_name: e.target.value })}
- />
+
+
+
+ setInputValues({ locator_name: e.target.value })
+ }
+ />
- setInputValues({ locator_address: e.target.value })}
- />
- setInputValues({ locator_complement: e.target.value })}
- />
- setInputValues({ locator_city: e.target.value })}
- />
- setInputValues({ locator_state: e.target.value })}
- />
-
+
+ setInputValues({ locator_address: e.target.value })
+ }
+ />
+
+ setInputValues({ locator_complement: e.target.value })
+ }
+ />
+
+ setInputValues({ locator_city: e.target.value })
+ }
+ />
+
+ setInputValues({ locator_state: e.target.value })
+ }
+ />
+
)}
Salvar
@@ -341,12 +382,12 @@ const CadastroVan: React.FC = () => {
setShowToast(false)}
message={toastMessage}
duration={2500}
- />
+ />
);
diff --git a/src/pages/MinhasVans.tsx b/src/pages/MinhasVans.tsx
index d9129c5..4b0e93f 100644
--- a/src/pages/MinhasVans.tsx
+++ b/src/pages/MinhasVans.tsx
@@ -1,21 +1,32 @@
-import { IonBackButton, IonButtons, IonCard, IonCardContent, IonCardHeader, IonCardSubtitle, IonCardTitle, IonContent, IonHeader, IonIcon, IonItem, IonLabel, IonPage, IonTitle, IonToast, IonToolbar } from '@ionic/react';
-import { Color } from '@ionic/core';
-import { carOutline } from 'ionicons/icons';
-import { useContext, useEffect, useState } from 'react';
-import { useHistory, useLocation } from 'react-router';
+import { Color } from "@ionic/core";
+import {
+ IonBackButton,
+ IonButtons,
+ IonCard,
+ IonCardContent,
+ IonCardHeader,
+ IonCardSubtitle,
+ IonCardTitle,
+ IonContent,
+ IonHeader,
+ IonPage,
+ IonTitle,
+ IonToast,
+ IonToolbar,
+} from "@ionic/react";
+import { useEffect, useState } from "react";
+import { useHistory } from "react-router";
-import { UserContext } from '../App';
+import * as vansRoutes from "../services/api/vans";
-import * as vansRoutes from '../services/api/vans';
-
-import sessionsService from '../services/functions/sessionsService'
+import sessionsService from "../services/functions/sessionsService";
interface VanInfo {
plate: string;
brand: string;
model: string;
seats_number: string;
- document_status: boolean,
+ document_status: boolean;
locator_name: string;
locator_address: string;
locator_complement: string;
@@ -27,90 +38,104 @@ const MinhasVans: React.FC = () => {
const history = useHistory();
const [showToast, setShowToast] = useState(false);
- const [toastMessage, setToastMessage] = useState('');
+ const [toastMessage, setToastMessage] = useState("");
const [toastColor, setToastColor] = useState("primary");
const [userVans, setUserVans] = useState();
const redirectUserToLogin = () => {
- history.push({ pathname: '/login' });
- }
+ history.push({ pathname: "/login" });
+ };
useEffect(() => {
const getUserVans = async () => {
- let userId = ''
+ let userId = "";
+
+ const refreshSessionRes = await sessionsService.refreshSession();
- const refreshSessionRes = await sessionsService.refreshSession()
-
if (refreshSessionRes.error) {
- redirectUserToLogin()
- return
+ redirectUserToLogin();
+ return;
}
-
+
if (refreshSessionRes.userId) {
- userId = refreshSessionRes.userId
+ userId = refreshSessionRes.userId;
}
- vansRoutes.getByUserId(userId).then(response => {
- if (response.status === 'error') {
- setToastColor("danger")
- setToastMessage(response.message);
- setShowToast(true);
-
- return
- }
-
- setUserVans(response.data)
- }).catch((err) => {
- setToastColor("danger")
- setToastMessage(err);
- setShowToast(true);
- })
- }
+ vansRoutes
+ .getByUserId(userId)
+ .then((response) => {
+ if (response.status === "error") {
+ setToastColor("danger");
+ setToastMessage(response.message);
+ setShowToast(true);
+
+ return;
+ }
+
+ setUserVans(response.data);
+ })
+ .catch((err) => {
+ setToastColor("danger");
+ setToastMessage(err);
+ setShowToast(true);
+ });
+ };
+
+ getUserVans();
+ }, []);
- getUserVans()
- }, [])
-
return (
Minhas vans
-
-
-
-
-
-
-
- { userVans ? userVans.map((van, index) => {
+
+
+
+
+
+
+
+ {userVans ? (
+ userVans.map((van, index) => {
return (
-
- {van.plate}
- {van.brand} - {van.model}
-
- { van.locator_name ?
+
+ {van.plate}
+
+ {van.brand} - {van.model}
+
+
+ {van.locator_name ? (
<>
- {van.seats_number} assentos - Locador: {van.locator_name}
- > :
- <>
- {van.seats_number} assentos - Não é alugado
+
+ {van.seats_number} assentos - Locador: {van.locator_name}
+
>
- }
+ ) : (
+ <>
+
+ {van.seats_number} assentos - Não é alugado
+
+ >
+ )}
- )
- }) : <>>}
+ );
+ })
+ ) : (
+ <>>
+ )}
- setShowToast(false)}
- message={toastMessage}
- duration={2500}
- />
-
+ setShowToast(false)}
+ message={toastMessage}
+ duration={2500}
+ />
+
);
};
diff --git a/src/pages/Perfil.tsx b/src/pages/Perfil.tsx
index 3249a56..2a184b0 100644
--- a/src/pages/Perfil.tsx
+++ b/src/pages/Perfil.tsx
@@ -19,8 +19,6 @@ import {
IonToast,
IonToolbar,
} from "@ionic/react";
-import { useHistory, useLocation } from "react-router-dom";
-import React, { useState, useEffect, useReducer, useContext } from "react";
import {
callOutline,
cardOutline,
@@ -32,14 +30,19 @@ import {
shieldCheckmarkOutline,
starOutline,
} from "ionicons/icons";
+import React, { useContext, useEffect, useReducer, useState } from "react";
+import { useHistory, useLocation } from "react-router-dom";
-import "./Perfil.css";
import LocalStorage from "../LocalStorage";
+import "./Perfil.css";
-import sessionsService from "../services/functions/sessionsService";
-import usersService from "../services/functions/usersService";
-import { UserContext } from "../App";
import { Color } from "@ionic/core";
+import { UserContext } from "../App";
+import sessionsService from "../services/functions/sessionsService";
+import {
+ checkIfUserIsDriver,
+ getById,
+} from "../services/functions/usersService";
interface ScanNewProps {
match: {
@@ -131,7 +134,7 @@ const Perfil: React.FC = (props) => {
}
// get user info by ID
- const getByIdRes = await usersService.getById(userId);
+ const getByIdRes = await getById(userId);
if (getByIdRes.error) {
if (isVisitor && props.match.params.id) {
@@ -147,7 +150,7 @@ const Perfil: React.FC = (props) => {
}
// check if user is driver (if they have vans)
- const userIsDriverRes = await usersService.checkIfUserIsDriver(userId);
+ const userIsDriverRes = await checkIfUserIsDriver(userId);
// if (userIsDriverRes.error) {
// setToastColor('warning')
@@ -358,6 +361,15 @@ const Perfil: React.FC = (props) => {
Buscar passageiros
+
+ history.push({ pathname: "/cadastrar-itinerario" })
+ }
+ >
+
+ Cadastrar itinerário
+
diff --git a/src/pages/Transportes/Transportes.tsx b/src/pages/Transportes/Transportes.tsx
index 9853750..aa3ae96 100644
--- a/src/pages/Transportes/Transportes.tsx
+++ b/src/pages/Transportes/Transportes.tsx
@@ -1,52 +1,34 @@
import {
+ IonButton,
+ IonCard,
+ IonCardContent,
+ IonCheckbox,
IonContent,
- IonPage,
IonFab,
IonFabButton,
- IonIcon,
- IonCard,
- IonInput,
- IonRow,
- IonCol,
- IonCardContent,
- IonButton,
- IonHeader,
- IonToolbar,
- IonButtons,
- IonBackButton,
- IonTabs,
- IonTabBar,
- IonTabButton,
- IonLabel,
- IonBadge,
- IonRouterOutlet,
- IonSlides,
- IonSlide,
- IonModal,
- IonList,
- IonRadioGroup,
- IonListHeader,
- IonItem,
- IonRadio,
- IonCheckbox,
IonFooter,
+ IonHeader,
+ IonIcon,
+ IonItem,
+ IonLabel,
+ IonModal,
+ IonPage,
+ IonRadio,
+ IonRadioGroup,
+ IonSlide,
+ IonSlides,
IonToast,
+ IonToolbar,
} from "@ionic/react";
import {
- arrowBack,
- arrowBackOutline,
arrowForwardOutline,
chevronBackOutline,
- chevronForwardOutline,
closeOutline,
- locateOutline,
- locationOutline,
- timeOutline,
} from "ionicons/icons";
import { useEffect, useState } from "react";
import { useHistory, useLocation } from "react-router";
-import { getTransportes } from "../../services/functions/transportsService";
import { createUserSearch } from "../../services/api/users";
+import { getTransportes } from "../../services/functions/transportsService";
import "./Transportes.css";
interface InfoBusca {
@@ -63,8 +45,8 @@ const Transportes: React.FC = () => {
const [transportes, setTransportes] = useState([]);
const [showModalFilters, setShowModalFilters] = useState(false);
const [showToast, setShowToast] = useState(false);
- const [messageToast, setMessageToast ] = useState('');
- const [toastColor, setToastColor] = useState('success');
+ const [messageToast, setMessageToast] = useState("");
+ const [toastColor, setToastColor] = useState("success");
useEffect(() => {
if (props) {
@@ -77,15 +59,21 @@ const Transportes: React.FC = () => {
setTransportes(data);
}
- function criaAlerta(){
- createUserSearch(props.coordinatesFrom.lat, props.coordinatesFrom.lng, props.addressTo.label).then(() => {
- setMessageToast('Alerta criado com sucesso!');
- setShowToast(true);
- }).catch((err:any) => {
- setMessageToast('Não foi possível criar o alerta!');
- setToastColor('danger');
- setShowToast(true);
- })
+ function criaAlerta() {
+ createUserSearch(
+ props.coordinatesFrom.lat,
+ props.coordinatesFrom.lng,
+ props.addressTo.label
+ )
+ .then(() => {
+ setMessageToast("Alerta criado com sucesso!");
+ setShowToast(true);
+ })
+ .catch((err: any) => {
+ setMessageToast("Não foi possível criar o alerta!");
+ setToastColor("danger");
+ setShowToast(true);
+ });
}
return (
@@ -107,7 +95,7 @@ const Transportes: React.FC = () => {
- {transportes && transportes.length > 0? (
+ {transportes && transportes.length > 0 ? (
@@ -124,9 +112,11 @@ const Transportes: React.FC = () => {
- )
- :
- (Não foi encontrado nenhum transporte que atenda essa rota.
)}
+ ) : (
+
+ Não foi encontrado nenhum transporte que atenda essa rota.
+
+ )}
{transportes &&
transportes.map((record: any, index: any) => {
return (
@@ -139,7 +129,7 @@ const Transportes: React.FC = () => {