diff --git a/app/analytics/query.ts b/app/analytics/query.ts index 419b5c9c..fce0e48c 100644 --- a/app/analytics/query.ts +++ b/app/analytics/query.ts @@ -305,12 +305,9 @@ export class AnalyticsEngineAPI { column: T, interval: string, tz?: string, - page?: number, - limit?: number, + page: number = 1, + limit: number = 10, ) { - limit = limit || 10; - page = page || 1; - const intervalSql = intervalToSql(interval, tz); const _column = ColumnMappings[column]; @@ -369,13 +366,9 @@ export class AnalyticsEngineAPI { column: T, interval: string, tz?: string, - page?: number, - limit?: number, + page: number = 1, + limit: number = 10, ) { - // defaults to 1 day if not specified - limit = limit || 10; - page = page || 1; - const intervalSql = intervalToSql(interval, tz); const _column = ColumnMappings[column]; diff --git a/app/components/PaginatedTableCard.tsx b/app/components/PaginatedTableCard.tsx index 38c87c9b..9c028b82 100644 --- a/app/components/PaginatedTableCard.tsx +++ b/app/components/PaginatedTableCard.tsx @@ -13,16 +13,14 @@ const ReferrerCard = ({ }: { siteId: string; interval: string; - dataFetcher: any; + dataFetcher: any; // ignore type for now columnHeaders: string[]; loaderUrl: string; }) => { - // const dataFetcher = useFetcher(); const countsByProperty = dataFetcher.data?.countsByProperty || []; const page = dataFetcher.data?.page || 1; useEffect(() => { - // Your code here if (dataFetcher.state === "idle") { dataFetcher.load( `${loaderUrl}?site=${siteId}&interval=${interval}`, @@ -31,7 +29,6 @@ const ReferrerCard = ({ }, []); useEffect(() => { - // NOTE: intentionally resets page to default when interval or site changes if (dataFetcher.state === "idle") { dataFetcher.load( `${loaderUrl}?site=${siteId}&interval=${interval}`, @@ -40,7 +37,6 @@ const ReferrerCard = ({ }, [siteId, interval]); function handlePagination(page: number) { - // TODO: is there a way of updating the query string with this state without triggering a navigation? dataFetcher.load( `${loaderUrl}?site=${siteId}&interval=${interval}&page=${page}`, ); diff --git a/app/components/PaginationButtons.tsx b/app/components/PaginationButtons.tsx index 349e43c7..7639b7b5 100644 --- a/app/components/PaginationButtons.tsx +++ b/app/components/PaginationButtons.tsx @@ -16,7 +16,7 @@ const PaginationButtons: React.FC = ({ return (
- { if (page > 1) handlePagination(page - 1); }} @@ -27,8 +27,8 @@ const PaginationButtons: React.FC = ({ } > - - +
); }; diff --git a/app/components/TableCard.tsx b/app/components/TableCard.tsx index 94fee4ff..6f09624a 100644 --- a/app/components/TableCard.tsx +++ b/app/components/TableCard.tsx @@ -9,8 +9,6 @@ import { TableRow, } from "~/components/ui/table"; -import { Card } from "~/components/ui/card"; - type CountByProperty = [string, string][]; function calculateCountPercentages(countByProperty: CountByProperty) { diff --git a/app/lib/utils.ts b/app/lib/utils.ts index 6ff529fc..6d6d1fe5 100644 --- a/app/lib/utils.ts +++ b/app/lib/utils.ts @@ -1,6 +1,5 @@ import { type ClassValue, clsx } from "clsx"; import { twMerge } from "tailwind-merge"; -import * as React from "react"; export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); diff --git a/app/routes/dashboard.tsx b/app/routes/dashboard.tsx index 54bc9b98..ae5888fe 100644 --- a/app/routes/dashboard.tsx +++ b/app/routes/dashboard.tsx @@ -17,7 +17,6 @@ import { import { AnalyticsEngineAPI } from "../analytics/query"; -import TableCard from "~/components/TableCard"; import { ReferrerCard } from "./resources.referrer"; import { PathsCard } from "./resources.paths"; import { BrowserCard } from "./resources.browser"; diff --git a/app/routes/resources.referrer.tsx b/app/routes/resources.referrer.tsx index 5cad6576..5d4f0914 100644 --- a/app/routes/resources.referrer.tsx +++ b/app/routes/resources.referrer.tsx @@ -1,4 +1,3 @@ -import { useEffect } from "react"; import { useFetcher } from "@remix-run/react"; import type { LoaderFunctionArgs } from "@remix-run/cloudflare";