fix: 🐛 Fix a bugs of merge with develop
This commit is contained in:
@@ -1 +1,7 @@
|
||||
# tcc-vamos-frontend
|
||||
|
||||
# Primeiros passos para iniciar o desenvolvimento
|
||||
|
||||
- Rode o comando ```yarn``` para instalar as dependencias do projeto
|
||||
- Para iniciar o desenvolvimento de uma nova funcionalidade crie uma branch
|
||||
- Ao terminar o desenvolvimento abra um pull request para a branch "develop" e resolva os conflitos caso tenha
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
"@types/react-router": "^5.1.11",
|
||||
"@types/react-router-dom": "^5.1.7",
|
||||
"axios": "^0.26.1",
|
||||
"caniuse-lite": "1.0.30001393",
|
||||
"cross-env": "^7.0.3",
|
||||
"ionicons": "^5.4.0",
|
||||
"lodash.isequal": "^4.5.0",
|
||||
|
||||
@@ -26,15 +26,21 @@ import "./BuscarItinerario.css";
|
||||
|
||||
import itinerariesService from "../services/functions/itinerariesService";
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import { useState } from "react";
|
||||
import { useHistory } from "react-router";
|
||||
|
||||
import { geocodeByAddress, getLatLng } from "react-google-places-autocomplete";
|
||||
import { PageHeader } from "../components/PageHeader";
|
||||
import { Itinerary } from "../models/itinerary.model";
|
||||
import { closeToast } from "../services/utils";
|
||||
|
||||
import { Color } from "@ionic/core";
|
||||
import AutoCompleteInput from "../components/AutoCompleteInput";
|
||||
|
||||
interface Address {
|
||||
formatted_address: string;
|
||||
lat: number;
|
||||
lng: number;
|
||||
}
|
||||
|
||||
const BuscarItinerario: React.FC = () => {
|
||||
const history = useHistory();
|
||||
@@ -43,9 +49,9 @@ const BuscarItinerario: React.FC = () => {
|
||||
const [messageToast, setMessageToast] = useState("");
|
||||
const [toastColor, setToastColor] = useState<Color>("primary");
|
||||
|
||||
const [addressFrom, setAddressFrom] = useState<any>("");
|
||||
const [addressFrom, setAddressFrom] = useState<Address>();
|
||||
const [coordinatesFrom, setCoordinatesFrom] = useState<any>("");
|
||||
const [addressTo, setAddressTo] = useState<any>("");
|
||||
const [addressTo, setAddressTo] = useState<Address>();
|
||||
const [coordinatesTo, setCoordinatesTo] = useState<any>("");
|
||||
const [showModalEnd, setShowModalEnd] = useState(false);
|
||||
const [addressResults, setAddressResults] = useState<any[]>([]);
|
||||
@@ -88,24 +94,8 @@ const BuscarItinerario: React.FC = () => {
|
||||
// setShowModalEnd(false);
|
||||
// }
|
||||
|
||||
useEffect(() => {
|
||||
if (addressFrom.label && addressFrom.label.length > 0) {
|
||||
geocodeByAddress(addressFrom.label)
|
||||
.then((results) => getLatLng(results[0]))
|
||||
.then(({ lat, lng }) => setCoordinatesFrom({ lat, lng }));
|
||||
}
|
||||
}, [addressFrom]);
|
||||
|
||||
useEffect(() => {
|
||||
if (addressTo.label && addressTo.label.length > 0) {
|
||||
geocodeByAddress(addressTo.label)
|
||||
.then((results) => getLatLng(results[0]))
|
||||
.then(({ lat, lng }) => setCoordinatesTo({ lat, lng }));
|
||||
}
|
||||
}, [addressTo]);
|
||||
|
||||
async function buscarItinerarios() {
|
||||
if (!coordinatesFrom || !coordinatesTo || !addressFrom || !addressTo) {
|
||||
if (!addressFrom || !addressTo) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -120,16 +110,16 @@ const BuscarItinerario: React.FC = () => {
|
||||
setRecentSearches((arr) => [
|
||||
...arr,
|
||||
{
|
||||
addressFrom: addressFrom.label,
|
||||
addressTo: addressTo.label,
|
||||
addressFrom: addressFrom.formatted_address,
|
||||
addressTo: addressTo.formatted_address,
|
||||
time: Date.now(),
|
||||
},
|
||||
]);
|
||||
|
||||
await itinerariesService
|
||||
.searchItineraries({
|
||||
coordinatesFrom,
|
||||
coordinatesTo,
|
||||
coordinatesFrom: addressFrom,
|
||||
coordinatesTo: addressTo,
|
||||
})
|
||||
.then((response) => {
|
||||
// if (response.status === "error") {
|
||||
@@ -166,41 +156,21 @@ const BuscarItinerario: React.FC = () => {
|
||||
<IonCardContent>
|
||||
<div className="inputs-from-to">
|
||||
<IonIcon icon={locateOutline}></IonIcon>
|
||||
{/* <IonSearchbar
|
||||
showClearButton="never"
|
||||
onClick={() => setInputActiveOpenModal("from")}
|
||||
value={addressFrom}
|
||||
placeholder="R. José Paulino, 1234 - Centro, Campinas - SP, 13013-001"
|
||||
/> */}
|
||||
{/* <GooglePlacesAutocomplete
|
||||
apiKey={process.env.REACT_APP_KEY_API}
|
||||
apiOptions={{ language: "pt-br", region: "br" }}
|
||||
selectProps={{
|
||||
value: addressFrom,
|
||||
onChange: setAddressFrom,
|
||||
className: "input-autocomplete",
|
||||
placeholder: "R. José Paulino, 1234",
|
||||
}}
|
||||
/> */}
|
||||
<AutoCompleteInput
|
||||
placeholder="R. José Paulino, 1234"
|
||||
className="ml-2"
|
||||
onAddressSelected={(address: Address) =>
|
||||
setAddressFrom(address)
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="inputs-from-to">
|
||||
<IonIcon icon={locationOutline}></IonIcon>
|
||||
{/* <IonSearchbar
|
||||
showClearButton="never"
|
||||
onClick={() => setInputActiveOpenModal("to")}
|
||||
value={addressTo}
|
||||
<AutoCompleteInput
|
||||
placeholder="PUC Campinas"
|
||||
/> */}
|
||||
{/* <GooglePlacesAutocomplete
|
||||
apiKey={process.env.REACT_APP_KEY_API}
|
||||
apiOptions={{ language: "pt-br", region: "br" }}
|
||||
selectProps={{
|
||||
value: addressTo,
|
||||
onChange: setAddressTo,
|
||||
className: "input-autocomplete",
|
||||
placeholder: "PUC Campinas",
|
||||
}}
|
||||
/> */}
|
||||
className="ml-2"
|
||||
onAddressSelected={(address: Address) => setAddressTo(address)}
|
||||
/>
|
||||
</div>
|
||||
<div className="button-search">
|
||||
<IonButton color="primary" onClick={() => buscarItinerarios()}>
|
||||
@@ -216,35 +186,32 @@ const BuscarItinerario: React.FC = () => {
|
||||
<IonRow class="latest-searches">
|
||||
{recentSearches.map((search, index) => {
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<IonRow
|
||||
key={index}
|
||||
class="latest-searches"
|
||||
onClick={() => {
|
||||
fillSearchBars(search.addressFrom, search.addressTo);
|
||||
}}
|
||||
>
|
||||
<IonIcon
|
||||
className="icon-align-vcenter"
|
||||
size="large"
|
||||
icon={timeOutline}
|
||||
></IonIcon>
|
||||
<div className="div_from_to">
|
||||
<span>{search.addressFrom}</span>
|
||||
<IonIcon icon={arrowForwardOutline}></IonIcon>
|
||||
<span>{search.addressTo}</span>
|
||||
<br />
|
||||
<small>{search.time}</small>
|
||||
</div>
|
||||
<IonIcon
|
||||
className="icon-forward icon-align-vcenter"
|
||||
size="large"
|
||||
icon={chevronForwardOutline}
|
||||
></IonIcon>
|
||||
</IonRow>
|
||||
</div>
|
||||
</>
|
||||
<div key={index}>
|
||||
<IonRow
|
||||
class="latest-searches"
|
||||
onClick={() => {
|
||||
fillSearchBars(search.addressFrom, search.addressTo);
|
||||
}}
|
||||
>
|
||||
<IonIcon
|
||||
className="icon-align-vcenter"
|
||||
size="large"
|
||||
icon={timeOutline}
|
||||
></IonIcon>
|
||||
<div className="div_from_to">
|
||||
<span>{search.addressFrom}</span>
|
||||
<IonIcon icon={arrowForwardOutline}></IonIcon>
|
||||
<span>{search.addressTo}</span>
|
||||
<br />
|
||||
<small>{search.time}</small>
|
||||
</div>
|
||||
<IonIcon
|
||||
className="icon-forward icon-align-vcenter"
|
||||
size="large"
|
||||
icon={chevronForwardOutline}
|
||||
></IonIcon>
|
||||
</IonRow>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</IonRow>
|
||||
|
||||
@@ -1,9 +1,12 @@
|
||||
import { Color } from "@ionic/core";
|
||||
import {
|
||||
IonBackButton,
|
||||
IonButton,
|
||||
IonButtons,
|
||||
IonCheckbox,
|
||||
IonContent,
|
||||
IonDatetime,
|
||||
IonHeader,
|
||||
IonIcon,
|
||||
IonInput,
|
||||
IonItem,
|
||||
@@ -15,7 +18,9 @@ import {
|
||||
IonSelectOption,
|
||||
IonSlide,
|
||||
IonSlides,
|
||||
IonTitle,
|
||||
IonToast,
|
||||
IonToolbar,
|
||||
} from "@ionic/react";
|
||||
import {
|
||||
add,
|
||||
@@ -23,6 +28,7 @@ import {
|
||||
arrowBack,
|
||||
arrowForward,
|
||||
checkmark,
|
||||
close,
|
||||
informationCircle,
|
||||
locateOutline,
|
||||
locationOutline,
|
||||
@@ -31,7 +37,7 @@ import {
|
||||
import { useEffect, useRef, useState } from "react";
|
||||
import { useHistory } from "react-router";
|
||||
import AutoCompleteInput from "../../components/AutoCompleteInput";
|
||||
import * as vansRoutes from "../../services/api/vans";
|
||||
import * as vehiclesRoutes from "../../services/api/vehicles";
|
||||
import sessionsService from "../../services/functions/sessionsService";
|
||||
|
||||
const slideOpts = {
|
||||
@@ -143,9 +149,9 @@ export default function CadastrarItinerario() {
|
||||
userId = refreshSessionRes.userId;
|
||||
}
|
||||
|
||||
vansRoutes
|
||||
vehiclesRoutes
|
||||
.getByUserId(userId)
|
||||
.then((response) => {
|
||||
.then((response: any) => {
|
||||
if (response.status === "error") {
|
||||
setToastColor("danger");
|
||||
setToastMessage(response.message);
|
||||
@@ -156,7 +162,7 @@ export default function CadastrarItinerario() {
|
||||
|
||||
setVans(response.data);
|
||||
})
|
||||
.catch((err) => {
|
||||
.catch((err: any) => {
|
||||
setToastColor("danger");
|
||||
setToastMessage(err);
|
||||
setShowToast(true);
|
||||
@@ -178,10 +184,14 @@ export default function CadastrarItinerario() {
|
||||
|
||||
return (
|
||||
<IonPage>
|
||||
<PageHeader
|
||||
pageName="Cadastrar itinerário"
|
||||
backButtonPageUrl="/perfil"
|
||||
></PageHeader>
|
||||
<IonHeader>
|
||||
<IonToolbar>
|
||||
<IonTitle>Cadastrar Itinerário</IonTitle>
|
||||
<IonButtons slot="start">
|
||||
<IonBackButton icon={close} text="" defaultHref="/perfil" />
|
||||
</IonButtons>
|
||||
</IonToolbar>
|
||||
</IonHeader>
|
||||
|
||||
<IonContent fullscreen>
|
||||
<IonSlides ref={mySlides} options={slideOpts}>
|
||||
|
||||
@@ -1,22 +1,16 @@
|
||||
import {
|
||||
IonToast,
|
||||
IonItem,
|
||||
IonLabel,
|
||||
IonInput,
|
||||
IonBackButton,
|
||||
IonButton,
|
||||
IonButtons,
|
||||
IonContent,
|
||||
IonHeader,
|
||||
IonPage,
|
||||
IonToolbar,
|
||||
IonTitle,
|
||||
IonList,
|
||||
IonCheckbox,
|
||||
IonListHeader,
|
||||
IonContent,
|
||||
IonInput,
|
||||
IonItem,
|
||||
IonItemDivider,
|
||||
IonLabel,
|
||||
IonList,
|
||||
IonPage,
|
||||
IonSelect,
|
||||
IonSelectOption,
|
||||
IonItemDivider,
|
||||
IonToast,
|
||||
} from "@ionic/react";
|
||||
|
||||
import React, { useEffect, useReducer, useState } from "react";
|
||||
@@ -28,10 +22,10 @@ import carsService from "../services/functions/carsService";
|
||||
|
||||
import * as vehiclesRoutes from "../services/api/vehicles";
|
||||
|
||||
import "./VeiculoCadastro.css";
|
||||
import { Color } from "@ionic/core";
|
||||
import { closeToast } from "../services/utils";
|
||||
import { PageHeader } from "../components/PageHeader";
|
||||
import { closeToast } from "../services/utils";
|
||||
import "./VeiculoCadastro.css";
|
||||
|
||||
const VeiculoCadastro: React.FC = () => {
|
||||
const history = useHistory();
|
||||
@@ -209,7 +203,7 @@ const VeiculoCadastro: React.FC = () => {
|
||||
}
|
||||
|
||||
history.push({
|
||||
pathname: "/minhas-vehicles",
|
||||
pathname: "/veiculos/meus",
|
||||
state: {
|
||||
redirectData: {
|
||||
showToastMessage: true,
|
||||
@@ -262,7 +256,9 @@ const VeiculoCadastro: React.FC = () => {
|
||||
|
||||
<IonContent>
|
||||
<IonList lines="full" class="ion-no-margin">
|
||||
<IonItemDivider color={"primary"}>Informações do veículo</IonItemDivider>
|
||||
<IonItemDivider color={"primary"}>
|
||||
Informações do veículo
|
||||
</IonItemDivider>
|
||||
<IonItem>
|
||||
<IonLabel position="fixed">Placa </IonLabel>
|
||||
<IonInput
|
||||
|
||||
@@ -1,14 +1,16 @@
|
||||
import * as itinerariesRoutes from '../api/itineraries';
|
||||
import * as itinerariesRoutes from "../api/itineraries";
|
||||
|
||||
interface CoordinatesRequest {
|
||||
coordinatesFrom: {
|
||||
lat: number,
|
||||
lng: number
|
||||
},
|
||||
formatted_address: string;
|
||||
lat: number;
|
||||
lng: number;
|
||||
};
|
||||
coordinatesTo: {
|
||||
lat: number,
|
||||
lng: number
|
||||
}
|
||||
formatted_address: string;
|
||||
lat: number;
|
||||
lng: number;
|
||||
};
|
||||
}
|
||||
|
||||
export async function getAllItineraries(): Promise<any> {
|
||||
@@ -20,19 +22,21 @@ export async function getAllItineraries(): Promise<any> {
|
||||
// TODO
|
||||
}
|
||||
|
||||
return res.data
|
||||
return res.data;
|
||||
}
|
||||
|
||||
|
||||
export async function searchItineraries({ coordinatesFrom, coordinatesTo }: CoordinatesRequest): Promise<any> {
|
||||
let res: any
|
||||
export async function searchItineraries({
|
||||
coordinatesFrom,
|
||||
coordinatesTo,
|
||||
}: CoordinatesRequest): Promise<any> {
|
||||
let res: any;
|
||||
try {
|
||||
res = await itinerariesRoutes.search(coordinatesFrom, coordinatesTo);
|
||||
} catch (error) {
|
||||
// TODO
|
||||
}
|
||||
|
||||
return res.data
|
||||
return res.data;
|
||||
}
|
||||
|
||||
export default { getAllItineraries, searchItineraries }
|
||||
export default { getAllItineraries, searchItineraries };
|
||||
|
||||
Reference in New Issue
Block a user