import{r as e}from"./chunk-QTnfLwEv.js";import{n as t,t as n}from"./jsx-runtime-BWRPWl8p.js";import{t as r}from"./calendario-CKssedVC.js";import{Da as i,Ei as a,G as o,Li as s,W as c,da as l,ki as u,ma as d,nn as f,tn as p,wn as m,xn as h}from"./index-DccLTdzK.js";import{t as g}from"./withRouter-CRkgdzqj.js";import{t as _}from"./PageHeader-DNnlanBD.js";import{i as v}from"./recursosHumanos-DhFdyQQH.js";import{t as y}from"./react-select.esm-B6s_VbxN.js";import{t as b}from"./query-string-D4ReIoyH.js";var x=e(t(),1),S=n(),C=({setShow:e,history:t})=>{let[n,r]=(0,x.useState)(null),[o,c]=(0,x.useState)(``),[p,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=>{r(e.value)};return(0,S.jsx)(`div`,{style:{padding:`2%`},children:(0,S.jsxs)(s,{children:[(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(u,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(l,{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)(s.Label,{children:[`Nombre del empleado: `,(0,S.jsx)(`code`,{children:`*`})]})}),(0,S.jsx)(l,{sm:12,md:8,lg:8,children:(0,S.jsx)(y,{options:C,isSearchable:!0,placeholder:`Seleccionar...`,onChange:e=>D(e)})})]}),(0,S.jsxs)(u,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(l,{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)(s.Label,{children:[`Fecha de inicio: `,(0,S.jsx)(`code`,{children:`*`})]})}),(0,S.jsx)(l,{sm:12,md:8,lg:8,children:(0,S.jsx)(s.Control,{type:`date`,value:o,onChange:e=>c(e.target.value)})})]}),(0,S.jsxs)(u,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(l,{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)(s.Label,{children:[`Fecha de fin: `,(0,S.jsx)(`code`,{children:`*`})]})}),(0,S.jsx)(l,{sm:12,md:8,lg:8,children:(0,S.jsx)(s.Control,{type:`date`,value:p,onChange:e=>m(e.target.value)})})]}),(0,S.jsxs)(u,{className:`mb-2 mb-md-4 mb-lg-7`,children:[(0,S.jsx)(l,{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)(s.Label,{children:`Observaciones:`})}),(0,S.jsx)(l,{sm:12,md:8,lg:8,children:(0,S.jsx)(s.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)(d,{variant:`success`,onClick:r=>{if(r.preventDefault(),!n||!o||!p)i.warning(`Datos incompletos`);else try{f({empleado:n,fecha:{inicio:o,fin:p},motivo:g,estado:`true`}).then(n=>{let{data:r}=n;i.success(`Vacaciones registradas`),t({search:b.stringify(``)}),e(!1)})}catch(e){console.log(e)}},children:[(0,S.jsx)(a,{icon:h}),` Registrar`]})})]})})},w=e=>e.map(e=>({value:e.nombreCompleto+` - `+e.cargo,label:e.nombreCompleto}));function T(e){let{location:t,history:n}=e,[i,a]=(0,x.useState)(!0);(0,x.useEffect)(()=>{setTimeout(()=>{a(!1)},500)},[]);let[s,l]=(0,x.useState)([]),u=()=>{try{p().then(e=>{let{data:t}=e;l(t)}).catch(e=>{})}catch{}};(0,x.useEffect)(()=>{u()},[t]),console.log(s);let[d,f]=(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),f(!0)};return(0,S.jsxs)(S.Fragment,{children:[i&&(0,S.jsx)(c,{}),(0,S.jsx)(_,{title:`Vacaciones`,icon:m,onAddClick:()=>b((0,S.jsx)(C,{setShow:f,history:n})),addText:`Registrar`}),(0,S.jsx)(r,{eventosIniciales:s}),(0,S.jsx)(`div`,{className:`divTabla`}),(0,S.jsxs)(o,{show:d,onClose:()=>f(!1),maxWidth:`xl`,children:[(0,S.jsx)(o.Header,{closeButton:!0,onClose:()=>f(!1),children:v}),(0,S.jsx)(o.Body,{children:h})]})]})}var E=g(T);export{E as default};