import{J as C,u as g}from"./master-table.service-aef1f063.js";import{d as I,l as d,bc as L,o as b,c as k,q as e,w as a,ay as y,F as M,a as S,s as x,b as h,I as n,y as p,n as J,W as c,A as T,L as B,P as O,av as j,aw as E,U as G,b8 as P,aD as v,aE as q,aA as R}from"./index-2e57ee69.js";import{_ as W}from"./PageHeader.vue_vue_type_script_setup_true_lang-65daf951.js";import{V as z,a as H}from"./VTabs-837e0b88.js";import{q as K}from"./VDataTable-5c8d6498.js";import{V as Q,a as A}from"./VRow-22fc34ca.js";import{V as X}from"./VSpacer-0163be53.js";import{b as D}from"./route-block-83d24a4e.js";import"./pencil-rocket-162a63cb.js";import"./VSelect-a9073548.js";import"./VList-0b71c0f0.js";import"./VDivider-29fb9868.js";import"./VMenu-9f22b74a.js";import"./VCheckboxBtn-0a0e30be.js";import"./VChip-73a1db56.js";import"./VTable-4b4f67af.js";import"./filter-aa6f7ff4.js";const Y={class:"my-4 text-end"},Z=I({__name:"maintainers",setup(ee){const f=d("work_schedule"),i=d(C[f.value]),w=d([]),V=d(!1),u=d(!1),s=d({id:null,name:"",description:""}),m=g(i.value.apiBase),_=async()=>{V.value=!0;const{data:l}=await m.list();w.value=l,V.value=!1},N=()=>{s.value={id:null,name:"",description:""},u.value=!0},U=l=>{s.value={id:l.id,name:l.name,description:l.description},u.value=!0},$=async()=>{try{let l;s.value.id?l=await m.update(s.value.id,s.value):l=await m.create(s.value);const{success:o,message:t}=l;if(!o){v(t);return}q(t),u.value=!1,_()}catch(l){v(l)}},F=async l=>{if(await R({title:"Eliminar",content:`¿Estás seguro de que deseas eliminar este ${i.value.title.toLowerCase()}?`}))try{const{success:t,message:r}=await m.remove(l);if(!t){v(r);return}q(r),_()}catch(t){v(t)}};return L(()=>{i.value=C[f.value],Object.assign(m,g(i.value.apiBase)),_()}),(l,o)=>(b(),k("div",null,[e(W,{title:"Mantenedores de Bolsa Laboral",description:"Aquí puedes gestionar los mantenedores de la bolsa laboral."}),e(B,{class:"mt-2"},{default:a(()=>[e(y,null,{default:a(()=>[e(z,{modelValue:f.value,"onUpdate:modelValue":o[0]||(o[0]=t=>f.value=t),"show-arrows":""},{default:a(()=>[(b(!0),k(M,null,S(x(C),(t,r)=>(b(),h(H,{key:r,value:r},{default:a(()=>[n(p(t.title),1)]),_:2},1032,["value"]))),128))]),_:1},8,["modelValue"]),J("div",Y,[e(c,{color:"primary",onClick:N},{default:a(()=>[n("Crear "+p(i.value.title),1)]),_:1})]),e(x(K),{headers:[{title:"Nombre",key:"name"},{title:"Acciones",key:"actions",sortable:!1,align:"end"}],items:w.value,loading:V.value},{"item.actions":a(({item:t})=>[e(c,{icon:"",variant:"text",onClick:r=>U(t)},{default:a(()=>[e(T,null,{default:a(()=>[n("mdi-pencil")]),_:1})]),_:2},1032,["onClick"]),e(c,{icon:"",variant:"text",color:"error",onClick:r=>F(t.id)},{default:a(()=>[e(T,null,{default:a(()=>[n("mdi-delete")]),_:1})]),_:2},1032,["onClick"])]),_:1},8,["items","loading"])]),_:1})]),_:1}),e(P,{modelValue:u.value,"onUpdate:modelValue":o[4]||(o[4]=t=>u.value=t),"max-width":"500"},{default:a(()=>[e(B,null,{default:a(()=>[e(O,null,{default:a(()=>[n(p(s.value.id?"Editar":"Crear")+" "+p(i.value.title),1)]),_:1}),e(y,null,{default:a(()=>[e(j,null,{default:a(()=>[e(Q,null,{default:a(()=>[e(A,{cols:"12"},{default:a(()=>[e(E,{modelValue:s.value.name,"onUpdate:modelValue":o[1]||(o[1]=t=>s.value.name=t),label:"Nombre",required:""},null,8,["modelValue"])]),_:1}),e(A,{cols:"12"},{default:a(()=>[e(E,{modelValue:s.value.description,"onUpdate:modelValue":o[2]||(o[2]=t=>s.value.description=t),label:"Descripción"},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1}),e(G,null,{default:a(()=>[e(X),e(c,{text:"",onClick:o[3]||(o[3]=t=>u.value=!1)},{default:a(()=>[n("Cancelar")]),_:1}),e(c,{color:"primary",onClick:$},{default:a(()=>[n("Guardar")]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"])]))}});typeof D=="function"&&D(Z);export{Z as default};
