"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[3785,4101],{43785:(e,t,n)=>{n.r(t),n.d(t,{default:()=>s});var a=n(86087),o=n(56427),l=n(4219),c=n(45111),i=n(27723),r=n(74101),p=n(52043);const s=(0,a.memo)((function(){const{removeHelpNotice:e,addHelpNotice:t,fetchFieldsData:n,showSavedSettingsNotice:s}=(0,l.default)(),{selectedSubMenuItem:d}=(0,p.default)(),[m,u]=(0,a.useState)(!1),[g,_]=(0,a.useState)(!0),[f,z]=(0,a.useState)(!1);return(0,a.useEffect)((()=>{m&&("application/json"!==m.type?(_(!0),t("import_settings","warning",(0,i.__)("You can only upload .json files","complianz-gdpr"),(0,i.__)("Incorrect extension","complianz-gdpr"),!1)):(_(!1),e("import_settings")))}),[m]),(0,a.createElement)("div",{className:"cmplz-import-form"},(0,a.createElement)("div",{className:"cmplz-import-button-container"},m&&m.name,(0,a.createElement)(o.FormFileUpload,{accept:"",icon:(0,a.createElement)(c.default,{name:"upload",color:"black"}),onChange:e=>u(e.currentTarget.files[0])},(0,i.__)("Select file","complianz-gdpr")),(0,a.createElement)("button",{disabled:g,className:"button button-default",onClick:e=>(_(!0),z(!0),void(0,r.upload)("import_settings",m).then((e=>(e.data.success?n(d).then((()=>{s((0,i.__)("Settings imported","complianz-gdpr"))})):t("import_settings","warning",(0,i.__)("You can only upload .json files","complianz-gdpr"),(0,i.__)("Incorrect extension","complianz-gdpr"),!1),z(!1),u(!1),!0))).catch((e=>{console.error(e)})))},(0,i.__)("Import","complianz-gdpr"),f&&(0,a.createElement)(c.default,{name:"loading",color:"grey"}))))}))},74101:(e,t,n)=>{n.r(t),n.d(t,{upload:()=>l});var a=n(72505),o=n.n(a);const l=(e,t,n)=>{let a=new FormData;return a.append("data",t),void 0!==n&&a.append("details",JSON.stringify(n)),o().post(cmplz_settings.admin_url+"?page=complianz&cmplz_upload_file=1&action="+e,a,{headers:{"Content-Type":"multipart/form-data","X-WP-Nonce":cmplz_settings.nonce}})}}}]);