first commit

This commit is contained in:
Nermin Karic
2026-11-22 21:49:17 +01:00
commit f5e2fcbf98
693 changed files with 82975 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
"use client"
import { useState } from "react"
import { deleteLineItem } from "@lib/data/cart"
import { notifyCartUpdated } from "@lib/util/cart-events"
import { cn } from "@/lib/utils"
import { Trash2, Loader2 } from "lucide-react"
const DeleteButton = ({
id,
children,
className,
}: {
id: string
children?: React.ReactNode
className?: string
}) => {
const [isDeleting, setIsDeleting] = useState(false)
const handleDelete = async (id: string) => {
setIsDeleting(true)
await deleteLineItem(id)
.then(notifyCartUpdated)
.catch((_err) => {
setIsDeleting(false)
})
}
return (
<div className={cn("flex items-center", className)}>
<button
type="button"
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-destructive transition-colors disabled:opacity-50"
onClick={() => handleDelete(id)}
disabled={isDeleting}
aria-label="Ukloni artikal"
>
{isDeleting ? (
<Loader2 className="h-3.5 w-3.5 animate-spin" />
) : (
<Trash2 className="h-3.5 w-3.5" />
)}
{children && <span>{children}</span>}
</button>
</div>
)
}
export default DeleteButton