import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{fr as r,o as i,r as a}from"./axios-v6FV69Ne.js";import{t as o}from"./index.esm-DR3o6Tiw.js";import{t as s}from"./ctiAxios-BIVP6fGU.js";import{t as c}from"./button-C7b7AmGo.js";import{t as l}from"./useMutation-Dw_VO9_w.js";import{t as u}from"./queryOptions-Cg9orY1Y.js";import{t as d}from"./UndoOutlined-2WspCEN7.js";import{F as f,L as p,s as m}from"./index-BqyXv5bE.js";var h=`modules/pmsissr/php/PMSI_getImportsValo.php`;async function g(){let e=new FormData;return e.append(`action`,`get`),(await s({method:`post`,url:r()+h,data:e,headers:{"Content-Type":`multipart/form-data`},responseType:`json`})).data}async function _({file:e}){let t=new FormData;return t.append(`action`,`post`),t.append(`fileName`,e.name),t.append(`fileData`,e),(await s({method:`post`,url:r()+h,data:t,headers:{"Content-Type":`multipart/form-data`},responseType:`json`})).data}var v={all:[`valoSsrImports`],list:()=>[...v.all,`list`]},y=()=>u({queryKey:v.list(),queryFn:g}),b=()=>a(y());function x(){let e=i();return l({mutationFn:_,meta:{successMessage:`Fichier importé`,errorMessage:`Erreur lors de l'import du fichier`},onSettled:async()=>{await e.invalidateQueries({queryKey:v.list()})}})}var S=e(t()),C=n(),w=()=>{let e=b(),t=x(),n=e.data?.imports??[],r=(0,S.useRef)(),i=()=>{e.refetch()},a=()=>{r.current.click()},s=e=>{let n=e.target.files[0];n&&t.mutate({file:n})},l=[{title:`Import dans CTI`,dataKey:`date`},{title:`Nombre séjour`,dataKey:`nb_sejours`},{title:`Nombre séjour HC`,dataKey:`nb_sejours_hc`},{title:`Nombre séjour HP`,dataKey:`nb_sejours_hp`},{title:`Nombre séjour non valorisé`,dataKey:`nb_sejours_non_valorises`},{title:`Nombre séjour pédiatrique`,dataKey:`nb_sejours_pediatrique_valorises`},{title:`Année de valorisation`,dataKey:`vclass`},{title:`Coefficient Géographique`,dataKey:`coeffgeo`},{title:`Coefficient Spécialisation`,dataKey:`coeffspe`},{title:`Coefficient prudentiel`,dataKey:`coeffprud`},{title:`Coefficient honoraire`,dataKey:`coeffhono`},{title:`Coefficient transition`,dataKey:`coefftrans`},{title:`Fraction DMA`,dataKey:`fracdma`}].map(e=>({width:100,resizable:!0,key:e.dataKey,...e}));return(0,C.jsxs)(C.Fragment,{children:[(0,C.jsx)(o,{children:(0,C.jsx)(`title`,{children:`iCTI | Gestion des imports`})}),(0,C.jsxs)(`div`,{className:`component-header`,children:[(0,C.jsx)(`div`,{className:`header-title`,children:`Imports VALO SSR`}),(0,C.jsxs)(`div`,{className:`header-actions`,children:[(0,C.jsx)(f,{title:`Actualiser`,children:(0,C.jsx)(c,{type:`link`,onClick:i,children:(0,C.jsx)(d,{})})}),(0,C.jsx)(c,{size:`default`,type:`primary`,icon:(0,C.jsx)(p,{}),onClick:a,loading:t.isPending,children:`Importer un fichier`}),(0,C.jsx)(`input`,{type:`file`,ref:r,onChange:s,style:{display:`none`}})]})]}),(0,C.jsx)(`div`,{className:`component-content`,children:(0,C.jsx)(`div`,{className:`valo-imports`,children:(0,C.jsx)(m,{rowKey:`oid`,columns:l,loading:e.isFetching,data:n})})})]})};export{w as default};