Next prefer default refactor

This commit is contained in:
DavidAtSafelite 2023-08-14 08:08:53 -04:00
parent 53711ec62c
commit abb065ab0b
17 changed files with 28 additions and 30 deletions

View file

@ -1,7 +1,7 @@
// TintMap with array keys by location, lowercase to avoid as much string mismatching as possible.
// Src assumes you have a @/assets/img/tints/, making the final value @/assets/img/tints/{Src} in the markup.
// See vehicle-parts for implementation example.
const tintMap = {
const tintMap = Object.freeze({
other: [
// Blue Shade
{ name: 'blue tint, blue shade', src: 'Glass-BlueShade-BlueTint.svg' },
@ -71,23 +71,19 @@ const tintMap = {
// No shade or tint
{ name: 'clear', src: 'Windshield-NoShade-NoTint.svg' }
]
};
});
// Gets the tint image source string given the glass location, and the tint description (like 'Green Tint')
// Use lowered strings here to try to avoid mismatch. Returns an empty string if array key doesn't exist.
// Returns undefined if no items are found.
export function getTintImage(glassLocation, colorString) {
const getTintImage = (glassLocation, colorString) => {
// Windshield glass has special images, all other glass uses the same though.
if (glassLocation.toLowerCase() !== 'windshield') {
glassLocation = 'other';
}
if (tintMap[glassLocation.toLowerCase()] === undefined) {
const glassLoc = (glassLocation.toLowerCase() !== 'windshield') ? 'other' : 'windshield';
if (tintMap[glassLoc] === undefined) {
return '';
}
const tintImageSource = tintMap[glassLocation.toLowerCase()]
.find((item) => item.name.toLowerCase() === colorString.toLowerCase());
return tintMap[glassLoc].find((item) => item.name.toLowerCase() === colorString.toLowerCase());
};
return tintImageSource;
}
export default getTintImage;

View file

@ -1,4 +1,4 @@
const vehicleCategories = {
const vehicleCategories = Object.freeze({
CAR: 'CAR',
TRUCK: 'TRUCK',
VAN: 'VAN',
@ -6,6 +6,6 @@ const vehicleCategories = {
SUV: 'SUV',
MOTORHOME: 'MOTOR HOME',
SEMI: 'SEMI'
};
});
export { vehicleCategories };
export default vehicleCategories;

View file

@ -2,4 +2,4 @@ const vehicleSelectionOptions = Object.freeze({
VEHICLE_NOT_LISTED: 'Vehicle not listed'
});
export { vehicleSelectionOptions };
export default vehicleSelectionOptions;

View file

@ -4,4 +4,4 @@ const vinLookupMethodSelections = Object.freeze({
HOMEADDRESS: 'HomeAddress'
});
export { vinLookupMethodSelections };
export default vinLookupMethodSelections;

View file

@ -30,7 +30,7 @@ import {
handleButtonComponentFocus,
handleInputComponentBlur
} from '@/helpers/button-question-focus-helper';
import { inputButtonProps } from '@/digital-components/base-input-button/button-functionality-props';
import inputButtonProps from '@/digital-components/base-input-button/button-functionality-props';
export default {
name: 'base-input-button',

View file

@ -1,4 +1,4 @@
export const inputButtonProps = {
const inputButtonProps = {
value: {
type: [String, Number],
required: true
@ -36,3 +36,5 @@ export const inputButtonProps = {
},
suppressError: Boolean
};
export default inputButtonProps;

View file

@ -1,6 +1,6 @@
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios.js';
import { RouterLinkStub } from '@vue/test-utils';
import { vehicleCategories } from '@/constants/vehicle-categories.js';
import vehicleCategories from '@/constants/vehicle-categories.js';
import { issPageValues } from '@/router/router-constants/issPage-values';
import cookieNames from '@/constants/cookie-names';
import { Form } from 'vee-validate';

View file

@ -1,5 +1,5 @@
import { shallowMount } from '@vue/test-utils';
import { vehicleCategories } from '@/constants/vehicle-categories.js';
import vehicleCategories from '@/constants/vehicle-categories.js';
import { useMainStore } from '@/store';
import { createApp } from 'vue';
import { createPinia, mapStores } from 'pinia';

View file

@ -10,7 +10,7 @@ import { getRandomString, getRandomInt } from '@/helpers/data-generation';
import endorsementOptions from '@/constants/endorsement-options';
import { createTestingPinia } from '@pinia/testing';
import { issPageValues } from '@/router/router-constants/issPage-values';
import { vehicleSelectionOptions } from '@/constants/vehicle-selection-options';
import vehicleSelectionOptions from '@/constants/vehicle-selection-options';
// Mock fetchCmsContentForPage
jest.mock('@/helpers/cms-content-helper', () => ({

View file

@ -50,7 +50,7 @@ import { fetchCmsContentForPage } from '@/helpers/cms-content-helper.js';
import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin.js';
import { issPageValues } from '@/router/router-constants/issPage-values.js';
import { vehicleSelectionOptions } from '@/constants/vehicle-selection-options.js';
import vehicleSelectionOptions from '@/constants/vehicle-selection-options.js';
import endorsementOptions from '@/constants/endorsement-options.js';
import globalRules from '@/constants/global-rules.js';
import { useMainStore } from '@/store/index.js';

View file

@ -3,7 +3,7 @@ import { mount, flushPromises } from '@vue/test-utils';
import { createTestingPinia } from '@pinia/testing';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import { routerParams } from '@/router/router-params';
import { vehicleCategories } from '@/constants/vehicle-categories';
import vehicleCategories from '@/constants/vehicle-categories';
import VehicleDamageComponent from '@/layouts/vehicle-damage/vehicle-damage';
const mockRoute = {

View file

@ -3,7 +3,7 @@ import { mount } from '@vue/test-utils';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import queryStrings from '@/constants/query-strings';
import { GaActions } from '@/constants/analytics';
import { vinLookupMethodSelections } from '@/constants/vin-lookup-methods';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods';
import { useMainStore } from '@/store';
import { createTestingPinia } from '@pinia/testing';
import { mapStores } from 'pinia';

View file

@ -43,7 +43,7 @@ import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
import { settleAllPromises } from '@/helpers/layout-helper';
import { Form } from 'vee-validate';
import BaseFormMixin from '@/mixins/base-form-mixin';
import { vinLookupMethodSelections } from '@/constants/vin-lookup-methods';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods';
import { useMainStore } from '@/store';
// Import Component

View file

@ -13,7 +13,7 @@
// Import Other Supporting Files
import { useMainStore } from '@/store';
import { vinLookupMethodSelections } from '@/constants/vin-lookup-methods';
import vinLookupMethodSelections from '@/constants/vin-lookup-methods';
import { settleAllPromises } from '@/helpers/layout-helper';
import globalRules from '@/constants/global-rules';

View file

@ -46,7 +46,7 @@
import buttonQuestion from '@/digital-components/button-question/button-question';
// Supporting files
import { getTintImage } from '@/constants/tint-mapper';
import getTintImage from '@/constants/tint-mapper';
import getCustomTransformValue from '@/constants/dynamictext-mapper';
import { defineRule } from 'vee-validate';
import { required } from '@/helpers/validation-rules';

View file

@ -1,7 +1,7 @@
import { mapStores } from 'pinia';
import { useMainStore } from '@/store';
import { navigationScenarios } from '@/router/router-constants/navigation-scenarios';
import { vehicleCategories } from '@/constants/vehicle-categories.js';
import vehicleCategories from '@/constants/vehicle-categories.js';
import queryStrings from '@/constants/query-strings';
import dynamicStrings from '@/constants/dynamic-strings';
import { routerParams } from '@/router/router-constants/router-params';

View file

@ -1,4 +1,4 @@
import { inputButtonProps } from '@/digital-components/base-input-button/button-functionality-props';
import inputButtonProps from '@/digital-components/base-input-button/button-functionality-props';
export default {
model: {