import{o as e}from"./chunk-jRWAZmH_.js";import{n as t,t as n}from"./jsx-runtime-CEixWuwE.js";import{t as r}from"./index.esm-DR3o6Tiw.js";import{t as i}from"./button-C7b7AmGo.js";import{t as a}from"./table-DnmGk0cX.js";import{c as o,s,t as c}from"./chunk-4N6VE7H7-BV8msCgV.js";import{t as l}from"./Loader-C9fMgHPw.js";import{a as u,o as d,r as f,t as p}from"./ResetButton-De0DkZJ5.js";var m=e(t()),h=n();function g(){let e=s(),t=o(),[n,g]=(0,m.useState)(e.state?.filteredInfo||{}),_=Object.values(n).filter(Boolean).length!==0,v=f();if(v.status===`pending`)return(0,h.jsx)(`div`,{className:`loading-wrapper`,children:(0,h.jsx)(l,{style:{height:`auto`}})});if(v.status===`error`)return(0,h.jsx)(`p`,{children:`Error :(`});let y=_?u(v.data,n):[...v.data],b=[`matricule`,`nom`,`prenom`,`etablissement_contrat`,`qualification`],x={};b.forEach(e=>{let t=new Set(y?.map(t=>t[e]).filter(Boolean));x[e]=Array.from(t).sort((e,t)=>e.localeCompare(t)).map(e=>({text:e,value:e}))});let S=(n,r,i)=>{g(r),t(e.pathname,{replace:!0,state:{...e.state,filteredInfo:r}})},C=()=>{g({}),t(e.pathname,{replace:!0,state:{...e.state,filteredInfo:{}}})},w=[{title:`Matricule`,dataIndex:`matricule`,key:`matricule`,onFilter:(e,t)=>t.matricule.toString().toLowerCase().includes(e.toLowerCase()),filteredValue:n.matricule||null,filters:x.matricule,filterSearch:!0},{title:`Nom`,dataIndex:`nom`,key:`nom`,filteredValue:n.nom||null,filters:x.nom,filterSearch:!0,onFilter:(e,t)=>t.nom.toString().toLowerCase().includes(e.toLowerCase())},{title:`Prénom`,dataIndex:`prenom`,key:`prenom`,filteredValue:n.prenom||null,filters:x.prenom,onFilter:(e,t)=>t.prenom.toString().toLowerCase().includes(e.toLowerCase()),filterSearch:!0},{title:`Etablissement du contrat`,dataIndex:`etablissement_contrat`,key:`etablissement_contrat`,filteredValue:n.etablissement_contrat||null,filters:x.etablissement_contrat,onFilter:(e,t)=>t.etablissement_contrat.toString().toLowerCase().includes(e.toLowerCase()),filterSearch:!0},{title:`Qualification`,dataIndex:`qualification`,key:`qualification`,filteredValue:n.qualification||null,filters:x.qualification,onFilter:(e,t)=>t.qualification.toString().toLowerCase().includes(e.toLowerCase()),filterSearch:!0},{title:`Action`,dataIndex:``,key:`action`,width:`8%`,render:e=>(0,h.jsx)(c,{to:{pathname:`/rh/ventilations/${e.salarie_id}/settings`,state:{fromSider:!0,filteredSalarieIds:d(v.data,n),filteredInfo:n}},children:(0,h.jsx)(i,{children:`Éditer`})})}];return(0,h.jsxs)(`div`,{className:``,children:[(0,h.jsx)(r,{children:(0,h.jsx)(`title`,{children:`iCTI | Liste des Salariés`})}),(0,h.jsxs)(`div`,{className:`component-header`,children:[(0,h.jsx)(`div`,{className:`header-title`,children:`Liste des Salariés`}),(0,h.jsx)(p,{disabled:!_,onClick:C,children:`Réinitialiser les filtres`})]}),(0,h.jsx)(`div`,{className:`component-content`,children:(0,h.jsx)(a,{columns:w,dataSource:y,pagination:{pageSize:50},scroll:{y:`calc(100vh - 240px)`},onChange:S,size:`small`})})]})}export{g as default};