🐸 Rybbit - open-source and privacy-friendly alternative to Google Analytics that is 10x more intuitive.
Update client and server versions, enhance AdminLayout, and improve date formatting
Bill Yang0348f52946a6
diff --git a/client/package-lock.json b/client/package-lock.jsonindex 9985d3463..26ed70eb2 100644--- a/client/package-lock.json+++ b/client/package-lock.json@@ -1,12 +1,12 @@{"name": "client",- "version": "2.0.1",+ "version": "2.1.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "client",- "version": "2.0.1",+ "version": "2.1.0","dependencies": {"@hookform/resolvers": "5.0.1","@icons-pack/react-simple-icons": "^13.6.0",diff --git a/client/src/app/admin/components/organizations/Organizations.tsx b/client/src/app/admin/components/organizations/Organizations.tsxindex e39a85051..c4c191dea 100644--- a/client/src/app/admin/components/organizations/Organizations.tsx+++ b/client/src/app/admin/components/organizations/Organizations.tsx@@ -129,10 +129,7 @@ export function Organizations() {{accessorKey: "createdAt",header: ({ column }) => <SortableHeader column={column}>Created</SortableHeader>,- cell: ({ row }) =>- formatDistanceToNow(parseUtcTimestamp(row.getValue("createdAt")).toJSDate(), {- addSuffix: true,- }),+ cell: ({ row }) => <div>{parseUtcTimestamp(row.getValue("createdAt")).toRelative()}</div>,},{accessorKey: "monthlyEventCount",@@ -227,15 +224,15 @@ export function Organizations() {if (isError) {return (- <AdminLayout title="Organizations">+ <AdminLayout><ErrorAlert message="Failed to load organizations data. Please try again later." /></AdminLayout>);}return (- <AdminLayout title="Organizations">- <GrowthChart data={organizations || []} title="Organizations" color="#8b5cf6" />+ <AdminLayout>+ <GrowthChart data={organizations} color="#8b5cf6" title="Organizations" /><div className="mb-4"><SearchInputdiff --git a/client/src/app/admin/components/shared/AdminLayout.tsx b/client/src/app/admin/components/shared/AdminLayout.tsxindex 378eb1104..46cfa238f 100644--- a/client/src/app/admin/components/shared/AdminLayout.tsx+++ b/client/src/app/admin/components/shared/AdminLayout.tsx@@ -1,20 +1,16 @@"use client";-import { ReactNode } from "react";-import { redirect } from "next/navigation";-import { AlertCircle } from "lucide-react";-import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";import { Button } from "@/components/ui/button";+import { redirect } from "next/navigation";+import { ReactNode } from "react";import { useAdminPermission } from "../../hooks/useAdminPermission";interface AdminLayoutProps {children: ReactNode;- title: string;- showStopImpersonating?: boolean;}-export function AdminLayout({ children, title, showStopImpersonating = false }: AdminLayoutProps) {- const { isAdmin, isImpersonating, isCheckingAdmin, stopImpersonating } = useAdminPermission();+export function AdminLayout({ children }: AdminLayoutProps) {+ const { isAdmin, isCheckingAdmin } = useAdminPermission();// If not admin, show access deniedif (!isAdmin && !isCheckingAdmin) {@@ -29,17 +25,5 @@ export function AdminLayout({ children, title, showStopImpersonating = false }:);}- return (- <div>- <div className="flex items-center justify-between mb-6">- <h2 className="text-xl font-bold">{title}</h2>- {showStopImpersonating && isImpersonating && (- <Button onClick={stopImpersonating} variant="destructive">- Stop Impersonating- </Button>- )}- </div>- {children}- </div>- );+ return <div>{children}</div>;}diff --git a/client/src/app/admin/components/shared/GrowthChart.tsx b/client/src/app/admin/components/shared/GrowthChart.tsxindex ee8de0b52..d9e72c7ea 100644--- a/client/src/app/admin/components/shared/GrowthChart.tsx+++ b/client/src/app/admin/components/shared/GrowthChart.tsx@@ -5,12 +5,12 @@ import { ResponsiveLine } from "@nivo/line";import { parseUtcTimestamp } from "@/lib/dateTimeUtils";interface GrowthChartProps {- data: Array<{ createdAt: string }>;- title: string;+ data?: Array<{ createdAt: string }>;color?: string;+ title: string;}-export function GrowthChart({ data, title, color = "#3b82f6" }: GrowthChartProps) {+export function GrowthChart({ data, color = "#3b82f6", title }: GrowthChartProps) {const chartData = useMemo(() => {if (!data || data.length === 0) return [];@@ -36,134 +36,130 @@ export function GrowthChart({ data, title, color = "#3b82f6" }: GrowthChartPropsdata: chartPoints,},];- }, [data, title]);+ }, [data]);++ if (data === undefined) {+ return <div className="h-48 sm:h-64 flex items-center justify-center text-neutral-400 text-sm">Loading...</div>;+ }if (!data || data.length === 0) {return (- <div className="bg-neutral-900 border border-neutral-700 rounded-lg p-3 sm:p-6 mb-6">- <h3 className="text-base sm:text-lg font-semibold mb-3 sm:mb-4">{title} Growth</h3>- <div className="h-48 sm:h-64 flex items-center justify-center text-neutral-400 text-sm">No data available</div>- </div>+ <div className="h-48 sm:h-64 flex items-center justify-center text-neutral-400 text-sm">No data available</div>);}return (- <div className="bg-neutral-900 border border-neutral-700 rounded-lg p-3 sm:p-6 mb-6">- <h3 className="text-base sm:text-lg font-semibold mb-3 sm:mb-4">{title} Growth</h3>- <div className="h-48 sm:h-64">- <ResponsiveLine- data={chartData}- margin={{- top: 20,- right: 10,- bottom: 50,- left: 45,- }}- xScale={{- type: "time",- format: "%Y-%m-%d",- precision: "day",- }}- xFormat="time:%Y-%m-%d"- yScale={{- type: "linear",- min: 0,- max: "auto",- stacked: false,- }}- curve="monotoneX"- axisTop={null}- axisRight={null}- axisBottom={{- format: "%m/%d",- tickValues: "every 14 days",- tickRotation: -45,- tickSize: 5,- tickPadding: 5,- }}- axisLeft={{- tickSize: 5,- tickPadding: 5,- tickRotation: 0,- legend: `New ${title}`,- legendOffset: -35,- legendPosition: "middle",- }}- colors={[color]}- pointSize={4}- pointColor={{ theme: "background" }}- pointBorderWidth={2}- pointBorderColor={{ from: "serieColor" }}- pointLabelYOffset={-12}- useMesh={true}- enableGridX={false}- enableGridY={true}- gridYValues={5}- theme={{- background: "transparent",- text: {- fontSize: 11,- fill: "#a3a3a3",- },- axis: {- domain: {- line: {- stroke: "#525252",- strokeWidth: 1,- },- },- legend: {- text: {- fontSize: 11,- fill: "#a3a3a3",- },- },- ticks: {- line: {- stroke: "#525252",- strokeWidth: 1,- },- text: {- fontSize: 10,- fill: "#a3a3a3",- },- },- },- grid: {+ <div className="h-48 sm:h-64">+ <ResponsiveLine+ data={chartData}+ margin={{+ top: 10,+ right: 10,+ bottom: 40,+ left: 25,+ }}+ xScale={{+ type: "time",+ format: "%Y-%m-%d",+ precision: "day",+ }}+ xFormat="time:%Y-%m-%d"+ yScale={{+ type: "linear",+ min: 0,+ max: "auto",+ stacked: false,+ }}+ enableSlices="x"+ curve="monotoneX"+ axisTop={null}+ axisRight={null}+ axisBottom={{+ format: "%m/%d",+ tickValues: "every 14 days",+ tickRotation: -45,+ tickSize: 5,+ tickPadding: 5,+ }}+ axisLeft={{+ tickSize: 5,+ tickPadding: 5,+ tickRotation: 0,+ }}+ colors={[color]}+ pointSize={4}+ pointColor={{ theme: "background" }}+ pointBorderWidth={2}+ pointBorderColor={{ from: "serieColor" }}+ pointLabelYOffset={-12}+ useMesh={true}+ enableGridX={false}+ enableGridY={true}+ gridYValues={5}+ theme={{+ background: "transparent",+ text: {+ fontSize: 11,+ fill: "#a3a3a3",+ },+ axis: {+ domain: {line: {- stroke: "#404040",+ stroke: "#525252",strokeWidth: 1,},},- crosshair: {+ legend: {+ text: {+ fontSize: 11,+ fill: "#a3a3a3",+ },+ },+ ticks: {line: {- stroke: "#ffffff",+ stroke: "#525252",strokeWidth: 1,- strokeOpacity: 0.35,},- },- tooltip: {- container: {- background: "#262626",- color: "#ffffff",- fontSize: "11px",- borderRadius: "4px",- boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",- border: "1px solid #404040",- padding: "6px 8px",+ text: {+ fontSize: 10,+ fill: "#a3a3a3",},},- }}- tooltip={({ point }) => (- <div className="bg-neutral-800 border border-neutral-600 rounded px-2 py-1 text-xs sm:text-sm">- <div className="font-medium text-white">{point.data.xFormatted}</div>- <div className="text-neutral-300">- {point.data.y} new {title.toLowerCase()}- </div>+ },+ grid: {+ line: {+ stroke: "#404040",+ strokeWidth: 1,+ },+ },+ crosshair: {+ line: {+ stroke: "#ffffff",+ strokeWidth: 1,+ strokeOpacity: 0.35,+ },+ },+ tooltip: {+ container: {+ background: "#262626",+ color: "#ffffff",+ fontSize: "11px",+ borderRadius: "4px",+ boxShadow: "0 4px 6px -1px rgba(0, 0, 0, 0.1)",+ border: "1px solid #404040",+ padding: "6px 8px",+ },+ },+ }}+ tooltip={({ point }) => (+ <div className="bg-neutral-800 border border-neutral-600 rounded px-2 py-1 text-xs sm:text-sm">+ <div className="font-medium text-white">{point.data.xFormatted}</div>+ <div className="text-neutral-300">+ {point.data.y} new {title.toLowerCase()}</div>- )}- />- </div>+ </div>+ )}+ /></div>);}diff --git a/client/src/app/admin/components/sites/Sites.tsx b/client/src/app/admin/components/sites/Sites.tsxindex 59c454b8b..82a6343f6 100644--- a/client/src/app/admin/components/sites/Sites.tsx+++ b/client/src/app/admin/components/sites/Sites.tsx@@ -23,6 +23,7 @@ import { AdminLayout } from "../shared/AdminLayout";import { GrowthChart } from "../shared/GrowthChart";import Link from "next/link";import { Favicon } from "../../../../components/Favicon";+import { parseUtcTimestamp } from "../../../../lib/dateTimeUtils";export function Sites() {const { data: sites, isLoading, isError } = useAdminSites();@@ -75,13 +76,7 @@ export function Sites() {{accessorKey: "createdAt",header: ({ column }) => <SortableHeader column={column}>Created</SortableHeader>,- cell: ({ row }) => (- <div>- {formatDistanceToNow(row.getValue("createdAt"), {- addSuffix: true,- })}- </div>- ),+ cell: ({ row }) => <div>{parseUtcTimestamp(row.getValue("createdAt")).toRelative()}</div>,},{accessorKey: "public",@@ -142,15 +137,15 @@ export function Sites() {if (isError) {return (- <AdminLayout title="Sites">+ <AdminLayout><ErrorAlert message="Failed to load sites data. Please try again later." /></AdminLayout>);}return (- <AdminLayout title="Sites">- <GrowthChart data={sites || []} title="Sites" color="#10b981" />+ <AdminLayout>+ <GrowthChart data={sites} title="Sites" color="#10b981" /><div className="mb-4"><SearchInput placeholder="Search by domain or owner email..." value={searchQuery} onChange={setSearchQuery} />diff --git a/client/src/app/admin/components/users/Users.tsx b/client/src/app/admin/components/users/Users.tsxindex 4c664483f..4f7feb7c8 100644--- a/client/src/app/admin/components/users/Users.tsx+++ b/client/src/app/admin/components/users/Users.tsx@@ -47,14 +47,14 @@ export function Users() {if (isError) {return (- <AdminLayout title="Users" showStopImpersonating>+ <AdminLayout><ErrorAlert message="Failed to load users. Please try again later." /></AdminLayout>);}return (- <AdminLayout title="Users" showStopImpersonating>+ <AdminLayout><div className="space-y-4">{/* Filters */}<UserFiltersdiff --git a/client/src/app/admin/components/users/UsersTable.tsx b/client/src/app/admin/components/users/UsersTable.tsxindex 0752b8153..78195e132 100644--- a/client/src/app/admin/components/users/UsersTable.tsx+++ b/client/src/app/admin/components/users/UsersTable.tsx@@ -19,6 +19,7 @@ import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@import { UserTableSkeleton } from "./UserTableSkeleton";import { userStore } from "@/lib/userStore";import { SortableHeader } from "../shared/SortableHeader";+import { parseUtcTimestamp } from "../../../../lib/dateTimeUtils";interface UsersTableProps {data: { users: AdminUser[]; total: number } | undefined;@@ -73,7 +74,7 @@ export function UsersTable({{accessorKey: "createdAt",header: ({ column }) => <SortableHeader column={column}>Created At</SortableHeader>,- cell: ({ row }) => new Date(row.getValue("createdAt")).toLocaleDateString(),+ cell: ({ row }) => <div>{parseUtcTimestamp(row.getValue("createdAt")).toRelative()}</div>,},{id: "actions",diff --git a/client/src/app/admin/page.tsx b/client/src/app/admin/page.tsxindex c081c56a5..1838390cd 100644--- a/client/src/app/admin/page.tsx+++ b/client/src/app/admin/page.tsx@@ -56,9 +56,10 @@ export default function AdminPage() {<div className="mb-2"><MobileSidebar /></div>- <AdminLayout title="Admin Dashboard">+ <AdminLayout>+ <div className="text-2xl font-bold mb-4">Admin Dashboard</div><Tabs defaultValue="organizations" value={activeTab} onValueChange={setActiveTab}>- <TabsList className="mb-4">+ <TabsList className=""><TabsTrigger value="organizations">Organizations</TabsTrigger><TabsTrigger value="sites">Sites</TabsTrigger><TabsTrigger value="users">Users</TabsTrigger>diff --git a/server/package-lock.json b/server/package-lock.jsonindex 9bca2ae21..e2cba53aa 100644--- a/server/package-lock.json+++ b/server/package-lock.json@@ -1,12 +1,12 @@{"name": "rybbit-backend",- "version": "1.6.1",+ "version": "2.1.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "rybbit-backend",- "version": "1.6.1",+ "version": "2.1.0","dependencies": {"@aws-sdk/client-s3": "^3.842.0","@axiomhq/pino": "^1.3.1",