refactor(CheckoutView): use salix for checkOrder
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
gitea/hedera-web/pipeline/pr-beta This commit looks good
Details
This commit is contained in:
parent
e7f4ece0a7
commit
d3130f12f3
|
@ -168,6 +168,7 @@ export default {
|
|||
// Errors
|
||||
errors: {
|
||||
statusUnauthorized: 'Accés denegat',
|
||||
tokenConfig: 'Error al obtenir la configuració del token'
|
||||
tokenConfig: 'Error al obtenir la configuració del token',
|
||||
orderNotOwnedByUser: 'The order belongs to another user'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -200,6 +200,7 @@ export default {
|
|||
// Errors
|
||||
errors: {
|
||||
statusUnauthorized: 'Access denied',
|
||||
tokenConfig: 'Error fetching token config'
|
||||
tokenConfig: 'Error fetching token config',
|
||||
orderNotOwnedByUser: 'The order belongs to another user'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -200,6 +200,7 @@ export default {
|
|||
// Errors
|
||||
errors: {
|
||||
statusUnauthorized: 'Acceso denegado',
|
||||
tokenConfig: 'Error al obtener configuración de token'
|
||||
tokenConfig: 'Error al obtener configuración de token',
|
||||
orderNotOwnedByUser: 'The order belongs to another user'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -172,6 +172,7 @@ export default {
|
|||
errors: {
|
||||
statusUnauthorized: 'Accès refusé',
|
||||
tokenConfig:
|
||||
'Erreur lors de la récupération de la configuration du jeton'
|
||||
'Erreur lors de la récupération de la configuration du jeton',
|
||||
orderNotOwnedByUser: 'The order belongs to another user'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -166,6 +166,7 @@ export default {
|
|||
// Errors
|
||||
errors: {
|
||||
statusUnauthorized: 'Acesso negado',
|
||||
tokenConfig: 'Erro ao obter configuração do token'
|
||||
tokenConfig: 'Erro ao obter configuração do token',
|
||||
orderNotOwnedByUser: 'The order belongs to another user'
|
||||
}
|
||||
};
|
||||
|
|
|
@ -81,14 +81,6 @@ export const useAppStore = defineStore('hedera', {
|
|||
this.basketOrderId = localStorage.getItem(storageOrderName);
|
||||
},
|
||||
|
||||
async checkOrder(orderId) {
|
||||
const resultSet = await jApi.execQuery(
|
||||
'CALL myOrder_checkConfig(#id)',
|
||||
{ id: orderId }
|
||||
);
|
||||
resultSet.fetchValue();
|
||||
},
|
||||
|
||||
async check(checkoutContinue) {
|
||||
if (this.basketOrderId) {
|
||||
return await this.checkRedirect(checkoutContinue);
|
||||
|
@ -99,26 +91,37 @@ export const useAppStore = defineStore('hedera', {
|
|||
},
|
||||
|
||||
async checkRedirect(checkoutContinue) {
|
||||
try {
|
||||
await this.checkOrder(this.basketOrderId);
|
||||
return true;
|
||||
} catch (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;
|
||||
const orderId = this.basketOrderId;
|
||||
// const orderId = 'nope!';
|
||||
const myOrder_checkConfig = await api.post('applications/myOrder_checkConfig/execute-proc', {
|
||||
schema: 'hedera',
|
||||
params: [orderId],
|
||||
}, {
|
||||
validateStatus: () => true,
|
||||
});
|
||||
|
||||
if (myOrder_checkConfig.status >= 200 && myOrder_checkConfig.status < 300) {
|
||||
return true;
|
||||
}
|
||||
|
||||
switch (myOrder_checkConfig.data.error?.message) {
|
||||
case 'orderNotOwnedByUser':
|
||||
notify(t(`errors.orderNotOwnedByUser`), 'negative');
|
||||
case 'orderConfirmed':
|
||||
case 'orderNotOwnedByUser':
|
||||
this.unloadOrder();
|
||||
await this.redirect();
|
||||
break;
|
||||
default:
|
||||
this.router.push({
|
||||
name: 'checkout',
|
||||
params: { id: this.basketOrderId },
|
||||
query: { continue: checkoutContinue }
|
||||
});
|
||||
notify(myOrder_checkConfig.data.error.message, 'negative');
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
async redirect() {
|
||||
|
|
Loading…
Reference in New Issue