import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{In as r,Ln as i,jt as a,n as o,o as s}from"./axios-v6FV69Ne.js";import{t as c}from"./index.esm-DR3o6Tiw.js";import{t as l}from"./button-C7b7AmGo.js";import{t as u}from"./popconfirm-CrjlZKtV.js";import{t as d}from"./useMutation-Dw_VO9_w.js";import{t as f}from"./UndoOutlined-2WspCEN7.js";import{t as p}from"./Loader-C9fMgHPw.js";import{F as m,ht as h,s as g}from"./index-BqyXv5bE.js";import{a as _,i as v,n as y,r as b}from"./synchronize.queries-fAYtvNse.js";var x={icon:{tag:`svg`,attrs:{viewBox:`64 64 896 896`,focusable:`false`},children:[{tag:`path`,attrs:{d:`M880 112H144c-17.7 0-32 14.3-32 32v736c0 17.7 14.3 32 32 32h736c17.7 0 32-14.3 32-32V144c0-17.7-14.3-32-32-32zM641.7 520.8L442.3 677.6c-7.4 5.8-18.3.6-18.3-8.8V355.3c0-9.4 10.9-14.7 18.3-8.8l199.4 156.7a11.2 11.2 0 010 17.6z`}}]},name:`play-square`,theme:`filled`};i();var S=e(t()),C=S.forwardRef(function(e,t){return S.createElement(a,r(r({},e),{},{ref:t,icon:x}))});function w(){let e=s();return d({mutationFn:({exePath:e,year:t})=>v(e,t),meta:{successMessage:`Synchronisation lancée sur le serveur`,errorMessage:`Erreur lors du lancement de la synchronisation`},onSettled:async(t,n,r)=>{await e.invalidateQueries({queryKey:b.ssaeJobs(r.year)})}})}var T=e(o()),E=n(),D=({softCode:e,year:t})=>{let n=y(t),r=w(),i=()=>{n.refetch()},a=e=>{r.mutate({exePath:e,year:t})};function o(t){return e===`iCTI_ssae`?(0,E.jsx)(`div`,{style:{display:`flex`,flexDirection:`column`},children:t.map(e=>(0,E.jsxs)(`div`,{style:{padding:`10px 20px`},children:[(0,E.jsx)(u,{title:e.confirm,onConfirm:()=>a(e.exe_path),okText:`Lancer la synchronisation`,cancelText:`Annuler`,children:(0,E.jsx)(l,{type:`primary`,icon:(0,E.jsx)(C,{}),children:e.button})}),(0,E.jsx)(`br`,{}),(0,E.jsx)(`span`,{style:{margin:`10px 0px  0px`},children:e.last_status})]},e.button))}):(0,E.jsx)(`div`,{})}function s(e){return(0,E.jsx)(`div`,{className:`content-table`,children:(0,E.jsx)(g,{columns:_,data:e.map((e,t)=>({...e,key:t})),loading:n.isFetching})})}return!n.data?.jobs||n.isPending?(0,E.jsx)(`div`,{className:`loading-wrapper`,children:(0,E.jsx)(p,{})}):(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(c,{children:(0,E.jsx)(`title`,{children:`iCTI | Synchronisation`})}),(0,E.jsxs)(`div`,{className:`component-header`,children:[(0,E.jsx)(`div`,{className:`header-title`,children:`Synchronisation des données`}),(0,E.jsx)(`div`,{className:`header-actions`,children:(0,E.jsx)(m,{title:`Actualiser`,children:(0,E.jsx)(l,{type:`link`,onClick:i,children:(0,E.jsx)(f,{})})})})]}),(0,E.jsx)(`div`,{className:`component-content`,children:(0,E.jsx)(h,{defaultActiveKey:`1`,items:[{label:`Synchronisation des données`,key:`1`,children:(0,E.jsx)(E.Fragment,{children:o(n.data.execs)})},{label:`Historique des travaux`,key:`2`,children:(0,E.jsx)(E.Fragment,{children:s(n.data.jobs)})}]})})]})};D.propTypes={softCode:T.default.string,year:T.default.string};var O=S.memo(D);export{O as default};