1import{a as L,r as U,j as e,B as g,aI as I,C as n,d as c,ad as z,N as H,a0 as R,a1 as E,a2 as V,a3 as _,a4 as h,b as K,c as O,aS as X,F as j,aT as $,aU as q,aV as u,aW as r,aX as G,aY as l,e as o,aZ as P,a7 as f,D as p,$ as y,i as w,h as Q}from"./index-DGo-vssZ.js";import{r as v}from"./vendor-Qgthw7N1.js";import{A as N}from"./archive-CR8M3D3c.js";import{C as b}from"./circle-x--5-vDMIU.js";function ee(){const[d,T]=v.useState(""),[x,C]=v.useState("all"),{toast:S}=L(),{data:k=[],isLoading:m,refetch:D}=U({queryKey:["/api/file-activities"],retry:1}),t=k.filter(s=>{const a=s.originalFileName.toLowerCase().includes(d.toLowerCase())||s.userName.toLowerCase().includes(d.toLowerCase()),i=x==="all"||s.activityType===x;return a&&i}),F=(s,a)=>a==="processing"?e.jsx(w,{className:"w-4 h-4 text-yellow-500"}):a==="failed"?e.jsx(b,{className:"w-4 h-4 text-red-500"}):s==="import"?e.jsx(y,{className:"w-4 h-4 text-blue-500"}):s==="export"?e.jsx(p,{className:"w-4 h-4 text-green-500"}):e.jsx(j,{className:"w-4 h-4 text-gray-500"}),A=s=>{switch(s){case"completed":return e.jsxs(o,{variant:"outline",className:"text-green-600 border-green-200 bg-green-50",children:[e.jsx(Q,{className:"w-3 h-3 mr-1"}),"Completed"]});case"failed":return e.jsxs(o,{variant:"outline",className:"text-red-600 border-red-200 bg-red-50",children:[e.jsx(b,{className:"w-3 h-3 mr-1"}),"Failed"]});case"processing":return e.jsxs(o,{variant:"outline",className:"text-yellow-600 border-yellow-200 bg-yellow-50",children:[e.jsx(w,{className:"w-3 h-3 mr-1"}),"Processing"]});default:return e.jsx(o,{variant:"outline",children:"Unknown"})}},B=s=>{if(!s)return"Unknown";const a=["Bytes","KB","MB","GB"],i=Math.floor(Math.log(s)/Math.log(1024));return Math.round(s/Math.pow(1024,i)*100)/100+" "+a[i]},M=s=>{if(!s.canDownload){S({title:"Download Unavailable",description:"This file is no longer available for download or has expired.",variant:"destructive"});return}window.open(s.downloadUrl,"_blank")};return e.jsx("div",{className:"container mx-auto px-4 py-8 max-w-7xl",children:e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-gray-900 dark:text-white mb-2",children:"ð File History"}),e.jsx("p",{className:"text-gray-600 dark:text-gray-300",children:"Complete history of all imported and exported files with download capabilities"})]}),e.jsxs(g,{variant:"outline",onClick:()=>D(),disabled:m,children:[e.jsx(I,{className:`w-4 h-4 mr-2 ${m?"animate-spin":""}`}),"Refresh"]})]}),e.jsx(n,{className:"mb-6",children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"relative",children:[e.jsx(z,{className:"absolute left-3 top-3 w-4 h-4 text-gray-400"}),e.jsx(H,{placeholder:"Search files...",value:d,onChange:s=>T(s.target.value),className:"pl-10"})]}),e.jsxs(R,{value:x,onValueChange:C,children:[e.jsx(E,{children:e.jsx(V,{placeholder:"Filter by type"})}),e.jsxs(_,{children:[e.jsx(h,{value:"all",children:"All Activities"}),e.jsx(h,{value:"import",children:"Imports Only"}),e.jsx(h,{value:"export",children:"Exports Only"})]})]}),e.jsxs("div",{className:"flex items-center text-sm text-gray-500",children:[e.jsx(N,{className:"w-4 h-4 mr-2"}),t.length," files found"]})]})})}),e.jsxs(n,{children:[e.jsxs(K,{children:[e.jsxs(O,{className:"flex items-center",children:[e.jsx(N,{className:"w-5 h-5 mr-2"}),"File Activity History"]}),e.jsx(X,{children:"All imported and exported files are stored for 90 days with secure download links"})]}),e.jsx(c,{children:m?e.jsxs("div",{className:"flex justify-center items-center py-12",children:[e.jsx("div",{className:"animate-spin w-8 h-8 border-4 border-primary border-t-transparent rounded-full"}),e.jsx("span",{className:"ml-3 text-gray-600",children:"Loading file history..."})]}):t.length===0?e.jsxs("div",{className:"text-center py-12",children:[e.jsx(j,{className:"w-16 h-16 mx-auto mb-4 text-gray-300"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900 dark:text-white mb-2",children:d||x!=="all"?"No files match your search":"No file history yet"}),e.jsx("p",{className:"text-gray-500 dark:text-gray-400",children:d||x!=="all"?"Try adjusting your search criteria":"Import or export CSV files to see your history here"})]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs($,{children:[e.jsx(q,{children:e.jsxs(u,{children:[e.jsx(r,{className:"w-12"}),e.jsx(r,{children:"File Name"}),e.jsx(r,{children:"Type"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"Records"}),e.jsx(r,{children:"Size"}),e.jsx(r,{children:"User"}),e.jsx(r,{children:"Date"}),e.jsx(r,{children:"Actions"})]})}),e.jsx(G,{children:t.map(s=>{var a,i;return e.jsxs(u,{className:"hover:bg-gray-50 dark:hover:bg-gray-800",children:[e.jsx(l,{children:F(s.activityType,s.status)}),e.jsx(l,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.originalFileName}),((a=s.metadata)==null?void 0:a.exportType)&&e.jsxs("div",{className:"text-xs text-gray-500",children:["Type: ",s.metadata.exportType.replace("_"," ")]}),((i=s.metadata)==null?void 0:i.importType)&&e.jsxs("div",{className:"text-xs text-gray-500",children:["Type: ",s.metadata.importType.replace("_"," ")]})]})}),e.jsx(l,{children:e.jsx(o,{variant:"outline",className:"capitalize",children:s.activityType})}),e.jsx(l,{children:A(s.status)}),e.jsx(l,{children:e.jsx("span",{className:"font-mono text-sm",children:s.recordCount.toLocaleStr
1ing()})}),e.jsx(l,{children:e.jsx("span",{className:"text-sm text-gray-600",children:B(s.fileSize)})}),e.jsx(l,{children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(P,{className:"w-3 h-3 mr-1 text-gray-400"}),e.jsx("span",{className:"text-sm",children:s.userName})]})}),e.jsx(l,{children:e.jsxs("div",{className:"text-sm",children:[e.jsx("div",{children:f(new Date(s.createdAt),"MMM d, yyyy")}),e.jsx("div",{className:"text-xs text-gray-500",children:f(new Date(s.createdAt),"h:mm a")})]})}),e.jsx(l,{children:s.canDownload?e.jsxs(g,{variant:"ghost",size:"sm",onClick:()=>M(s),className:"h-8",children:[e.jsx(p,{className:"w-3 h-3 mr-1"}),"Download"]}):e.jsx("span",{className:"text-xs text-gray-400",children:"Expired"})})]},s.id)})})]})})})]}),t.length>0&&e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-4 gap-4 mt-6",children:[e.jsx(n,{children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(y,{className:"w-8 h-8 text-blue-500 mr-3"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:t.filter(s=>s.activityType==="import").length}),e.jsx("div",{className:"text-sm text-gray-500",children:"Imports"})]})]})})}),e.jsx(n,{children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(p,{className:"w-8 h-8 text-green-500 mr-3"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:t.filter(s=>s.activityType==="export").length}),e.jsx("div",{className:"text-sm text-gray-500",children:"Exports"})]})]})})}),e.jsx(n,{children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(j,{className:"w-8 h-8 text-purple-500 mr-3"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:t.reduce((s,a)=>s+a.recordCount,0).toLocaleString()}),e.jsx("div",{className:"text-sm text-gray-500",children:"Total Records"})]})]})})}),e.jsx(n,{children:e.jsx(c,{className:"p-4",children:e.jsxs("div",{className:"flex items-center",children:[e.jsx(N,{className:"w-8 h-8 text-orange-500 mr-3"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-2xl font-bold",children:t.filter(s=>s.canDownload).length}),e.jsx("div",{className:"text-sm text-gray-500",children:"Available Downloads"})]})]})})})]})]})})}export{ee 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.