Merge branch 'develop' of https://github.com/CloudAlb/tcc-vamos-frontend into feature/VAN-16-view-create-itinerary

This commit is contained in:
Hugo Falcao
2022-09-11 22:38:27 -03:00
40 changed files with 1279 additions and 13306 deletions

View File

@@ -1,30 +1,29 @@
import * as carsRoutes from "../api/cars";
interface getAllCarModelsReturn {
data?: {
id_model: string;
name: string;
}[];
interface CarObject {
codigo: string;
nome: string;
}
interface getAllCarBrandsReturn {
data?: CarObject[];
error?: {
errorMessage: string;
};
}
interface getAllCarModelsRes {
interface getAllCarBrandsRes {
status?: string;
message: string;
data?: {
id_model: string;
name: string;
}[];
data?: CarObject[];
}
const getAllCarModels = async (): Promise<getAllCarModelsReturn> => {
const getAllCarBrands = async (): Promise<getAllCarBrandsReturn> => {
try {
let res: getAllCarModelsRes = await carsRoutes.list();
let res: getAllCarBrandsRes = await carsRoutes.listAllBrands();
if (res.status === "error") {
return {
@@ -40,14 +39,36 @@ const getAllCarModels = async (): Promise<getAllCarModelsReturn> => {
} catch (err) {
return {
error: {
errorMessage: "Por favor, autentique-se.",
errorMessage: "Por favor, tente novamente.",
},
};
}
};
const method = {
getAllCarModels,
const getCarModels = async (
carBrandId: string
): Promise<getAllCarBrandsReturn> => {
try {
let res: getAllCarBrandsRes = await carsRoutes.listCarModels(carBrandId);
if (res.status === "error") {
return {
error: {
errorMessage: res.message,
},
};
}
return {
data: res.data,
};
} catch (err) {
return {
error: {
errorMessage: "Por favor, tente novamente.",
},
};
}
};
export default method;
export default { getAllCarBrands, getCarModels };

View File

@@ -0,0 +1,38 @@
import * as itinerariesRoutes from '../api/itineraries';
interface CoordinatesRequest {
coordinatesFrom: {
lat: number,
lng: number
},
coordinatesTo: {
lat: number,
lng: number
}
}
export async function getAllItineraries(): Promise<any> {
let res: any;
try {
res = await itinerariesRoutes.get();
} catch (error) {
// TODO
}
return res.data
}
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
}
export default { getAllItineraries, searchItineraries }

View File

@@ -1,18 +0,0 @@
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) {}
}