'use client'

import { useState } from 'react'
import { useRouter } from 'next/navigation'
import { Button } from '@/components/ui/button'
import { ProductDialog } from '@/components/dialogs/product-dialog'

export function NewProductButton() {
  const [open, setOpen] = useState(false)
  const router = useRouter()

  return (
    <>
      <Button onClick={() => setOpen(true)}>+ Nieuw product</Button>
      <ProductDialog
        mode="create"
        open={open}
        onOpenChange={setOpen}
        onSaved={(id) => router.push(`/products/${id}`)}
      />
    </>
  )
}
