import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{o 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{u as o}from"./ctiAxios-BIVP6fGU.js";import{t as s}from"./button-C7b7AmGo.js";import{n as c,t as l}from"./row-D9jSUsjd.js";import{t as u}from"./useMutation-Dw_VO9_w.js";import{t as d}from"./UndoOutlined-2WspCEN7.js";import{t as f}from"./Loader-C9fMgHPw.js";import{F as p,G as m,K as h,Q as g,et as _,g as v,h as y,m as b,p as x,s as S}from"./index-BqyXv5bE.js";function C(){let e=r();return u({mutationFn:e=>v(e),meta:{successMessage:`Licence ajoutée`,errorMessage:`Erreur lors de l'ajout de la licence`},onSettled:async()=>{await e.invalidateQueries({queryKey:y.all})}})}var w=e(t()),T=n(),E=[{title:`Modules installés`,dataKey:`label`,key:`label`,width:250,dataGetter:({columns:e,column:t,columnIndex:n,rowData:r,rowIndex:i})=>(0,T.jsxs)(`div`,{children:[r.label,` `,(0,T.jsx)(`span`,{style:{float:`right`},children:r.licenceOK===`OK`?(0,T.jsx)(h,{twoToneColor:`#52c41a`}):(0,T.jsx)(m,{twoToneColor:`#cf1322`})})]})},{title:`Code`,dataKey:`softCode`,key:`softCode`,width:250},{title:`Expiration`,dataKey:`licenceDate`,key:`licenceDate`,width:250},{title:`Type`,dataKey:`licenceType`,key:`licenceType`,width:250}],D=[{title:`Licences serveur installées`,dataKey:`machineName`,key:`machineName`,width:250},{title:`FINESS`,dataKey:`finess`,key:`finess`,width:250,dataGetter:({columns:e,column:t,columnIndex:n,rowData:r,rowIndex:i})=>(0,T.jsxs)(`div`,{children:[r.finess,(0,T.jsx)(`span`,{style:{float:`right`},children:r.finessOK===`true`?(0,T.jsx)(h,{twoToneColor:`#52c41a`}):(0,T.jsx)(m,{twoToneColor:`#cf1322`})})]})},{title:`Module`,dataKey:`softCode`,key:`softCode`,width:250},{title:`Date expiration`,dataKey:`endDate`,key:`endDate`,width:250,dataGetter:({columns:e,column:t,columnIndex:n,rowData:r,rowIndex:i})=>(0,T.jsxs)(`div`,{children:[r.endDate,(0,T.jsx)(`span`,{style:{float:`right`},children:r.endDateOK===`true`?(0,T.jsx)(h,{twoToneColor:`#52c41a`}):(0,T.jsx)(m,{twoToneColor:`#cf1322`})})]})}],O=()=>{let e=b(),t=C(),n=e.data??x,[r,u]=(0,w.useState)(!1),[m,h]=(0,w.useState)(``),[v,O]=(0,w.useState)(!1),k=()=>{o.invalidateQueries({queryKey:y.all})},A=e=>{u(e)},j=()=>{O(!v)};return e.isPending?(0,T.jsx)(`div`,{className:`loading-wrapper`,children:(0,T.jsx)(f,{style:{height:`auto`}})}):(0,T.jsxs)(T.Fragment,{children:[(0,T.jsx)(i,{children:(0,T.jsx)(`title`,{children:`iCTI | Gestion des licences`})}),(0,T.jsx)(_,{open:v,onCancel:j,onOk:()=>{t.mutate(m,{onSuccess:()=>{h(``),j()}})},okText:`Ajouter`,cancelText:`Annuler`,confirmLoading:t.isPending,title:`Ajouter une licence`,children:(0,T.jsx)(`div`,{className:`form-row`,children:(0,T.jsxs)(`div`,{className:`form-item`,children:[(0,T.jsx)(`span`,{className:`first-label`,children:`Clé de la licence`}),(0,T.jsx)(a,{value:m,onChange:e=>{h(e.target.value)}})]})})}),(0,T.jsxs)(`div`,{className:`component-header`,children:[(0,T.jsx)(`div`,{className:`header-title`,children:`Gestions des licences`}),(0,T.jsxs)(`div`,{className:`header-actions`,children:[(0,T.jsx)(p,{title:`Actualiser`,children:(0,T.jsx)(s,{type:`link`,onClick:k,children:(0,T.jsx)(d,{})})}),(0,T.jsx)(s,{type:`primary`,onClick:j,children:`Ajouter une licence`})]})]}),(0,T.jsx)(`div`,{className:`licences-info`,children:(0,T.jsxs)(l,{children:[(0,T.jsxs)(c,{span:12,children:[(0,T.jsxs)(`div`,{className:`licences-info-row`,children:[(0,T.jsx)(`span`,{children:`FINESS :`}),n.env.FINESS]}),(0,T.jsxs)(`div`,{className:`licences-info-row`,children:[(0,T.jsx)(`span`,{children:`Serveur :`}),n.session.SERVERNAME]})]}),(0,T.jsx)(c,{span:12,children:(0,T.jsxs)(`div`,{className:`settings-single-check`,children:[(0,T.jsx)(g,{size:`small`,className:`switch`,checked:r,onChange:A}),(0,T.jsx)(`span`,{children:`Afficher les licences installées`})]})})]})}),(0,T.jsx)(`div`,{className:`component-content`,children:r?(0,T.jsx)(S,{columns:D,data:n.licences}):(0,T.jsx)(S,{columns:E,data:n.modules})})]})};O.propTypes={};export{O as default};