|
1
|
|
-import{s as H,t as O,E as T,a as U,g as j,v as Q,x as W,e as q,D as J,N as K,o as G,Q as X,z as Y,A as Z,B as x,r as ee,h as te,d as le}from"./element-plus.js?ver=2.11.0";import"./dayjs.js?ver=2.11.0";import{I as oe}from"./app.js?ver=2.11.0";import{ae as V,af as S,D as c,E as y,I as o,K as l,Q as n,S as s,J as B,F as u,ab as I,R as k,P as m,a7 as se,O as F,B as ae}from"./vue.js?ver=2.11.0";import{_ as N}from"./emoji-picker.js?ver=2.11.0";import"./fcom-utils.js?ver=2.11.0";import"./vendor.js?ver=2.11.0";import"./vue-router.js?ver=2.11.0";import"./pinia.js?ver=2.11.0";import"./milkdown.js?ver=2.11.0";const ie={name:"AddPaywallModal",props:{modelValue:{type:Boolean,default:!1},spaceProfile:{type:Object,required:!0}},emits:["update:modelValue","added"],data(){return{products:[],productID:null,saving:!1,creatingProduct:!1,fetchingProducts:!1,newPaywall:{title:"",price:0}}},computed:{addPaywallModal:{get(){return this.modelValue},set(e){this.$emit("update:modelValue",e)}}},methods:{isProductAdded(e){var t,_;return(_=(t=this.spaceProfile.settings)==null?void 0:t.cart_product_ids)==null?void 0:_.includes(e)},initCreateProduct(){this.productID=null,this.newPaywall={title:"",price:0}},createProduct(){var e,t;this.creatingProduct=!0,this.$post("cart/products/create",{title:(e=this.newPaywall)==null?void 0:e.title,price:(t=this.newPaywall)==null?void 0:t.price}).then(_=>{var b;this.products.push(_.product),this.productID=(b=_.product)==null?void 0:b.id,this.productID&&this.addPaywall()}).catch(_=>{this.$handleError(_)}).finally(()=>{this.creatingProduct=!1})},searchProducts(e=""){e&&e.length<3||this.fetchProducts(e)},fetchProducts(e=""){this.fetchingProducts=!0,this.$get("cart/products/search",{search:e,space_id:this.spaceProfile.id}).then(t=>{this.products=t.products}).catch(t=>{this.$handleError(t)}).finally(()=>{this.fetchingProducts=!1})},addPaywall(){this.saving=!0,this.$post("cart/spaces/"+this.spaceProfile.id+"/paywalls",{cart_product_id:this.productID,space_id:this.spaceProfile.id}).then(e=>{var t;this.$notify.success(e.message),this.$emit("added",(t=e.paywall)==null?void 0:t.ID),this.addPaywallModal=!1}).catch(e=>{this.$handleError(e)}).finally(()=>{this.saving=!1})}},mounted(){this.fetchProducts()}},ne={class:"fcom_topic_selector"},de={class:"fcom_select_photo",style:{float:"left"}},ce=["src","alt"],re=["innerHTML"];function _e(e,t,_,b,a,r){const f=H,M=O,g=V("Plus"),C=T,w=U,P=j,p=Q,v=W,E=q,A=J,D=S("loading");return c(),y(A,{"modal-class":"fcom_common_dialog",class:"fcom_high_drawer",size:e.drawerWidth,modelValue:r.addPaywallModal,"onUpdate:modelValue":t[6]||(t[6]=d=>r.addPaywallModal=d),"close-on-click-modal":!1,visible:r.addPaywallModal,direction:"rtl"},{header:o(()=>[l("h4",null,n(e.$t("Add Paywall")),1)]),default:o(()=>[s(v,{onSubmit:t[5]||(t[5]=se(d=>e.doNothing(),["prevent"])),"label-position":"top"},{default:o(()=>[s(p,null,{default:o(()=>[l("div",ne,[B((c(),y(M,{style:{width:"100%"},"fit-input-width":"",modelValue:a.productID,"onUpdate:modelValue":t[0]||(t[0]=d=>a.productID=d),filterable:"",clearable:"",remote:"",loading:a.fetchingProducts,"remote-method":r.searchProducts,placeholder:e.$t("Search Product")},{default:o(()=>[(c(!0),u(k,null,I(a.products,d=>(c(),y(f,{key:d.id,label:d.title,value:d.id,disabled:r.isProductAdded(d.id),class:"fcom_with_photo_option"},{default:o(()=>[l("span",de,[l("img",{src:d.image,alt:d.title},null,8,ce),l("span",null,n(d.title),1)]),l("span",{style:{float:"right",color:"#8492a6","font-size":"13px"},innerHTML:d.price},null,8,re)]),_:2},1032,["label","value","disabled"]))),128))]),_:1},8,["modelValue","loading","remote-method","placeholder"])),[[D,a.fetchingProducts]]),s(E,{ref:"creating_product_ref",onShow:r.initCreateProduct,placement:"bottom",width:400,trigger:"click"},{reference:o(()=>[s(w,{class:"fcom_secondary_button"},{default:o(()=>[s(C,null,{default:o(()=>[s(g)]),_:1}),l("span",null,n(e.$t("New")),1)]),_:1})]),default:o(()=>[s(v,{modelValue:a.newPaywall,"onUpdate:modelValue":t[4]||(t[4]=d=>a.newPaywall=d),"label-position":"top"},{default:o(()=>[s(p,{label:e.$t("Title")},{default:o(()=>[s(P,{modelValue:a.newPaywall.title,"onUpdate:modelValue":t[1]||(t[1]=d=>a.newPaywall.title=d),placeholder:e.$t("Title of the product")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(p,{label:e.$t("Price")},{default:o(()=>[s(P,{modelValue:a.newPaywall.price,"onUpdate:modelValue":t[2]||(t[2]=d=>a.newPaywall.price=d),type:"number",placeholder:e.$t("Price of the product"),min:0},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(p,null,{default:o(()=>[s(w,{class:"fcom_primary_button",onClick:t[3]||(t[3]=d=>r.createProduct()),loading:a.creatingProduct,disabled:a.creatingProduct},{default:o(()=>[m(n(e.$t("Create")),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["onShow"])])]),_:1}),s(p,null,{default:o(()=>[s(w,{class:"fcom_primary_button",loading:a.saving,onClick:r.addPaywall},{default:o(()=>[m(n(e.$t("Add")),1)]),_:1},8,["loading","onClick"])]),_:1})]),_:1})]),_:1},8,["size","modelValue","visible"])}const ue=N(ie,[["render",_e]]),me={name:"ManagePaywalls",components:{ImagePlaceholder:oe,AddPaywallModal:ue},props:["spaceProfile","savingCount"],emits:["close"],data(){return{paywalls:[],loading:!1,removing:!1,addPaywallModal:!1,removePaywallModal:!1,revokeAccess:!1,removePaywall:null,installing:!1,hasFluentCart:this.hasFeature("has_fluentcart")}},computed:{spaceType(){return this.spaceProfile.type=="course"?this.$t("courses"):this.$t("spaces")}},methods:{copyCheckoutUrl(e){this.$toClipboard(e,this.$t("Checkout URL copied to clipboard"))},initRemovePaywall(e){this.$nextTick(()=>{this.removePaywallModal=!0,this.removePaywall=e})},initAddPaywall(){this.$nextTick(()=>{this.addPaywallModal=!0})},resetPaywall(){var t;const e=((t=this.spaceProfile.settings)==null?void 0:t.cart_product_ids)||[];e.splice(e.indexOf(this.removePaywall.ID),1),this.spaceProfile.settings.cart_product_ids=e,this.removePaywall=null,this.revokeAccess=!1,this.getPaywalls()},paywallAdded(e){var _;const t=((_=this.spaceProfile.settings)==null?void 0:_.cart_product_ids)||[];t.includes(e)||t.push(e),this.spaceProfile.settings.cart_product_ids=t,this.getPaywalls()},getPaywalls(){this.loading=!0,this.$get("cart/spaces/"+this.spaceProfile.id+"/paywalls",{space_id:this.spaceProfile.id}).then(e=>{this.paywalls=e.paywalls}).catch(e=>{this.$handleError(e)}).finally(()=>{this.loading=!1})},deletePaywall(){this.removing=!0,this.$del("cart/spaces/"+this.spaceProfile.id+"/paywalls",{cart_product_id:this.removePaywall.ID,revoke_access:this.revokeAccess}).then(e=>{this.$notify.success(e.message),this.removePaywallModal=!1,this.resetPaywall()}).catch(e=>{this.$handleError(e)}).finally(()=>{this.removing=!1})},installPlugin(){this.installing=!0,this.$post("settings/install_plugin",{plugin:"fluent-cart"}).then(e=>{e.is_installed?this.$notify.success(e.message):this.$handleError(this.$t("Sorry, FluentCart could not be installed")),this.hasFluentCart=!0,this.getPaywalls()}).catch(e=>{this.$handleError(e)}).finally(()=>{this.installing=!1})}},mounted(){var t;(((t=this.spaceProfile.settings)==null?void 0:t.cart_product_ids)||[])&&this.hasFluentCart&&this.getPaywalls()}},he={style:{"max-width":"800px",margin:"0 auto"}},pe={class:"fcom_card_sections"},fe={class:"fcom_card_section_heading"},Pe={class:"fcom_section_primary_item_title"},ye={class:"fcom_heading_item"},ge={key:0,class:"fcom_section_item_actions"},we={class:"fcom_section_primary"},ve={class:"fcom_section_primary_item"},ke={class:"fcom_section_primary_item_title"},be={class:"fcom_heading_item"},Ce={class:"fcom_shape"},Ve={class:"fcom_section_item_actions"},Me=["href"],Ee=["href"],Ae={class:"fcom_section_items"},De={class:"fcom_section_item_title"},Ie={class:"fcom_heading_item"},$e={class:"fcom_shape"},Fe={class:"fcom_section_item_actions"},Te=["innerHTML"],Ue={key:2,style:{padding:"1rem"}},Se={key:1,class:"fcom_section_item"},Be={class:"fcom_section_primary"},Ne={class:"fcom_section_primary_item"},ze=["disabled"],Le={class:"dialog_header"},Re={class:"dialog_left"},He={class:"dialog_body"},Oe={style:{"text-align":"center"}},je={class:"fcom_heading_item",style:{"justify-content":"center"}},Qe={class:"fcom_shape"},We={style:{margin:"1rem 0px 0.8rem"}},qe={class:"dialog_footer"};function Je(e,t,_,b,a,r){const f=U,M=le,g=X,C=V("MoreFilled"),w=T,P=Y,p=Z,v=x,E=V("ImagePlaceholder"),A=ee,D=K,d=V("AddPaywallModal"),z=te,L=G,R=S("loading");return c(),u(k,null,[s(D,{class:"fcom_full_editor_main lockscreen_editor"},{default:o(()=>[s(A,null,{default:o(()=>[l("div",he,[l("div",pe,[l("div",fe,[l("div",Pe,[l("div",ye,[ae(e.$slots,"title",{},()=>[l("h4",null,n(e.$t("Manage Paywalls")),1)])])]),a.hasFluentCart?(c(),u("div",ge,[s(f,{class:"fcom_primary_button",onClick:t[0]||(t[0]=i=>r.initAddPaywall())},{default:o(()=>[m(n(e.$t("Add Paywall")),1)]),_:1})])):F("",!0)]),a.hasFluentCart?(c(),u(k,{key:0},[a.loading||a.removing?(c(),y(M,{key:0,class:"white_loaded",rows:5,animated:!0})):a.paywalls.length?(c(!0),u(k,{key:1},I(a.paywalls,i=>(c(),u("div",{class:"fcom_section_item",key:i.ID},[l("div",we,[l("div",ve,[l("div",ke,[l("h4",be,[l("span",Ce,[s(g,{src:i==null?void 0:i.thumbnail},null,8,["src"])]),l("span",null,n((i==null?void 0:i.post_title)||""),1)])]),l("div",Ve,[s(v,{trigger:"click","popper-class":"fcom_pop_action"},{dropdown:o(()=>[s(p,null,{default:o(()=>[s(P,null,{default:o(()=>[l("a",{href:i==null?void 0:i.view_url,target:"_blank",rel:"noopener"},n(e.$t("View Product")),9,Me)]),_:2},1024),s(P,null,{default:o(()=>[l("a",{href:i==null?void 0:i.admin_url,target:"_blank",rel:"noopener"},n(e.$t("Edit Product")),9,Ee)]),_:2},1024),s(P,{type:"danger",onClick:h=>r.initRemovePaywall(i)},{default:o(()=>[m(n(e.$t("Delete Paywall")),1)]),_:1},8,["onClick"])]),_:2},1024)]),default:o(()=>[s(f,{"aria-label":e.$t("View actions"),size:"small",class:"fcom_dot_menu",text:""},{default:o(()=>[s(w,null,{default:o(()=>[s(C)]),_:1})]),_:1},8,["aria-label"])]),_:2},1024)])]),l("div",Ae,[(c(!0),u(k,null,I(i.variants,h=>(c(),u("div",{class:"fcom_section_item",key:h.id},[l("div",De,[l("div",Ie,[l("span",$e,[h.photo?(c(),y(g,{key:0,src:h.photo},null,8,["src"])):(c(),y(g,{key:1},{default:o(()=>[s(E)]),_:1}))]),l("span",null,n(h.variation_title),1)])]),l("div",Fe,[l("span",{class:"fcom_price",innerHTML:h.total_price},null,8,Te),s(v,{trigger:"click"},{dropdown:o(()=>[s(p,null,{default:o(()=>[s(P,{onClick:$=>r.copyCheckoutUrl(h.checkout_url)},{default:o(()=>[m(n(e.$t("Copy Checkout URL")),1)]),_:1},8,["onClick"])]),_:2},1024)]),default:o(()=>[s(f,{"aria-label":e.$t("View actions"),size:"small",class:"fcom_dot_menu",text:"",style:{padding:"0 6px"}},{default:o(()=>[s(w,null,{default:o(()=>[s(C)]),_:1})]),_:1},8,["aria-label"])]),_:2},1024)])]))),128))])])]))),128)):(c(),u("div",Ue,[l("p",null,n(e.$t("No paywall has been added yet")),1)]))],64)):(c(),u("div",Se,[l("div",Be,[l("div",Ne,[l("span",null,[m(n(e.$t("To monetize your ")+r.spaceType+", ")+" ",1),B((c(),u("a",{disabled:a.installing,onClick:t[1]||(t[1]=(...i)=>r.installPlugin&&r.installPlugin(...i)),class:"fcom_link"},[m(n(e.$t("click here")),1)],8,ze)),[[R,a.installing]]),m(" "+n(e.$t("to install and activate FluentCart.")),1)])])])]))])])]),_:3})]),_:3}),a.addPaywallModal?(c(),y(d,{key:0,modelValue:a.addPaywallModal,"onUpdate:modelValue":t[2]||(t[2]=i=>a.addPaywallModal=i),spaceProfile:_.spaceProfile,onAdded:r.paywallAdded},null,8,["modelValue","spaceProfile","onAdded"])):F("",!0),s(L,{"modal-class":"fcom_common_dialog","close-on-click-modal":!1,"append-to-body":!0,width:e.drawerWidth,modelValue:a.removePaywallModal,"onUpdate:modelValue":t[5]||(t[5]=i=>a.removePaywallModal=i),direction:"rtl",onClose:t[6]||(t[6]=i=>a.removePaywallModal=!1)},{header:o(()=>[l("div",Le,[l("div",Re,[l("h4",null,n(e.$t("Delete Paywall")),1)])])]),footer:o(()=>[l("div",qe,[s(f,{class:"fcom_primary_button",disabled:a.removing,onClick:r.deletePaywall},{default:o(()=>[m(n(e.$t("Delete")),1)]),_:1},8,["disabled","onClick"]),s(f,{class:"fcom_secondary_button",onClick:t[4]||(t[4]=i=>a.removePaywallModal=!1)},{default:o(()=>[m(n(e.$t("Cancel")),1)]),_:1})])]),default:o(()=>{var i,h;return[l("div",He,[l("div",Oe,[l("h4",je,[l("span",Qe,[s(g,{src:(i=a.removePaywall)==null?void 0:i.thumbnail},null,8,["src"])]),l("span",null,n((h=a.removePaywall)==null?void 0:h.post_title),1)]),l("p",We,n(e.$t("Are you sure you want to delete this paywall? This action cannot be undone.")),1),s(z,{class:"fcom_checkbox",modelValue:a.revokeAccess,"onUpdate:modelValue":t[3]||(t[3]=$=>a.revokeAccess=$),"true-value":"yes","false-value":"no"},{default:o(()=>[m(n(e.$t("Also remove the this space from the product integration?")),1)]),_:1},8,["modelValue"])])])]}),_:1},8,["width","modelValue"])],64)}const st=N(me,[["render",Je]]);export{st as default}; |
|
1
|
+import{s as H,t as O,E as T,a as U,g as j,v as Q,x as W,e as q,D as J,N as K,o as G,Q as X,z as Y,A as Z,B as x,r as ee,h as te,d as le}from"./element-plus.js?ver=2.10.01";import"./dayjs.js?ver=2.10.01";import{I as oe}from"./app.js?ver=2.10.01";import{ae as V,af as S,D as c,E as y,I as o,K as l,Q as n,S as s,J as B,F as u,ab as I,R as k,P as m,a7 as se,O as F,B as ae}from"./vue.js?ver=2.10.01";import{_ as N}from"./emoji-picker.js?ver=2.10.01";import"./fcom-utils.js?ver=2.10.01";import"./vendor.js?ver=2.10.01";import"./vue-router.js?ver=2.10.01";import"./pinia.js?ver=2.10.01";import"./milkdown.js?ver=2.10.01";const ie={name:"AddPaywallModal",props:{modelValue:{type:Boolean,default:!1},spaceProfile:{type:Object,required:!0}},emits:["update:modelValue","added"],data(){return{products:[],productID:null,saving:!1,creatingProduct:!1,fetchingProducts:!1,newPaywall:{title:"",price:0}}},computed:{addPaywallModal:{get(){return this.modelValue},set(e){this.$emit("update:modelValue",e)}}},methods:{isProductAdded(e){var t,_;return(_=(t=this.spaceProfile.settings)==null?void 0:t.cart_product_ids)==null?void 0:_.includes(e)},initCreateProduct(){this.productID=null,this.newPaywall={title:"",price:0}},createProduct(){var e,t;this.creatingProduct=!0,this.$post("cart/products/create",{title:(e=this.newPaywall)==null?void 0:e.title,price:(t=this.newPaywall)==null?void 0:t.price}).then(_=>{var b;this.products.push(_.product),this.productID=(b=_.product)==null?void 0:b.id,this.productID&&this.addPaywall()}).catch(_=>{this.$handleError(_)}).finally(()=>{this.creatingProduct=!1})},searchProducts(e=""){e&&e.length<3||this.fetchProducts(e)},fetchProducts(e=""){this.fetchingProducts=!0,this.$get("cart/products/search",{search:e,space_id:this.spaceProfile.id}).then(t=>{this.products=t.products}).catch(t=>{this.$handleError(t)}).finally(()=>{this.fetchingProducts=!1})},addPaywall(){this.saving=!0,this.$post("cart/spaces/"+this.spaceProfile.id+"/paywalls",{cart_product_id:this.productID,space_id:this.spaceProfile.id}).then(e=>{var t;this.$notify.success(e.message),this.$emit("added",(t=e.paywall)==null?void 0:t.ID),this.addPaywallModal=!1}).catch(e=>{this.$handleError(e)}).finally(()=>{this.saving=!1})}},mounted(){this.fetchProducts()}},ne={class:"fcom_topic_selector"},de={class:"fcom_select_photo",style:{float:"left"}},ce=["src","alt"],re=["innerHTML"];function _e(e,t,_,b,a,r){const f=H,M=O,g=V("Plus"),C=T,w=U,P=j,p=Q,v=W,E=q,A=J,D=S("loading");return c(),y(A,{"modal-class":"fcom_common_dialog",class:"fcom_high_drawer",size:e.drawerWidth,modelValue:r.addPaywallModal,"onUpdate:modelValue":t[6]||(t[6]=d=>r.addPaywallModal=d),"close-on-click-modal":!1,visible:r.addPaywallModal,direction:"rtl"},{header:o(()=>[l("h4",null,n(e.$t("Add Paywall")),1)]),default:o(()=>[s(v,{onSubmit:t[5]||(t[5]=se(d=>e.doNothing(),["prevent"])),"label-position":"top"},{default:o(()=>[s(p,null,{default:o(()=>[l("div",ne,[B((c(),y(M,{style:{width:"100%"},"fit-input-width":"",modelValue:a.productID,"onUpdate:modelValue":t[0]||(t[0]=d=>a.productID=d),filterable:"",clearable:"",remote:"",loading:a.fetchingProducts,"remote-method":r.searchProducts,placeholder:e.$t("Search Product")},{default:o(()=>[(c(!0),u(k,null,I(a.products,d=>(c(),y(f,{key:d.id,label:d.title,value:d.id,disabled:r.isProductAdded(d.id),class:"fcom_with_photo_option"},{default:o(()=>[l("span",de,[l("img",{src:d.image,alt:d.title},null,8,ce),l("span",null,n(d.title),1)]),l("span",{style:{float:"right",color:"#8492a6","font-size":"13px"},innerHTML:d.price},null,8,re)]),_:2},1032,["label","value","disabled"]))),128))]),_:1},8,["modelValue","loading","remote-method","placeholder"])),[[D,a.fetchingProducts]]),s(E,{ref:"creating_product_ref",onShow:r.initCreateProduct,placement:"bottom",width:400,trigger:"click"},{reference:o(()=>[s(w,{class:"fcom_secondary_button"},{default:o(()=>[s(C,null,{default:o(()=>[s(g)]),_:1}),l("span",null,n(e.$t("New")),1)]),_:1})]),default:o(()=>[s(v,{modelValue:a.newPaywall,"onUpdate:modelValue":t[4]||(t[4]=d=>a.newPaywall=d),"label-position":"top"},{default:o(()=>[s(p,{label:e.$t("Title")},{default:o(()=>[s(P,{modelValue:a.newPaywall.title,"onUpdate:modelValue":t[1]||(t[1]=d=>a.newPaywall.title=d),placeholder:e.$t("Title of the product")},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(p,{label:e.$t("Price")},{default:o(()=>[s(P,{modelValue:a.newPaywall.price,"onUpdate:modelValue":t[2]||(t[2]=d=>a.newPaywall.price=d),type:"number",placeholder:e.$t("Price of the product"),min:0},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),s(p,null,{default:o(()=>[s(w,{class:"fcom_primary_button",onClick:t[3]||(t[3]=d=>r.createProduct()),loading:a.creatingProduct,disabled:a.creatingProduct},{default:o(()=>[m(n(e.$t("Create")),1)]),_:1},8,["loading","disabled"])]),_:1})]),_:1},8,["modelValue"])]),_:1},8,["onShow"])])]),_:1}),s(p,null,{default:o(()=>[s(w,{class:"fcom_primary_button",loading:a.saving,onClick:r.addPaywall},{default:o(()=>[m(n(e.$t("Add")),1)]),_:1},8,["loading","onClick"])]),_:1})]),_:1})]),_:1},8,["size","modelValue","visible"])}const ue=N(ie,[["render",_e]]),me={name:"ManagePaywalls",components:{ImagePlaceholder:oe,AddPaywallModal:ue},props:["spaceProfile","savingCount"],emits:["close"],data(){return{paywalls:[],loading:!1,removing:!1,addPaywallModal:!1,removePaywallModal:!1,revokeAccess:!1,removePaywall:null,installing:!1,hasFluentCart:this.hasFeature("has_fluentcart")}},computed:{spaceType(){return this.spaceProfile.type=="course"?this.$t("courses"):this.$t("spaces")}},methods:{copyCheckoutUrl(e){this.$toClipboard(e,this.$t("Checkout URL copied to clipboard"))},initRemovePaywall(e){this.$nextTick(()=>{this.removePaywallModal=!0,this.removePaywall=e})},initAddPaywall(){this.$nextTick(()=>{this.addPaywallModal=!0})},resetPaywall(){var t;const e=((t=this.spaceProfile.settings)==null?void 0:t.cart_product_ids)||[];e.splice(e.indexOf(this.removePaywall.ID),1),this.spaceProfile.settings.cart_product_ids=e,this.removePaywall=null,this.revokeAccess=!1,this.getPaywalls()},paywallAdded(e){var _;const t=((_=this.spaceProfile.settings)==null?void 0:_.cart_product_ids)||[];t.includes(e)||t.push(e),this.spaceProfile.settings.cart_product_ids=t,this.getPaywalls()},getPaywalls(){this.loading=!0,this.$get("cart/spaces/"+this.spaceProfile.id+"/paywalls",{space_id:this.spaceProfile.id}).then(e=>{this.paywalls=e.paywalls}).catch(e=>{this.$handleError(e)}).finally(()=>{this.loading=!1})},deletePaywall(){this.removing=!0,this.$del("cart/spaces/"+this.spaceProfile.id+"/paywalls",{cart_product_id:this.removePaywall.ID,revoke_access:this.revokeAccess}).then(e=>{this.$notify.success(e.message),this.removePaywallModal=!1,this.resetPaywall()}).catch(e=>{this.$handleError(e)}).finally(()=>{this.removing=!1})},installPlugin(){this.installing=!0,this.$post("settings/install_plugin",{plugin:"fluent-cart"}).then(e=>{e.is_installed?this.$notify.success(e.message):this.$handleError(this.$t("Sorry, FluentCart could not be installed")),this.hasFluentCart=!0,this.getPaywalls()}).catch(e=>{this.$handleError(e)}).finally(()=>{this.installing=!1})}},mounted(){var t;(((t=this.spaceProfile.settings)==null?void 0:t.cart_product_ids)||[])&&this.hasFluentCart&&this.getPaywalls()}},he={style:{"max-width":"800px",padding:"20px",margin:"0 auto"}},pe={class:"fcom_card_sections"},fe={class:"fcom_card_section_heading"},Pe={class:"fcom_section_primary_item_title"},ye={class:"fcom_heading_item"},ge={key:0,class:"fcom_section_item_actions"},we={class:"fcom_section_primary"},ve={class:"fcom_section_primary_item"},ke={class:"fcom_section_primary_item_title"},be={class:"fcom_heading_item"},Ce={class:"fcom_shape"},Ve={class:"fcom_section_item_actions"},Me=["href"],Ee=["href"],Ae={class:"fcom_section_items"},De={class:"fcom_section_item_title"},Ie={class:"fcom_heading_item"},$e={class:"fcom_shape"},Fe={class:"fcom_section_item_actions"},Te=["innerHTML"],Ue={key:2,style:{padding:"1rem"}},Se={key:1,class:"fcom_section_item"},Be={class:"fcom_section_primary"},Ne={class:"fcom_section_primary_item"},ze=["disabled"],Le={class:"dialog_header"},Re={class:"dialog_left"},He={class:"dialog_body"},Oe={style:{"text-align":"center"}},je={class:"fcom_heading_item",style:{"justify-content":"center"}},Qe={class:"fcom_shape"},We={style:{margin:"1rem 0px 0.8rem"}},qe={class:"dialog_footer"};function Je(e,t,_,b,a,r){const f=U,M=le,g=X,C=V("MoreFilled"),w=T,P=Y,p=Z,v=x,E=V("ImagePlaceholder"),A=ee,D=K,d=V("AddPaywallModal"),z=te,L=G,R=S("loading");return c(),u(k,null,[s(D,{class:"fcom_full_editor_main lockscreen_editor"},{default:o(()=>[s(A,null,{default:o(()=>[l("div",he,[l("div",pe,[l("div",fe,[l("div",Pe,[l("div",ye,[ae(e.$slots,"title",{},()=>[l("h4",null,n(e.$t("Manage Paywalls")),1)])])]),a.hasFluentCart?(c(),u("div",ge,[s(f,{class:"fcom_primary_button",onClick:t[0]||(t[0]=i=>r.initAddPaywall())},{default:o(()=>[m(n(e.$t("Add Paywall")),1)]),_:1})])):F("",!0)]),a.hasFluentCart?(c(),u(k,{key:0},[a.loading||a.removing?(c(),y(M,{key:0,class:"white_loaded",rows:5,animated:!0})):a.paywalls.length?(c(!0),u(k,{key:1},I(a.paywalls,i=>(c(),u("div",{class:"fcom_section_item",key:i.ID},[l("div",we,[l("div",ve,[l("div",ke,[l("h4",be,[l("span",Ce,[s(g,{src:i==null?void 0:i.thumbnail},null,8,["src"])]),l("span",null,n((i==null?void 0:i.post_title)||""),1)])]),l("div",Ve,[s(v,{trigger:"click","popper-class":"fcom_pop_action"},{dropdown:o(()=>[s(p,null,{default:o(()=>[s(P,null,{default:o(()=>[l("a",{href:i==null?void 0:i.view_url,target:"_blank",rel:"noopener"},n(e.$t("View Product")),9,Me)]),_:2},1024),s(P,null,{default:o(()=>[l("a",{href:i==null?void 0:i.admin_url,target:"_blank",rel:"noopener"},n(e.$t("Edit Product")),9,Ee)]),_:2},1024),s(P,{type:"danger",onClick:h=>r.initRemovePaywall(i)},{default:o(()=>[m(n(e.$t("Delete Paywall")),1)]),_:1},8,["onClick"])]),_:2},1024)]),default:o(()=>[s(f,{"aria-label":e.$t("View actions"),size:"small",class:"fcom_dot_menu",text:""},{default:o(()=>[s(w,null,{default:o(()=>[s(C)]),_:1})]),_:1},8,["aria-label"])]),_:2},1024)])]),l("div",Ae,[(c(!0),u(k,null,I(i.variants,h=>(c(),u("div",{class:"fcom_section_item",key:h.id},[l("div",De,[l("div",Ie,[l("span",$e,[h.photo?(c(),y(g,{key:0,src:h.photo},null,8,["src"])):(c(),y(g,{key:1},{default:o(()=>[s(E)]),_:1}))]),l("span",null,n(h.variation_title),1)])]),l("div",Fe,[l("span",{class:"fcom_price",innerHTML:h.total_price},null,8,Te),s(v,{trigger:"click"},{dropdown:o(()=>[s(p,null,{default:o(()=>[s(P,{onClick:$=>r.copyCheckoutUrl(h.checkout_url)},{default:o(()=>[m(n(e.$t("Copy Checkout URL")),1)]),_:1},8,["onClick"])]),_:2},1024)]),default:o(()=>[s(f,{"aria-label":e.$t("View actions"),size:"small",class:"fcom_dot_menu",text:"",style:{padding:"0 6px"}},{default:o(()=>[s(w,null,{default:o(()=>[s(C)]),_:1})]),_:1},8,["aria-label"])]),_:2},1024)])]))),128))])])]))),128)):(c(),u("div",Ue,[l("p",null,n(e.$t("No paywall has been added yet")),1)]))],64)):(c(),u("div",Se,[l("div",Be,[l("div",Ne,[l("span",null,[m(n(e.$t("To monetize your ")+r.spaceType+", ")+" ",1),B((c(),u("a",{disabled:a.installing,onClick:t[1]||(t[1]=(...i)=>r.installPlugin&&r.installPlugin(...i)),class:"fcom_link"},[m(n(e.$t("click here")),1)],8,ze)),[[R,a.installing]]),m(" "+n(e.$t("to install and activate FluentCart.")),1)])])])]))])])]),_:3})]),_:3}),a.addPaywallModal?(c(),y(d,{key:0,modelValue:a.addPaywallModal,"onUpdate:modelValue":t[2]||(t[2]=i=>a.addPaywallModal=i),spaceProfile:_.spaceProfile,onAdded:r.paywallAdded},null,8,["modelValue","spaceProfile","onAdded"])):F("",!0),s(L,{"modal-class":"fcom_common_dialog","close-on-click-modal":!1,"append-to-body":!0,width:e.drawerWidth,modelValue:a.removePaywallModal,"onUpdate:modelValue":t[5]||(t[5]=i=>a.removePaywallModal=i),direction:"rtl",onClose:t[6]||(t[6]=i=>a.removePaywallModal=!1)},{header:o(()=>[l("div",Le,[l("div",Re,[l("h4",null,n(e.$t("Delete Paywall")),1)])])]),footer:o(()=>[l("div",qe,[s(f,{class:"fcom_primary_button",disabled:a.removing,onClick:r.deletePaywall},{default:o(()=>[m(n(e.$t("Delete")),1)]),_:1},8,["disabled","onClick"]),s(f,{class:"fcom_secondary_button",onClick:t[4]||(t[4]=i=>a.removePaywallModal=!1)},{default:o(()=>[m(n(e.$t("Cancel")),1)]),_:1})])]),default:o(()=>{var i,h;return[l("div",He,[l("div",Oe,[l("h4",je,[l("span",Qe,[s(g,{src:(i=a.removePaywall)==null?void 0:i.thumbnail},null,8,["src"])]),l("span",null,n((h=a.removePaywall)==null?void 0:h.post_title),1)]),l("p",We,n(e.$t("Are you sure you want to delete this paywall? This action cannot be undone.")),1),s(z,{class:"fcom_checkbox",modelValue:a.revokeAccess,"onUpdate:modelValue":t[3]||(t[3]=$=>a.revokeAccess=$),"true-value":"yes","false-value":"no"},{default:o(()=>[m(n(e.$t("Also remove the this space from the product integration?")),1)]),_:1},8,["modelValue"])])])]}),_:1},8,["width","modelValue"])],64)}const st=N(me,[["render",Je]]);export{st as default}; |