1import{j as e}from"./vendor-react-DKbe1Umz.js";import{u as T}from"./vendor-data-CjSe2wkl.js";import{H as C,aG as j,r as b,B as v,l as m,C as i,s as n,t as d,v as c,A as B,E as z,F as h,G as u,w as g}from"./index-DZ74KeH3.js";import{T as f,a as p,b as x,c as a,d as N,e as r}from"./table-CAeITjOT.js";import{cr as E,cD as k,$ as P,dH as A,B as O,bb as D}from"./vendor-ui-DMaW9-Ov.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-dates-5UNeOyFW.js";import"./vendor-forms-C2vWC2ab.js";function w({status:o}){const l=o==="ACTIVE"?"default":o==="COMPLETE"?"secondary":"outline";return e.jsx(m,{variant:l,className:"text-xs",children:o})}function R(){const l=C().id,{data:t,isLoading:y}=T({queryKey:["/api/platform/organizations",l,"view-dashboard"],queryFn:async()=>{const s=await fetch(`/api/platform/organizations/${l}/view-dashboard`,{credentials:"include"});if(!s.ok)throw new Error("Failed to load organization dashboard");return s.json()},enabled:!!l});return y?e.jsx("div",{className:"min-h-screen bg-background p-6",children:e.jsxs("div",{className:"container mx-auto space-y-6",children:[e.jsx(j,{className:"h-10 w-64"}),e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[1,2,3,4].map(s=>e.jsx(j,{className:"h-28"},s))}),e.jsx(j,{className:"h-96"})]})}):t?e.jsx("div",{className:"min-h-screen bg-background","data-testid":"view-as-org-page",children:e.jsxs("main",{className:"container mx-auto px-4 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("div",{className:"flex items-center gap-3 mb-2",children:e.jsx(b,{href:`/admin/organizations/${l}`,children:e.jsxs(v,{variant:"ghost",size:"sm","data-testid":"button-back-org-detail",children:[e.jsx(E,{className:"h-4 w-4 mr-1"}),"Back to Org Detail"]})})}),e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5 text-amber-600"}),e.jsx(m,{variant:"outline",className:"text-amber-600 border-amber-300 bg-amber-50",children:"READ-ONLY VIEW"})]})}),e.jsx("h1",{className:"text-2xl font-bold text-foreground mt-2","data-testid":"text-view-as-org-title",children:t.organization.name}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Viewing organization data for support purposes â no edit capabilities"})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2 lg:grid-cols-4 mb-8",children:[e.jsxs(i,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Users"}),e.jsx(P,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold","data-testid":"text-org-user-count",children:t.stats.userCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Team members"})]})]}),e.jsxs(i,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Projects"}),e.jsx(A,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold","data-testid":"text-org-project-count",children:t.stats.projectCount}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:[t.stats.activeProjects," active · ",t.stats.completedProjects," completed"]})]})]}),e.jsxs(i,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Bids"}),e.jsx(O,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold","data-testid":"text-org-bid-count",children:t.stats.bidCount}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Total bids"})]})]}),e.jsxs(i,{children:[e.jsxs(n,{className:"flex flex-row items-center justify-between gap-2 space-y-0 pb-2",children:[e.jsx(d,{className:"text-sm font-medium",children:"Equipment"}),e.jsx(D,{className:"h-4 w-4 text-muted-foreground"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold","data-testid":"text-org-equipment-count",children:t.stats.totalEquipment}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Equipment items"})]})]})]}),e.jsxs(B,{defaultValue:"projects",className:"w-full",children:[e.jsxs(z,{className:"mb-4","data-testid":"tabs-org-view",children:[e.jsx(h,{value:"projects","data-testid":"tab-projects",children:"Projects"}),e.jsx(h,{value:"bids","data-testid":"tab-bids",children:"Bids"}),e.jsx(h,{value:"users","data-testid":"tab-users",children:"Users"})]}),e.jsx(u,{value:"projects",children:e.jsxs(i,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"Projects"}),e.jsx(g,{children:"Organization's projects (read-only)"})]}),e.jsx(c,{children:t.recentProjects.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No projects found"}):e.jsxs(f,{children:[e.jsx(p,{children:e.jsxs(x,{children:[e.jsx(a,{children:"Project Name"}),e.jsx(a,{children:"Status"}),e.jsx(a,{children:"Created"})]})}),e.jsx(N,{children:t.recentProjects.map(s=>e.jsxs(x,{"data-testid":`row-project-${s.id}`,children:[e.jsx(r,{className:"font-medium",children:s.name}),e.jsx(r,{children:e.jsx(w,{status:s.status})}),e.jsx(r,{className:"text-sm text-muted-foreground",children:new Date(s.createdAt).toLocaleDateString()})]},s.id))})]})})]})}),e.jsx(u,{value:"bids",children:e.jsxs(i,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"Bids"}),e.jsx(g,{children:"Organization's bids (read-only)"})]}),e.jsx(c,{children:t.recentBids.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No bids found"}):e.jsxs(f,{children:[e.jsx(p,{children:e.jsxs(x,{children:[e.jsx(a,{children:"Bid Name"}),e.jsx(a,{children:"Status"}),e.jsx(a,{children:"Created"})]})}),e.jsx(N,{children:t.recentBids.map(s=>e.jsxs(x,{"data-testid":`row-bid-${s.id}`,children:[e.jsx(r,{className:"font-medium",children:s.name}),e.jsx(r,{children:e.jsx(w,{status:s.status})}),e.jsx(r,{className:"text-sm text-muted-foreground",children:new Date(s.createdAt).toLocaleDateString()})]},s.id))})]})})]})}),e.jsx(u,{value:"users",children:e.jsxs(i,{children:[e.jsxs(n,{children:[e.jsx(d,{children:"Team Members"}),e.jsx(g,{children:"Organization's users (read-only)"})]}),e.jsx(c,{children:t.users.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No users found"}):e.jsxs(f,{children:[e.jsx(p,{children:e.jsxs(x,{children:[e.jsx(a,{children:"Name"}),e.jsx(a,{children:"Email"}),e.jsx(a,{children:"Role"}),e.jsx(a,{children:"Status"})]})}),e.jsx(N,{children:t.users.map(s=>e.jsxs(x,{"data-testid":`row-user-${s.id}`,children:[e.jsxs(r,{className:"font-medium",children:[s.firstName," ",s.lastName]}),e.jsx(r,{className:"text-sm",children:s.email}),e.jsx(r,{children:e.jsx(m,{variant:"outline",className:"text-xs",children:s.role})}),e.jsx(r,{children:e.jsx(m,{variant:s.isActive?"default":"secondary",className:"text-xs",children:s.isActive?"Active":"Inactive"})})]},s.id))})]})})]})})]})]})}):e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center",children:e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("p",{className:"text-muted-foreground",children:"Organization not found"}),e.jsx(b,{href:"/admin/organizations",children:e.jsx(v,{variant:"outline","data-testid":"button-back-orgs",children:"Back to Organizations"})})]})})}export{R as default};
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.