This commit is contained in:
Jeremy Zimmerman 2023-02-17 15:04:38 -05:00
parent 329a9fbae3
commit dc11f727b6
2 changed files with 32 additions and 43 deletions

View file

@ -23,29 +23,15 @@
}, },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
mainStore.resetISSConfigState();
mainStore.$reset();
//const resp = validateISSClientTag("8953C31B-165D-4E4E-9827-C90FBF77017B");
//const resp = validateISSClientTag("asdf");
return { mainStore }; return { mainStore };
}, },
mounted() { mounted() {
const mainStore = useMainStore();
mainStore.$reset();
mainStore.issConfig.clientName = "";
this.validateClientTagOnEntry(); this.validateClientTagOnEntry();
}, },
/*
async beforeRouteEnter(to, from, next) async beforeRouteEnter(to, from, next)
{ {
// validate clienttag + signature here?
// Call APIs // Call APIs
const cmsContentPromise = fetchCmsContentForPage(to.query.issPage); const cmsContentPromise = fetchCmsContentForPage(to.query.issPage);
@ -64,6 +50,7 @@
vm.setCmsContent(resultMap.cmsContent); vm.setCmsContent(resultMap.cmsContent);
}); });
}, },
*/
methods: methods:
{ {
navigateForward() { navigateForward() {
@ -76,36 +63,31 @@
const mainStore = useMainStore(); const mainStore = useMainStore();
console.log("Client Name on-load: " + mainStore.issConfig.clientName);
console.log("Client Name: " + mainStore.issConfig.clientName);
const clientTag = this.$route.query.ClientTag; 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:{ computed:{

View file

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