blob: 7af0a9e25b4a5232ca2a49807fa424a3f753f7e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
import { Drive_log } from "@/lib/drive_server"
import { HistoryView } from "@/components/history/HistoryView"
interface HistoryPageProps {
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
}
export default async function HistoryPage({ searchParams }: HistoryPageProps) {
const logEntries = await Drive_log()
const resolvedSearchParams = await searchParams
// Parse page parameter (default to 0)
const page = parseInt((resolvedSearchParams.page as string) || '0', 10)
const pageSize = 50
// Sort by timestamp descending (most recent first)
const sortedEntries = logEntries.sort((a, b) => b.timestamp - a.timestamp)
// Calculate pagination
const startIndex = page * pageSize
const endIndex = startIndex + pageSize
const paginatedEntries = sortedEntries.slice(startIndex, endIndex)
const hasNextPage = endIndex < sortedEntries.length
const hasPrevPage = page > 0
return (
<HistoryView
entries={paginatedEntries}
currentPage={page}
hasNextPage={hasNextPage}
hasPrevPage={hasPrevPage}
totalEntries={sortedEntries.length}
/>
)
}
|