Corrige diversos toasts
This commit is contained in:
@@ -9,6 +9,7 @@ import * as UsersService from '../../services/api/users'
|
|||||||
import LocalStorage from '../../LocalStorage';
|
import LocalStorage from '../../LocalStorage';
|
||||||
import { UserContext } from '../../App';
|
import { UserContext } from '../../App';
|
||||||
import { Color } from '@ionic/core';
|
import { Color } from '@ionic/core';
|
||||||
|
import { closeToast } from '../../services/utils';
|
||||||
|
|
||||||
const Cadastro: React.FC = () => {
|
const Cadastro: React.FC = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -216,7 +217,7 @@ const Cadastro: React.FC = () => {
|
|||||||
<IonToast
|
<IonToast
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={messageToast}
|
message={messageToast}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import { callOutline, documentTextOutline } from "ionicons/icons";
|
|||||||
|
|
||||||
import '../Cadastro/Cadastro.css'
|
import '../Cadastro/Cadastro.css'
|
||||||
import { Color } from "@ionic/core";
|
import { Color } from "@ionic/core";
|
||||||
|
import { closeToast } from "../../services/utils";
|
||||||
|
|
||||||
interface cardItem {
|
interface cardItem {
|
||||||
icon: string;
|
icon: string;
|
||||||
@@ -130,7 +131,7 @@ const CadastroCompletar: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={toastMessage}
|
message={toastMessage}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import { saveOutline } from "ionicons/icons";
|
|||||||
import * as usersRoutes from '../../services/api/users';
|
import * as usersRoutes from '../../services/api/users';
|
||||||
|
|
||||||
import validateCpf from '../../services/validateCpf'
|
import validateCpf from '../../services/validateCpf'
|
||||||
|
import { closeToast } from "../../services/utils";
|
||||||
|
|
||||||
interface documentTypesInterface {
|
interface documentTypesInterface {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -206,7 +207,7 @@ const CompletarDocumento: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color='danger'
|
color='danger'
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={messageToast}
|
message={messageToast}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ import { saveOutline } from "ionicons/icons";
|
|||||||
|
|
||||||
import * as usersRoutes from '../../services/api/users';
|
import * as usersRoutes from '../../services/api/users';
|
||||||
import { Color } from "@ionic/core";
|
import { Color } from "@ionic/core";
|
||||||
|
import { closeToast } from "../../services/utils";
|
||||||
|
|
||||||
interface documentTypesInterface {
|
interface documentTypesInterface {
|
||||||
label: string;
|
label: string;
|
||||||
@@ -156,7 +157,7 @@ const CompletarTelefone: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={messageToast}
|
message={messageToast}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import * as vansRoutes from '../services/api/vans';
|
|||||||
|
|
||||||
import "./CadastroVan.css";
|
import "./CadastroVan.css";
|
||||||
import { Color } from "@ionic/core";
|
import { Color } from "@ionic/core";
|
||||||
|
import { closeToast } from "../services/utils";
|
||||||
|
|
||||||
const CadastroVan: React.FC = () => {
|
const CadastroVan: React.FC = () => {
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
@@ -364,7 +365,7 @@ const CadastroVan: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={toastMessage}
|
message={toastMessage}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import { useHistory, useLocation } from 'react-router';
|
|||||||
import { UserContext } from '../App';
|
import { UserContext } from '../App';
|
||||||
|
|
||||||
import * as sessionRoutes from '../services/api/session';
|
import * as sessionRoutes from '../services/api/session';
|
||||||
|
import { closeToast } from '../services/utils';
|
||||||
|
|
||||||
interface LocationState {
|
interface LocationState {
|
||||||
redirectData?: {
|
redirectData?: {
|
||||||
@@ -59,7 +60,7 @@ const Home: React.FC = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
refreshUserToken()
|
refreshUserToken()
|
||||||
}, [])
|
}, [location.state, user, history])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IonPage>
|
<IonPage>
|
||||||
@@ -68,7 +69,7 @@ const Home: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={toastMessage}
|
message={toastMessage}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
119
src/pages/Itinerario.tsx
Normal file
119
src/pages/Itinerario.tsx
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
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 { UserContext } from '../App';
|
||||||
|
|
||||||
|
import * as vansRoutes from '../services/api/vans';
|
||||||
|
|
||||||
|
import sessionsService from '../services/functions/sessionsService'
|
||||||
|
import { closeToast } from '../services/utils';
|
||||||
|
|
||||||
|
interface VanInfo {
|
||||||
|
plate: string;
|
||||||
|
brand: string;
|
||||||
|
model: string;
|
||||||
|
seats_number: string;
|
||||||
|
document_status: boolean,
|
||||||
|
locator_name: string;
|
||||||
|
locator_address: string;
|
||||||
|
locator_complement: string;
|
||||||
|
locator_city: string;
|
||||||
|
locator_state: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Itinerario: React.FC = () => {
|
||||||
|
const history = useHistory();
|
||||||
|
|
||||||
|
const [showToast, setShowToast] = useState(false);
|
||||||
|
const [toastMessage, setToastMessage] = useState('');
|
||||||
|
const [toastColor, setToastColor] = useState<Color>("primary");
|
||||||
|
|
||||||
|
const [userVans, setUserVans] = useState<VanInfo[]>();
|
||||||
|
|
||||||
|
const redirectUserToLogin = () => {
|
||||||
|
history.push({ pathname: '/login' });
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const getUserVans = async () => {
|
||||||
|
let userId = ''
|
||||||
|
|
||||||
|
const refreshSessionRes = await sessionsService.refreshSession()
|
||||||
|
|
||||||
|
if (refreshSessionRes.error) {
|
||||||
|
redirectUserToLogin()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (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);
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
getUserVans()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IonPage>
|
||||||
|
<IonHeader>
|
||||||
|
<IonToolbar>
|
||||||
|
<IonTitle>Minhas vans</IonTitle>
|
||||||
|
<IonButtons slot="start">
|
||||||
|
<IonBackButton defaultHref="/perfil" />
|
||||||
|
</IonButtons>
|
||||||
|
</IonToolbar>
|
||||||
|
</IonHeader>
|
||||||
|
|
||||||
|
<IonContent>
|
||||||
|
{ userVans ? userVans.map((van, index) => {
|
||||||
|
return (
|
||||||
|
<IonCard key={index}>
|
||||||
|
<IonCardHeader>
|
||||||
|
<IonCardTitle>{van.plate}</IonCardTitle>
|
||||||
|
<IonCardSubtitle>{van.brand} - {van.model}</IonCardSubtitle>
|
||||||
|
</IonCardHeader>
|
||||||
|
{ van.locator_name ?
|
||||||
|
<>
|
||||||
|
<IonCardContent>{van.seats_number} assentos - Locador: {van.locator_name}</IonCardContent>
|
||||||
|
</> :
|
||||||
|
<>
|
||||||
|
<IonCardContent>{van.seats_number} assentos - Não é alugado</IonCardContent>
|
||||||
|
</>
|
||||||
|
}
|
||||||
|
</IonCard>
|
||||||
|
)
|
||||||
|
}) : <></>}
|
||||||
|
|
||||||
|
<IonToast
|
||||||
|
position="top"
|
||||||
|
color={toastColor}
|
||||||
|
isOpen={showToast}
|
||||||
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
|
message={toastMessage}
|
||||||
|
duration={2500}
|
||||||
|
/>
|
||||||
|
</IonContent>
|
||||||
|
</IonPage>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default Itinerario;
|
||||||
@@ -19,6 +19,7 @@ import * as sessionRoutes from '../services/api/session';
|
|||||||
import LocalStorage from '../LocalStorage';
|
import LocalStorage from '../LocalStorage';
|
||||||
import { Action } from "../components/Action";
|
import { Action } from "../components/Action";
|
||||||
import { UserContext } from "../App";
|
import { UserContext } from "../App";
|
||||||
|
import { closeToast } from "../services/utils";
|
||||||
|
|
||||||
const Page: React.FC = () => {
|
const Page: React.FC = () => {
|
||||||
const [showToast, setShowToast] = useState(false);
|
const [showToast, setShowToast] = useState(false);
|
||||||
@@ -162,7 +163,7 @@ const Page: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color='danger'
|
color='danger'
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={messageToast}
|
message={messageToast}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ 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'
|
||||||
|
import { closeToast } from '../services/utils';
|
||||||
|
|
||||||
interface VanInfo {
|
interface VanInfo {
|
||||||
plate: string;
|
plate: string;
|
||||||
@@ -106,7 +107,7 @@ const MinhasVans: React.FC = () => {
|
|||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={toastMessage}
|
message={toastMessage}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -40,6 +40,7 @@ import sessionsService from "../services/functions/sessionsService";
|
|||||||
import usersService from "../services/functions/usersService";
|
import usersService from "../services/functions/usersService";
|
||||||
import { UserContext } from "../App";
|
import { UserContext } from "../App";
|
||||||
import { Color } from "@ionic/core";
|
import { Color } from "@ionic/core";
|
||||||
|
import { closeToast } from "../services/utils";
|
||||||
|
|
||||||
interface ScanNewProps {
|
interface ScanNewProps {
|
||||||
match: {
|
match: {
|
||||||
@@ -393,7 +394,7 @@ const Perfil: React.FC<ScanNewProps> = (props) => {
|
|||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={toastMessage}
|
message={toastMessage}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import * as usersRoutes from '../services/api/users';
|
|||||||
|
|
||||||
import './Cadastro/Cadastro.css'
|
import './Cadastro/Cadastro.css'
|
||||||
import { Color } from "@ionic/core";
|
import { Color } from "@ionic/core";
|
||||||
|
import { closeToast } from "../services/utils";
|
||||||
|
|
||||||
interface userData {
|
interface userData {
|
||||||
name: string;
|
name: string;
|
||||||
@@ -190,7 +191,7 @@ const PerfilEditar: React.FC = () => {
|
|||||||
<IonToast
|
<IonToast
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={messageToast}
|
message={messageToast}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { useHistory, useLocation } from "react-router";
|
|||||||
import itinerariesService from "../../services/functions/itinerariesService";
|
import itinerariesService from "../../services/functions/itinerariesService";
|
||||||
import { createUserSearch } from "../../services/api/users";
|
import { createUserSearch } from "../../services/api/users";
|
||||||
import "./Transportes.css";
|
import "./Transportes.css";
|
||||||
|
import { closeToast } from "../../services/utils";
|
||||||
|
|
||||||
interface InfoBusca {
|
interface InfoBusca {
|
||||||
addressFrom: any;
|
addressFrom: any;
|
||||||
@@ -210,7 +211,7 @@ const Transportes: React.FC = () => {
|
|||||||
// cssClass={"toast-notification"}
|
// cssClass={"toast-notification"}
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => closeToast(setShowToast)}
|
||||||
message={messageToast}
|
message={messageToast}
|
||||||
duration={2500}
|
duration={2500}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -4,4 +4,9 @@ export async function autoCompleteAddress(address:string) {
|
|||||||
|
|
||||||
const response = await instance.get(`https://api.geoapify.com/v1/geocode/autocomplete?text=${address}&apiKey=ee574aacff6f440a84378bbbf7e2f20d`);
|
const response = await instance.get(`https://api.geoapify.com/v1/geocode/autocomplete?text=${address}&apiKey=ee574aacff6f440a84378bbbf7e2f20d`);
|
||||||
return response.data.features;
|
return response.data.features;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function closeToast(setShowToast: React.Dispatch<React.SetStateAction<boolean>>) {
|
||||||
|
setShowToast(false)
|
||||||
|
window.history.replaceState({}, document.title)
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user