class PostcodeStatusPopupController extends Stimulus.Controller{static get targets(){return["modal","local","national","enterPostcode"]}initialize(){}async connect(){document.addEventListener("postcode-checked",event=>{this._openRelevantPopup()})}close(){$(this.modalTarget).hide()}open(){$(this.modalTarget).show()}async _openRelevantPopup(){await fieldDoctorAPI.delivery.local()?Cookies.get("localpopupshown")||(this.openLocal(),Cookies.set("localpopupshown",!0,{expires:1})):await fieldDoctorAPI.delivery.national()?Cookies.get("nationalpopupshown")||(this.openNational(),Cookies.set("nationalpopupshown",!0,{expires:1})):this.openEnterPostcode()}_hideAll(){$(this.localTarget).hide(),$(this.nationalTarget).hide(),$(this.enterPostcodeTarget).hide()}openLocal(){this._hideAll(),$(this.localTarget).show(),this.open()}openNational(){this._hideAll(),$(this.nationalTarget).show(),this.open()}openEnterPostcode(){Cookies.get("newslettershown")||($("#newsModal").show(),$("#newsModalPostcode").text(fieldDoctorAPI.delivery.postcode),Cookies.set("newslettershown",!0,{expires:1/288}))}} //# sourceMappingURL=/cdn/shop/t/104/assets/postcode-status-popup_controller.js.map

search