Fixing submittedOrder DNE

This commit is contained in:
Michaela Brydon 2024-08-01 13:53:35 -04:00
parent 80b1b4749d
commit 1e3ead2470
7 changed files with 37 additions and 22 deletions

View file

@ -24,7 +24,7 @@ export default {
} }
const imageUrl = (this.mainStore.hasSubmittedOrder()) const imageUrl = (this.mainStore.hasSubmittedOrder())
? this.mainStore.submittedOrder.vehicle.imageUrl ? this.mainStore.getSubmittedOrder().vehicle.imageUrl
: this.mainStore.order.vehicle.imageUrl; : this.mainStore.order.vehicle.imageUrl;
if (!imageUrl || imageUrl === 'NULL') { if (!imageUrl || imageUrl === 'NULL') {
@ -54,7 +54,7 @@ export default {
}, },
methods: { methods: {
getUnmatchedVehicleIcon() { getUnmatchedVehicleIcon() {
const category = this.mainStore.submittedOrder?.vehicle.category ?? this.mainStore.order.vehicle.category; const category = this.mainStore.getSubmittedOrder()?.vehicle.category ?? this.mainStore.order.vehicle.category;
switch (category) { switch (category) {
case this.vehicleCategories.CAR: case this.vehicleCategories.CAR:
return this.carUnmatchedVehicleIcon; return this.carUnmatchedVehicleIcon;

View file

@ -57,7 +57,7 @@ export default {
}, },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
const { submittedOrder } = mainStore; const submittedOrder = mainStore.getSubmittedOrder();
return { mainStore, submittedOrder }; return { mainStore, submittedOrder };
}, },
data() { data() {

View file

@ -139,7 +139,7 @@ export default {
}, },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
const { submittedOrder } = mainStore; const submittedOrder = mainStore.getSubmittedOrder();
return { mainStore, submittedOrder }; return { mainStore, submittedOrder };
}, },
computed: { computed: {

View file

@ -301,20 +301,31 @@ export default {
if (this.paymentMethod === paymentMethods.PAY_AT_TIME_OF_SERVICE) { if (this.paymentMethod === paymentMethods.PAY_AT_TIME_OF_SERVICE) {
try { try {
await submitWorkOrder({ submitType: submitType.SAFELITE }).then(() => { await submitWorkOrder({ submitType: submitType.SAFELITE });
this.$router.navigate( this.$router.navigate(
this.navigationScenarios.CLICKED_FORWARD, this.navigationScenarios.CLICKED_FORWARD,
this.$route this.$route
); );
}).catch((submitError) => { // await submitWorkOrder({ submitType: submitType.SAFELITE }).then(() => {
useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data)); // this.$router.navigate(
this.$router.navigate( // this.navigationScenarios.CLICKED_FORWARD,
this.navigationScenarios.SAVE_SESSION_FAILED, // this.$route
this.$route, // );
{ query: { issPage: issPageValues.PAYMENT_METHOD } } // }).catch((submitError) => {
); // useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data));
}); // this.$router.navigate(
// this.navigationScenarios.SAVE_SESSION_FAILED,
// this.$route,
// { query: { issPage: issPageValues.PAYMENT_METHOD } }
// );
// });
} catch (error) { } catch (error) {
useMainStore().setBailout(bailoutMessage.saveSessionError(submitError.data));
this.$router.navigate(
this.navigationScenarios.SAVE_SESSION_FAILED,
this.$route,
{ query: { issPage: issPageValues.PAYMENT_METHOD } }
);
console.error(`error: response from submit work order:${error.message}`); console.error(`error: response from submit work order:${error.message}`);
} }
} else { } else {

View file

@ -127,7 +127,7 @@ export default {
}, },
setup() { setup() {
const mainStore = useMainStore(); const mainStore = useMainStore();
const { submittedOrder } = mainStore; const submittedOrder = mainStore.getSubmittedOrder();
return { mainStore, submittedOrder }; return { mainStore, submittedOrder };
}, },
computed: { computed: {

View file

@ -50,7 +50,7 @@ const routes = [
// Intercept all navigation if a submitted order exists in storage // Intercept all navigation if a submitted order exists in storage
if (useMainStore().hasSubmittedOrder()) { if (useMainStore().hasSubmittedOrder()) {
if (to.query.issPage !== issPageValues.ENTRY_PAGE) { if (to.query.issPage !== issPageValues.ENTRY_PAGE) {
return await GoToConfirmationPage(next, useMainStore().submittedOrder); return await GoToConfirmationPage(next, useMainStore().getSubmittedOrder());
} }
} }

View file

@ -419,8 +419,7 @@ export const useMainStore = defineStore({
experimentSettings: (state) => state.applicationUser.experiments experimentSettings: (state) => state.applicationUser.experiments
.filter((x) => !!x.isActive) .filter((x) => !!x.isActive)
.map((x) => x.settings) .map((x) => x.settings)
.reduce((r, c) => Object.assign(r, c), {}) ?? {}, .reduce((r, c) => Object.assign(r, c), {}) ?? {}
submittedOrder: () => JSON.parse(window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER))
}, },
actions: actions:
{ {
@ -1559,7 +1558,8 @@ export const useMainStore = defineStore({
}, },
resetState() { resetState() {
Object.assign(this, getDefaultState()); //Object.assign(this, getDefaultState());
this.$reset();
}, },
resetRegistrationState() { resetRegistrationState() {
@ -2529,6 +2529,10 @@ export const useMainStore = defineStore({
return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null; return window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER) !== null;
}, },
getSubmittedOrder() {
return JSON.parse(window.sessionStorage.getItem(webStorageConstants.SUBMITTED_ORDER));
},
createSubmittedOrder(submitType) { createSubmittedOrder(submitType) {
if (this.hasSubmittedOrder()) { if (this.hasSubmittedOrder()) {
return; return;