Reverting more
This commit is contained in:
parent
f02c152c6f
commit
c57078df6b
1 changed files with 29 additions and 10 deletions
|
|
@ -556,8 +556,10 @@ export const useMainStore = defineStore({
|
|||
const { vin } = vehicle;
|
||||
|
||||
// create a new array to avoid mutating state
|
||||
console.log('compatible format');
|
||||
const glassArrayForPayload = convertGlassPieceToBackEndCompatibleFormat(glassArray);
|
||||
|
||||
console.log('before api call');
|
||||
const response = await globalMethods.callHttpClient({
|
||||
method: endpoints.GetPartsOrQuestions.method,
|
||||
endpoint: endpoints.GetPartsOrQuestions.url,
|
||||
|
|
@ -569,6 +571,7 @@ export const useMainStore = defineStore({
|
|||
}
|
||||
});
|
||||
|
||||
console.log('about to convert');
|
||||
// Flatten location and name properties
|
||||
response.data.partsOrQuestions = convertGlassPieceNamingFromApi(response.data.partsOrQuestions);
|
||||
|
||||
|
|
@ -1988,12 +1991,20 @@ function sortArrayOfObjectsByPropertyValue(arrayOfObjects, propertyName) {
|
|||
|
||||
function convertGlassPieceNamingForApi(glassArray) {
|
||||
// check if array already converted. (likely when a session has been saved previously and then reloaded)
|
||||
if (glassArray == null || glassArray.length === 0) return [];
|
||||
if (!glassArray || glassArray.length === 0) return [];
|
||||
|
||||
if (glassArray[0].location !== undefined) {
|
||||
return glassArray;
|
||||
}
|
||||
|
||||
// const converted = [];
|
||||
// glassArray.forEach((glass) => {
|
||||
// converted.push({
|
||||
// location: glass.glassLocation,
|
||||
// name: glass.glassName
|
||||
// });
|
||||
// });
|
||||
// return converted;
|
||||
return glassArray.map((glass) => ({
|
||||
location: glass?.glassLocation,
|
||||
name: glass?.glassName
|
||||
|
|
@ -2001,18 +2012,26 @@ function convertGlassPieceNamingForApi(glassArray) {
|
|||
}
|
||||
|
||||
function convertResultsForApi(resultsArray) {
|
||||
return resultsArray?.map((answer) => new {
|
||||
location: answer.glassLocation,
|
||||
name: answer.glassName,
|
||||
result: answer.result
|
||||
}()) ?? [];
|
||||
if (!resultsArray) return [];
|
||||
const converted = [];
|
||||
resultsArray.forEach((answer) => {
|
||||
converted.push({
|
||||
location: answer.glassLocation,
|
||||
name: answer.glassName,
|
||||
result: answer.result
|
||||
});
|
||||
});
|
||||
return converted;
|
||||
}
|
||||
|
||||
function convertGlassPieceNamingFromApi(glassArray) {
|
||||
return glassArray?.map((glass) => new {
|
||||
glassLocation: glass.glassPiece.location,
|
||||
glassName: glass.glassPiece.name
|
||||
}()) ?? [];
|
||||
glassArray.forEach((glass) => {
|
||||
glass.glassLocation = glass.glassPiece.location;
|
||||
glass.glassName = glass.glassPiece.name;
|
||||
delete glass.glassPiece;
|
||||
return glass;
|
||||
});
|
||||
return glassArray;
|
||||
}
|
||||
|
||||
function addPricesToLineItems(lineItems, pricingLineItems) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue