Incluindo lista de marcas de carro do backend

This commit is contained in:
Matheus Albino Brunhara
2022-05-28 16:26:45 -05:00
parent 34c08df016
commit efba742455
6 changed files with 197 additions and 52 deletions

View File

@@ -0,0 +1,51 @@
import * as carsRoutes from "../api/cars";
interface getAllCarModelsReturn {
data?: {
id_model: string;
name: string;
}[];
error?: {
errorMessage: string;
}
}
interface getAllCarModelsRes {
status?: string;
message: string
data?: {
id_model: string;
name: string;
}[];
}
const getAllCarModels = async (): Promise<getAllCarModelsReturn> => {
try {
let res: getAllCarModelsRes = await carsRoutes.list();
if (res.status === "error") {
return {
error: {
errorMessage: res.message,
},
};
}
return {
data: res.data,
};
} catch (err) {
return {
error: {
errorMessage: "Por favor, autentique-se.",
},
};
}
};
export default { getAllCarModels };