import{k as f,l as h,o as x,R as o,j as t,E as S,aS as T,a9 as i}from"./app-BgLa5dit.js";import{O as d}from"./DG_07YWO.chunk.js";import{O as g}from"./DNClpFKN.chunk.js";import{C as j}from"./CQCJQXSQ.chunk.js";function v(s){var u;const m=f(),r=h(),a=x(g.getOrganisation(s.id)),[n,c]=o.useState(a.data.orgType);o.useEffect(()=>{var e;(e=a.data)!=null&&e.orgType&&c(a.data.orgType)},[(u=a.data)==null?void 0:u.orgType]);const[p,l]=o.useState(!1);async function y(){try{l(!0),await m(g.updateOrganisation(s.id,{name:a.data.name,orgType:n})),r.success("Successfully updated organisation type.")}catch{r.error("Failed to update organisation type. Please try again.")}finally{l(!1),s.closePopup()}}return t.jsxs(S,{title:"Update organisation type",closePopup:s.closePopup,showLoadingSpinner:!a.hasCompleted,children:[t.jsx("div",{className:"mb-3",children:t.jsx("select",{className:"form-select ",onChange:e=>{c(parseInt(e.target.value))},value:n,children:T.values(d).filter(e=>typeof e=="number"&&e!==d.System).map(e=>t.jsx("option",{value:e,className:"text-dark",children:j.mapOrgTypeToLabel(e)},e))})}),t.jsxs(i,{children:[t.jsx(i.Cancel,{text:"Cancel",onClick:s.closePopup}),t.jsx(i.Submit,{text:"Save changes",variant:"dark",onClick:y,showSpinner:p,disabled:p||n===a.data.orgType})]})]})}export{v as UpdateOrganisationTypeView};
//# sourceMappingURL=V-4TmvC9.chunk.js.map
