update cf on insights

This commit is contained in:
2025-12-18 00:20:02 -03:00
parent 3857620f89
commit 8081e838a3
10 changed files with 51 additions and 45 deletions

View File

@@ -3,6 +3,7 @@ import type { Route } from './+types/route'
import { Suspense } from 'react'
import { Await } from 'react-router'
import { cloudflareContext } from '@repo/auth/context'
import { DataTable } from '@repo/ui/components/data-table'
import { Skeleton } from '@repo/ui/components/skeleton'
import { createSearch } from '@repo/util/meili'
@@ -14,6 +15,7 @@ export function meta({}: Route.MetaArgs) {
}
export async function loader({ context, request }: Route.LoaderArgs) {
const cloudflare = context.get(cloudflareContext)
const { searchParams } = new URL(request.url)
const page = Number(searchParams.get('p')) + 1
const sort = searchParams.get('sort') || 'create_date:desc'
@@ -25,7 +27,7 @@ export async function loader({ context, request }: Route.LoaderArgs) {
sort: [sort],
page,
hitsPerPage,
env: context.cloudflare.env
env: cloudflare.env
})
}
}
@@ -38,7 +40,7 @@ export default function Route({ loaderData: { data } }: Route.ComponentProps) {
</div>
<Await resolve={data}>
{({ hits, page, hitsPerPage, totalHits }) => {
{({ hits, page = 1, hitsPerPage, totalHits }) => {
return (
<DataTable
sort={[{ id: 'created_at', desc: true }]}