0
1
Fork 0
hedera-web-mindshore/js/hedera/basket.js

43 lines
915 B
JavaScript
Raw Normal View History

2023-01-30 10:08:26 +00:00
module.exports = class {
constructor(app) {
this.app = app;
let orderId = localStorage.getItem('hederaBasket');
if (orderId) orderId = parseInt(orderId);
this.orderId = orderId;
}
async check(conn, hash) {
this.hash = hash;
const orderId = localStorage.getItem('hederaBasket');
const resultSet = await this.app.conn.execQuery(
'CALL myOrder_check(#id)',
{id: orderId}
);
const status = resultSet.fetchValue();
if (!status) return;
const isOk = status == 'updated' || status == 'ok';
if (status == 'updated')
Htk.Toast.showWarning(_('Order items updated'));
if (!isOk) {
const params = {form: 'ecomerce/checkout'};
if (orderId) params.id = orderId;
this.hash.setAll(params);
}
return isOk;
}
async load(orderId) {
if (this.orderId != orderId) {
localStorage.setItem('hederaBasket', orderId);
this.orderId = orderId;
}
await this.check()
}
};