import{a as e}from"./chunk-BNv3lrIs.js";import{n as t,t as n}from"./jsx-runtime-pmtNMKr4.js";import{n as r}from"./toast-hrvP3G3Q.js";import{t as i}from"./Button-_yTP2B6J.js";import{t as a}from"./calendario-CYAmrXPS.js";import{t as o}from"./Col-Cmv4fRfN.js";import{t as s}from"./load-HIf6x4Qy.js";import{A as c,Rt as l,bi as u,fi as d,in as f,li as p,sn as m,zt as h}from"./index-CBXvBSuP.js";import{t as g}from"./withRouter-BfV3B9Vo.js";import{t as _}from"./PageHeader-C3X_ZaAc.js";import{i as v}from"./recursosHumanos-4BAI-bDJ.js";import{t as y}from"./react-select.esm-Bc2Lyozz.js";import{t as b}from"./query-string-B0XJl1mO.js";var x=e(t(),1),S=n(),C=({setShow:e,history:t})=>{let[n,a]=(0,x.useState)(null),[s,c]=(0,x.useState)(``),[l,m]=(0,x.useState)(``),[g,_]=(0,x.useState)(``),[C,T]=(0,x.useState)([]),E=()=>{try{v().then(e=>{let{data:t}=e;console.log(t),T(w(t.filter(e=>e.estado==`true`)))}).catch(e=>{})}catch{}};(0,x.useEffect)(()=>{E()},[]);let D=e=>{a(e.value)};return(0,S.jsx)(`div`,{style:{padding:`2%`},children:(0,S.jsxs)(u,{children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(d,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(o,{sm:12,md:4,lg:4,className:`d-flex align-items-end justify-content-start justify-content-md-end justify-content-lg-end`,children:(0,S.jsxs)(u.Label,{children:[`Nombre del empleado: `,(0,S.jsx)(`code`,{children:`*`})]})}),(0,S.jsx)(o,{sm:12,md:8,lg:8,children:(0,S.jsx)(y,{options:C,isSearchable:!0,placeholder:`Seleccionar...`,onChange:e=>D(e)})})]}),(0,S.jsxs)(d,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(o,{sm:12,md:4,lg:4,className:`d-flex align-items-end justify-content-start justify-content-md-end justify-content-lg-end`,children:(0,S.jsxs)(u.Label,{children:[`Fecha de inicio: `,(0,S.jsx)(`code`,{children:`*`})]})}),(0,S.jsx)(o,{sm:12,md:8,lg:8,children:(0,S.jsx)(u.Control,{type:`date`,value:s,onChange:e=>c(e.target.value)})})]}),(0,S.jsxs)(d,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(o,{sm:12,md:4,lg:4,className:`d-flex align-items-end justify-content-start justify-content-md-end justify-content-lg-end`,children:(0,S.jsxs)(u.Label,{children:[`Fecha de fin: `,(0,S.jsx)(`code`,{children:`*`})]})}),(0,S.jsx)(o,{sm:12,md:8,lg:8,children:(0,S.jsx)(u.Control,{type:`date`,value:l,onChange:e=>m(e.target.value)})})]}),(0,S.jsxs)(d,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(o,{sm:12,md:4,lg:4,className:`d-flex align-items-start justify-content-start justify-content-md-end justify-content-lg-end`,children:(0,S.jsx)(u.Label,{children:`Observaciones:`})}),(0,S.jsx)(o,{sm:12,md:8,lg:8,children:(0,S.jsx)(u.Control,{as:`textarea`,placeholder:`Ingresa observaciones en caso de ser necesarias`,value:g,onChange:e=>_(e.target.value)})})]})]}),(0,S.jsx)(`div`,{className:`divSubmit`,children:(0,S.jsxs)(i,{variant:`success`,onClick:i=>{if(i.preventDefault(),!n||!s||!l)r.warning(`Datos incompletos`);else try{h({empleado:n,fecha:{inicio:s,fin:l},motivo:g,estado:`true`}).then(n=>{let{data:i}=n;r.success(`Vacaciones registradas`),t({search:b.stringify(``)}),e(!1)})}catch(e){console.log(e)}},children:[(0,S.jsx)(p,{icon:f}),` Registrar`]})})]})})},w=e=>e.map(e=>({value:e.nombreCompleto+` - `+e.cargo,label:e.nombreCompleto}));function T(e){let{location:t,history:n}=e,[r,i]=(0,x.useState)(!0);(0,x.useEffect)(()=>{setTimeout(()=>{i(!1)},500)},[]);let[o,u]=(0,x.useState)([]),d=()=>{try{l().then(e=>{let{data:t}=e;u(t)}).catch(e=>{})}catch{}};(0,x.useEffect)(()=>{d()},[t]),console.log(o);let[f,p]=(0,x.useState)(!1),[h,g]=(0,x.useState)(null),[v,y]=(0,x.useState)(null),b=e=>{y(`Registar vacaciones de empleado`),g(e),p(!0)};return(0,S.jsxs)(S.Fragment,{children:[r&&(0,S.jsx)(s,{}),(0,S.jsx)(_,{title:`Vacaciones`,icon:m,onAddClick:()=>b((0,S.jsx)(C,{setShow:p,history:n})),addText:`Registrar`}),(0,S.jsx)(a,{eventosIniciales:o}),(0,S.jsx)(`div`,{className:`divTabla`}),(0,S.jsxs)(c,{show:f,onClose:()=>p(!1),maxWidth:`xl`,children:[(0,S.jsx)(c.Header,{closeButton:!0,onClose:()=>p(!1),children:v}),(0,S.jsx)(c.Body,{children:h})]})]})}var E=g(T);export{E as default};