31 lines
No EOL
967 B
JavaScript
31 lines
No EOL
967 B
JavaScript
import store from "@/store";
|
|
import baseMixin from "@/mixins/base-mixin.js";
|
|
import { storeActions } from "@/constants/store-actions";
|
|
|
|
export function getDamageString() {
|
|
return store.getters.damage.glassToReplace.length > 1 ? "match" : store.getters.damage.glassToReplace[0].location;
|
|
}
|
|
|
|
export async function isGlassAvailableForCarId(carId){
|
|
const newGlassOptions = await baseMixin.methods.dispatchNonBlockingStoreAction(
|
|
storeActions.GET_DAMAGE_OPTIONS,
|
|
{ carId: carId }
|
|
);
|
|
|
|
const currentGlassOptions = store.getters.damage.glassToReplace;
|
|
|
|
const optionsMap = {
|
|
Windshield: "windshieldOptions",
|
|
Driver: "driverSideOptions",
|
|
Passenger: "passengerSideOptions",
|
|
Rear: "backGlassOptions"
|
|
}
|
|
|
|
for(const option of currentGlassOptions){
|
|
if(!newGlassOptions.data[optionsMap[option.location]].availableReplacementOptions.includes(option.name)){
|
|
return false;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
} |