Merge branch 'develop' into feature/digital/SSR-178

This commit is contained in:
Kroell 2023-01-10 09:08:52 -05:00
commit b975bfc97c
2 changed files with 40 additions and 0 deletions

View file

@ -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",

View file

@ -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;