@salla.sa/twilight-components
Version:
Salla Web Component
4 lines • 2.82 kB
JavaScript
/*!
* Crafted with ❤ by Salla
*/
import{r as s,h as t,H as a,a as i}from"./p-Dbv0I4re.js";const e=class{constructor(t){s(this,t),this.exclude=[]}componentWillLoad(){return salla.onReady().then((()=>{if("string"==typeof this.exclude)try{this.exclude=JSON.parse(this.exclude)}catch(s){salla.logger.error("salla-payments:: failed to parse the exclude props!",this.exclude),this.exclude=[]}this.paymentSlot=this.host.querySelector('[slot="payment"]')?.innerHTML||'<li class="s-payments-list-item"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" alt="{payment}" /></li>',this.sbcSlot=this.host.querySelector('[slot="sbc"]')?.innerHTML||'<li class="s-payments-list-item"><a target="_blank" href="{link}"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" class="s-payments-sbc-image" alt="SBC" /></a></li>',this.codSlot=this.host.querySelector('[slot="cod"]')?.innerHTML||'<li class="s-payments-list-item"><img width="100%" height="100%" decoding="async" loading="lazy" src="{image}" alt="COD" /></li>',this.payments=salla.config.get("store.settings.payments")}))}render(){const s=!this.exclude.includes("made-in-ksa")&&salla.config.get("store.settings.made_in_ksa"),i=this.exclude.includes("sbc")?null:salla.config.get("store.settings.certificate.id");return t(a,{key:"6afc19aa3f0a72847228c7de6c783c3ba9f38ee9",class:"s-payments-list-wrap"},t("ul",{key:"8311e5bc5aa86535d77ccad64b56c5ddb3028f87",class:"s-payments-list"},s&&t("li",{key:"5b8769a8c89273363e835905de1cd9f02fec1df6",class:"s-payments-list-item"},t("img",{key:"7b42b4a0a14f4bdab3138e79c37ad62e74247732",width:"100%",height:"100%",decoding:"async",loading:"lazy",src:salla.url.cdn("images/made-in-ksa.svg",58,58),alt:"made in KSA certified"})),this.payments.map((s=>t("div","cod"==s?{id:"cod-slot",innerHTML:this.codSlot.replace(/\{image\}/g,salla.url.cdn("images/payment/cod_mini.png",58,58))}:{id:"payment-slot",innerHTML:this.paymentSlot.replace(/\{image\}/g,salla.url.cdn(`images/payment/${s}_mini.png`,58,58)).replace(/\{payment\}/g,s)}))),i&&t("div",{key:"253ef6d5520979a22c48f1e63c53eab3fd5e21ad",id:"sbc-slot",innerHTML:this.sbcSlot.replace(/\{image\}/g,salla.url.cdn("images/sbc.png",58,58)).replace(/\{link\}/g,`https://eauthenticate.saudibusiness.gov.sa/certificate-details/${i}`)})))}componentDidRender(){this.host.querySelectorAll("#payment-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll("#sbc-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelectorAll("#cod-slot").forEach((s=>s.replaceWith(s.firstChild))),this.host.querySelector('[slot="payment"]')?.remove(),this.host.querySelector('[slot="sbc"]')?.remove(),this.host.querySelector('[slot="cod"]')?.remove()}get host(){return i(this)}};e.style=":host{display:block}";export{e as salla_payments}