Files
2026-04-28 15:13:50 +02:00

1 line
9.8 KiB
JavaScript

"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[1629,2489,4101,5228,6281],{25228:(e,t,a)=>{a.r(t),a.d(t,{default:()=>o});var n=a(86087),l=a(21366),s=a(45111),i=a(27723),c=a(10790);const o=(0,n.memo)(({value:e=!1,onChange:t,required:a,defaultValue:n,disabled:o,options:r={},canBeEmpty:d=!0,label:p})=>{if(Array.isArray(r)){let e={};r.map(t=>{e[t.value]=t.label}),r=e}return d?(""===e||!1===e||0===e)&&(e="0",r={0:(0,i.__)("Select an option","complianz-gdpr"),...r}):e||(e=Object.keys(r)[0]),(0,c.jsx)("div",{className:"cmplz-input-group cmplz-select-group",children:(0,c.jsxs)(l.bL,{value:e,defaultValue:n,onValueChange:t,required:a,disabled:o&&!Array.isArray(o),children:[(0,c.jsxs)(l.l9,{className:"cmplz-select-group__trigger",children:[(0,c.jsx)(l.WT,{}),(0,c.jsx)(s.default,{name:"chevron-down"})]}),(0,c.jsxs)(l.UC,{className:"cmplz-select-group__content",position:"popper",children:[(0,c.jsx)(l.PP,{className:"cmplz-select-group__scroll-button",children:(0,c.jsx)(s.default,{name:"chevron-up"})}),(0,c.jsx)(l.LM,{className:"cmplz-select-group__viewport",children:(0,c.jsx)(l.YJ,{children:Object.entries(r).map(([e,t])=>(0,c.jsx)(l.q7,{disabled:Array.isArray(o)&&o.includes(e),className:"cmplz-select-group__item",value:e,children:(0,c.jsx)(l.p4,{children:t})},e))})}),(0,c.jsx)(l.wn,{className:"cmplz-select-group__scroll-button",children:(0,c.jsx)(s.default,{name:"chevron-down"})})]})]})},p)})},32489:(e,t,a)=>{a.r(t),a.d(t,{default:()=>s});var n=a(51609),l=a(10790);const s=(0,n.memo)(({value:e,onChange:t,required:a,disabled:s,id:i,name:c,placeholder:o})=>{const r=i||c,[d,p]=(0,n.useState)("");return(0,n.useEffect)(()=>{p(e||"")},[e]),(0,n.useEffect)(()=>{if(e===d)return;const a=setTimeout(()=>{t(d)},400);return()=>{clearTimeout(a)}},[d]),(0,l.jsx)("div",{className:"cmplz-input-group cmplz-text-input-group",children:(0,l.jsx)("input",{type:"text",id:r,name:c,value:d,onChange:e=>(e=>{p(e)})(e.target.value),required:a,disabled:s,className:"cmplz-text-input-group__input",placeholder:o})})})},74101:(e,t,a)=>{a.r(t),a.d(t,{upload:()=>l});var n=a(71083);const l=(e,t,a)=>{let l=new FormData;return l.append("data",t),void 0!==a&&l.append("details",JSON.stringify(a)),n.A.post(cmplz_settings.admin_url+"?page=complianz&cmplz_upload_file=1&action="+e,l,{headers:{"Content-Type":"multipart/form-data","X-WP-Nonce":cmplz_settings.nonce}})}},81629:(e,t,a)=>{a.r(t),a.d(t,{default:()=>c});var n=a(81621),l=a(16535),s=a(9588),i=a(73710);const c=(0,n.vt)((e,t)=>({documentsLoaded:!1,region:"",fileName:"",serviceName:"",fetching:!1,updating:!1,loadingFields:!1,documents:[],regions:[],fields:[],editDocumentId:!1,resetEditDocumentId:t=>{e({editDocumentId:!1,region:"",serviceName:""})},editDocument:async t=>{e({updating:!0}),await s.doAction("load_processing_agreement",{id:t}).then(t=>{e({fields:t.fields,region:t.region,serviceName:t.serviceName,updating:!1,fileName:t.file_name})}).catch(e=>{console.error(e)}),e({editDocumentId:t})},setRegion:t=>{e({region:t})},setServiceName:t=>{e({serviceName:t})},updateField:(a,n)=>{let s=!1,c=!1;e((0,l.Ay)(e=>{e.fields.forEach(function(e,t){e.id===a&&(c=t,s=!0)}),!1!==c&&(e.fields[c].value=n)}));let o=(0,i.updateFieldsListWithConditions)(t().fields);e({fields:o})},save:async(a,n)=>{e({updating:!0});let l=t().editDocumentId;await s.doAction("save_processing_agreement",{fields:t().fields,region:a,serviceName:n,post_id:l}).then(t=>(e({updating:!1}),t)).catch(e=>{console.error(e)}),t().fetchData()},deleteDocuments:async a=>{let n=t().documents.filter(e=>a.includes(e.id));e(e=>({documents:e.documents.filter(e=>!a.includes(e.id))}));let l={};l.documents=n,await s.doAction("delete_processing_agreement",l).then(e=>e).catch(e=>{console.error(e)})},fetchData:async()=>{if(t().fetching)return;e({fetching:!0});const{documents:a,regions:n}=await s.doAction("get_processing_agreements",{}).then(e=>e).catch(e=>{console.error(e)});e(()=>({documentsLoaded:!0,documents:a,regions:n,fetching:!1}))},fetchFields:async t=>{let a={region:t};e({loadingFields:!0});const{fields:n}=await s.doAction("get_processing_agreement_fields",a).then(e=>e).catch(e=>{console.error(e)});let l=(0,i.updateFieldsListWithConditions)(n);e(e=>({fields:l,loadingFields:!1}))}}))},86281:(e,t,a)=>{a.r(t),a.d(t,{default:()=>f});var n=a(81629),l=a(86087),s=a(27723),i=a(56427),c=a(32636),o=a(4219),r=a(45111),d=a(74101),p=a(25228),m=a(32489),u=a(59387),g=a(10790);const f=(0,l.memo)(()=>{const{fields:e,fileName:t,fetching:a,loadingFields:f,updating:h,regions:_,resetEditDocumentId:b,fetchData:x,fetchFields:j,updateField:v,save:z,editDocumentId:N,region:y,setRegion:C,serviceName:w,setServiceName:F}=(0,n.default)(),[k,S]=(0,l.useState)(!0),[A,D]=(0,l.useState)(0),{allRequiredFieldsCompleted:E,fetchAllFieldsCompleted:q,fieldsLoaded:I,addHelpNotice:T,showSavedSettingsNotice:L,removeHelpNotice:R}=(0,o.default)();let P=React.createRef();const[U,V]=(0,l.useState)(!1),[W,H]=(0,l.useState)(!1),[O,J]=(0,l.useState)(!0),[M,Y]=(0,l.useState)(!1),[B,X]=(0,l.useState)("");(0,l.useEffect)(()=>{N&&P.current&&P.current.scrollIntoView({behavior:"smooth",block:"start"})},[N]),(0,l.useEffect)(()=>{q()},[I]),(0,l.useEffect)(()=>{S(""===y||""===w)},[y,w,a,N]),(0,l.useEffect)(()=>{(async()=>{U&&("application/pdf"!==U.type&&"application/msword"!==U.type&&"application/vnd.openxmlformats-officedocument.wordprocessingml.document"!==U.type?(J(!0),T("create-processing-agreements","warning",(0,s.__)("You can only upload .pdf, .doc or .docx files","complianz-gdpr"),(0,s.__)("Incorrect extension","complianz-gdpr"),!1)):(J(!1),R("create-processing-agreements")),U&&S(!0))})()},[U]);const G=async()=>{await z(y,w),L()};(0,l.useEffect)(()=>{""===y||""===w||a||S(!1)},[y,w,a]);let K=e.filter(e=>e=>void 0===e.conditionallyDisabled||!1===e.conditionallyDisabled),Q=Math.ceil(K.length/5),Z=(e=>{const t=5*(A-1),a=t+5;return e.slice(t,a)})(e);return(0,g.jsxs)(g.Fragment,{children:[!E&&(0,g.jsx)("div",{className:"cmplz-locked",children:(0,g.jsxs)("div",{className:"cmplz-locked-overlay",children:[(0,g.jsx)("span",{className:"cmplz-task-status cmplz-warning",children:(0,s.__)("Incomplete","complianz-gdpr")}),(0,g.jsx)("span",{children:(0,s.__)("The wizard has not been completed yet, but this field requires information from the wizard. Please complete the wizard first.","complianz-gdpr")})]})}),0===A&&(0,g.jsxs)(g.Fragment,{children:[N&&(0,g.jsx)("div",{className:"cmplz-selected-document",children:t}),(0,g.jsx)(u.default,{id:"region_for_processing_agreement",label:(0,s.__)("Region","complianz-gdpr"),required:!0,type:"select"}),(0,g.jsx)(p.default,{innerRef:P,disabled:h,onChange:e=>C(e),options:_,value:y,required:!0}),(0,g.jsx)(u.default,{id:"servicename_for_processing_agreement",label:(0,s.__)("Service name","complianz-gdpr"),required:!0,type:"text"}),(0,g.jsx)(m.default,{placeholder:(0,s.__)("e.g. Alphabet Inc","complianz-gdpr"),onChange:e=>F(e),value:w||"",disabled:h,required:!0}),(0,g.jsx)("div",{className:"cmplz-table-header",children:(0,g.jsxs)("div",{className:"cmplz-table-header-controls",children:[N&&(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)("button",{disabled:h,className:"button button-default",onClick:()=>{b(),D(0)},children:(0,s.__)("Cancel","complianz-gdpr")}),(0,g.jsx)("button",{disabled:h,className:"button button-primary",onClick:()=>D(A+1),children:(0,s.__)("Next","complianz-gdpr")}),(0,g.jsx)("button",{disabled:h,className:"button button-primary",onClick:()=>G(),children:(0,s.__)("Save","complianz-gdpr")})]}),!N&&(0,g.jsxs)(g.Fragment,{children:[U&&U.name,(0,g.jsx)(i.FormFileUpload,{accept:".pdf,.doc,.docx,application/pdf,application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document",icon:(0,g.jsx)(r.default,{name:"upload",color:"black"}),onChange:e=>V(e.currentTarget.files[0]),children:(0,s.__)("Select file","complianz-gdpr")}),(0,g.jsxs)("button",{disabled:O,className:"button button-default",onClick:e=>(J(!0),H(!0),void(0,d.upload)("upload_processing_agreement",U,{region:y,serviceName:w}).then(e=>(e.data.success?L((0,s.__)("File uploaded successfully","complianz-gdpr")):(X(e.data.error_message||(0,s.__)("Upload failed","complianz-gdpr")),Y(!0)),H(!1),V(!1),b(),x(),!0)).catch(e=>{console.error(e),T("upload_error","error",(0,s.__)("Upload failed due to network error","complianz-gdpr"),(0,s.__)("Network Error","complianz-gdpr"),!1),H(!1),V(!1)})),children:[(0,s.__)("Upload","complianz-gdpr"),W&&(0,g.jsx)(r.default,{name:"loading",color:"grey"})]}),(0,g.jsxs)("button",{disabled:k||f,className:"button cmplz-button button-primary",onClick:()=>(async()=>{await j(y),D(1)})(),children:[(0,s.__)("Create","complianz-gdpr"),f&&(0,g.jsx)(r.default,{name:"loading",color:"grey"})]})]})]})}),M&&(0,g.jsx)("div",{className:"cmplz-error-text",style:{display:M?"block":"none"},children:(0,g.jsx)("p",{children:B})})]}),A>0&&(0,g.jsxs)(g.Fragment,{children:[A<=Q&&Z.map((e,t)=>(0,g.jsx)(c.default,{index:t,field:e,isCustomField:!0,customChangeHandler:(e,t)=>((e,t)=>{v(e,t)})(e,t)},t)),(0,g.jsx)("div",{className:"cmplz-table-header",children:(0,g.jsxs)("div",{className:"cmplz-table-header-controls",children:[(0,g.jsx)("button",{disabled:h,className:"button button-default",onClick:()=>{b(),D(0)},children:(0,s.__)("Cancel","complianz-gdpr")}),(0,g.jsx)("button",{className:"button button-default",onClick:()=>D(A-1),children:(0,s.__)("Previous","complianz-gdpr")}),A<Q&&(0,g.jsx)(g.Fragment,{children:(0,g.jsx)("button",{className:"button button-primary",onClick:()=>D(A+1),children:(0,s.__)("Next","complianz-gdpr")})}),A===Q&&(0,g.jsx)(g.Fragment,{children:(0,g.jsxs)("button",{className:"button button-primary",onClick:()=>(async()=>{await z(y,w),D(0),L(),b()})(),children:[(0,s.__)("Finish","complianz-gdpr"),h&&(0,g.jsx)(r.default,{name:"loading",color:"grey"})]})}),N&&A<Q&&(0,g.jsx)(g.Fragment,{children:(0,g.jsx)("button",{disabled:h,className:"button button-primary",onClick:()=>G(),children:(0,s.__)("Save","complianz-gdpr")})})]})})]})]})})}}]);