'use client' import { useEffect, useState } from 'react' import Link from 'next/link' import { useAuth } from '@/lib/auth/context' import { initiateOAuthFlow, initiateSignupFlow } from '@/lib/api/oauth' import { listSites, deleteSite, type Site } from '@/lib/api/sites' import { LoadingOverlay } from '@ciphera-net/ui' import SiteList from '@/components/sites/SiteList' import { Button } from '@ciphera-net/ui' import { BarChartIcon, LockIcon, ZapIcon } from '@ciphera-net/ui' import { toast } from '@ciphera-net/ui' export default function HomePage() { const { user, loading: authLoading } = useAuth() const [sites, setSites] = useState([]) const [sitesLoading, setSitesLoading] = useState(true) useEffect(() => { if (user) { loadSites() } }, [user]) const loadSites = async () => { try { setSitesLoading(true) const data = await listSites() setSites(Array.isArray(data) ? data : []) } catch (error: any) { toast.error('Failed to load sites: ' + (error.message || 'Unknown error')) setSites([]) } finally { setSitesLoading(false) } } const handleDelete = async (id: string) => { if (!confirm('Are you sure you want to delete this site? This action cannot be undone.')) { return } try { await deleteSite(id) toast.success('Site deleted successfully') loadSites() } catch (error: any) { toast.error('Failed to delete site: ' + (error.message || 'Unknown error')) } } if (authLoading) { return } if (!user) { return (
{/* Hero Section */}
Privacy-First Pulse

Simple analytics for
privacy-conscious apps.

Respect your users' privacy while getting the insights you need. No cookies, no IP tracking, fully GDPR compliant.

{/* Features Grid */}

Privacy First

We don't track personal data. No IP addresses, no fingerprints, no cookies.

Simple Insights

Get the metrics that matter without the clutter. Page views, visitors, and sources.

Lightweight

Our script is less than 1kb. It won't slow down your site or affect your SEO.

) } // * Wait for organization context before rendering SiteList to avoid "Organization Required" flash if (user && !user.org_id) { return } return (

Your Sites

Manage your analytics sites and view insights.

Add New Site
{/* Global Overview */}

Total Sites

{sites.length}

Total Visitors (24h)

--

Plan Status

Pro Plan

) }