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