Merge pull request #173 from Safelite/feature/Digital/SSR-261

SSR-261
This commit is contained in:
Jeremy-Z 2023-02-23 10:36:49 -05:00 committed by GitHub
commit 2fc636df77
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 9786 additions and 5285 deletions

14932
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -8,6 +8,7 @@ const applicationConfig = {
SITE_ENTRY_TRIGGER_VALUE: "SelfService",
APPLICATION_ABBREVIATION: "iss",
PAGE_QUERYSTRING: 'issPage',
CLIENTTAG_QUERYSTRING: 'CientTag',
GOOGLE_PLACES_API_KEY: process.env.VUE_APP_GOOGLE_PLACES_API_KEY,
ISS_DEV_CMS_DOMAIN: "https://digitalisscms.dev.safelite.io",
};

View file

@ -89,7 +89,11 @@ const endpoints = {
},
GooglePlaces: {
url: "https://maps.googleapis.com/maps/api/js?key={apiKey}&libraries=places"
}
},
ValidateClientTag: {
url: "/clientauth/api/v1/clientauth/validateClientTag",
method: "GET",
},
};
export { endpoints };

View file

@ -0,0 +1,17 @@
import { useMainStore } from '@/store';
export function validateISSClientTag(clientTag) {
const store = useMainStore()
return store.validateClientTag(clientTag)
.then(
(response) => {
// Success
return response;
},
(error) => {
// Error
return null;
}
);
}

View file

@ -4,7 +4,8 @@ import { useMainStore } from '@/store';
export function fetchCmsContentForPage(issPage) {
const store = useMainStore()
const clientName = store.issConfig.clientName;
const clientOverride = (clientName.length > 0);
const accountNumber = store.issConfig.accountNumber;
const clientOverride = (clientName.length > 0 && accountNumber > 0);
return store.getPageData(issPage)
.then(

View file

@ -0,0 +1,75 @@
<template>
<p id="message" v-show="unauthorized">Unauthorized Access.</p>
</template>
<script>
// Supporting files
import { issPageValues } from "@/router/router-constants/issPage-values";
import { validateISSClientTag } from "@/helpers/clientauth-helper";
import { useMainStore } from '@/store';
export default {
name: "entry-page",
mixins: [],
data() {
return {
unauthorized: false,
}
},
setup() {
const mainStore = useMainStore();
mainStore.resetISSConfigState();
return { mainStore };
},
mounted() {
this.validateClientTagOnEntry();
},
methods:
{
navigateForward() {
this.$router.navigate(
this.navigationScenarios.MOVE_FORWARD_ENTRY_PAGE,
this.$route
);
},
async validateClientTagOnEntry() {
const mainStore = useMainStore();
const clientTag = this.$route.query.ClientTag;
const clientTagPresent = !!clientTag;
let authorized = false;
if ( clientTagPresent )
{
const resp = await validateISSClientTag(clientTag);
if ( resp?.data.active && resp?.data.accountName.length > 0 )
{
this.mainStore.issConfig.clientName = resp.data.accountName;
this.mainStore.issConfig.accountNumber = resp.data.accountNumber;
this.mainStore.issConfig.styleSheet = resp.data.styleSheet;
authorized = true;
}
}
this.unauthorized = !authorized;
if ( authorized )
{
// Forced full location redirect here. We do not want the entry page as part of the router/flow/path history.
window.location = "/?issPage=" + issPageValues.WELCOME_PAGE;
}
},
},
computed:{
},
components: {
},
}
</script>
<style lang="scss">
#message {
text-align: center;
}
</style>

View file

@ -184,6 +184,10 @@
},
setup() {
const mainStore = useMainStore();
// Set order account number from the issConfig.
mainStore.order.accountNumber = mainStore.issConfig.accountNumber;
return { mainStore };
},
async beforeRouteEnter(to, from, next)

View file

@ -1,4 +1,5 @@
export const issPageValues = {
ENTRY_PAGE: "entry-page",
WELCOME_PAGE: "welcome-page",
POLICY_HOLDER_DETAILS: "policy-holder-details",
VEHICLE_MAKE: "vehicle-make",

View file

@ -3,6 +3,9 @@ const navigationScenarios = {
CLICKED_BACK: "CLICKED_BACK",
CLICKED_FORWARD: "CLICKED_FORWARD",
// Entry
MOVE_FORWARD_ENTRY_PAGE: "MOVE_FORWARD_ENTRY_PAGE",
// YMMS
SELECTED_YEAR: "SELECTED_YEAR",
SELECTED_MAKE: "SELECTED_MAKE",

View file

@ -354,6 +354,19 @@ const routingTable = function(store) {
},
],
},
{
issPageValue: issPageValues.ENTRY_PAGE,
maps: [
{
scenario: navigationScenarios.CLICKED_BACK,
destinationIssPageValue: issPageValues.ENTRY_PAGE
},
{
scenario: navigationScenarios.MOVE_FORWARD_ENTRY_PAGE,
destinationIssPageValue: issPageValues.WELCOME_PAGE
},
],
},
{
issPageValue: issPageValues.WELCOME_PAGE,
maps: [

View file

@ -100,8 +100,8 @@ const getDefaultState = () => {
},
issConfig: {
clientName: "",
accountNumber: 0,
styleSheet: "",
clientTag: "",
}
};
};
@ -480,6 +480,13 @@ export const useMainStore = defineStore({
this.order.vehicle.registration.lastName = null;
},
resetISSConfigState()
{
this.issConfig.clientName = "";
this.issConfig.accountNumber = 0;
this.issConfig.styleSheet = "";
},
updateSupportingItems(partsData) {
this.order.lineItems.supportingItems = partsData;
},
@ -915,6 +922,13 @@ export const useMainStore = defineStore({
});
},
async validateClientTag(clientTag) {
return await globalMethods.callHttpClient({
methods: endpoints.ValidateClientTag.method,
endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`,
});
},
saveServiceLocation(serviceLocationInfo) {
this.updateServiceLocation(serviceLocationInfo);
},