0
1
Fork 0

Unload order when checkOrder fails

This commit is contained in:
William Buezas 2024-09-10 12:38:36 -03:00
parent a9427ddab9
commit decf955224
1 changed files with 21 additions and 16 deletions

View File

@ -97,22 +97,21 @@ export const useAppStore = defineStore('hedera', {
await this.checkOrder(this.basketOrderId);
return true;
} catch (err) {
if (err.exception === 'Vn.Lib.UserError') {
switch (err.code) {
case 'orderConfirmed':
case 'orderNotOwnedByUser':
await this.redirect();
break;
default:
this.router.push({
name: 'checkout',
params: { id: this.basketOrderId },
query: { continue: checkoutContinue }
});
notify(err.message, 'negative');
}
return false;
} else throw err;
switch (err.code) {
case 'orderConfirmed':
case 'orderNotOwnedByUser':
this.unloadOrder();
await this.redirect();
break;
default:
this.router.push({
name: 'checkout',
params: { id: this.basketOrderId },
query: { continue: checkoutContinue }
});
notify(err.message, 'negative');
}
return false;
}
},
@ -134,6 +133,12 @@ export const useAppStore = defineStore('hedera', {
localStorage.setItem('hederaBasket', orderId);
notify('orderLoadedIntoBasket', 'positive');
}
},
unloadOrder() {
console.log('unloadOrder');
localStorage.removeItem('hederaBasket');
this.basketOrderId = null;
}
},
getters: {