import{d as j,G as F,c as b,s as x,v as H,a as u,o as s,w as d,g as l,u as a,i as I,j as i,e as C,f as _,l as k,h as v,b as g,F as $,p as V,k as P,W as c}from"./app-Cb9hmj6k.js";import{a as U}from"./AppLayout.vue_vue_type_script_setup_true_lang-CteAxl0C.js";import{_ as W,a as D}from"./Layout.vue_vue_type_script_setup_true_lang-BUO1b7TX.js";import{_ as K}from"./Input.vue_vue_type_script_setup_true_lang-t_rUv_4v.js";import{_ as f}from"./AppLogoIcon.vue_vue_type_script_setup_true_lang-DKWl2XLX.js";import{t as w}from"./index-bRFR14ax.js";import{P as G,T as q}from"./trash-Cw7Sd6FH.js";import"./index-hboZUdbT.js";import"./RovingFocusGroup-CP1IPgEn.js";import"./Separator.vue_vue_type_script_setup_true_lang-BOE17VcD.js";const A={class:"space-y-6"},J={class:"flex gap-2"},O={class:"border rounded-xl overflow-hidden"},Q={class:"flex-1"},R={key:0,class:"text-sm"},X={class:"flex items-center gap-3"},Y=["onClick"],Z={key:0,class:"text-center text-sm text-muted-foreground py-6"},ee={class:"flex gap-2 flex-wrap"},me=j({__name:"Types",setup(te){const N=[{title:"Типы заявок",href:"/settings/types"}],h=F(),y=b(()=>h.props.types),z=b(()=>h.props.editingType),p=x(""),o=x(""),n=x(null);H(z,t=>{t&&(n.value=t.id,o.value=t.name)},{immediate:!0});function S(){p.value.trim()&&c.post("/settings/types",{name:p.value},{preserveScroll:!0,onSuccess:()=>{p.value="",w.success("Тип заявки успешно добавлен")}})}function B(t){c.get(`/settings/types/${t.id}/edit`,{},{preserveScroll:!0,preserveState:!0})}function T(){!n.value||!o.value.trim()||c.put(`/settings/types/${n.value}`,{name:o.value},{preserveScroll:!0,onSuccess:()=>{n.value=null,o.value="",w.success("Тип заявки успешно обновлён")}})}function E(){n.value=null,o.value="",c.get("/settings/types",{},{preserveScroll:!0,preserveState:!0})}function L(t){confirm("Вы уверены, что хотите удалить этот тип заявки?")&&c.delete(`/settings/types/${t}`,{preserveScroll:!0,onSuccess:()=>{w.success("Тип заявки успешно удалён")}})}function M(t){t&&c.visit(t,{preserveScroll:!0,preserveState:!0})}return(t,r)=>(s(),u(U,{breadcrumbs:N},{default:d(()=>[l(a(I),{title:"Типы заявок"}),l(W,null,{default:d(()=>[i("div",A,[l(D,{title:"Типы заявок",description:"Добавление и управление типами заявок"}),i("div",J,[l(a(K),{modelValue:p.value,"onUpdate:modelValue":r[0]||(r[0]=e=>p.value=e),placeholder:"Название типа",onKeydown:C(_(S,["prevent"]),["enter"])},null,8,["modelValue","onKeydown"]),l(a(f),{onClick:S},{default:d(()=>r[2]||(r[2]=[k("Добавить")])),_:1,__:[2]})]),i("div",O,[(s(!0),v($,null,V(y.value.data,e=>(s(),v("div",{key:e.id,class:"flex items-center justify-between px-4 py-2 hover:bg-muted transition"},[i("div",Q,[n.value!==e.id?(s(),v("span",R,P(e.name),1)):(s(),u(a(K),{key:1,modelValue:o.value,"onUpdate:modelValue":r[1]||(r[1]=m=>o.value=m),class:"max-w-xs",onKeydown:C(_(T,["prevent"]),["enter"])},null,8,["modelValue","onKeydown"]))]),i("div",X,[n.value!==e.id?(s(),u(a(f),{key:0,size:"sm",variant:"outline",onClick:_(m=>B(e),["stop"]),class:"border-none shadow-none cursor-pointer"},{default:d(()=>[l(a(G),{class:"w-4 h-4"})]),_:2},1032,["onClick"])):g("",!0),n.value===e.id?(s(),u(a(f),{key:1,size:"sm",onClick:T,class:"cursor-pointer"},{default:d(()=>r[3]||(r[3]=[k(" Сохранить ")])),_:1,__:[3]})):g("",!0),n.value===e.id?(s(),u(a(f),{key:2,size:"sm",variant:"ghost",onClick:E,class:"cursor-pointer"},{default:d(()=>r[4]||(r[4]=[k(" Отмена ")])),_:1,__:[4]})):g("",!0),i("span",{class:"text-xs text-red-500 cursor-pointer hover:underline",onClick:_(m=>L(e.id),["stop"])},[l(a(q),{class:"w-5 h-5"})],8,Y)])]))),128)),y.value.data.length?g("",!0):(s(),v("div",Z," Нет типов заявок "))]),i("div",ee,[(s(!0),v($,null,V(y.value.links,(e,m)=>(s(),u(a(f),{key:m,size:"sm",variant:"outline",disabled:!e.url,onClick:se=>M(e.url),innerHTML:e.label},null,8,["disabled","onClick","innerHTML"]))),128))])])]),_:1})]),_:1}))}});export{me as default};
