forked from verdnatura/hedera-web
43 lines
915 B
JavaScript
43 lines
915 B
JavaScript
|
|
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()
|
|
}
|
|
};
|
|
|