From dc11f727b61221457ef007c38c983b67dceddb78 Mon Sep 17 00:00:00 2001 From: Jeremy Zimmerman Date: Fri, 17 Feb 2023 15:04:38 -0500 Subject: [PATCH] Updates. --- src/layouts/entry-page/entry-page.vue | 62 ++++++++++----------------- src/store/index.js | 13 ++++-- 2 files changed, 32 insertions(+), 43 deletions(-) diff --git a/src/layouts/entry-page/entry-page.vue b/src/layouts/entry-page/entry-page.vue index 920ce986..ae40e627 100644 --- a/src/layouts/entry-page/entry-page.vue +++ b/src/layouts/entry-page/entry-page.vue @@ -22,30 +22,16 @@ data() { }, setup() { - const mainStore = useMainStore(); - - mainStore.$reset(); - - - - //const resp = validateISSClientTag("8953C31B-165D-4E4E-9827-C90FBF77017B"); - //const resp = validateISSClientTag("asdf"); - + const mainStore = useMainStore(); + mainStore.resetISSConfigState(); return { mainStore }; }, mounted() { - const mainStore = useMainStore(); - - mainStore.$reset(); - - mainStore.issConfig.clientName = ""; - this.validateClientTagOnEntry(); }, + /* async beforeRouteEnter(to, from, next) { - // validate clienttag + signature here? - // Call APIs const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); @@ -63,7 +49,8 @@ next((vm) => { vm.setCmsContent(resultMap.cmsContent); }); - }, + }, + */ methods: { navigateForward() { @@ -76,36 +63,31 @@ const mainStore = useMainStore(); - - console.log("Client Name: " + mainStore.issConfig.clientName); + console.log("Client Name on-load: " + mainStore.issConfig.clientName); const clientTag = this.$route.query.ClientTag; + const clientTagPresent = !!clientTag; - if ( !clientTag ) + if ( clientTagPresent ) { + const resp = await validateISSClientTag(clientTag); + console.log(resp); + 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; + } + + console.log("Client Name after-load: " + mainStore.issConfig.clientName); + + //this.navigateForward(); + //this.$router.push({ path: '/?issPage=welcome-page' }); + //window.location = "/?issPage=welcome-page"; } - const resp = await validateISSClientTag(clientTag); - - - console.log(resp); - - if ( resp === null ) - { - - - } - else if ( resp.data.active && resp.data.accountName.length > 0 ) - { - this.mainStore.issConfig.clientName = resp.data.accountName; - } - - //this.navigateForward(); - //this.$router.push({ path: '/?issPage=welcome-page' }); - //window.location = "/?issPage=welcome-page"; - }, }, computed:{ diff --git a/src/store/index.js b/src/store/index.js index c327b3c7..d741b9b1 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -100,8 +100,8 @@ const getDefaultState = () => { }, issConfig: { clientName: "", + accountNumber: 0, styleSheet: "", - clientTag: "", } }; }; @@ -481,6 +481,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; }, @@ -893,8 +900,8 @@ export const useMainStore = defineStore({ }); }, - validateClientTag(clientTag) { - return globalMethods.callHttpClient({ + async validateClientTag(clientTag) { + return await globalMethods.callHttpClient({ methods: endpoints.ValidateClientTag.method, endpoint: `${endpoints.ValidateClientTag.url}/${clientTag}`, });