1import{c as A,u as H,y as W,r as a,j as e,C as k}from"./index-XB6epCF0.js";import{u as J,a as K,L as Q,m as p,F as C,b as X}from"./useDocumentCategories-BlYSSf3V.js";import{u as Y}from"./usePagination-p-poCejx.js";import{A as ee}from"./AdminPagination-Xyty1qv7.js";import{E as se}from"./EmailDisplay-DPNrSKPe.js";import{A as te}from"./arrow-left-DpszcY8V.js";import{F as m}from"./file-text-QS4b1Ouq.js";import{S as re}from"./search-SdDT25e6.js";import{E as F}from"./eye-BzoXVKnY.js";import"./useClipboard-B5-2iLZp.js";import"./mail-LHkY63w1.js";import"./check-Bf01jIXS.js";import"./copy-D47oPYuz.js";/** 2 * @license lucide-react v0.441.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const ae=A("FileImage",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["circle",{cx:"10",cy:"12",r:"2",key:"737tya"}],["path",{d:"m20 17-1.296-1.296a2.41 2.41 0 0 0-3.408 0L9 22",key:"wt3hpn"}]]);/** 7 * @license lucide-react v0.441.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const ie=A("Grid3x3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 9h18",key:"1pudct"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"M15 3v18",key:"14nvp0"}]]),je=()=>{const c=H(),{user:r,logout:f,isLoading:x}=W(),[h,L]=a.useState(""),[u,T]=a.useState(""),[n,j]=a.useState("grid"),{categories:l,isLoading:z}=J(),[t,y]=a.useState(null),[_,M]=a.useState({}),E=a.useRef(null);a.useEffect(()=>{const s=setTimeout(()=>{T(h)},300);return()=>clearTimeout(s)},[h]),a.useEffect(()=>{l.length>0&&!t&&y(l[0].id)},[l,t]);const d=u.length>0,o=l.find(s=>s.id===t),i=t&&_[t]||"created_at",P=i==="created_at_asc"?"created_at":i==="title_desc"?"title":i,D=i==="title"||i==="created_at_asc"?"asc":"desc",{currentPage:I,pageSize:B,setPage:O,setPageSize:V,resetPagination:N,paginationParams:$}=Y({defaultPageSize:25});a.useEffect(()=>{N()},[u,i,t,N]);const q=r&&(r.role==="admin"||r.memberId!=null&&r.membershipStatus==="active");a.useEffect(()=>{x||(r?r.role!=="admin"&&!r.memberId?c("/members"):r.memberId&&r.membershipStatus!=="active"&&(f(),c("/members")):c("/members"))},[r,f,c,x]);const{documents:v,isLoading:g,error:b,totalPages:R,total:Z}=K({...$,search:u||void 0,categoryId:!d&&t?t:void 0,sortBy:P,sortOrder:D}),w=s=>{switch(p.getFileTypeFromMimeType(s.mimeType)){case"pdf":return e.jsx(m,{className:"w-8 h-8 text-red-500"});case"doc":return e.jsx(C,{className:"w-8 h-8 text-blue-500"});case"excel":return e.jsx(X,{className:"w-8 h-8 text-green-500"});case"image":return e.jsx(ae,{className:"w-8 h-8 text-purple-500"});default:return e.jsx(C,{className:"w-8 h-8 text-gray-500"})}},G=s=>{t&&M(S=>({...S,[t]:s}))},U=s=>{y(s)};return x||!q?e.jsx("div",{className:"min-h-screen bg-gray-50 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin rounded-full h-12 w-12 border-b-2 border-blue-600 mx-auto mb-4"}),e.jsx("p",{className:"text-gray-600",children:"Checking authentication..."})]})}):e.jsxs("div",{className:"min-h-screen bg-gray-50",children:[e.jsx("div",{className:"bg-white shadow-sm border-b",children:e.jsx("div",{className:"container mx-auto px-4 py-4 sm:py-6",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("button",{onClick:()=>c("/members"),className:"flex items-center text-gray-600 hover:text-blue-600 p-2 rounded-lg hover:bg-gray-50 transition-colors flex-shrink-0","aria-label":"Back to members area",children:[e.jsx(te,{className:"w-5 h-5 sm:mr-1"}),e.jsx("span",{className:"hidden sm:inline",children:"Back"})]}),e.jsxs("div",{className:"flex items-center justify-center flex-1 min-w-0",children:[e.jsx(m,{className:"hidden sm:block w-6 h-6 sm:w-8 sm:h-8 text-blue-600 mr-2 sm:mr-3 flex-shrink-0"}),e.jsxs("div",{className:"text-center min-w-0",children:[e.jsx("h1",{className:"text-lg sm:text-2xl font-bold text-gray-900 truncate",children:"Member Documents"}),e.jsx("p",{className:"hidden sm:block text-sm sm:text-base text-gray-600",children:"Access club documents, forms, and important information"})]})]}),e.jsx("div",{className:"w-8 sm:w-24 flex-shrink-0"})]})})}),e.jsxs("div",{className:"container mx-auto px-4 py-6",children:[e.jsx("div",{className:"bg-white rounded-lg shadow-sm p-6 mb-6",children:e.jsxs("div",{className:"flex flex-col sm:flex-row gap-4",children:[e.jsx("div",{className:"flex-1",children:e.jsxs("div",{className:"relative",children:[e.jsx(re,{className:"absolute left-3 top-3 w-5 h-5 text-gray-400"}),e.jsx("input",{type:"text",placeholder:"Search documents...",value:h,onChange:s=>L(s.target.value),className:"w-full pl-10 pr-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent"})]})}),e.jsxs("div",{className:"flex border border-gray-300 rounded-lg overflow-hidden",children:[e.jsx("button",{onClick:()=>j("grid"),className:`px-3 py-2 ${n==="grid"?"bg-blue-600 text-white":"bg-white text-gray-600"}`,children:e.jsx(ie,{size:20})}),e.jsx("button",{onClick:()=>j("list"),className:`px-3 py-2 ${n==="list"?"bg-blue-600 text-white":"bg-white text-gray-600"}`,children:e.jsx(Q,{size:20})})]})]})}),!d&&e.jsx(e.Fragment,{children:z?e.jsxs("div",{className:"text-center py-6",children:[e.jsx("div",{className:"animate-spin rounded-full h-8 w-8 border-b-2 border-blue-600 mx-auto mb-2"}),e.jsx("p",{className:"text-gray-600 text-sm",children:"Loading c
11ategories..."})]}):l.length>0?e.jsxs(e.Fragment,{children:[e.jsx("div",{ref:E,className:"flex overflow-x-auto bg-white rounded-t-lg shadow-sm border border-b-0 scrollbar-hide",style:{scrollBehavior:"smooth",msOverflowStyle:"none",scrollbarWidth:"none"},children:l.map(s=>e.jsxs("button",{onClick:()=>U(s.id),className:`flex-shrink-0 px-5 py-3 text-sm font-medium transition-colors whitespace-nowrap border-b-2 ${t===s.id?"text-blue-600 border-blue-600 bg-blue-50":"text-gray-600 border-transparent hover:text-gray-900 hover:bg-gray-50"}`,children:[s.name," (",s.documentCount,")"]},s.id))}),(o==null?void 0:o.description)&&e.jsx("div",{className:"bg-blue-50 border-x border-blue-100 px-5 py-3",children:e.jsx("p",{className:"text-sm text-blue-700",children:o.description})}),e.jsx("div",{className:"bg-white border rounded-b-lg shadow-sm px-5 py-3 mb-6 flex items-center justify-end",children:e.jsxs("select",{value:i,onChange:s=>G(s.target.value),className:"text-sm px-3 py-1.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent",children:[e.jsx("option",{value:"created_at",children:"Newest First"}),e.jsx("option",{value:"created_at_asc",children:"Oldest First"}),e.jsx("option",{value:"title",children:"Title A-Z"}),e.jsx("option",{value:"title_desc",children:"Title Z-A"})]})})]}):null}),g&&e.jsx("div",{className:"text-center py-12",children:e.jsx("div",{className:"text-gray-600",children:"Loading documents..."})}),b&&e.jsx("div",{className:"text-center py-12",children:e.jsxs("div",{className:"text-red-600",children:["Error loading documents: ",b]})}),!g&&!b&&e.jsxs(e.Fragment,{children:[v.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(m,{className:"w-16 h-16 text-gray-400 mx-auto mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 mb-2",children:d?"No documents found":"No documents in this category yet."}),e.jsx("p",{className:"text-gray-600",children:d?"Try adjusting your search criteria.":""})]}):e.jsx("div",{className:n==="grid"?"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-6":"space-y-4",children:v.map(s=>e.jsx("div",{className:`bg-white rounded-lg shadow-sm border hover:shadow-md transition-shadow ${n==="list"?"flex items-center p-4":"p-6"}`,children:n==="grid"?e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"mb-4",children:w(s)}),e.jsx("h3",{className:"font-medium text-gray-900 mb-2 line-clamp-2",children:s.title}),s.description&&e.jsx("p",{className:"text-sm text-gray-600 mb-3 line-clamp-2",children:s.description}),e.jsxs("div",{className:"space-y-2 text-xs text-gray-500 mb-4",children:[e.jsxs("div",{className:"flex items-center justify-center",children:[e.jsx(k,{size:12,className:"mr-1"}),s.createdAt?new Date(s.createdAt).toLocaleDateString():"N/A"]}),e.jsx("div",{children:p.formatFileSize(s.fileSizeBytes)})]}),e.jsx("div",{className:"flex justify-center",children:e.jsxs("a",{href:s.fileUrl,target:"_blank",rel:"noopener noreferrer",className:"bg-blue-600 hover:bg-blue-700 text-white px-6 py-2 rounded-lg font-medium transition-colors flex items-center justify-center",children:[e.jsx(F,{size:16,className:"mr-2"}),"View"]})})]}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"mr-4 flex-shrink-0",children:w(s)}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("h3",{className:"font-medium text-gray-900 truncate",children:s.title}),s.description&&e.jsx("p",{className:"text-sm text-gray-600 mt-1 truncate",children:s.description}),e.jsxs("div",{className:"flex items-center text-xs text-gray-500 mt-2",children:[e.jsx(k,{size:12,className:"mr-1"}),e.jsx("span",{className:"mr-4",children:s.createdAt?new Date(s.createdAt).toLocaleDateString():"N/A"}),e.jsx("span",{children:p.formatFileSize(s.fileSizeBytes)})]})]}),e.jsx("div",{className:"ml-4 flex-shrink-0",children:e.jsxs("a",{href:s.fileUrl,target:"_blank",rel:"noopener noreferrer",className:"bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg font-medium transition-colors flex items-center",children:[e.jsx(F,{size:16,className:"mr-2"}),"View"]}
11)})]})},s.id))}),e.jsx("div",{className:"mt-6",children:e.jsx(ee,{currentPage:I,totalPages:R,total:Z,pageSize:B,onPageChange:O,onPageSizeChange:V,isLoading:g})})]}),e.jsx("div",{className:"mt-8 bg-blue-50 border border-blue-200 rounded-lg p-6",children:e.jsxs("div",{className:"flex items-start",children:[e.jsx(m,{className:"w-6 h-6 text-blue-600 mr-3 mt-0.5"}),e.jsxs("div",{children:[e.jsx("h3",{className:"font-semibold text-blue-900 mb-2",children:"Need help accessing documents?"}),e.jsx("p",{className:"text-blue-700 text-sm mb-3",children:"If you're having trouble downloading or viewing any documents, please contact the club office."}),e.jsxs("p",{className:"text-blue-600 text-sm",children:["Contact us at"," ",e.jsx(se,{email:"[email protected]"})]})]})]})})]})]})};export{je 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.