1 2!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a9f64662-b032-5f2f-9e50-55655b8df953")}catch(e){}}(); 3import{V as p,bL as C,bM as y,bN as N,R as e,ad as f,ai as O,bI as g,Y as _,n as w,bY as S,j as z,bi as m,l as P,W as v,x as A,bJ as I,y as T}from"./index-Cs-In7Vx.js";import{O as U}from"./OrganizationDialog-DUPX4n5_.js";import{S as D}from"./SearchInput-6k8qtIIx.js";import{A as F}from"./ApartmentRounded-xr62LVSX.js";import{U as k}from"./UserImpersonationButton-BwjJAZIR.js";import"./AccountCircle-DAKWRHmi.js";import"./validateCNPJ-D1dZ3Lbf.js";import"./validateCPF-BkwZ4IBk.js";import"./apiEndpoints-DMnpAh1j.js";const H="/api/v2/admin/organizations";let d;function h(r=d){d=r;const t=p.queryParamsObjectToString(r);return`${H}?${t}`}function Y(r){const{data:t,error:s,mutate:o}=C(h(r),y,{dedupingInterval:1e4});return{data:t?.data,totalRecords:t?.total||0,isLoading:!s&&!t,isError:s,mutate:o}}const u=N(r=>({filters:{page:1,per_page:10,search_text:""},updateFilter:(t,s)=>r(o=>({...o,filters:t==="page"?{...o.filters,[t]:s}:{...o.filters,[t]:s,page:1}}))}));function M({openOrganizationDialog:r}){const t=u(n=>n.updateFilter),[s,o]=e.useState(""),{hasUserRolePermissions:i}=f(),l=e.useMemo(()=>O(n=>{t("search_text",n)},600),[t]),c=e.useRef(!0);return e.useEffect(()=>{c.current?(c.current=!1,t("search_text","")):l(s)},[s,l,t]),e.createElement("div",{className:"flex w-full flex-col flex-wrap justify-between space-x-0 space-y-16 md:flex-row md:space-x-16 md:space-y-0"},e.createElement("div",{className:"flex space-x-12"},e.createElement(D,{placeholder:"Pesquise pela organização, administrador ou domÃnio",value:s,onChange:n=>o(n.target.value),wrapperClassName:"w-full md:w-512"})),i(g.ORGANIZATIONS_CREATE)&&e.createElement("div",{className:"flex justify-center space-x-12"},e.createElement(_,{variant:"outlined",className:"flex-shrink-0 bg-white",startIcon:e.createElement(F,null),onClick:()=>r()},"Nova Organização")))}function j(){const r=w(),t=u(a=>a.filters),s=u(a=>a.updateFilter),[o,i]=e.useState(null),{data:l,totalRecords:c,isLoading:n,isError:E}=Y(t),{hasUserRolePermissions:b}=f();e.useEffect(()=>{l&&i(l)},[l]);const x=a=>{s("page",a+1)},R=a=>{s("per_page",a)};return e.createElement(S,{data:o,totalRows:c,onChangePage:x,onChangeRowsPerPage:R,onRowClick:({id:a})=>r.push(`/organizacoes/${a}`),resetCurrentPage:t.page===1,loading:n||!o&&l,loadingRowsQuantity:5,showError:E,stickyHeader:!0,columns:[{Header:"Organização",sortable:!1,className:"min-w-288 max-w-320",Cell:({row:a})=>e.createElement("div",{className:"flex-1 space-y-1 truncate"},e.createElement(z,{title:`Identificador ${a.id}`,placement:"top-start",arrow:!0},e.createElement("div",{className:"truncate font-bold"},a.name)),a.address?.city&&a.address?.state&&e.createElement("div",{className:"font-light"},a.address.city,"/",a.address.state))},{Header:"Administrador",accessor:"primary_users",sortable:!1,className:"min-w-224",formatDataFunction:a=>a?.[0]?a[0].name:e.createElement(m,{color:"grey"},"Desconhecido")},{Header:"Criada em",accessor:"created_at",sortable:!1,className:"min-w-136",formatDataFunction:a=>P(a).format("DD/MM/YYYY")},{Header:"Assinaturas ativas",accessor:"active_subscriptions_quantity",sortable:!1},{Header:"Integrada ao Asaas",accessor:"connected_to_asaas",sortable:!1,formatDataFunction:a=>a?e.createElement(m,{color:"green"},"Sim"):e.createElement(m,{color:"blue"},"Não")},b(g.ORGANIZATIONS_ACCESS_ACCOUNT)&&{Header:"",sortable:!1,align:"right",Cell:({row:a})=>a.kind!=="cardapio_web"&&e.createElement(k,{userEmail:a.primary_users?.[0]?.email})}].filter(Boolean)})}function J(){const r=v(),t=A(({auth:n})=>n.user.role),[s,o]=e.useState({open:!1,data:null}),{mutate:i}=I(),l=e.useCallback(n=>{if(n&&n.kind==="cardapio_web"&&!p.hasPermission(T.admin,t)){r.info("Essa organização não pode ser editada!");return}o({open:!0,data:n})},[r,t]),c=e.useCallback(()=>i(h()),[i]);return e.createElement("div",{className:"flex w-full flex-1 flex-col space-y-20 overflow-auto px-12 py-24 sm:px-28"},e.createElement(M,{openOrganizationDialog:l}),e.createElement(j,null),e.createElement(U,{open:s.open,defaultValues:s.data,onClose:()=>o(!1),onUpdate:c}))}export{J as default}; 4 5//# debugId=a9f64662-b032-5f2f-9e50-55655b8df953
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.