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

@ -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:{

View file

@ -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}`,
});