'use client' import { useParams, useRouter } from 'next/navigation' import { deleteFunnel, type Funnel } from '@/lib/api/funnels' import { useFunnels } from '@/lib/swr/dashboard' import { toast, PlusIcon, ArrowRightIcon, ChevronLeftIcon, TrashIcon, Button } from '@ciphera-net/ui' import { FunnelsListSkeleton, useMinimumLoading, useSkeletonFade } from '@/components/skeletons' import Link from 'next/link' import Image from 'next/image' export default function FunnelsPage() { const params = useParams() const router = useRouter() const siteId = params.id as string const { data: funnels = [], isLoading, mutate } = useFunnels(siteId) 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') mutate() } catch (error) { toast.error('Failed to delete funnel') } } const showSkeleton = useMinimumLoading(isLoading && !funnels.length) const fadeClass = useSkeletonFade(showSkeleton) if (showSkeleton) { return } return (

Funnels

Track user journeys and identify drop-off points

{funnels.length === 0 ? (
Create your first funnel

No funnels yet

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

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

{funnel.name}

{funnel.description && (

{funnel.description}

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