1 line
6.1 KiB
JavaScript
1 line
6.1 KiB
JavaScript
"use strict";(globalThis.webpackChunkcomplianz_gdpr=globalThis.webpackChunkcomplianz_gdpr||[]).push([[1222,2752],{12752:(a,t,s)=>{s.r(t),s.d(t,{default:()=>i});var n=s(86087),e=s(27723),r=s(4219),l=s(21222),o=s(10790);const i=(0,n.memo)(()=>{const{showSavedSettingsNotice:a}=(0,r.default)(),{translationStatus:t,translationDataLoading:s,saving:i,error:c,testResults:d,fetchTranslationStatus:u,fetchTranslations:g,testTranslations:m,clearError:p}=(0,l.UseTranslationsData)();(0,n.useEffect)(()=>{u()},[]);return s?(0,o.jsx)("div",{className:"cmplz-translation-management",children:(0,o.jsx)("p",{children:(0,e.__)("Loading translation status...","complianz-gdpr")})}):c?(0,o.jsxs)("div",{className:"cmplz-translation-management",children:[(0,o.jsx)("p",{className:"cmplz-error",children:c}),(0,o.jsx)("button",{className:"button button-secondary",onClick:()=>{p(),u()},children:(0,e.__)("Retry","complianz-gdpr")})]}):t?(0,o.jsxs)("div",{className:"cmplz-translation-management",children:[t.language_files&&Object.keys(t.language_files).length>0&&(0,o.jsxs)("div",{className:"cmplz-language-files",children:[(0,o.jsx)("h4",{children:(0,e.__)("Language Files Status","complianz-gdpr")}),(0,o.jsx)("p",{children:(0,e.__)("If the translations have been recently fetched or updated, you may want to reload the page or clear the cache to see the latest changes.","complianz-gdpr")}),(0,o.jsxs)("table",{className:"wp-list-table widefat fixed striped",children:[(0,o.jsx)("thead",{children:(0,o.jsxs)("tr",{children:[(0,o.jsx)("th",{children:(0,e.__)("Language","complianz-gdpr")}),(0,o.jsx)("th",{children:(0,e.__)("Status","complianz-gdpr")}),(0,o.jsx)("th",{children:(0,e.__)("Last Updated","complianz-gdpr")})]})}),(0,o.jsx)("tbody",{children:Object.entries(t.language_files).map(([a,t])=>{const s=(a=>{const t={no_translation_needed:{icon:"✓",text:(0,e.__)("No translation needed","complianz-gdpr"),className:"cmplz-status-ok"},available:{icon:"✓",text:(0,e.__)("Available","complianz-gdpr"),className:"cmplz-status-ok"},not_fetched:{icon:"⏳",text:(0,e.__)("Not fetched","complianz-gdpr"),className:"cmplz-status-warning"},not_supported:{icon:"✗",text:(0,e.__)("Not supported","complianz-gdpr"),className:"cmplz-status-error"},version_mismatch:{icon:"⚠",text:(0,e.__)("Version mismatch","complianz-gdpr"),className:"cmplz-status-warning"},invalid_format:{icon:"✗",text:(0,e.__)("Invalid format","complianz-gdpr"),className:"cmplz-status-error"},error:{icon:"✗",text:(0,e.__)("Error","complianz-gdpr"),className:"cmplz-status-error"}};return t[a.status]||t.unknown})(t);return(0,o.jsxs)("tr",{children:[(0,o.jsx)("td",{children:(0,o.jsx)("strong",{children:a})}),(0,o.jsx)("td",{children:(0,o.jsxs)("span",{className:s.className,children:[s.icon," ",s.text]})}),(0,o.jsx)("td",{children:t.last_updated?new Date(1e3*t.last_updated).toLocaleString():(0,e.__)("N/A","complianz-gdpr")})]},a)})})]})]}),(0,o.jsx)("div",{style:{marginBottom:"20px",textAlign:"center"},children:(0,o.jsx)("button",{className:"button button-primary",onClick:async()=>{const t=await g();t.success&&a(t.message)},disabled:i,children:i?(0,e.__)("Checking...","complianz-gdpr"):(0,e.__)("Check Now","complianz-gdpr")})})]}):(0,o.jsx)("div",{className:"cmplz-translation-management",children:(0,o.jsx)("p",{children:(0,e.__)("No status information available","complianz-gdpr")})})})},21222:(a,t,s)=>{s.r(t),s.d(t,{UseTranslationsData:()=>r});var n=s(81621),e=s(9588);const r=(0,n.vt)((a,t)=>({translationDataLoaded:!1,translationDataLoading:!1,saving:!1,error:null,translationStatus:null,cronStatus:null,cronInterval:"cmplz_weekly",testResults:null,fetchTranslationStatus:async()=>{if(!t().translationDataLoading){a({translationDataLoading:!0,error:null});try{const t=await e.doAction("get_translation_status",{});t.request_success?a({translationStatus:t.data,translationDataLoaded:!0,translationDataLoading:!1,error:null}):a({translationDataLoaded:!0,translationDataLoading:!1,error:t.message||"Failed to load translation status"})}catch(t){a({translationDataLoaded:!0,translationDataLoading:!1,error:"Error loading translation status"})}}},fetchCronStatus:async()=>{a({translationDataLoading:!0,error:null});try{const t=await e.doAction("get_cron_status",{});t.request_success?a({cronStatus:t.data,cronInterval:t.data.interval_setting||"cmplz_weekly",translationDataLoaded:!0,translationDataLoading:!1,error:null}):a({translationDataLoaded:!0,translationDataLoading:!1,error:t.message||"Failed to load cron status"})}catch(t){a({translationDataLoaded:!0,translationDataLoading:!1,error:"Error loading cron status"})}},updateCronInterval:async s=>{a({saving:!0,error:null});try{const n=await e.doAction("update_cron_interval",{interval:s});return n.request_success?(a({cronInterval:s,saving:!1,error:null}),await t().fetchCronStatus(),{success:!0,message:n.message}):(a({saving:!1,error:n.message||"Failed to update interval"}),{success:!1,message:n.message})}catch(t){return a({saving:!1,error:"Error updating interval"}),{success:!1,message:"Error updating interval"}}},fetchTranslations:async()=>{a({saving:!0,error:null});try{const s=await e.doAction("fetch_translations",{});return s.request_success?(a({saving:!1,error:null}),await t().fetchTranslationStatus(),{success:!0,message:s.message||"Translations fetched successfully!"}):(a({saving:!1,error:s.message||"Failed to fetch translations"}),{success:!1,message:s.message})}catch(t){return a({saving:!1,error:"Error fetching translations"}),{success:!1,message:"Error fetching translations"}}},refreshCronStatus:async()=>{await t().fetchCronStatus()},testTranslations:async()=>{a({saving:!0,error:null});try{const t=await e.doAction("test_translations",{});return t.request_success?(a({testResults:t.data,saving:!1,error:null}),{success:!0,message:"Translation test completed!"}):(a({saving:!1,error:t.message||"Failed to test translations"}),{success:!1,message:t.message})}catch(t){return a({saving:!1,error:"Error testing translations"}),{success:!1,message:"Error testing translations"}}},clearError:()=>{a({error:null})},reset:()=>{a({translationDataLoaded:!1,translationDataLoading:!1,saving:!1,error:null,translationStatus:null,cronStatus:null,cronInterval:"cmplz_weekly",testResults:null})}}))}}]); |