Use camelCase for component tag and when passing props to match the style in Concept Funnel.
171 lines
4.8 KiB
Vue
171 lines
4.8 KiB
Vue
<template>
|
|
<Form
|
|
@submit="onSubmit"
|
|
@invalidSubmit="onInvalidSubmit"
|
|
v-slot="{ meta }"
|
|
>
|
|
<div class="page-container-grouped-styles overflow-auto">
|
|
<siteHeader
|
|
cmsWidgetName="SiteHeaderWidget"
|
|
/>
|
|
<vehicleBanner
|
|
cmsWidgetName="VehicleBannerWidget"
|
|
:displayGenericVehicleImage="false"
|
|
/>
|
|
<siteSubHeader
|
|
cmsWidgetName="SiteSubHeaderWidget"
|
|
/>
|
|
<div class="fade-on-route-transition sub-container make-tall mt-5">
|
|
<vinLookupAlerts
|
|
:activeAlertType="activeVehicleLookupAlertType"
|
|
/>
|
|
|
|
<vinQuestion
|
|
v-model="vin"
|
|
/>
|
|
|
|
<vinLocationInformation />
|
|
|
|
<siteFooter
|
|
cmsWidgetName="SiteFooterWidget"
|
|
:isForwardActionDisabled="!meta.valid"
|
|
@backClicked="backButtonAction"
|
|
@forwardClicked="forwardButtonAction"
|
|
ref="siteFooter"
|
|
/>
|
|
</div>
|
|
</div>
|
|
</Form>
|
|
</template>
|
|
<script>
|
|
// Import Supporting Files
|
|
import { computed } from 'vue';
|
|
import { endpoints } from '@/constants/endpoints';
|
|
import vehicleLookupAlertTypes from '@/constants/vehicle-lookup-alert-types';
|
|
import globalMethods from '@/global-methods';
|
|
import { fetchCmsContentForPage } from '@/helpers/cms-content-helper';
|
|
import { settleAllPromises } from '@/helpers/layout-helper';
|
|
import { useMainStore } from '@/store';
|
|
|
|
// Import Component
|
|
import baseFormMixin from '@/mixins/base-form-mixin';
|
|
import { Form } from 'vee-validate';
|
|
import siteFooter from '@/common-components/site-footer/site-footer.vue';
|
|
import siteHeader from '@/common-components/site-header/site-header.vue';
|
|
import siteSubHeader from '@/common-components/site-sub-header/site-sub-header.vue';
|
|
import vehicleBanner from '@/common-components/vehicle-banner/vehicle-banner.vue';
|
|
import vinLocationInformation from './vin-location-information/vin-location-information.vue';
|
|
import vinLookupAlerts from './vin-lookup-alerts/vin-lookup-alerts.vue';
|
|
import vinQuestion from './vin-question/vin-question.vue';
|
|
|
|
export default {
|
|
name: 'vin-lookup',
|
|
mixins: [baseFormMixin],
|
|
components: {
|
|
siteFooter,
|
|
siteHeader,
|
|
siteSubHeader,
|
|
Form,
|
|
vehicleBanner,
|
|
vinLocationInformation,
|
|
vinLookupAlerts,
|
|
vinQuestion,
|
|
},
|
|
setup() {
|
|
const mainStore = useMainStore();
|
|
|
|
return { mainStore };
|
|
},
|
|
data() {
|
|
return {
|
|
activeVehicleLookupAlertType: null,
|
|
vehicleFromLookup: null,
|
|
vin: null,
|
|
};
|
|
},
|
|
provide() {
|
|
return {
|
|
vehicleFromLookup: computed(() => this.vehicleFromLookup),
|
|
};
|
|
},
|
|
async beforeRouteEnter(to, from, next) {
|
|
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
|
|
|
|
// Settle promises and get results
|
|
const promiseResultMap = [
|
|
{
|
|
resultKey: 'cmsContent',
|
|
promise: cmsContentPromise,
|
|
},
|
|
];
|
|
|
|
const resultMap = await settleAllPromises(promiseResultMap);
|
|
|
|
next((vm) => {
|
|
vm.setCmsContent(resultMap.cmsContent);
|
|
});
|
|
},
|
|
methods: {
|
|
arePagePrerequisiteValid() {
|
|
return true;
|
|
},
|
|
backButtonAction() {
|
|
/**
|
|
* this.navigationScenarios comes from base-mixin
|
|
*/
|
|
this.$router.navigate(this.navigationScenarios.CLICKED_BACK, this.$route);
|
|
},
|
|
async forwardButtonAction() {
|
|
this.resetActiveAlert();
|
|
|
|
// NOTE: If form is not valid, this method is not called when 'Continue' button is clicked
|
|
const vehicleLookupResponse = await this.lookupVehicleByVin(this.vin);
|
|
|
|
if (vehicleLookupResponse.error) {
|
|
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_FOUND;
|
|
this.resetVehicleFromLookup();
|
|
this.$refs.siteFooter.removeLoader();
|
|
return;
|
|
}
|
|
|
|
this.vehicleFromLookup = vehicleLookupResponse.data;
|
|
if (this.vehicleFromLookup.carId !== this.mainStore.vehicle.carId) {
|
|
this.activeVehicleLookupAlertType = vehicleLookupAlertTypes.NOT_MATCHED;
|
|
|
|
const vehicleYearMakeModel = `${this.vehicleFromLookup.year} ${this.vehicleFromLookup.make} ${this.vehicleFromLookup.model}`;
|
|
|
|
this.$refs.siteFooter.updateButtonText(`Continue with ${vehicleYearMakeModel}`);
|
|
this.$refs.siteFooter.removeLoader();
|
|
}
|
|
|
|
// Continue
|
|
},
|
|
async lookupVehicleByVin(vin) {
|
|
try {
|
|
const response = await globalMethods.callHttpClient({
|
|
method: endpoints.LookupVehicleByVin.method,
|
|
endpoint: endpoints.LookupVehicleByVin.url,
|
|
payload: {
|
|
vin,
|
|
},
|
|
});
|
|
|
|
return response;
|
|
} catch (responseError) {
|
|
return {
|
|
error: {
|
|
status: responseError.status,
|
|
},
|
|
};
|
|
}
|
|
},
|
|
resetActiveAlert() {
|
|
this.activeVehicleLookupAlertType = null;
|
|
},
|
|
resetVehicleFromLookup() {
|
|
this.vehicleFromLookup = null;
|
|
},
|
|
resetDependentState() {},
|
|
},
|
|
};
|
|
</script>
|