Addressing problems
This commit is contained in:
parent
81ec8d4d14
commit
9118d59878
4 changed files with 13 additions and 43 deletions
|
|
@ -112,9 +112,7 @@ function setISSCookieProperties(properties) {
|
||||||
Will update the cookie if present, or create a new one if not.
|
Will update the cookie if present, or create a new one if not.
|
||||||
*/
|
*/
|
||||||
export function updateOrCreateISSCookie() {
|
export function updateOrCreateISSCookie() {
|
||||||
console.log('in cookie function');
|
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
console.log(store);
|
|
||||||
|
|
||||||
// Set up cookie with all the props.
|
// Set up cookie with all the props.
|
||||||
setISSCookieProperties({
|
setISSCookieProperties({
|
||||||
|
|
|
||||||
|
|
@ -6,54 +6,23 @@ import { updateOrCreateISSCookie } from '@/helpers/cookie-helper';
|
||||||
This will also set Referral information in the store after saving, and then
|
This will also set Referral information in the store after saving, and then
|
||||||
update the cookie. To force synchronous behavior pass in 'true' for shouldAwaitSaveSessionQueue
|
update the cookie. To force synchronous behavior pass in 'true' for shouldAwaitSaveSessionQueue
|
||||||
*/
|
*/
|
||||||
// encapsulate when you transition back into heritage
|
|
||||||
// we need eon from first call to get pricing
|
|
||||||
// eon is a number that some services require
|
|
||||||
// save session takes time
|
|
||||||
// not necessary for much throughout the flow
|
|
||||||
// we want each save session call to happen sequentially, but asynchronously
|
|
||||||
export async function saveSession({ shouldAwaitSaveSessionQueue = false }) {
|
export async function saveSession({ shouldAwaitSaveSessionQueue = false }) {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
console.log('order helper');
|
var saveSessionPromise = store.applicationUser.saveSessionPromise
|
||||||
console.log(store);
|
? store.applicationUser.saveSessionPromise.then(() => { return saveSessionHelper(store); })
|
||||||
var saveSessionPromise;
|
: saveSessionHelper(store);
|
||||||
if (store.applicationUser.saveSessionPromise){
|
|
||||||
console.log('if promise exists');
|
|
||||||
console.log(store.applicationUser.saveSessionPromise);
|
|
||||||
|
|
||||||
// .then returns another promise but waiting for another to finish
|
|
||||||
saveSessionPromise = store.applicationUser.saveSessionPromise
|
|
||||||
.then(() => {
|
|
||||||
console.log('then');
|
|
||||||
return saveSessionHelper(store);
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
console.log("saveSessionPromise failed: " + error.message);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
console.log('else');
|
|
||||||
saveSessionPromise = saveSessionHelper(store);
|
|
||||||
}
|
|
||||||
// var saveSessionPromise =
|
|
||||||
// store.applicationUser.saveSessionPromise
|
|
||||||
// ? store.applicationUser.saveSessionPromise.then(() => { return saveSessionHelper(store); })
|
|
||||||
// : saveSessionHelper(store);
|
|
||||||
console.log('promise exists');
|
|
||||||
store.setSaveSessionPromise(saveSessionPromise);
|
store.setSaveSessionPromise(saveSessionPromise);
|
||||||
console.log('set information');
|
|
||||||
if (!store.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) {
|
if (!store.applicationUser.savedSessionId || shouldAwaitSaveSessionQueue) {
|
||||||
console.log('pre await');
|
|
||||||
await saveSessionPromise;
|
await saveSessionPromise;
|
||||||
}
|
}
|
||||||
console.log('done');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Encapsulates asynchronous Save Session logic inside a promise to allow for Save Session queuing
|
Encapsulates asynchronous Save Session logic inside a promise to allow for Save Session queuing
|
||||||
*/
|
*/
|
||||||
async function saveSessionHelper(store) {
|
async function saveSessionHelper(store) {
|
||||||
console.log('helper helper called');
|
|
||||||
const savedSessionInfo = await store.saveSession();
|
const savedSessionInfo = await store.saveSession();
|
||||||
store.setSaveSessionInfo(savedSessionInfo.data);
|
store.setSaveSessionInfo(savedSessionInfo.data);
|
||||||
updateOrCreateISSCookie();
|
updateOrCreateISSCookie();
|
||||||
|
|
|
||||||
|
|
@ -88,13 +88,12 @@ router.afterEach(async (to, from) => {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
// Update lastPageVisited in the store
|
// Update lastPageVisited in the store
|
||||||
store.updateLastPageVisited(to.name);
|
store.updateLastPageVisited(to.name);
|
||||||
console.log('after each');
|
|
||||||
|
if (from.redirectedFrom == undefined){
|
||||||
|
store.clearSaveSessionPromise();
|
||||||
|
}
|
||||||
|
|
||||||
await saveSession({shouldAwaitSaveSessionQueue: true}).then(() => {
|
await saveSession({shouldAwaitSaveSessionQueue: true}).catch((error) => {
|
||||||
console.log('then');
|
|
||||||
}).catch((error) => {
|
|
||||||
console.log(error);
|
|
||||||
console.log("catch");
|
|
||||||
if (from.name === issPageValues.WELCOME_PAGE) {
|
if (from.name === issPageValues.WELCOME_PAGE) {
|
||||||
router.navigate(navigationScenarios.SAVE_SESSION_FAILED, {query: {issPage: issPageValues.WELCOME_PAGE}})
|
router.navigate(navigationScenarios.SAVE_SESSION_FAILED, {query: {issPage: issPageValues.WELCOME_PAGE}})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -806,6 +806,10 @@ export const useMainStore = defineStore({
|
||||||
this.applicationUser.saveSessionPromise = promise;
|
this.applicationUser.saveSessionPromise = promise;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
clearSaveSessionPromise(){
|
||||||
|
this.applicationUser.saveSessionPromise = null;
|
||||||
|
},
|
||||||
|
|
||||||
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
saveVehicleDamage(isWindshieldRepair, selectedGlassToReplace, selectedWindshieldChipCount) {
|
||||||
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
const selectedGlassPassedInSorted = selectedGlassToReplace.slice().sort();
|
||||||
const isGlassToReplaceTheSame
|
const isGlassToReplaceTheSame
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue