import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{n as r}from"./axios-v6FV69Ne.js";import{t as i}from"./index.esm-DR3o6Tiw.js";import{t as a}from"./input-Fres-Ye6.js";import{i as o}from"./ctiAxios-BIVP6fGU.js";import{a as s}from"./notification-C7Dk1wtU.js";import{t as c}from"./button-C7b7AmGo.js";import{t as l}from"./popconfirm-CrjlZKtV.js";import{t as u}from"./UndoOutlined-2WspCEN7.js";import{t as d}from"./Loader-C9fMgHPw.js";import{F as f,ht as p,ot as m,s as h}from"./index-BqyXv5bE.js";import{a as g,t as _}from"./synchronize.queries-fAYtvNse.js";var v=e(t()),y=e(r()),b=n(),x=({swfData:e})=>{let[t]=m.useForm(),n=(0,v.useMemo)(()=>{let t=e.split(`|`);return{exe:t[0],title:t[1],options:t.splice(2,t.length-1).filter(e=>e)}},[e]),r=_(n.exe),y=()=>{r.refetch()},x=async()=>{let e=t.getFieldsValue(),r={exe:n.exe},i=``;for(let t in e)e[t]&&(i=`${i}${t} ${e[t]} `);r.args=i,s({type:`success`,message:`Synchronisation`,description:`Synchronisation lancée sur le serveur`}),await o(`modules/outils/php/httpService_synchronizeManager_exec.php`,r),y()};function S(e){return(0,b.jsx)(`div`,{className:`content-table`,children:(0,b.jsx)(h,{columns:g,data:e.map((e,t)=>({...e,key:t})),loading:r.isFetching})})}return!r.data?.jobs||r.isPending?(0,b.jsx)(`div`,{className:`loading-wrapper`,children:(0,b.jsx)(d,{})}):(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(i,{children:(0,b.jsx)(`title`,{children:`iCTI | Synchronisation`})}),(0,b.jsxs)(`div`,{className:`component-header`,children:[(0,b.jsx)(`div`,{className:`header-title`,children:n.title}),(0,b.jsx)(`div`,{className:`header-actions`,children:(0,b.jsx)(f,{title:`Actualiser`,children:(0,b.jsx)(c,{type:`link`,onClick:y,children:(0,b.jsx)(u,{})})})})]}),(0,b.jsx)(`div`,{className:`component-content`,children:(0,b.jsx)(p,{defaultActiveKey:`1`,items:[{label:`Synchronisation des données`,key:`1`,children:(0,b.jsxs)(b.Fragment,{children:[!n.options||!n.options.length?null:(0,b.jsx)(`div`,{className:`sync-options`,children:(0,b.jsx)(m,{form:t,children:n.options.map(e=>{let t=e.split(`#`)[0],n=e.split(`#`)[1],r=e.split(`#`)[3];return(0,b.jsxs)(`div`,{className:`form-item`,children:[(0,b.jsx)(`div`,{className:`first-label`,children:t}),(0,b.jsx)(m.Item,{name:n,extra:r,children:(0,b.jsx)(a,{})},n)]},n)})})}),(0,b.jsx)(`div`,{style:{display:`flex`,flexDirection:`row`,justifyContent:`center`},children:(0,b.jsxs)(l,{title:`Êtes-vous sur de vouloir lancer la synchronisation ?`,onConfirm:x,children:[(0,b.jsx)(c,{type:`primary`,style:{width:500},children:`Lancer`}),(0,b.jsx)(`p`,{children:r.data.lastJobs[0].last_all_endded})]})})]})},{label:`Historique des travaux`,key:`2`,children:(0,b.jsx)(b.Fragment,{children:S(r.data.jobs)})}]})})]})};x.propTypes={data:y.default.string};var S=v.memo(x);export{S as default};