'use client' import { useAuth } from '@/lib/auth/context' import { useEffect, useState } from 'react' import { useParams, useRouter } from 'next/navigation' import { listFunnels, deleteFunnel, type Funnel } from '@/lib/api/funnels' import { toast, LoadingOverlay, Card } from '@ciphera-net/ui' import Link from 'next/link' import { LuPlus as PlusIcon, LuTrash as TrashIcon, LuArrowRight as ArrowRightIcon, LuChevronLeft as ChevronLeftIcon } from 'react-icons/lu' export default function FunnelsPage() { const { user } = useAuth() const params = useParams() const router = useRouter() const siteId = params.id as string const [funnels, setFunnels] = useState([]) const [loading, setLoading] = useState(true) useEffect(() => { loadFunnels() }, [siteId]) const loadFunnels = async () => { try { setLoading(true) const data = await listFunnels(siteId) setFunnels(data) } catch (error) { toast.error('Failed to load funnels') } finally { setLoading(false) } } const handleDelete = async (e: React.MouseEvent, funnelId: string) => { e.preventDefault() // Prevent navigation if (!confirm('Are you sure you want to delete this funnel?')) return try { await deleteFunnel(siteId, funnelId) toast.success('Funnel deleted') loadFunnels() } catch (error) { toast.error('Failed to delete funnel') } } if (loading) { return } return (

Funnels

Track user journeys and identify drop-off points

Create Funnel
{funnels.length === 0 ? (

No funnels yet

Create a funnel to track how users move through your site and where they drop off.

Create Funnel
) : (
{funnels.map((funnel) => (

{funnel.name}

{funnel.description && (

{funnel.description}

)}
{funnel.steps.map((step, i) => (
{step.name} {i < funnel.steps.length - 1 && ( )}
))}
))}
)}
) }