'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
Track user journeys and identify drop-off points
Create a funnel to track how users move through your site and where they drop off.
{funnel.description}
)}