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
|
||||||
errors: {
|
errors: {
|
||||||
statusUnauthorized: 'Accés denegat',
|
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
|
||||||
errors: {
|
errors: {
|
||||||
statusUnauthorized: 'Access denied',
|
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
|
||||||
errors: {
|
errors: {
|
||||||
statusUnauthorized: 'Acceso denegado',
|
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: {
|
errors: {
|
||||||
statusUnauthorized: 'Accès refusé',
|
statusUnauthorized: 'Accès refusé',
|
||||||
tokenConfig:
|
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
|
||||||
errors: {
|
errors: {
|
||||||
statusUnauthorized: 'Acesso negado',
|
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);
|
this.basketOrderId = localStorage.getItem(storageOrderName);
|
||||||
},
|
},
|
||||||
|
|
||||||
async checkOrder(orderId) {
|
|
||||||
const resultSet = await jApi.execQuery(
|
|
||||||
'CALL myOrder_checkConfig(#id)',
|
|
||||||
{ id: orderId }
|
|
||||||
);
|
|
||||||
resultSet.fetchValue();
|
|
||||||
},
|
|
||||||
|
|
||||||
async check(checkoutContinue) {
|
async check(checkoutContinue) {
|
||||||
if (this.basketOrderId) {
|
if (this.basketOrderId) {
|
||||||
return await this.checkRedirect(checkoutContinue);
|
return await this.checkRedirect(checkoutContinue);
|
||||||
|
@ -99,26 +91,37 @@ export const useAppStore = defineStore('hedera', {
|
||||||
},
|
},
|
||||||
|
|
||||||
async checkRedirect(checkoutContinue) {
|
async checkRedirect(checkoutContinue) {
|
||||||
try {
|
const orderId = this.basketOrderId;
|
||||||
await this.checkOrder(this.basketOrderId);
|
// const orderId = 'nope!';
|
||||||
return true;
|
const myOrder_checkConfig = await api.post('applications/myOrder_checkConfig/execute-proc', {
|
||||||
} catch (err) {
|
schema: 'hedera',
|
||||||
switch (err.code) {
|
params: [orderId],
|
||||||
case 'orderConfirmed':
|
}, {
|
||||||
case 'orderNotOwnedByUser':
|
validateStatus: () => true,
|
||||||
this.unloadOrder();
|
});
|
||||||
await this.redirect();
|
|
||||||
break;
|
if (myOrder_checkConfig.status >= 200 && myOrder_checkConfig.status < 300) {
|
||||||
default:
|
return true;
|
||||||
this.router.push({
|
|
||||||
name: 'checkout',
|
|
||||||
params: { id: this.basketOrderId },
|
|
||||||
query: { continue: checkoutContinue }
|
|
||||||
});
|
|
||||||
notify(err.message, 'negative');
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
async redirect() {
|
||||||
|
|
Loading…
Reference in New Issue