import{aA as l,j as e,G as y,az as I,ax as m,F as j,aP as O,l as f,R as F,o as h,b7 as S,ar as x,aQ as C}from"./app-BgLa5dit.js";import{N as q}from"./C9Rwpp7a.chunk.js";import{F as A}from"./w68yffRy.chunk.js";import{S as p}from"./CfEK6qIW.chunk.js";const w=l.object().shape({name:l.string().max(255,"Org name is too long").required("Org name is required"),description:l.string().max(255,"Org description is too long").required("Org description is required")}),R="system.orgIdManager",u=j.encloseNamespace(R);function E(a){const{addOrgId:t}=a,s={id:"",name:"",description:""};return e.jsx(y,{initialValues:s,validationSchema:w,onSubmit:t,children:e.jsx(I,{children:e.jsxs("div",{className:"row",children:[e.jsx("div",{className:"col-5",children:e.jsx(m,{label:"Name",name:"name",id:"name",placeholder:u("enterNewOrgName")})}),e.jsx("div",{className:"col-5",children:e.jsx(m,{label:"Description",name:"description",id:"description",placeholder:u("enterDescription")})}),e.jsx("div",{className:"col-2",children:e.jsx("div",{className:"mt-labelHeight",children:e.jsx(A,{isNew:!0,submitText:"Add"})})})]})})})}function M(a){return e.jsxs("tr",{children:[e.jsx("td",{className:"ps-3",children:a.orgId.name}),e.jsx("td",{className:"ps-3",children:a.orgId.description})]})}function D(a){var t;return e.jsxs("table",{className:"table m-0",children:[e.jsxs("thead",{children:[e.jsx("th",{scope:"col",className:"ps-3",children:"Name"}),e.jsx("th",{scope:"col",className:"ps-3",children:"Description"})]}),e.jsx("tbody",{children:(t=a.orgIds)==null?void 0:t.map(s=>e.jsx(M,{orgId:s},s.id))})]})}const L="_selector_kxycu_1",P={selector:L},g="system.orgIdManager",r=j.encloseNamespace(g);function T(){const a=O(),t=f(),[s,N]=F.useState(),n=h(s&&p.getOrgIds(s)),o=h(q.countries());function v(c,i){const{name:d,description:b}=c;C(a,p.addOrgId(d,b,s,()=>{i({reset:!0}),t.success(r("createSuccess"))},()=>{i(),t.error(r("createError"))}))}return e.jsxs(e.Fragment,{children:[e.jsx("h1",{className:"h3 mb-2",children:r("orgIdManager")}),e.jsx("p",{className:"mb-3",children:e.jsx(S,{namespace:g,phrase:"description"})}),(()=>{var c,i;return o.isFetching?e.jsx("div",{className:"text-center py-3",children:e.jsx(x,{as:"div",animation:"border",role:"status"})}):(c=o.data)!=null&&c.length?e.jsxs("select",{name:"country",id:"country",onChange:d=>N(d.target.value),value:s,className:`${P.selector} rounded ps-2 py-1`,children:[e.jsx("option",{value:"",children:r("selectCountry")}),(i=o.data)==null?void 0:i.map(d=>e.jsx("option",{value:d.code,children:d.code},d.code))]}):e.jsx("div",{className:"px-3 py-2",children:e.jsx("em",{children:r("empty")})})})(),s&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"card mt-3",children:[e.jsx("div",{className:"card-header border-bottom-0",children:e.jsx("h3",{className:"h5 m-0",children:r("addOrgId")})}),e.jsx("div",{className:"card-body",children:e.jsx(E,{addOrgId:v})})]}),e.jsxs("div",{className:"card mt-3",children:[e.jsx("div",{className:"card-header border-bottom-0",children:e.jsx("h3",{className:"h5 m-0",children:r("orgs",{countryCode:s})})}),e.jsx("div",{className:"card-body p-0",children:(()=>{var c;return n.hasError?e.jsx("div",{className:"text-danger",children:r("errorFetching")}):n.isFetching?e.jsx("div",{className:"text-center py-3",children:e.jsx(x,{as:"div",animation:"border",role:"status"})}):(c=n.data)!=null&&c.length?e.jsx(D,{orgIds:n.data}):e.jsx("div",{className:"px-3 py-2",children:e.jsx("em",{children:r("empty")})})})()})]})]})]})}export{T as OrgIdManagerView};
//# sourceMappingURL=CoCQAN-d.chunk.js.map
