import{j as e,ej as f,Y as C,h as n,i as m,o as u,e2 as y,at as j,bk as O,ag as S,e9 as b,P as N,eE as T,aO as v,aR as I}from"./app-BgLa5dit.js";import{S as w}from"./1Of0XWgF.chunk.js";import{B as R}from"./3nM7jLnE.chunk.js";import{C as L}from"./WqgNB-L4.chunk.js";import{u as k,R as A}from"./D2PVoBDN.chunk.js";import{T as V}from"./lZO4aq5x.chunk.js";import{O as r}from"./DG_07YWO.chunk.js";import{O as P}from"./Vn1DtJ-y.chunk.js";import{H as E}from"./wvigAl7i.chunk.js";import{C as U}from"./c3I67AiW.chunk.js";import{O as q}from"./DNClpFKN.chunk.js";import{C as _}from"./sy3ipODZ.chunk.js";import{C as B,a as D}from"./8iu0vnCW.chunk.js";import"./CPXlV0fg.chunk.js";import"./0GREfvNX.chunk.js";import"./itQZri94.chunk.js";import"./Zwjmkasg.chunk.js";import"./C6-eluIr.chunk.js";import"./DR2FaZH9.chunk.js";import"./q-IBKcuF.chunk.js";import"./DUpYPoLs.chunk.js";import"./EZim8aq-.chunk.js";import"./BD9MrUJP.chunk.js";import"./s6cGcwlA.chunk.js";import"./4qGb1BIY.chunk.js";import"./DnXDEnAR.chunk.js";import"./DpUpv6rY.chunk.js";import"./CG7zbly5.chunk.js";import"./m4aqaK_l.chunk.js";import"./MEkA24R1.chunk.js";import"./C53kfXmd.chunk.js";import"./C8_78Eqq.chunk.js";import"./BfMtaC_g.chunk.js";import"./KUnagq9Z.chunk.js";import"./DULWIWQR.chunk.js";import"./CCcwLDvu.chunk.js";import"./DDfKZ_ng.chunk.js";r.Unclassified+"",r.Educational+"",r.Government+"",r.ClickView+"",r.System+"";const o=f(),H={name:()=>o.accessor(a=>a,{id:"name",header:"Name",cell:a=>{const t=a.getValue();return e.jsx(C,{appLink:{application:m.CRM_STUDIO,action:n.CrmStudio.ORGANISATION_OVERVIEW,args:[t.id]},className:"text-info",children:t.name})},size:500}),id:()=>o.accessor("id",{id:"id",header:"ID",cell:a=>{const t=a.getValue();return e.jsx(E,{value:t,applink:null})}}),type:()=>o.accessor("orgType",{id:"orgType",header:"Type",cell:a=>{const t=a.getValue();return e.jsx(P,{type:t})}})};function G(a){return e.jsx(V,{data:a.data,columns:Object.values(H).map(t=>t()),theme:U})}function ve(a){var p,d;const t=u(I.currentUser()),s=u(!!a.query&&q.searchOrganisation(a.query,a.cursor)),{isLoading:g}=k("organisation"),c=s.hasCompleted&&!g&&t.hasCompleted,i=(p=s.data)==null?void 0:p.data,x=(d=s.data)==null?void 0:d.pagination,l=i&&y.convertLegacyPaginatedCollection(s.data).pagination.cursors,h=_.canEditProtectedProperty(t.data);return e.jsx(B,{view:D.Organisations,children:e.jsxs("div",{className:"d-flex flex-column gap-4",children:[e.jsxs("div",{className:"d-flex flex-row justify-content-between",children:[e.jsxs("div",{children:[e.jsx("h1",{children:"Organisations"}),e.jsx(R,{breadcrumbs:[{name:"Curation Studio"},{name:"Organisations",active:!0}]})]}),e.jsxs("div",{className:"w-50 gap-2 d-flex flex-row align-items-start",children:[e.jsx("div",{className:"w-75",children:e.jsx(w,{id:"organisation-search",queryParamName:"query",placeholder:"Enter organisation name",searchAppLink:{application:m.CRM_STUDIO,action:n.CrmStudio.ORGANISATIONS},searchIndices:[]})}),h&&e.jsx(j,{className:"btn btn-outline-dark",svg:O,appLink:{application:m.CRM_STUDIO,action:n.CrmStudio.NEW_ORGANISATION_WIZARD},children:"Add new organisation"})]})]}),(!a.query||a.query.trim()==="")&&e.jsx(A,{entityType:S.Organisation}),a.query&&!c&&e.jsx(b,{}),c&&((i==null?void 0:i.length)>0?e.jsxs("div",{className:"d-flex flex-column gap-2",children:[e.jsxs("div",{className:"d-flex flex-row justify-content-between mt-3",children:[e.jsx("h2",{className:"h6 mb-0",children:"Search results"}),e.jsxs("p",{className:"fw-semibold mb-0",children:["Showing ",i.length," of ",x.totalItems," results"]})]}),e.jsx(G,{data:i}),l&&e.jsx(N,{cursors:l,appLink:T.getCurrentContext().appLink,buttonVariant:"outline-dark",className:"text-end pe-1 mt-2"})]}):e.jsx(L,{heading:"Oops... no results found :(",info:"It appears that organisation is not in our system.",imageUrl:v.CrmStudio.NOT_FOUND}))]})})}export{ve as OrganisationsView};
//# sourceMappingURL=DJPqVoyU.chunk.js.map
