1import{r as k,j as e}from"./vendor-react-DKbe1Umz.js";import{u as D}from"./vendor-data-CjSe2wkl.js";import{y as b,u as C,cH as S,ay as B,aG as T,C as u,v as h,l as i,B as r,D as z,c as F,d as $,e as U,o as L}from"./index-DZ74KeH3.js";import{F as d,bz as p,k as j,cD as f,cT as N,dr as g,bU as P}from"./vendor-ui-DMaW9-Ov.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-dates-5UNeOyFW.js";import"./vendor-forms-C2vWC2ab.js";function w(t){return t<1024?`${t} B`:t<1024*1024?`${(t/1024).toFixed(1)} KB`:`${(t/(1024*1024)).toFixed(1)} MB`}async function v(t){try{return(await(await L("GET",`/api/documents/${t}/download-url`)).json()).url||null}catch{return null}}function K(){const{user:t}=b(),{toast:l}=C(),[a,c]=k.useState(null);if(!S(t==null?void 0:t.role))return e.jsx(B,{to:"/dashboard"});const{data:o=[],isLoading:y}=D({queryKey:["/api/vendor/documents"]});async function m(s){const n=await v(s.id);n?window.open(n,"_blank","noopener,noreferrer"):l({title:"Unable to download",description:"Could not retrieve the document URL.",variant:"destructive"})}async function x(s){const n=await v(s.id);n?window.open(n,"_blank","noopener,noreferrer"):l({title:"Unable to preview",description:"Could not retrieve the document URL.",variant:"destructive"})}return e.jsxs("div",{className:"min-h-screen bg-background","data-testid":"vendor-documents-page",children:[e.jsxs("main",{className:"container mx-auto px-4 py-6",children:[e.jsxs("div",{className:"mb-6",children:[e.jsx("h1",{className:"text-2xl font-bold text-foreground","data-testid":"text-vendor-documents-title",children:"Shared Documents"}),e.jsx("p",{className:"text-muted-foreground",children:"Click any document to view its details"})]}),y?e.jsx("div",{className:"space-y-3",children:[1,2,3,4].map(s=>e.jsx(T,{className:"h-20 w-full"},s))}):o.length===0?e.jsx(u,{children:e.jsx(h,{className:"py-12",children:e.jsxs("div",{className:"text-center text-muted-foreground",children:[e.jsx(d,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{className:"text-lg font-medium",children:"No documents shared yet"}),e.jsx("p",{className:"text-sm mt-1",children:"Documents will appear here when contractors share them with you"})]})})}):e.jsx("div",{className:"space-y-3",children:o.map(s=>e.jsx(u,{"data-testid":`card-document-${s.id}`,className:"cursor-pointer hover:bg-muted/50 transition-colors",onClick:()=>c(s),children:e.jsx(h,{className:"p-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.jsx(d,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-sm","data-testid":`text-doc-name-${s.id}`,children:s.fileName}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(p,{className:"h-3 w-3"}),s.contractorOrgName]}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),e.jsx("span",{className:"text-xs text-muted-foreground",children:w(s.fileSize)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:"·"}),e.jsxs("span",{className:"text-xs text-muted-foreground flex items-center gap-1",children:[e.jsx(j,{className:"h-3 w-3"}),new Date(s.sharedAt).toLocaleDateString()]})]})]})]}),e.jsxs("div",{className:"flex items-center gap-2",onClick:n=>n.stopPropagation(),children:[s.category&&e.jsx(i,{variant:"outline",className:"text-xs",children:s.category}),e.jsx(i,{variant:"secondary",className:"text-xs",children:s.fileType}),e.jsx(r,{variant:"ghost",size:"sm",onClick:()=>x(s),"data-testid":`button-preview-doc-${s.id}`,children:e.jsx(f,{className:"h-4 w-4"})}),e.jsx(r,{variant:"ghost",size:"sm",onClick:()=>m(s),"data-testid":`button-download-doc-${s.id}`,children:e.jsx(N,{className:"h-4 w-4"})})]})]})})},s.id))})]}),e.jsx(z,{open:!!a,onOpenChange:s=>{s||c(null)},children:e.jsxs(F,{className:"max-w-lg","data-testid":"modal-document-detail",children:[e.jsx($,{children:e.jsxs(U,{className:"flex items-center gap-2",children:[e.jsx(d,{className:"w-5 h-5 text-primary"}),"Document Details"]}
1)}),a&&e.jsxs("div",{className:"space-y-5 pt-1",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:"File Name"}),e.jsx("p",{className:"text-base font-semibold break-all","data-testid":"text-modal-filename",children:a.fileName})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(g,{className:"w-3 h-3"})," File Type"]}),e.jsx(i,{variant:"secondary",className:"text-xs","data-testid":"text-modal-filetype",children:a.fileType})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(P,{className:"w-3 h-3"})," File Size"]}),e.jsx("p",{className:"text-sm","data-testid":"text-modal-filesize",children:w(a.fileSize)})]})]}),a.category&&e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(g,{className:"w-3 h-3"})," Category"]}),e.jsx(i,{variant:"outline",className:"text-xs","data-testid":"text-modal-category",children:a.category})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(p,{className:"w-3 h-3"})," Shared By"]}),e.jsxs("p",{className:"text-sm","data-testid":"text-modal-sharedby",children:[e.jsx("span",{className:"font-medium",children:a.sharedByName}),e.jsxs("span",{className:"text-muted-foreground",children:[" · ",a.contractorOrgName]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide flex items-center gap-1",children:[e.jsx(j,{className:"w-3 h-3"})," Shared On"]}),e.jsx("p",{className:"text-sm","data-testid":"text-modal-sharedat",children:new Date(a.sharedAt).toLocaleDateString("en-US",{weekday:"long",year:"numeric",month:"long",day:"numeric"})})]}),e.jsxs("div",{className:"flex gap-2 pt-2 border-t",onClick:s=>s.stopPropagation(),children:[e.jsxs(r,{className:"flex-1",variant:"outline",onClick:()=>x(a),"data-testid":"button-modal-preview",children:[e.jsx(f,{className:"w-4 h-4 mr-2"})," Preview"]}),e.jsxs(r,{className:"flex-1",onClick:()=>m(a),"data-testid":"button-modal-download",children:[e.jsx(N,{className:"w-4 h-4 mr-2"})," Download"]})]})]})]})})]})}export{K 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.