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