@salla.sa/twilight-components
Version:
Salla Web Component
51 lines (46 loc) • 2.11 kB
JavaScript
/*!
* Crafted with ❤ by Salla
*/
'use strict';
var index = require('./index-uoA36zqH.js');
const sallaOrderDetailsCss = "";
const SallaOrderDetails = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
}
parseOrderDetailsData(newValue) {
this.parsedOrderDetailsData = newValue;
if (typeof this.orderDetails === 'string') {
this.parsedOrderDetailsData = JSON.parse(newValue);
}
else {
this.parsedOrderDetailsData = newValue;
}
}
componentWillLoad() {
this.parseOrderDetailsData(this.orderDetails);
console.log('Parent componentWillLoad - parsedOrderDetailsData:', this.parsedOrderDetailsData);
}
renderOrderDetailsContent() {
// Check if we have parsed data
if (!this.parsedOrderDetailsData) {
console.warn('No parsedOrderDetailsData available');
return null;
}
return [
/* Product Options */
this.parsedOrderDetailsData.options && this.parsedOrderDetailsData.options.length > 0 && (index.h("salla-order-details-options", { options: this.parsedOrderDetailsData.options })),
/* Bundle Subproducts */
this.parsedOrderDetailsData.sub_products &&
this.parsedOrderDetailsData.sub_products.length > 0 && (index.h(index.Fragment, null, index.h("h2", { class: "s-order-details-bundle-title" }, salla.lang.get('pages.orders.sub_products')), index.h("div", { class: "s-order-details-bundle-content" }, this.parsedOrderDetailsData.sub_products.map(product => (index.h("salla-order-details-multiple-bundle-product", { key: product?.id, productDetails: product })))))),
];
}
render() {
return index.h(index.Host, { key: '3e7538927ca00fbb3265b1ad407fcb90e7f30ec3', class: "s-order-details-wrapper" }, this.renderOrderDetailsContent());
}
static get watchers() { return {
"orderDetails": ["parseOrderDetailsData"]
}; }
};
SallaOrderDetails.style = sallaOrderDetailsCss;
exports.salla_order_details = SallaOrderDetails;