diff --git a/src/constants/endpoints.js b/src/constants/endpoints.js index cadc84fb..8512c417 100644 --- a/src/constants/endpoints.js +++ b/src/constants/endpoints.js @@ -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", diff --git a/src/store/index.js b/src/store/index.js index cd726469..90065277 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -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;