@salla.sa/twilight-components
Version:
Salla Web Component
4 lines • 1.23 kB
JavaScript
/*!
* Crafted with ❤ by Salla
*/
import{r as t,h as s,H as e}from"./p-BQQ2x3w_.js";const r=class{constructor(s){t(this,s),this.parsedSections=[]}parseProducts(t){let s=[];if("string"==typeof t)try{const e=JSON.parse(t);s=this.extractSections(e)}catch(e){console.error("Invalid JSON passed to bundleSections prop:",t),s=[]}else t&&(s=this.extractSections(t));this.parsedSections=s}extractSections(t){return t.bundle&&t.bundle.sections&&Array.isArray(t.bundle.sections)?t.bundle.sections:Array.isArray(t)?t:t.sections&&Array.isArray(t.sections)?t.sections:(console.warn("No valid sections found in data:",t),[])}isCartPage(){return salla.url.is_page("cart")}renderCartPage(){return s("salla-multiple-bundle-product-cart",{sections:this.parsedSections})}renderDetailsPage(){return s("salla-multiple-bundle-product-details",{sections:this.parsedSections})}componentWillLoad(){this.parseProducts(this.bundleSections)}render(){return s(e,{key:"2a4510d1ccd3dc840d25a288cb0788a7dd23672c",class:"s-multiple-bundle-product-wrapper"},this.isCartPage()?this.renderCartPage():this.renderDetailsPage())}static get watchers(){return{bundleSections:["parseProducts"]}}};r.style=":host{display:block}";export{r as salla_multiple_bundle_product}