1import{u as y,o as g,b as v,a as N,r as d,d as f,j as s,L as w,n as m}from"./index-B84LkA6E.js";import{u as C}from"./useMutation-BcSImYzm.js";import{a as S,u as D,c as E}from"./distributorApi-dNcdahhJ.js";import{D as k}from"./DistributorCompanyForm-DJhbz13q.js";const p=["distributor","companies"];function q(){const{t}=y(),u=g(),l=v(),b=N(),[h,o]=d.useState(!1),[e,x]=d.useState(null),{data:r=[],isLoading:n}=f({queryKey:p,queryFn:S}),a=()=>{x(null),o(!1)},j=()=>{a(),o(!0)},c=C({mutationFn:i=>e?D(e._id,i):E(i),onSuccess:()=>{u.success(t(e?"app.distributor.companies.messages.updated":"app.distributor.companies.messages.created")),a(),b.invalidateQueries({queryKey:p})},onError:i=>l(i)});return s.jsxs("div",{"data-testid":"distributor-companies",children:[s.jsxs("div",{className:"settings-team-header",children:[s.jsxs("div",{children:[s.jsx("h2",{children:t("app.distributor.companies.title")}),s.jsx("p",{className:"settings-company-muted",children:t("app.distributor.companies.subtitle")})]}),s.jsx("button",{type:"button",className:"nordic-btn nordic-btn-primary",onClick:j,children:t("app.distributor.companies.addNew")})]}),h&&s.jsxs("div",{className:"nordic-card settings-team-form",children:[s.jsx("h3",{children:t(e?"app.distributor.companies.editTitle":"app.distributor.companies.addNew")}),s.jsx(k,{company:e,isSaving:c.isPending,onCancel:a,onSave:i=>c.mutate(i)})]}),s.jsxs("div",{className:"nordic-card distributor-companies-card",children:[n&&s.jsx(w,{}),!n&&r.length===0&&s.jsx("p",{className:"settings-company-muted distributor-companies-empty",children:t("app.distributor.companies.emptyState")}),r.length>0&&s.jsx("div",{className:"distributor-companies-table-wrap",children:s.jsxs("table",{className:"nordic-table distributor-companies-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:t("app.distributor.companies.table.name")}),s.jsx("th",{className:"distributor-companies-col-action","aria-label":t("app.common.actions")})]})}),s.jsx("tbody",{children:r.map(i=>s.jsxs("tr",{children:[s.jsx("td",{children:s.jsx(m,{to:`/distributor/companies/${i._id}`,className:"distributor-companies-name",children:i.name||"â"})}),s.jsx("td",{className:"distributor-companies-col-action",children:s.jsxs(m,{to:`/distributor/companies/${i._id}`,className:"nordic-btn nordic-btn-sm distributor-companies-view-btn",children:[t("app.distributor.companyDetail.view"),s.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2","aria-hidden":!0,children:s.jsx("path",{d:"M5 12h14M13 6l6 6-6 6",strokeLinecap:"round",strokeLinejoin:"round"})})]})})]},i._id))})]})})]})]})}export{q as DistributorCompaniesPage};
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.