import{a0 as w,k as b,d as n,h as N,n as h,r as L,f as j,q as i,j as o,L as C}from"./index-lOezWVmi.js";import{N as x,t as y,a as B}from"./NetworkLoadBalancerForm-Cii09QPL.js";import{c as g}from"./network-load-balancers-DR25Swbu.js";import{B as v}from"./BaseLayout-CM5eWMFT.js";import{H as F}from"./HelpLink-8_zL-2ID.js";import{F as S}from"./FormFooterLayout-B1eckygM.js";import{u as $}from"./useNetworks-Dvw5If3E.js";import"./NotificationRow-DdxAfFhk.js";import"./formFields-D9YYYKxX.js";import"./networks-C9MSk_NH.js";const _=()=>{const d=w(),m=b(),c=n.useNotify(),u=n.useToastNotification(),k=N(),{network:t,project:a}=h(),{data:l,error:r}=$(t??"",a??"");L.useEffect(()=>{r&&c.failure("Loading networks failed",r)},[r]);const e=j({initialValues:{listenAddress:"",backends:[],ports:[]},validationSchema:x,onSubmit:p=>{const f=y(p);g(t??"",f,a??"").then(s=>{k.invalidateQueries({queryKey:[i.projects,a,i.networks,l,i.loadBalancers]}),m(`/ui/project/${encodeURIComponent(a??"")}/network/${encodeURIComponent(t??"")}/load-balancers`),u.success(`Network load balancer with listen address ${s} created.`)}).catch(s=>{e.setSubmitting(!1),c.failure("Network load balancer creation failed",s)})}});return o.jsxs(v,{title:o.jsx(F,{href:`${d}/howto/network_load_balancers/`,title:"Learn more about network load balancers",children:"Create a network load balancer"}),contentClassName:"create-network",children:[o.jsx(B,{formik:e,network:l}),o.jsxs(S,{children:[o.jsx(C,{className:"p-button--base",to:`/ui/project/${encodeURIComponent(a??"")}/network/${encodeURIComponent(t??"")}/load-balancers`,children:"Cancel"}),o.jsx(n.ActionButton,{loading:e.isSubmitting,disabled:!e.isValid||e.isSubmitting||!e.values.listenAddress,onClick:()=>void e.submitForm(),children:"Create"})]})]})};export{_ as default};
