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-DyZtLAjB.js";import{N as x,t as y,a as B}from"./NetworkLoadBalancerForm-B3jhHbVv.js";import{c as g}from"./network-load-balancers-Cl8NshTC.js";import{B as v}from"./BaseLayout-BBVAHUxR.js";import{H as F}from"./HelpLink-D3hDVaXE.js";import{F as S}from"./FormFooterLayout-BVf_vA5z.js";import{u as $}from"./useNetworks-C137e8fZ.js";import"./NotificationRow-Cej0AnMm.js";import"./formFields-BbQUt1T2.js";import"./networks-D-awX-Ft.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};
