Add getPartsOrQuestions action. Needed in multiple pages.
This commit is contained in:
parent
96f1279d78
commit
551d6edde6
2 changed files with 40 additions and 0 deletions
|
|
@ -31,6 +31,10 @@ const endpoints = {
|
|||
url: "/parts/api/v1/parts/damage-options",
|
||||
method: "GET",
|
||||
},
|
||||
GetPartsOrQuestions: {
|
||||
url: "/parts/api/v1/parts/parts-or-questions",
|
||||
method: "POST",
|
||||
},
|
||||
GetParts: {
|
||||
url: "/parts/api/v1/parts/parts",
|
||||
method: "POST",
|
||||
|
|
|
|||
|
|
@ -232,6 +232,42 @@ export const useMainStore = defineStore({
|
|||
});
|
||||
},
|
||||
|
||||
// PartsOrQuestions API Actions
|
||||
async getPartsOrQuestions() {
|
||||
const vehicle = this.vehicle;
|
||||
const damage = this.damage;
|
||||
const order = this.order;
|
||||
|
||||
const carId = vehicle.carId;
|
||||
const glassArray = damage.glassToReplace;
|
||||
// zip code is not available yet at the time of writing
|
||||
// const zipCode = order.serviceLocation.zipCode;
|
||||
// To Do: replace with actual zip code
|
||||
const zipCode = '43215';
|
||||
const vin = vehicle.vin;
|
||||
|
||||
// create a new array to avoid mutating state
|
||||
const glassArrayForPayload = convertGlassPieceNamingForApi(glassArray);
|
||||
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetPartsOrQuestions.method,
|
||||
endpoint: endpoints.GetPartsOrQuestions.url,
|
||||
payload: {
|
||||
carId: carId,
|
||||
glassPieces: glassArrayForPayload,
|
||||
zip: zipCode,
|
||||
vin: vin,
|
||||
},
|
||||
});
|
||||
|
||||
// Flatten location and name properties
|
||||
response.data.partsOrQuestions = convertGlassPieceNamingFromApi(
|
||||
response.data.partsOrQuestions
|
||||
);
|
||||
|
||||
return response;
|
||||
},
|
||||
|
||||
async getParts() {
|
||||
const vehicle = this.getters.vehicle;
|
||||
const damage = this.getters.damage;
|
||||
|
|
|
|||
Loading…
Reference in a new issue