This commit is contained in:
Hugo Falcao
2022-09-06 20:49:00 -03:00
parent 33fd007755
commit e8209762c0
19 changed files with 1500 additions and 720 deletions

View File

@@ -8,20 +8,18 @@ interface getAllCarModelsReturn {
error?: {
errorMessage: string;
}
};
}
interface getAllCarModelsRes {
status?: string;
message: string
message: string;
data?: {
id_model: string;
name: string;
}[];
}
const getAllCarModels = async (): Promise<getAllCarModelsReturn> => {
@@ -48,4 +46,8 @@ const getAllCarModels = async (): Promise<getAllCarModelsReturn> => {
}
};
export default { getAllCarModels };
const method = {
getAllCarModels,
};
export default method;

View File

@@ -14,7 +14,7 @@ interface refreshSessionResponse {
const refreshSession = async (): Promise<refreshSessionReturn> => {
try {
let res: refreshSessionResponse = await sessionRoutes.refresh()
let res: refreshSessionResponse = await sessionRoutes.refresh();
if (res.status === "error") {
return {
@@ -26,7 +26,7 @@ const refreshSession = async (): Promise<refreshSessionReturn> => {
return {
userId: res.userId,
};
} catch(err) {
} catch (err) {
return {
error: true,
errorMessage: "Por favor, autentique-se.",
@@ -40,7 +40,11 @@ const refreshSession = async (): Promise<refreshSessionReturn> => {
// } else {
// // Anything else
// }
// }
// }
};
export default { refreshSession }
const method = {
refreshSession,
};
export default method;

View File

@@ -1,20 +1,18 @@
import * as transportsRoutes from '../api/transports';
interface CoordinatesRequest {
coordinatesFrom:{
lat: number,
lng: number
},
coordinatesTo:{
lat: number,
lng: number
}
coordinatesFrom: {
lat: number;
lng: number;
};
coordinatesTo: {
lat: number;
lng: number;
};
}
export async function getTransportes(request: CoordinatesRequest) : Promise<any> {
export async function getTransportes(
request: CoordinatesRequest
): Promise<any> {
try {
let res : any = await transportsRoutes.get(request);
} catch (error) {
}
// let res : any = await transportsRoutes.get(request);
} catch (error) {}
}

View File

@@ -10,10 +10,10 @@ interface getByIdReturn {
bio: string;
document_type: string;
document: string;
},
};
error?: {
errorMessage: string;
}
};
}
interface getByIdRes {
@@ -29,65 +29,67 @@ interface getByIdRes {
bio: string;
document_type: string;
document: string;
},
};
}
const getById = async (userId: string): Promise<getByIdReturn> => {
export const getById = async (userId: string): Promise<getByIdReturn> => {
try {
let res: getByIdRes = await usersRoutes.getById(userId)
let res: getByIdRes = await usersRoutes.getById(userId);
if (res.status === "error") {
return {
error: {
errorMessage: res.message,
}
},
};
}
return {
userData: res.data,
};
} catch(err) {
} catch (err) {
return {
error: {
errorMessage: "Por favor, autentique-se.",
}
},
};
}
};
interface getByIdReturn {
data?: {
phone: '',
whatsapp: '',
facebook: '',
telegram: '',
},
phone: "";
whatsapp: "";
facebook: "";
telegram: "";
};
error?: {
errorMessage: string;
}
};
}
const getUserSocialInfo = async (userId: string): Promise<getByIdReturn> => {
export const getUserSocialInfo = async (
userId: string
): Promise<getByIdReturn> => {
try {
let res: getByIdRes = await usersRoutes.getSocialInfo(userId)
let res: getByIdRes = await usersRoutes.getSocialInfo(userId);
if (res.status === "error") {
return {
error: {
errorMessage: res.message,
}
},
};
}
return {
userData: res.data,
};
} catch(err) {
} catch (err) {
return {
error: {
errorMessage: "Por favor, autentique-se.",
}
},
};
}
};
@@ -96,7 +98,7 @@ interface checkIfUserIsDriverReturn {
result?: boolean;
error?: {
errorMessage: string;
}
};
}
interface checkIfUserIsDriverResponse {
@@ -105,31 +107,32 @@ interface checkIfUserIsDriverResponse {
result?: boolean;
error?: {
errorMessage: string;
}
};
}
const checkIfUserIsDriver = async (id_user: string): Promise<checkIfUserIsDriverReturn> => {
export const checkIfUserIsDriver = async (
id_user: string
): Promise<checkIfUserIsDriverReturn> => {
try {
let res: checkIfUserIsDriverResponse = await usersRoutes.checkIfUserIsDriver(id_user)
let res: checkIfUserIsDriverResponse =
await usersRoutes.checkIfUserIsDriver(id_user);
if (res.status === "error") {
return {
error: {
errorMessage: res.message,
}
},
};
}
return {
result: res.result,
};
} catch(err) {
} catch (err) {
return {
error: {
errorMessage: "Por favor, autentique-se.",
}
},
};
}
};
export default { getById, getUserSocialInfo, checkIfUserIsDriver }