import{V as v,u as w,$ as h,x as y,d as N,a0 as V,K as _,e as m,f as C,k as E,p as I,i as t,h as S,m as i,C as $}from"./app-BsP-5XS6.js";import{F as k}from"./Form-BkUnzt6c.js";import{u as K}from"./bus-CBDJ_pm6.js";/*! 2FAuth version 5.2.0 - Copyright (c) 2024 Bubka - https://github.com/Bubka/2FAuth */const U={__name:"CreateUpdate",props:{groupId:[Number,String]},setup(c){const p=v(),d=w(),l=h(),s=K(),a=c,r=y(()=>a.groupId!=null),o=N(new k({name:""}));V(()=>{l.name=="editGroup"&&(s.editedGroupName?(o.name=s.editedGroupName,s.editedGroupName=void 0):_.get(a.groupId).then(e=>{o.name=e.data.name}))});function f(){r.value?B():g()}async function g(){o.post("/api/v1/groups").then(e=>{p.addOrEdit(e.data),d.push({name:"groups"})})}async function B(){o.put("/api/v1/groups/"+a.groupId).then(e=>{p.addOrEdit(e.data),d.push({name:"groups"})})}return(e,n)=>{const F=m("FormField"),b=m("FormButtons"),G=m("FormWrapper");return C(),E(G,{title:t(r)?e.$t("groups.forms.rename_group"):e.$t("groups.forms.new_group")},{default:I(()=>[S("form",{onSubmit:$(f,["prevent"]),onKeydown:n[1]||(n[1]=u=>t(o).onKeydown(u))},[i(F,{modelValue:t(o).name,"onUpdate:modelValue":n[0]||(n[0]=u=>t(o).name=u),fieldName:"name",fieldError:t(o).errors.get("name"),label:"commons.name",autofocus:""},null,8,["modelValue","fieldError"]),i(b,{submitId:t(r)?"btnEditGroup":"btnCreateGroup",isBusy:t(o).isBusy,caption:t(r)?e.$t("commons.save"):e.$t("commons.create"),showCancelButton:!0,cancelLandingView:"groups"},null,8,["submitId","isBusy","caption"])],32)]),_:1},8,["title"])}}};export{U as default};
