import Link from "next/link"; import { ListTree } from "lucide-react"; import { getWorkspace } from "@/lib/session"; import { API_PUBLIC_URL } from "@/lib/utils"; import { parseRequestFilters, requestsHref, REQUESTS_PAGE_SIZE, type SearchParams } from "@/lib/requests-filters"; import { listRequests, projectHasRequests, type Scope } from "@/lib/queries/dashboard"; import { PageHeader } from "@/components/ui/page-header"; import { Card } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { EmptyState } from "@/components/ui/empty-state"; import { CodeBlock } from "@/components/ui/code-block"; import { RequestsTable } from "@/components/dashboard/requests/requests-table"; import { ActiveFilterChips, RequestsFilterForm } from "@/components/dashboard/requests/requests-filters"; import { Pagination } from "@/components/dashboard/requests/pagination"; export const dynamic = "force-dynamic"; const CURL_SNIPPET = `curl -X POST ${API_PUBLIC_URL}/v1/fetch \\ -H "Authorization: Bearer fch_live_YOUR_KEY" \\ -H "Content-Type: application/json" \\ -d '{ "url": "https://example.com", "country": "CA", "format": "text" }'`; export default async function RequestsPage({ searchParams }: { searchParams: Promise }) { const [ws, sp] = await Promise.all([getWorkspace(), searchParams]); const scope: Scope = { organizationId: ws.organization.id, projectId: ws.project.id }; const filters = parseRequestFilters(sp); const [hasAny, result] = await Promise.all([projectHasRequests(scope), listRequests(scope, filters, REQUESTS_PAGE_SIZE)]); return (
{!hasAny ? ( } className="pb-8" /> ) : null} {!hasAny ? (
) : ( <> No requests match these filters. Widen the date range or clear the filters.} /> requestsHref(filters, { page: p })} /> )}
); }