Current File : /home/kelaby89/jrncommunityhousing.charity/wp-content/plugins/give/build/campaignBlockApp.js |
(()=>{"use strict";const e=window.React,a=window.wp.element,n=window.wp.coreData,o=window.wp.i18n;function t(){return window.GiveCampaignOptions}window.wp.apiFetch;const i=(e,a)=>{switch(e){case"amount":case"amountFromSubscriptions":const{currency:e}=t(),n=function(e){return new Intl.NumberFormat(navigator.language,{style:"currency",currency:e})}(e);return n.format(a);default:return a}},r=({showImage:a,showGoal:n,showDescription:r,campaign:c})=>{var s,m;const g=t();return(0,e.createElement)("div",{className:"give-campaigns-component-campaign",style:{"--givewp-primary-color":null!==(s=c.primaryColor)&&void 0!==s?s:"#0b72d9","--givewp-secondary-color":null!==(m=c.secondaryColor)&&void 0!==m?m:"#27ae60",...c.pagePermalink&&!g.isAdmin&&{cursor:"pointer"}},...c.pagePermalink&&!g.isAdmin&&{onClick:()=>window.location=c.pagePermalink}},a&&c.image&&(0,e.createElement)("div",{style:{backgroundImage:`url(${c.image})`},className:"give-campaigns-component-campaign-image"}),(0,e.createElement)("div",{className:"give-campaigns-component-campaign-title"},c.title),r&&(0,e.createElement)("div",{className:"give-campaigns-component-campaign-description"},c.shortDescription),n&&(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal"},(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress"},(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress-container"},(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal-progress-bar",style:{width:`${c.goalStats.percentage}%`}}))),(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal-container"},(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal-container-item"},(0,e.createElement)("span",null,(e=>{switch(e){case"amount":return(0,o.__)("Amount raised","give");case"donations":return(0,o.__)("Number of donations","give");case"donors":return(0,o.__)("Number of donors","give");case"amountFromSubscriptions":return(0,o.__)("Recurring amount raised","give");case"subscriptions":return(0,o.__)("Number of recurring donations","give");case"donorsFromSubscriptions":return(0,o.__)("Number of recurring donors","give")}})(c.goalType)),(0,e.createElement)("strong",null,i(c.goalType,c.goalStats.actual))),(0,e.createElement)("div",{className:"give-campaigns-component-campaign__goal-container-item"},(0,e.createElement)("span",null,(0,o.__)("Our goal","give")),(0,e.createElement)("strong",null,i(c.goalType,c.goal))))))},c=({attributes:a})=>{const{campaign:o,hasResolved:t}=function(e){const a=(0,n.useEntityRecord)("givewp","campaign",e);return{campaign:{...a?.record},hasResolved:a?.hasResolved}}(a?.campaignId);return t?(0,e.createElement)(r,{campaign:o,showImage:a?.showImage,showDescription:a?.showDescription,showGoal:a?.showGoal}):null},s=document.querySelectorAll("[data-givewp-campaign-block]");s&&Array.from(s).map((n=>{const o=JSON.parse(n.dataset?.attributes);return(0,a.createRoot)(n).render((0,e.createElement)(c,{attributes:o}))}))})();