import{aT as r,l as D,k as f,j as e,E as P,ao as s,a9 as c}from"./app-BgLa5dit.js";import{P as b}from"./BH2LS0pQ.chunk.js";function A(t){const[o,m]=r.useState(""),[l,p]=r.useState(""),[n,d]=r.useState(!1),i=D(),u=f(),x=/^[^.]+\..*[^.]$/;async function h(){const a=o.trim();if(a){if(!x.test(a)){i.error("Please enter a valid domain, e.g. example.com");return}try{d(!0),await u(b.createDomain({name:a,status:"unverified",description:l.trim()||void 0})),i.success("Domain has been added")}catch(j){i.error("Error updating domains: ".concat(String(j)))}finally{d(!1),t.closePopup()}}}return e.jsxs(P,{size:"md",title:"Add New Domain",closePopup:t.closePopup,children:[e.jsxs("div",{className:"pb-3",children:[e.jsxs(s.Group,{className:"mb-3",children:[e.jsx(s.Label,{children:"Domain Name"}),e.jsx(s.Control,{type:"text",placeholder:"example.com",pattern:"^[^.]+\\..*[^.]$",value:o,onChange:a=>m(a.target.value),disabled:n})]}),e.jsxs(s.Group,{className:"mb-3",children:[e.jsx(s.Label,{children:"Description (Optional)"}),e.jsx(s.Control,{as:"textarea",rows:3,placeholder:"Add a description...",value:l,onChange:a=>p(a.target.value),disabled:n})]})]}),e.jsxs(c,{children:[e.jsx(c.Cancel,{onClick:t.closePopup}),e.jsx(c.Submit,{text:"Add Domain",variant:"dark",disabled:!o.trim(),showSpinner:n,onClick:h})]})]})}export{A as AddDomainPopupView};
//# sourceMappingURL=DkZBmFDe.chunk.js.map
