1 line
5.8 KiB
JavaScript
1 line
5.8 KiB
JavaScript
"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[8084,8895],{88895:(t,a,e)=>{e.r(a),e.d(a,{default:()=>n});var s=e(81621),l=e(9588);const i={optin:{labels:["Functional","Statistics","Marketing","Do Not Track","No Choice","No Warning"],categories:["functional","statistics","marketing","do_not_track","no_choice","no_warning"],datasets:[{data:["0","0","0","0","0","0"],backgroundColor:"rgba(46, 138, 55, 1)",borderColor:"rgba(46, 138, 55, 1)",label:"A (default)",fill:"false",borderDash:[0,0]},{data:["0","0","0","0","0","0"],backgroundColor:"rgba(244, 191, 62, 1)",borderColor:"rgba(244, 191, 62, 1)",label:"B",fill:"false",borderDash:[0,0]}],max:5},optout:{labels:["Functional","Statistics","Marketing","Do Not Track","No Choice","No Warning"],categories:["functional","statistics","marketing","do_not_track","no_choice","no_warning"],datasets:[{data:["0","0","0","0","0","0"],backgroundColor:"rgba(46, 138, 55, 1)",borderColor:"rgba(46, 138, 55, 1)",label:"A (default)",fill:"false",borderDash:[0,0]},{data:["0","0","0","0","0","0"],backgroundColor:"rgba(244, 191, 62, 1)",borderColor:"rgba(244, 191, 62, 1)",label:"B",fill:"false",borderDash:[0,0]}],max:5}},o={optin:{labels:["Functional","Statistics","Marketing","Do Not Track","No Choice","No Warning"],categories:["functional","statistics","marketing","do_not_track","no_choice","no_warning"],datasets:[{data:["29","747","174","292","30","10"],backgroundColor:"rgba(46, 138, 55, 1)",borderColor:"rgba(46, 138, 55, 1)",label:"Demo A (default)",fill:"false",borderDash:[0,0]},{data:["3","536","240","389","45","32"],backgroundColor:"rgba(244, 191, 62, 1)",borderColor:"rgba(244, 191, 62, 1)",label:"Demo B",fill:"false",borderDash:[0,0]}],max:5},optout:{labels:["Functional","Statistics","Marketing","Do Not Track","No Choice","No Warning"],categories:["functional","statistics","marketing","do_not_track","no_choice","no_warning"],datasets:[{data:["29","747","174","292","30","10"],backgroundColor:"rgba(46, 138, 55, 1)",borderColor:"rgba(46, 138, 55, 1)",label:"A (default)",fill:"false",borderDash:[0,0]},{data:["3","536","240","389","45","32"],backgroundColor:"rgba(244, 191, 62, 1)",borderColor:"rgba(244, 191, 62, 1)",label:"Demo B",fill:"false",borderDash:[0,0]}],max:5}},n=(0,s.vt)((t,a)=>({consentType:"optin",setConsentType:a=>{t({consentType:a})},statisticsLoading:!1,consentTypes:[],regions:[],defaultConsentType:"optin",loaded:!1,statisticsData:i,emptyStatisticsData:i,bestPerformerEnabled:!1,daysLeft:"",abTrackingCompleted:!1,labels:[],setLabels:a=>{t({labels:a})},fetchStatisticsData:async()=>{if(!cmplz_settings.is_premium)return void t({saving:!1,loaded:!0,consentType:"optin",consentTypes:["optin","optout"],statisticsData:o,defaultConsentType:"optin",bestPerformerEnabled:!1,regions:"eu",daysLeft:11,abTrackingCompleted:!1});if(t({saving:!0}),a().loaded)return;const{daysLeft:e,abTrackingCompleted:s,consentTypes:i,statisticsData:n,defaultConsentType:r,regions:c,bestPerformerEnabled:d}=await l.doAction("get_statistics_data",{}).then(t=>t).catch(t=>{console.error(t)});t({saving:!1,loaded:!0,consentType:r,consentTypes:i,statisticsData:n,defaultConsentType:r,bestPerformerEnabled:d,regions:c,daysLeft:e,abTrackingCompleted:s})}}))},98084:(t,a,e)=>{e.r(a),e.d(a,{default:()=>r});var s=e(45111),l=e(27723),i=e(88895),o=e(86087),n=e(10790);const r=()=>{const[t,a]=(0,o.useState)(!1),[e,r]=(0,o.useState)(0),[c,d]=(0,o.useState)(0),[g,b]=(0,o.useState)(0),[m,p]=(0,o.useState)({}),{consentType:h,statisticsData:f,loaded:u,fetchStatisticsData:k,labels:C,setLabels:_}=(0,i.default)();(0,o.useEffect)(()=>{!u&&cmplz_settings.is_premium&&k()},[]),(0,o.useEffect)(()=>{""!==h&&u&&f&&f.hasOwnProperty(h)&&_(f[h].labels)},[u,h]),(0,o.useEffect)(()=>{if(""===h||!u||!f)return;let t=f[h].datasets;if(r(f[h].total),t.length>0){let e=[],s=0,l=0;t.forEach(t=>{let a=t.data;0===e.length&&(e=new Array(a.length).fill(0)),a.forEach((t,a)=>{e[a]+=parseInt(t)}),s+=parseInt(t.full_consent),l+=parseInt(t.no_consent)}),d(s),b(l),a(e)}},[u,h]);const x=t=>{let a="dial-med-low-light";return 1===t?a="dial-med-light":2===t?a="dial-light":3===t?a="dial-off-light":4===t?a="dial-min-light":5===t?a="dial-low-light":6===t&&(a="dial-med-light"),(0,n.jsx)(n.Fragment,{children:(0,n.jsx)(s.default,{name:a,color:"black"})})},N=(t,a)=>void 0===m[a]||!0===m[a]?`${(t=>t&&0!==t?(t=parseInt(t),parseFloat((t/e*100).toFixed(1))):0)(t)}%`:t;return(0,n.jsxs)("div",{className:"cmplz-statistics",children:[(0,n.jsxs)("div",{className:"cmplz-statistics-select",children:[(0,n.jsxs)("div",{className:"cmplz-statistics-select-item",children:[(0,n.jsx)(s.default,{name:"dial-max-light",color:"blue",size:"22"}),(0,n.jsx)("h2",{children:e}),(0,n.jsx)("span",{children:(0,l.__)("Total","complianz-gdpr")})]}),(0,n.jsxs)("div",{className:"cmplz-statistics-select-item",children:[(0,n.jsx)(s.default,{name:"dial-med-light",color:"green",size:"22"}),(0,n.jsx)("h2",{children:c}),(0,n.jsx)("span",{children:(0,l.__)("Full Consent","complianz-gdpr")})]}),(0,n.jsxs)("div",{className:"cmplz-statistics-select-item",children:[(0,n.jsx)(s.default,{name:"dial-min-light",color:"red",size:"22"}),(0,n.jsx)("h2",{children:g}),(0,n.jsx)("span",{children:(0,l.__)("No Consent","complianz-gdpr")})]})]}),(0,n.jsxs)("div",{className:"cmplz-statistics-list",children:[C.length>0&&C.map((a,e)=>(0,n.jsxs)("div",{className:"cmplz-statistics-list-item",children:[x(e),(0,n.jsx)("p",{className:"cmplz-statistics-list-item-text",children:a}),(0,n.jsx)("p",{className:"cmplz-statistics-list-item-number",onClick:()=>(t=>{p(a=>({...a,[t]:void 0!==a[t]&&!a[t]}))})(e),children:(0,n.jsx)("span",{children:t.hasOwnProperty(e)&&N(t[e],e)})})]},e)),0===C.length&&(0,n.jsx)("div",{className:"cmplz-statistics-list-item",children:(0,n.jsx)("p",{className:"cmplz-statistics-list-item-text",children:(0,l.__)("No data.","complianz-gdpr")})})]})]})}}}]); |