Skip to content

🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.

Refactor pagination components across multiple pages

Bill Yang2c9370ce008c
diff --git a/client/src/app/[site]/goals/page.tsx b/client/src/app/[site]/goals/page.tsx
index a1d206ac6..df6b0d90e 100644
--- a/client/src/app/[site]/goals/page.tsx
+++ b/client/src/app/[site]/goals/page.tsx
@@ -7,7 +7,7 @@ import {
} from "../../../api/analytics/goals/useGetGoals";
import { DisabledOverlay } from "../../../components/DisabledOverlay";
import { NothingFound } from "../../../components/NothingFound";
-import { TablePagination } from "../../../components/pagination";
+import { Pagination } from "../../../components/pagination";
import { useSetPageTitle } from "../../../hooks/useSetPageTitle";
import { GOALS_PAGE_FILTERS, useStore } from "../../../lib/store";
import { SubHeader } from "../components/SubHeader/SubHeader";
@@ -147,7 +147,7 @@ export default function GoalsPage() {
<GoalsList goals={goalsData.data} siteId={Number(site)} />
{goalsData.meta.totalPages > 1 && (
- <TablePagination
+ <Pagination
table={paginationController}
data={paginationData}
pagination={pagination}
diff --git a/client/src/app/[site]/pages/page.tsx b/client/src/app/[site]/pages/page.tsx
index e11cf52a1..f7fa25fbe 100644
--- a/client/src/app/[site]/pages/page.tsx
+++ b/client/src/app/[site]/pages/page.tsx
@@ -4,7 +4,7 @@ import {
PageTitleItem,
useGetPageTitlesPaginated,
} from "@/api/analytics/useGetPageTitles";
-import { TablePagination } from "@/components/pagination";
+import { Pagination } from "@/components/pagination";
import { useSetPageTitle } from "@/hooks/useSetPageTitle";
import { useStore } from "@/lib/store";
import { useEffect, useState } from "react";
@@ -137,7 +137,7 @@ export default function Pages() {
/>
))}
{totalPages > 0 && (
- <TablePagination
+ <Pagination
table={table}
data={{ items: pagesDataArray || [], total: totalCount || 0 }}
pagination={pagination}
diff --git a/client/src/app/[site]/performance/components/PerformanceTable.tsx b/client/src/app/[site]/performance/components/PerformanceTable.tsx
index e7bfea06e..d86d69c23 100644
--- a/client/src/app/[site]/performance/components/PerformanceTable.tsx
+++ b/client/src/app/[site]/performance/components/PerformanceTable.tsx
@@ -32,7 +32,7 @@ import {
PerformanceByDimensionItem,
useGetPerformanceByDimension,
} from "../../../../api/analytics/performance/useGetPerformanceByDimension";
-import { TablePagination } from "../../../../components/pagination";
+import { Pagination } from "../../../../components/pagination";
import { FilterParameter } from "@rybbit/shared";
import { useStore, addFilter, removeFilter } from "../../../../lib/store";
import { PerformanceMetric, usePerformanceStore } from "../performanceStore";
@@ -501,7 +501,7 @@ export function PerformanceTable({ dimension, title }: PerformanceTableProps) {
{totalPages > 1 && (
<div className="mt-4">
- <TablePagination
+ <Pagination
table={paginationController}
data={paginationData}
pagination={pagination}
diff --git a/client/src/app/[site]/users/page.tsx b/client/src/app/[site]/users/page.tsx
index af5e0c3cd..18152863f 100644
--- a/client/src/app/[site]/users/page.tsx
+++ b/client/src/app/[site]/users/page.tsx
@@ -24,7 +24,7 @@ import { useParams } from "next/navigation";
import { useState } from "react";
import { useGetUsers, UsersResponse } from "../../../api/analytics/users";
import { Button } from "../../../components/ui/button";
-import { TablePagination } from "../../../components/pagination";
+import { Pagination } from "../../../components/pagination";
import {
Tooltip,
TooltipContent,
@@ -369,7 +369,7 @@ export default function UsersPage() {
{/* Pagination */}
<div className="border-t border-neutral-800">
<div className="px-4 py-3">
- <TablePagination
+ <Pagination
table={table}
data={{ items: data?.data || [], total: data?.totalCount || 0 }}
pagination={pagination}
diff --git a/client/src/app/admin/components/organizations/Organizations.tsx b/client/src/app/admin/components/organizations/Organizations.tsx
index e6e984451..02e913a7e 100644
--- a/client/src/app/admin/components/organizations/Organizations.tsx
+++ b/client/src/app/admin/components/organizations/Organizations.tsx
@@ -28,7 +28,7 @@ import {
} from "lucide-react";
import Link from "next/link";
import { Button } from "@/components/ui/button";
-import { TablePagination } from "@/components/pagination";
+import { Pagination } from "@/components/pagination";
import { authClient } from "@/lib/auth";
import { userStore } from "@/lib/userStore";
import {
@@ -554,7 +554,7 @@ export function Organizations() {
</div>
<div className="mt-4">
- <TablePagination
+ <Pagination
table={paginationController}
data={
table.getRowModel().rows.length > 0
diff --git a/client/src/app/admin/components/shared/AdminTablePagination.tsx b/client/src/app/admin/components/shared/AdminTablePagination.tsx
index ab29f5735..61b291265 100644
--- a/client/src/app/admin/components/shared/AdminTablePagination.tsx
+++ b/client/src/app/admin/components/shared/AdminTablePagination.tsx
@@ -1,7 +1,7 @@
"use client";
import { Table } from "@tanstack/react-table";
-import { TablePagination } from "@/components/pagination";
+import { Pagination } from "@/components/pagination";
interface AdminTablePaginationProps<TData> {
table: Table<TData>;
@@ -21,7 +21,7 @@ export function AdminTablePagination<TData>({
itemName,
}: AdminTablePaginationProps<TData>) {
return (
- <TablePagination
+ <Pagination
table={table}
data={data}
pagination={pagination}
diff --git a/client/src/components/pagination.tsx b/client/src/components/pagination.tsx
index dea12a3ba..b68f948cf 100644
--- a/client/src/components/pagination.tsx
+++ b/client/src/components/pagination.tsx
@@ -36,7 +36,7 @@ interface PaginationProps<TData> {
itemName?: string;
}
-export function TablePagination<TData>({
+export function Pagination<TData>({
table,
data,
pagination,
@@ -46,7 +46,7 @@ export function TablePagination<TData>({
}: PaginationProps<TData>) {
return (
<div className="flex items-center justify-between">
- <div className="text-sm text-neutral-400">
+ <div className="hidden text-sm text-neutral-400 md:block">
{isLoading ? (
<span>Loading {itemName}...</span>
) : (
@@ -72,7 +72,7 @@ export function TablePagination<TData>({
)}
</div>
<div className="flex items-center space-x-2">
- <div className="mr-4 flex items-center space-x-2">
+ <div className="mr-4 hidden items-center space-x-2 md:flex">
<span className="text-sm text-neutral-400">Page size:</span>
<Select
value={pagination.pageSize.toString()}