DigitalConsumer.ISS/src/helpers/damage-helper.js
Johan Gunawan ce35f538d2 No damage string for repair
New requirement says that if the damage is a repair, the navigation is not going to go to the vehicle lookup pages (by vin, by license place, by address). 
No damage string for repair

New requirement says that if the damage is a repair, the navigation is not going to go to the vehicle lookup pages (by vin, by license place, by address).
2023-01-11 12:01:57 -05:00

84 lines
2.4 KiB
JavaScript

import damageCustomLabels from '@/constants/damage-custom-labels';
import { damageLocationsSelected } from '@/constants/damage-locations-selected';
import { useMainStore } from '@/store';
export function getDamageString() {
const mainStore = useMainStore();
const { isRepair } = mainStore.damage;
const damageLocations = mainStore.damage.glassToReplace;
if (isRepair || !damageLocations || !Array.isArray(damageLocations)) {
return '';
}
if (damageLocations.length > 1) {
return damageCustomLabels.MATCH;
}
const { glassLocation } = damageLocations[0];
if (glassLocation) {
switch (glassLocation) {
case damageLocationsSelected.WINDSHIELD:
return damageCustomLabels.WINDSHIELD;
case damageLocationsSelected.DRIVER:
case damageLocationsSelected.PASSENGER:
return damageCustomLabels.SIDE_WINDOW;
case damageLocationsSelected.REAR:
return damageCustomLabels.REAR_WINDOW;
default:
return '';
}
}
// No condition is matched
return '';
}
/**
* Commented code are copied directly from DigitalConsumer.FixMyGlass
* and have not been adjusted for ISS.
*/
// import store from "@/store";
// import baseMixin from "@/mixins/base-mixin.js";
// import { storeActions } from "@/constants/store-actions";
// export function getIsWindshieldOnly() {
// const damageLocations = store.getters.damage.glassToReplace;
// const returnString =
// damageLocations &&
// damageLocations.length === 1 &&
// damageLocations[0]?.glassLocation === "Windshield"
// ? "windshield"
// : "glass";
// return returnString;
// }
// export async function isGlassAvailableForCarId(carId) {
// const newGlassOptions = await baseMixin.methods.dispatchStoreAction(
// 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.glassLocation]
// ].availableReplacementOptions.includes(option.glassName)
// ) {
// return false;
// }
// }
// return true;
// }