'use client'
import { useState } from 'react'
import { toggleItem } from '@/lib/actions'
import { CheckCircle2, Circle } from 'lucide-react'
interface ToggleItemButtonProps {
itemId: string
completed: boolean
variant?: 'full' | 'icon'
}
export default function ToggleItemButton({ itemId, completed, variant = 'full' }: ToggleItemButtonProps) {
const [isToggling, setIsToggling] = useState(false)
const handleToggle = async (e: React.MouseEvent) => {
e.preventDefault()
e.stopPropagation()
setIsToggling(true)
try {
await toggleItem(itemId)
} catch (error) {
console.error('Error toggling item:', error)
} finally {
setIsToggling(false)
}
}
if (variant === 'icon') {
return (
)
}
return (
)
}