1
.gitignore
vendored
1
.gitignore
vendored
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
# misc
|
# misc
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
.env
|
||||||
.env.local
|
.env.local
|
||||||
.env.development.local
|
.env.development.local
|
||||||
.env.test.local
|
.env.test.local
|
||||||
|
|||||||
3992
package-lock.json
generated
3992
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -23,12 +23,12 @@
|
|||||||
"@types/react-router-dom": "^5.1.7",
|
"@types/react-router-dom": "^5.1.7",
|
||||||
"axios": "^0.26.1",
|
"axios": "^0.26.1",
|
||||||
"ionicons": "^5.4.0",
|
"ionicons": "^5.4.0",
|
||||||
|
"lodash.isequal": "^4.5.0",
|
||||||
"pigeon-maps": "^0.21.0",
|
"pigeon-maps": "^0.21.0",
|
||||||
"pullstate": "^1.24.0",
|
"pullstate": "^1.24.0",
|
||||||
"lodash.isequal": "^4.5.0",
|
|
||||||
"react": "^17.0.1",
|
"react": "^17.0.1",
|
||||||
"react-dom": "^17.0.1",
|
"react-dom": "^17.0.1",
|
||||||
"react-google-places-autocomplete": "^3.3.4",
|
"react-google-places-autocomplete": "^3.4.0",
|
||||||
"react-hook-form": "^7.30.0",
|
"react-hook-form": "^7.30.0",
|
||||||
"react-router": "^5.2.0",
|
"react-router": "^5.2.0",
|
||||||
"react-router-dom": "^5.2.0",
|
"react-router-dom": "^5.2.0",
|
||||||
@@ -51,7 +51,6 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "react-scripts start",
|
"start": "react-scripts start",
|
||||||
"start:mock": "json-server --port 8080 --watch ./mock/db.json",
|
|
||||||
"build": "react-scripts build",
|
"build": "react-scripts build",
|
||||||
"test": "react-scripts test --transformIgnorePatterns 'node_modules/(?!(@ionic/react|@ionic/react-router|@ionic/core|@stencil/core|ionicons)/)'",
|
"test": "react-scripts test --transformIgnorePatterns 'node_modules/(?!(@ionic/react|@ionic/react-router|@ionic/core|@stencil/core|ionicons)/)'",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject"
|
||||||
@@ -80,5 +79,5 @@
|
|||||||
"@types/lodash.isequal": "^4.5.6",
|
"@types/lodash.isequal": "^4.5.6",
|
||||||
"react-scripts": "5.0.1"
|
"react-scripts": "5.0.1"
|
||||||
},
|
},
|
||||||
"description": "An Ionic project"
|
"description": "Projeto de conclusão de curso a fim de resolver a dificuldade de alunos universitários ao buscar vans para suas universidades"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ import { search, home, person } from 'ionicons/icons';
|
|||||||
import { useState, useContext } from 'react';
|
import { useState, useContext } from 'react';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import MinhasVans from './pages/MinhasVans';
|
import MinhasVans from './pages/MinhasVans';
|
||||||
|
import MeusItinerarios from './pages/MeusItinerarios/MeusItinerarios';
|
||||||
|
import CadastrarItinerario from './pages/CadastrarItinerario/CadastrarItinerario';
|
||||||
|
|
||||||
setupIonicReact();
|
setupIonicReact();
|
||||||
|
|
||||||
@@ -73,6 +75,8 @@ const routes = (
|
|||||||
|
|
||||||
<Route exact path="/cadastro-van" component={CadastroVan}></Route>
|
<Route exact path="/cadastro-van" component={CadastroVan}></Route>
|
||||||
<Route exact path="/minhas-vans" component={MinhasVans}></Route>
|
<Route exact path="/minhas-vans" component={MinhasVans}></Route>
|
||||||
|
<Route exact path="/cadastrar-itinerario" component={CadastrarItinerario}></Route>
|
||||||
|
<Route exact path="/meus-itinerarios" component={MeusItinerarios}></Route>
|
||||||
<Route exact path="/">
|
<Route exact path="/">
|
||||||
<Redirect to="/login" />
|
<Redirect to="/login" />
|
||||||
</Route>
|
</Route>
|
||||||
@@ -103,7 +107,7 @@ const IonicApp: React.FC = () => {
|
|||||||
<IonRouterOutlet>{routes}</IonRouterOutlet>
|
<IonRouterOutlet>{routes}</IonRouterOutlet>
|
||||||
|
|
||||||
<IonTabBar slot="bottom">
|
<IonTabBar slot="bottom">
|
||||||
<IonTabButton tab="buscar" href="/buscar">
|
<IonTabButton tab="buscar" href="/buscar-transporte">
|
||||||
<IonIcon icon={search} />
|
<IonIcon icon={search} />
|
||||||
<IonLabel>Buscar</IonLabel>
|
<IonLabel>Buscar</IonLabel>
|
||||||
</IonTabButton>
|
</IonTabButton>
|
||||||
|
|||||||
14
src/constants/routes/transportsRoutes.ts
Normal file
14
src/constants/routes/transportsRoutes.ts
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
const transportsRoutesDefault = '/transports';
|
||||||
|
const transportsRoutes = {
|
||||||
|
create: {
|
||||||
|
url: `${transportsRoutesDefault}`
|
||||||
|
},
|
||||||
|
get: {
|
||||||
|
url: `${transportsRoutesDefault}`
|
||||||
|
},
|
||||||
|
update: {
|
||||||
|
url: `${transportsRoutesDefault}`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
export default transportsRoutes;
|
||||||
@@ -1,18 +1,13 @@
|
|||||||
import {
|
import {
|
||||||
IonContent,
|
|
||||||
IonPage,
|
|
||||||
IonIcon,
|
|
||||||
IonCard,
|
|
||||||
IonInput,
|
|
||||||
IonRow,
|
|
||||||
IonCardContent,
|
|
||||||
IonButton,
|
IonButton,
|
||||||
IonSearchbar,
|
IonCard,
|
||||||
IonModal,
|
IonCardContent,
|
||||||
IonProgressBar,
|
IonContent,
|
||||||
|
IonIcon,
|
||||||
|
IonPage,
|
||||||
|
IonRow,
|
||||||
} from "@ionic/react";
|
} from "@ionic/react";
|
||||||
import {
|
import {
|
||||||
arrowBack,
|
|
||||||
arrowForwardOutline,
|
arrowForwardOutline,
|
||||||
chevronForwardOutline,
|
chevronForwardOutline,
|
||||||
locateOutline,
|
locateOutline,
|
||||||
@@ -22,7 +17,6 @@ import {
|
|||||||
import "./BuscarTransporte.css";
|
import "./BuscarTransporte.css";
|
||||||
|
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { autoCompleteAddress } from "../../services/utils";
|
|
||||||
import { useHistory } from "react-router";
|
import { useHistory } from "react-router";
|
||||||
|
|
||||||
import GooglePlacesAutocomplete, {
|
import GooglePlacesAutocomplete, {
|
||||||
@@ -89,7 +83,7 @@ const BuscarTransporte: React.FC = () => {
|
|||||||
}
|
}
|
||||||
}, [addressTo]);
|
}, [addressTo]);
|
||||||
|
|
||||||
function buscaTransporte(){
|
function buscaTransporte() {
|
||||||
if (coordinatesFrom && coordinatesTo && addressFrom && addressTo) {
|
if (coordinatesFrom && coordinatesTo && addressFrom && addressTo) {
|
||||||
history.push({
|
history.push({
|
||||||
pathname: "/transportes",
|
pathname: "/transportes",
|
||||||
@@ -117,7 +111,7 @@ const BuscarTransporte: React.FC = () => {
|
|||||||
placeholder="R. José Paulino, 1234 - Centro, Campinas - SP, 13013-001"
|
placeholder="R. José Paulino, 1234 - Centro, Campinas - SP, 13013-001"
|
||||||
/> */}
|
/> */}
|
||||||
<GooglePlacesAutocomplete
|
<GooglePlacesAutocomplete
|
||||||
apiKey="AIzaSyAGfCsaNwxwyj4Ajtfy7MTNADE6JwmnZvA"
|
apiKey={process.env.REACT_APP_KEY_API}
|
||||||
apiOptions={{ language: "pt-br", region: "br" }}
|
apiOptions={{ language: "pt-br", region: "br" }}
|
||||||
selectProps={{
|
selectProps={{
|
||||||
value: addressFrom,
|
value: addressFrom,
|
||||||
@@ -136,7 +130,7 @@ const BuscarTransporte: React.FC = () => {
|
|||||||
placeholder="PUC Campinas"
|
placeholder="PUC Campinas"
|
||||||
/> */}
|
/> */}
|
||||||
<GooglePlacesAutocomplete
|
<GooglePlacesAutocomplete
|
||||||
apiKey="AIzaSyAGfCsaNwxwyj4Ajtfy7MTNADE6JwmnZvA"
|
apiKey={process.env.REACT_APP_KEY_API}
|
||||||
apiOptions={{ language: "pt-br", region: "br" }}
|
apiOptions={{ language: "pt-br", region: "br" }}
|
||||||
selectProps={{
|
selectProps={{
|
||||||
value: addressTo,
|
value: addressTo,
|
||||||
@@ -147,10 +141,7 @@ const BuscarTransporte: React.FC = () => {
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="button-search">
|
<div className="button-search">
|
||||||
<IonButton
|
<IonButton color="primary" onClick={() => buscaTransporte()}>
|
||||||
color="primary"
|
|
||||||
onClick={() => buscaTransporte()}
|
|
||||||
>
|
|
||||||
Buscar
|
Buscar
|
||||||
</IonButton>
|
</IonButton>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
99
src/pages/CadastrarItinerario/CadastrarItinerario.tsx
Normal file
99
src/pages/CadastrarItinerario/CadastrarItinerario.tsx
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
import {
|
||||||
|
IonBackButton,
|
||||||
|
IonButton,
|
||||||
|
IonButtons,
|
||||||
|
IonCard,
|
||||||
|
IonCardContent,
|
||||||
|
IonContent,
|
||||||
|
IonHeader,
|
||||||
|
IonIcon,
|
||||||
|
IonItem,
|
||||||
|
IonLabel,
|
||||||
|
IonList,
|
||||||
|
IonListHeader,
|
||||||
|
IonPage,
|
||||||
|
IonRadio,
|
||||||
|
IonRadioGroup,
|
||||||
|
IonTitle,
|
||||||
|
IonToolbar,
|
||||||
|
} from "@ionic/react";
|
||||||
|
import { close, locateOutline, locationOutline } from "ionicons/icons";
|
||||||
|
import { useState } from "react";
|
||||||
|
import GooglePlacesAutocomplete from "react-google-places-autocomplete";
|
||||||
|
|
||||||
|
export default function CadastrarItinerario() {
|
||||||
|
const [selected, setSelected] = useState<any>("");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IonPage>
|
||||||
|
<IonHeader>
|
||||||
|
<IonToolbar>
|
||||||
|
<IonButtons slot="start">
|
||||||
|
<IonBackButton icon={close} text="" defaultHref="/perfil" />
|
||||||
|
</IonButtons>
|
||||||
|
</IonToolbar>
|
||||||
|
</IonHeader>
|
||||||
|
<IonContent fullscreen>
|
||||||
|
<IonHeader collapse="condense">
|
||||||
|
<IonToolbar>
|
||||||
|
<IonTitle size="large">Cadastrar Itinerário</IonTitle>
|
||||||
|
</IonToolbar>
|
||||||
|
</IonHeader>
|
||||||
|
<IonCard>
|
||||||
|
<IonCardContent>
|
||||||
|
<div className="inputs-from-to">
|
||||||
|
<IonIcon icon={locateOutline}></IonIcon>
|
||||||
|
<GooglePlacesAutocomplete
|
||||||
|
apiKey={process.env.REACT_APP_KEY_API}
|
||||||
|
apiOptions={{ language: "pt-br", region: "br" }}
|
||||||
|
selectProps={{
|
||||||
|
className: "input-autocomplete",
|
||||||
|
placeholder: "R. José Paulino, 1234",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div className="inputs-from-to">
|
||||||
|
<IonIcon icon={locationOutline}></IonIcon>
|
||||||
|
<GooglePlacesAutocomplete
|
||||||
|
apiKey={process.env.REACT_APP_KEY_API}
|
||||||
|
apiOptions={{ language: "pt-br", region: "br" }}
|
||||||
|
selectProps={{
|
||||||
|
className: "input-autocomplete",
|
||||||
|
placeholder: "PUC Campinas",
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<IonList>
|
||||||
|
<IonRadioGroup
|
||||||
|
value={selected}
|
||||||
|
onIonChange={(e) => setSelected(e.detail.value)}
|
||||||
|
>
|
||||||
|
<IonListHeader>
|
||||||
|
<IonLabel>Name</IonLabel>
|
||||||
|
</IonListHeader>
|
||||||
|
|
||||||
|
<IonItem>
|
||||||
|
<IonLabel>Biff</IonLabel>
|
||||||
|
<IonRadio slot="start" value="biff" />
|
||||||
|
</IonItem>
|
||||||
|
|
||||||
|
<IonItem>
|
||||||
|
<IonLabel>Griff</IonLabel>
|
||||||
|
<IonRadio slot="start" value="griff" />
|
||||||
|
</IonItem>
|
||||||
|
|
||||||
|
<IonItem>
|
||||||
|
<IonLabel>Buford</IonLabel>
|
||||||
|
<IonRadio slot="start" value="buford" />
|
||||||
|
</IonItem>
|
||||||
|
</IonRadioGroup>
|
||||||
|
</IonList>
|
||||||
|
<div className="button-search">
|
||||||
|
<IonButton color="primary">Cadastrar</IonButton>
|
||||||
|
</div>
|
||||||
|
</IonCardContent>
|
||||||
|
</IonCard>
|
||||||
|
</IonContent>
|
||||||
|
</IonPage>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -179,7 +179,7 @@ const CadastroVan: React.FC = () => {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
history.push({ pathname: '/perfil', state: {
|
history.push({ pathname: '/minhas-vans', state: {
|
||||||
redirectData: {
|
redirectData: {
|
||||||
showToastMessage: true,
|
showToastMessage: true,
|
||||||
toastColor: "success",
|
toastColor: "success",
|
||||||
|
|||||||
10
src/pages/MeusItinerarios/MeusItinerarios.css
Normal file
10
src/pages/MeusItinerarios/MeusItinerarios.css
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
.icons-location-divider{
|
||||||
|
margin-left: 0.33rem;
|
||||||
|
margin-bottom: 0.4rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.addresses-itinerary{
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
146
src/pages/MeusItinerarios/MeusItinerarios.tsx
Normal file
146
src/pages/MeusItinerarios/MeusItinerarios.tsx
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
import {
|
||||||
|
IonBackButton,
|
||||||
|
IonButtons,
|
||||||
|
IonCard,
|
||||||
|
IonCardContent,
|
||||||
|
IonCardHeader,
|
||||||
|
IonCardTitle,
|
||||||
|
IonContent,
|
||||||
|
IonFab,
|
||||||
|
IonFabButton,
|
||||||
|
IonHeader,
|
||||||
|
IonIcon,
|
||||||
|
IonPage,
|
||||||
|
IonTitle,
|
||||||
|
IonToolbar,
|
||||||
|
} from "@ionic/react";
|
||||||
|
import { add, locateOutline, locationOutline } from "ionicons/icons";
|
||||||
|
import { useState } from "react";
|
||||||
|
import "./MeusItinerarios.css";
|
||||||
|
|
||||||
|
interface ItineraryInfo {
|
||||||
|
id_itinerary: number;
|
||||||
|
van_plate: string;
|
||||||
|
days_of_week: number;
|
||||||
|
specific_day: string;
|
||||||
|
estimated_departure_time: string;
|
||||||
|
estimated_arrival_time: string;
|
||||||
|
available_seats: number;
|
||||||
|
price: number;
|
||||||
|
itinerary_nickname: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function MeusItinerarios() {
|
||||||
|
const [routes, setRoutes] = useState<ItineraryInfo[]>(
|
||||||
|
[
|
||||||
|
{
|
||||||
|
id_itinerary: 1,
|
||||||
|
van_plate: 'FSS1918',
|
||||||
|
days_of_week: 3,
|
||||||
|
specific_day: '24/08/2022',
|
||||||
|
estimated_departure_time: '10:00',
|
||||||
|
estimated_arrival_time: '12:00',
|
||||||
|
available_seats: 20,
|
||||||
|
price: 108.20,
|
||||||
|
itinerary_nickname: 'Itinerário teste',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id_itinerary: 1,
|
||||||
|
van_plate: 'FSS1918',
|
||||||
|
days_of_week: 3,
|
||||||
|
specific_day: '24/08/2022',
|
||||||
|
estimated_departure_time: '10:00',
|
||||||
|
estimated_arrival_time: '12:00',
|
||||||
|
available_seats: 20,
|
||||||
|
price: 108.20,
|
||||||
|
itinerary_nickname: 'Itinerário teste 2',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id_itinerary: 1,
|
||||||
|
van_plate: 'FSS1918',
|
||||||
|
days_of_week: 3,
|
||||||
|
specific_day: '24/08/2022',
|
||||||
|
estimated_departure_time: '10:00',
|
||||||
|
estimated_arrival_time: '12:00',
|
||||||
|
available_seats: 20,
|
||||||
|
price: 108.20,
|
||||||
|
itinerary_nickname: 'Itinerário teste',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id_itinerary: 1,
|
||||||
|
van_plate: 'FSS1918',
|
||||||
|
days_of_week: 3,
|
||||||
|
specific_day: '24/08/2022',
|
||||||
|
estimated_departure_time: '10:00',
|
||||||
|
estimated_arrival_time: '12:00',
|
||||||
|
available_seats: 20,
|
||||||
|
price: 108.20,
|
||||||
|
itinerary_nickname: 'Itinerário teste',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id_itinerary: 1,
|
||||||
|
van_plate: 'FSS1918',
|
||||||
|
days_of_week: 3,
|
||||||
|
specific_day: '24/08/2022',
|
||||||
|
estimated_departure_time: '10:00',
|
||||||
|
estimated_arrival_time: '12:00',
|
||||||
|
available_seats: 20,
|
||||||
|
price: 108.20,
|
||||||
|
itinerary_nickname: 'Itinerário teste',
|
||||||
|
},
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<IonPage>
|
||||||
|
<IonHeader translucent>
|
||||||
|
<IonToolbar>
|
||||||
|
<IonTitle>Meus Itinerários</IonTitle>
|
||||||
|
<IonButtons slot="start">
|
||||||
|
<IonBackButton text={""} defaultHref="/perfil" />
|
||||||
|
</IonButtons>
|
||||||
|
</IonToolbar>
|
||||||
|
</IonHeader>
|
||||||
|
<IonContent fullscreen>
|
||||||
|
<IonHeader collapse="condense">
|
||||||
|
<IonToolbar>
|
||||||
|
<IonTitle size="large">Meus Itinerários</IonTitle>
|
||||||
|
</IonToolbar>
|
||||||
|
</IonHeader>
|
||||||
|
{routes ? (
|
||||||
|
routes.map((itinerary, index) => {
|
||||||
|
return (
|
||||||
|
<IonCard key={index}>
|
||||||
|
<IonCardHeader>
|
||||||
|
<IonCardTitle>{itinerary.itinerary_nickname}</IonCardTitle>
|
||||||
|
</IonCardHeader>
|
||||||
|
<IonCardContent>
|
||||||
|
<div className="addresses-itinerary">
|
||||||
|
<IonIcon icon={locateOutline}></IonIcon>
|
||||||
|
Rua Francisco Glicerio, nº 100, Vila Novam aaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
</div>
|
||||||
|
<div className="icons-location-divider">
|
||||||
|
|
|
||||||
|
</div>
|
||||||
|
<div className="addresses-itinerary">
|
||||||
|
<IonIcon icon={locationOutline}></IonIcon>
|
||||||
|
PUC Campinas H15 Campus 1 aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
|
||||||
|
</div>
|
||||||
|
</IonCardContent>
|
||||||
|
</IonCard>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
) : (
|
||||||
|
<h1 className="msg-not-found">
|
||||||
|
Você ainda não possui nenhum itinerário cadastrado!
|
||||||
|
</h1>
|
||||||
|
)}
|
||||||
|
<IonFab vertical="bottom" horizontal="end" slot="fixed">
|
||||||
|
<IonFabButton size="small" href="/cadastrar-itinerario">
|
||||||
|
<IonIcon icon={add}></IonIcon>
|
||||||
|
</IonFabButton>
|
||||||
|
</IonFab>
|
||||||
|
</IonContent>
|
||||||
|
</IonPage>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -21,30 +21,40 @@ import {
|
|||||||
} from "@ionic/react";
|
} from "@ionic/react";
|
||||||
import { useHistory, useLocation } from "react-router-dom";
|
import { useHistory, useLocation } from "react-router-dom";
|
||||||
import React, { useState, useEffect, useReducer, useContext } from "react";
|
import React, { useState, useEffect, useReducer, useContext } from "react";
|
||||||
import { callOutline, cardOutline, carOutline, createOutline, exitOutline, logoFacebook, logoWhatsapp, personOutline, shieldCheckmarkOutline, starOutline } from "ionicons/icons";
|
import {
|
||||||
|
callOutline,
|
||||||
|
cardOutline,
|
||||||
|
carOutline,
|
||||||
|
createOutline,
|
||||||
|
exitOutline,
|
||||||
|
mapOutline,
|
||||||
|
personOutline,
|
||||||
|
shieldCheckmarkOutline,
|
||||||
|
starOutline,
|
||||||
|
} from "ionicons/icons";
|
||||||
|
|
||||||
import './Perfil.css'
|
import "./Perfil.css";
|
||||||
import LocalStorage from "../LocalStorage";
|
import LocalStorage from "../LocalStorage";
|
||||||
|
|
||||||
import sessionsService from '../services/functions/sessionsService'
|
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";
|
||||||
|
|
||||||
interface ScanNewProps {
|
interface ScanNewProps {
|
||||||
match: {
|
match: {
|
||||||
params: {
|
params: {
|
||||||
id: string;
|
id: string;
|
||||||
}
|
};
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
interface LocationState {
|
interface LocationState {
|
||||||
redirectData?: {
|
redirectData?: {
|
||||||
showToastMessage: boolean;
|
showToastMessage: boolean;
|
||||||
toastColor: Color;
|
toastColor: Color;
|
||||||
toastMessage: string;
|
toastMessage: string;
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const Perfil: React.FC<ScanNewProps> = (props) => {
|
const Perfil: React.FC<ScanNewProps> = (props) => {
|
||||||
@@ -53,92 +63,92 @@ const Perfil: React.FC<ScanNewProps> = (props) => {
|
|||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const location = useLocation<LocationState>();
|
const location = useLocation<LocationState>();
|
||||||
|
|
||||||
const [isVisitor, setIsVisitor] = useState(true)
|
const [isVisitor, setIsVisitor] = useState(true);
|
||||||
const [isDriver, setIsDriver] = useState(false)
|
const [isDriver, setIsDriver] = useState(false);
|
||||||
|
|
||||||
const [incompleteProfile, setIncompleteProfile] = useState(false)
|
const [incompleteProfile, setIncompleteProfile] = useState(false);
|
||||||
const [incompleteProfileCounter, setIncompleteProfileCounter] = useState(0)
|
const [incompleteProfileCounter, setIncompleteProfileCounter] = useState(0);
|
||||||
|
|
||||||
const [showToast, setShowToast] = useState(false);
|
const [showToast, setShowToast] = useState(false);
|
||||||
const [toastMessage, setToastMessage] = useState('');
|
const [toastMessage, setToastMessage] = useState("");
|
||||||
const [toastColor, setToastColor] = useState<Color>("primary");
|
const [toastColor, setToastColor] = useState<Color>("primary");
|
||||||
|
|
||||||
const [inputValues, setInputValues] = useReducer(
|
const [inputValues, setInputValues] = useReducer(
|
||||||
(state: any, newState: any) => ({ ...state, ...newState }),
|
(state: any, newState: any) => ({ ...state, ...newState }),
|
||||||
{
|
{
|
||||||
id: '',
|
id: "",
|
||||||
name: '',
|
name: "",
|
||||||
lastname: '',
|
lastname: "",
|
||||||
email: '',
|
email: "",
|
||||||
phone_number: '',
|
phone_number: "",
|
||||||
birth_date: '',
|
birth_date: "",
|
||||||
bio: '',
|
bio: "",
|
||||||
document_type: '',
|
document_type: "",
|
||||||
document: '',
|
document: "",
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
const redirectUserToLogin = () => {
|
const redirectUserToLogin = () => {
|
||||||
history.push({ pathname: '/login' });
|
history.push({ pathname: "/login" });
|
||||||
setToastMessage("Por favor, autentique-se!");
|
setToastMessage("Por favor, autentique-se!");
|
||||||
setShowToast(true);
|
setShowToast(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
const logoff = () => {
|
const logoff = () => {
|
||||||
LocalStorage.clearToken()
|
LocalStorage.clearToken();
|
||||||
user.setIsLoggedIn(false);
|
user.setIsLoggedIn(false);
|
||||||
history.push({ pathname: '/login' });
|
history.push({ pathname: "/login" });
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (location.state && location.state.redirectData) {
|
if (location.state && location.state.redirectData) {
|
||||||
const redirectData = location.state.redirectData
|
const redirectData = location.state.redirectData;
|
||||||
|
|
||||||
if (redirectData.showToastMessage) {
|
if (redirectData.showToastMessage) {
|
||||||
setToastColor(redirectData.toastColor)
|
setToastColor(redirectData.toastColor);
|
||||||
setToastMessage(redirectData.toastMessage)
|
setToastMessage(redirectData.toastMessage);
|
||||||
setShowToast(true)
|
setShowToast(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const loadUserData = async () => {
|
const loadUserData = async () => {
|
||||||
let userId = ''
|
let userId = "";
|
||||||
|
|
||||||
// verify if user is authenticated
|
// verify if user is authenticated
|
||||||
if (props.match.params.id) {
|
if (props.match.params.id) {
|
||||||
userId = props.match.params.id
|
userId = props.match.params.id;
|
||||||
} else {
|
} else {
|
||||||
const refreshSessionRes = await sessionsService.refreshSession()
|
const refreshSessionRes = await sessionsService.refreshSession();
|
||||||
|
|
||||||
if (refreshSessionRes.error) {
|
if (refreshSessionRes.error) {
|
||||||
redirectUserToLogin()
|
redirectUserToLogin();
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (refreshSessionRes.userId) {
|
if (refreshSessionRes.userId) {
|
||||||
userId = refreshSessionRes.userId
|
userId = refreshSessionRes.userId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// get user info by ID
|
// get user info by ID
|
||||||
const getByIdRes = await usersService.getById(userId)
|
const getByIdRes = await usersService.getById(userId);
|
||||||
|
|
||||||
if (getByIdRes.error) {
|
if (getByIdRes.error) {
|
||||||
if (isVisitor && props.match.params.id) {
|
if (isVisitor && props.match.params.id) {
|
||||||
setToastMessage('Usuário não existe!')
|
setToastMessage("Usuário não existe!");
|
||||||
setShowToast(true)
|
setShowToast(true);
|
||||||
history.push({ pathname: '/home' })
|
history.push({ pathname: "/home" });
|
||||||
} else {
|
} else {
|
||||||
setToastMessage(getByIdRes.error.errorMessage)
|
setToastMessage(getByIdRes.error.errorMessage);
|
||||||
setShowToast(true)
|
setShowToast(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// check if user is driver (if they have vans)
|
// check if user is driver (if they have vans)
|
||||||
const userIsDriverRes = await usersService.checkIfUserIsDriver(userId)
|
const userIsDriverRes = await usersService.checkIfUserIsDriver(userId);
|
||||||
|
|
||||||
// if (userIsDriverRes.error) {
|
// if (userIsDriverRes.error) {
|
||||||
// setToastColor('warning')
|
// setToastColor('warning')
|
||||||
// setToastMessage(userIsDriverRes.error.errorMessage)
|
// setToastMessage(userIsDriverRes.error.errorMessage)
|
||||||
@@ -147,91 +157,102 @@ const Perfil: React.FC<ScanNewProps> = (props) => {
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
if (!userIsDriverRes.error && userIsDriverRes.result !== undefined) {
|
if (!userIsDriverRes.error && userIsDriverRes.result !== undefined) {
|
||||||
setIsDriver(userIsDriverRes.result)
|
setIsDriver(userIsDriverRes.result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getByIdRes.userData) {
|
if (getByIdRes.userData) {
|
||||||
const userData = getByIdRes.userData
|
const userData = getByIdRes.userData;
|
||||||
|
|
||||||
if (isMounted) {
|
if (isMounted) {
|
||||||
setInputValues({
|
setInputValues({
|
||||||
'id': userId,
|
id: userId,
|
||||||
'name': userData.name,
|
name: userData.name,
|
||||||
'lastname': userData.lastname,
|
lastname: userData.lastname,
|
||||||
'email': userData.email,
|
email: userData.email,
|
||||||
'phone_number': userData.phone_number,
|
phone_number: userData.phone_number,
|
||||||
'birth_date': userData.birth_date,
|
birth_date: userData.birth_date,
|
||||||
'bio': userData.bio,
|
bio: userData.bio,
|
||||||
'document_type': userData.document_type,
|
document_type: userData.document_type,
|
||||||
'document': userData.document
|
document: userData.document,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!props.match.params.id) {
|
if (!props.match.params.id) {
|
||||||
setIsVisitor(false)
|
setIsVisitor(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userData.document || !userData.phone_number) {
|
if (!userData.document || !userData.phone_number) {
|
||||||
setIncompleteProfile(true)
|
setIncompleteProfile(true);
|
||||||
|
|
||||||
let counter = 0
|
let counter = 0;
|
||||||
|
|
||||||
if (!userData.document) counter++
|
if (!userData.document) counter++;
|
||||||
if (!userData.phone_number) counter++
|
if (!userData.phone_number) counter++;
|
||||||
|
|
||||||
setIncompleteProfileCounter(counter)
|
setIncompleteProfileCounter(counter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
let isMounted = true;
|
let isMounted = true;
|
||||||
|
|
||||||
const userToken = LocalStorage.getToken()
|
const userToken = LocalStorage.getToken();
|
||||||
|
|
||||||
if (!userToken) {
|
if (!userToken) {
|
||||||
redirectUserToLogin()
|
redirectUserToLogin();
|
||||||
}
|
}
|
||||||
|
|
||||||
loadUserData()
|
|
||||||
|
|
||||||
return () => { isMounted = false };
|
loadUserData();
|
||||||
|
|
||||||
|
return () => {
|
||||||
|
isMounted = false;
|
||||||
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<IonPage>
|
<IonPage>
|
||||||
<IonHeader>
|
<IonHeader translucent>
|
||||||
<IonToolbar>
|
<IonToolbar>
|
||||||
<IonTitle>Seu perfil</IonTitle>
|
<IonTitle>Seu perfil</IonTitle>
|
||||||
<IonButtons slot="start">
|
<IonButtons slot="start">
|
||||||
<IonBackButton defaultHref="/home" />
|
<IonBackButton text="" defaultHref="/home" />
|
||||||
</IonButtons>
|
</IonButtons>
|
||||||
</IonToolbar>
|
</IonToolbar>
|
||||||
</IonHeader>
|
</IonHeader>
|
||||||
|
|
||||||
<IonContent>
|
<IonContent fullscreen>
|
||||||
<IonHeader collapse="condense">
|
<IonHeader collapse="condense">
|
||||||
<IonToolbar>
|
<IonToolbar>
|
||||||
<IonTitle size="large">Seu perfil</IonTitle>
|
<IonTitle size="large">Seu perfil</IonTitle>
|
||||||
</IonToolbar>
|
</IonToolbar>
|
||||||
</IonHeader>
|
</IonHeader>
|
||||||
|
|
||||||
<IonCard>
|
<IonCard>
|
||||||
<IonCardContent>
|
<IonCardContent>
|
||||||
<img src="https://static.generated.photos/vue-static/home/feed/adult.png" alt="avatar" className='avatar' id='avatar'/>
|
<img
|
||||||
{/* <img src="https://lastfm.freetls.fastly.net/i/u/avatar170s/faa68f71f3b2a48ca89228c2c2aa72d3" alt="avatar" className='avatar' id='avatar'/> */}
|
src="https://static.generated.photos/vue-static/home/feed/adult.png"
|
||||||
|
alt="avatar"
|
||||||
|
className="avatar"
|
||||||
|
id="avatar"
|
||||||
|
/>
|
||||||
|
{/* <img src="https://lastfm.freetls.fastly.net/i/u/avatar170s/faa68f71f3b2a48ca89228c2c2aa72d3" alt="avatar" className='avatar' id='avatar'/> */}
|
||||||
<IonCardHeader>
|
<IonCardHeader>
|
||||||
<IonCardTitle class="ion-text-center">{inputValues.name} {inputValues.lastname}</IonCardTitle>
|
<IonCardTitle class="ion-text-center">
|
||||||
|
{inputValues.name} {inputValues.lastname}
|
||||||
|
</IonCardTitle>
|
||||||
</IonCardHeader>
|
</IonCardHeader>
|
||||||
|
|
||||||
<div id='profile-status'>
|
<div id="profile-status">
|
||||||
{ isDriver ?
|
{isDriver ? (
|
||||||
<>
|
<>
|
||||||
<IonChip>
|
<IonChip>
|
||||||
<IonIcon icon={carOutline}></IonIcon>
|
<IonIcon icon={carOutline}></IonIcon>
|
||||||
<IonLabel color="primary">Motorista</IonLabel>
|
<IonLabel color="primary">Motorista</IonLabel>
|
||||||
</IonChip>
|
</IonChip>
|
||||||
</> : <></>
|
</>
|
||||||
}
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
<IonChip>
|
<IonChip>
|
||||||
<IonIcon icon={personOutline}></IonIcon>
|
<IonIcon icon={personOutline}></IonIcon>
|
||||||
<IonLabel color="primary">Passageiro</IonLabel>
|
<IonLabel color="primary">Passageiro</IonLabel>
|
||||||
@@ -245,7 +266,7 @@ const Perfil: React.FC<ScanNewProps> = (props) => {
|
|||||||
<IonCardTitle>Biografia</IonCardTitle>
|
<IonCardTitle>Biografia</IonCardTitle>
|
||||||
</IonCardHeader>
|
</IonCardHeader>
|
||||||
<IonCardContent>
|
<IonCardContent>
|
||||||
{inputValues.bio ? inputValues.bio : 'Sem biografia.' }
|
{inputValues.bio ? inputValues.bio : "Sem biografia."}
|
||||||
</IonCardContent>
|
</IonCardContent>
|
||||||
</IonCard>
|
</IonCard>
|
||||||
|
|
||||||
@@ -254,67 +275,123 @@ const Perfil: React.FC<ScanNewProps> = (props) => {
|
|||||||
<IonCardTitle>Informações de contato</IonCardTitle>
|
<IonCardTitle>Informações de contato</IonCardTitle>
|
||||||
</IonCardHeader>
|
</IonCardHeader>
|
||||||
<IonCardContent>
|
<IonCardContent>
|
||||||
{ !inputValues.phone_number ?
|
{!inputValues.phone_number ? (
|
||||||
<>Sem informações de contato.</>
|
<>Sem informações de contato.</>
|
||||||
: <>
|
) : (
|
||||||
{
|
<>
|
||||||
inputValues.phone_number ?
|
{inputValues.phone_number ? (
|
||||||
<>
|
<>
|
||||||
<IonChip>
|
<IonChip>
|
||||||
<IonIcon icon={callOutline} />
|
<IonIcon icon={callOutline} />
|
||||||
<IonLabel>{inputValues.phone_number}</IonLabel>
|
<IonLabel>{inputValues.phone_number}</IonLabel>
|
||||||
</IonChip>
|
</IonChip>
|
||||||
</> : <></>
|
</>
|
||||||
}
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
}
|
)}
|
||||||
</IonCardContent>
|
</IonCardContent>
|
||||||
</IonCard>
|
</IonCard>
|
||||||
|
|
||||||
{ !isVisitor ?
|
{!isVisitor ? (
|
||||||
<IonList>
|
<IonList>
|
||||||
<IonListHeader>Configurações</IonListHeader>
|
<IonListHeader>Configurações</IonListHeader>
|
||||||
<IonItem button onClick={() => history.push({ pathname: '/perfil/editar', state: { userData: inputValues } })}>
|
<IonItem
|
||||||
<IonIcon icon={createOutline} slot="start" />
|
button
|
||||||
<IonLabel>Editar perfil</IonLabel>
|
onClick={() =>
|
||||||
</IonItem>
|
history.push({
|
||||||
|
pathname: "/perfil/editar",
|
||||||
|
state: { userData: inputValues },
|
||||||
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<IonIcon icon={createOutline} slot="start" />
|
||||||
|
<IonLabel>Editar perfil</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
|
||||||
{ incompleteProfile ?
|
{incompleteProfile ? (
|
||||||
<>
|
<>
|
||||||
<IonItem button onClick={() => history.push({ pathname: '/perfil/completar', state: { userData: inputValues } })}>
|
<IonItem
|
||||||
<IonIcon icon={shieldCheckmarkOutline} slot="start" />
|
button
|
||||||
<IonLabel>Completar cadastro</IonLabel>
|
onClick={() =>
|
||||||
<IonBadge color="primary">{incompleteProfileCounter}</IonBadge>
|
history.push({
|
||||||
</IonItem>
|
pathname: "/perfil/completar",
|
||||||
</>
|
state: { userData: inputValues },
|
||||||
: <></> }
|
})
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<IonIcon icon={shieldCheckmarkOutline} slot="start" />
|
||||||
|
<IonLabel>Completar cadastro</IonLabel>
|
||||||
|
<IonBadge color="primary">
|
||||||
|
{incompleteProfileCounter}
|
||||||
|
</IonBadge>
|
||||||
|
</IonItem>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
|
||||||
<IonItem button onClick={() => history.push({ pathname: '/cadastro-van'})}>
|
<IonItem
|
||||||
<IonIcon icon={carOutline} slot="start" />
|
button
|
||||||
<IonLabel>Cadastrar Van</IonLabel>
|
onClick={() => history.push({ pathname: "/cadastro-van" })}
|
||||||
</IonItem>
|
>
|
||||||
<IonItem button onClick={() => history.push({ pathname: '/minhas-vans'})}>
|
<IonIcon icon={carOutline} slot="start" />
|
||||||
<IonIcon icon={carOutline} slot="start" />
|
<IonLabel>Cadastrar van</IonLabel>
|
||||||
<IonLabel>Minhas Vans</IonLabel>
|
</IonItem>
|
||||||
</IonItem>
|
|
||||||
<IonItem>
|
{isDriver ? (
|
||||||
<IonIcon icon={cardOutline} slot="start" />
|
<>
|
||||||
<IonLabel>Pagamentos</IonLabel>
|
<IonItem
|
||||||
</IonItem>
|
button
|
||||||
<IonItem>
|
onClick={() => history.push({ pathname: "/minhas-vans" })}
|
||||||
<IonIcon icon={starOutline} slot="start" />
|
>
|
||||||
<IonLabel>Avaliações</IonLabel>
|
<IonIcon icon={carOutline} slot="start" />
|
||||||
</IonItem>
|
<IonLabel>Minhas vans</IonLabel>
|
||||||
<IonItem button onClick={logoff}>
|
</IonItem>
|
||||||
<IonIcon icon={exitOutline} slot="start" />
|
<IonItem
|
||||||
<IonLabel>Sair da conta</IonLabel>
|
button
|
||||||
</IonItem>
|
onClick={() =>
|
||||||
</IonList> : <></>
|
history.push({ pathname: "/buscar-passageiro" })
|
||||||
}
|
}
|
||||||
|
>
|
||||||
|
<IonIcon icon={personOutline} slot="start" />
|
||||||
|
<IonLabel>Buscar passageiros</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
<IonItem
|
||||||
|
button
|
||||||
|
onClick={() =>
|
||||||
|
history.push({ pathname: "/meus-itinerarios" })
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<IonIcon icon={mapOutline} slot="start" />
|
||||||
|
<IonLabel>Meus itinerários</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
|
||||||
|
<IonItem>
|
||||||
|
<IonIcon icon={cardOutline} slot="start" />
|
||||||
|
<IonLabel>Pagamentos</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
<IonItem>
|
||||||
|
<IonIcon icon={starOutline} slot="start" />
|
||||||
|
<IonLabel>Avaliações</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
<IonItem button onClick={logoff}>
|
||||||
|
<IonIcon icon={exitOutline} slot="start" />
|
||||||
|
<IonLabel>Sair da conta</IonLabel>
|
||||||
|
</IonItem>
|
||||||
|
</IonList>
|
||||||
|
) : (
|
||||||
|
<></>
|
||||||
|
)}
|
||||||
|
|
||||||
<IonToast
|
<IonToast
|
||||||
position="top"
|
position="top"
|
||||||
color={toastColor}
|
color={toastColor}
|
||||||
isOpen={showToast}
|
isOpen={showToast}
|
||||||
onDidDismiss={() => setShowToast(false)}
|
onDidDismiss={() => setShowToast(false)}
|
||||||
message={toastMessage}
|
message={toastMessage}
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ import {
|
|||||||
} from "ionicons/icons";
|
} from "ionicons/icons";
|
||||||
import { useEffect, useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
import { useHistory, useLocation } from "react-router";
|
import { useHistory, useLocation } from "react-router";
|
||||||
import { getTransportes } from "../../services/transportes";
|
import { getTransportes } from "../../services/functions/transportsService";
|
||||||
import { createUserSearch } from "../../services/api/users";
|
import { createUserSearch } from "../../services/api/users";
|
||||||
import "./Transportes.css";
|
import "./Transportes.css";
|
||||||
|
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import axios from "axios";
|
|
||||||
|
|
||||||
export class ApiClient{
|
|
||||||
private static api = axios.create({
|
|
||||||
baseURL: "http://localhost:8080"
|
|
||||||
});
|
|
||||||
|
|
||||||
public static async doPost (url: string, body: any): Promise<any> {
|
|
||||||
return await this.api
|
|
||||||
.post(url, body)
|
|
||||||
.then(res => {
|
|
||||||
console.log(res.data);
|
|
||||||
})
|
|
||||||
.catch(error => {
|
|
||||||
console.log(error);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
}
|
|
||||||
38
src/services/api/transports.ts
Normal file
38
src/services/api/transports.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import instance from './api';
|
||||||
|
// import LocalStorage from '../LocalStorage';
|
||||||
|
|
||||||
|
import transportsRoutes from '../../constants/routes/transportsRoutes';
|
||||||
|
import { AxiosRequestHeaders } from 'axios';
|
||||||
|
import LocalStorage from '../../LocalStorage';
|
||||||
|
import { setStore } from '../../store/RecordsStore';
|
||||||
|
|
||||||
|
let token: string;
|
||||||
|
let header: AxiosRequestHeaders;
|
||||||
|
|
||||||
|
function updateHeader() {
|
||||||
|
token = LocalStorage.getToken();
|
||||||
|
|
||||||
|
header = {
|
||||||
|
"Accept": 'application/json',
|
||||||
|
"Content-Type": 'application/json',
|
||||||
|
"Authorization": 'Bearer ' + token
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface getTransportsRequest {
|
||||||
|
coordinatesFrom: {
|
||||||
|
lat: number,
|
||||||
|
lng: number
|
||||||
|
},
|
||||||
|
coordinatesTo: {
|
||||||
|
lat: number,
|
||||||
|
lng: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function get(coordinates: getTransportsRequest) {
|
||||||
|
updateHeader();
|
||||||
|
|
||||||
|
const response = await instance.get(transportsRoutes.get.url + `/${coordinates}`, { headers: header });
|
||||||
|
return response.data;
|
||||||
|
}
|
||||||
20
src/services/functions/transportsService.ts
Normal file
20
src/services/functions/transportsService.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import * as transportsRoutes from '../api/transports';
|
||||||
|
|
||||||
|
interface CoordinatesRequest {
|
||||||
|
coordinatesFrom:{
|
||||||
|
lat: number,
|
||||||
|
lng: number
|
||||||
|
},
|
||||||
|
coordinatesTo:{
|
||||||
|
lat: number,
|
||||||
|
lng: number
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getTransportes(request: CoordinatesRequest) : Promise<any> {
|
||||||
|
try {
|
||||||
|
let res : any = await transportsRoutes.get(request);
|
||||||
|
} catch (error) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
import instance from "../services/api/api";
|
|
||||||
import { setStore } from "../store/RecordsStore";
|
|
||||||
// import LocalStorage from '../LocalStorage';
|
|
||||||
|
|
||||||
// let token:string;
|
|
||||||
let header: string;
|
|
||||||
|
|
||||||
function updateHeader() {
|
|
||||||
// token = LocalStorage.getToken();
|
|
||||||
header = `{
|
|
||||||
"Accept": 'application/json',
|
|
||||||
"Content-Type": 'application/json',
|
|
||||||
"Authorization": 'Bearer ' + token
|
|
||||||
}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
interface CoordinatesRequest {
|
|
||||||
coordinatesFrom:{
|
|
||||||
lat: number,
|
|
||||||
lng: number
|
|
||||||
},
|
|
||||||
coordinatesTo:{
|
|
||||||
lat: number,
|
|
||||||
lng: number
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function getTransportes(request: CoordinatesRequest) {
|
|
||||||
updateHeader();
|
|
||||||
|
|
||||||
console.log(request)
|
|
||||||
const response = await instance.post("http://localhost:3333/transportes/", request);
|
|
||||||
return response.data as [];
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user