feat(dashboard,nav): edit-knop op productlijst + zichtbare product-switch
- nav-bar: vervang `router.push(/products/{id})` door `router.refresh()` na
setActiveProductAction; voeg success-toast toe. Maakt de actieve-product
switch zichtbaar zonder context-switch naar de detail-page; client-cache
wordt nu correct geinvalideerd.
- product-list (dashboard): integreer EditProductButton naast Activeer/Actief.
Owner én members kunnen editten (per productAccessFilter); demo-modus
rendert disabled+tooltip.
- edit-product-button: optionele isDemo + size + variant props; wraps
DemoTooltip; e.stopPropagation om card-click te voorkomen.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
e390e7cdef
commit
7716b379e5
3 changed files with 40 additions and 19 deletions
|
|
@ -10,6 +10,7 @@ import { CodeBadge } from '@/components/shared/code-badge'
|
||||||
import { DemoTooltip } from '@/components/shared/demo-tooltip'
|
import { DemoTooltip } from '@/components/shared/demo-tooltip'
|
||||||
import { restoreProductAction } from '@/actions/products'
|
import { restoreProductAction } from '@/actions/products'
|
||||||
import { setActiveProductAction } from '@/actions/active-product'
|
import { setActiveProductAction } from '@/actions/active-product'
|
||||||
|
import { EditProductButton } from '@/components/products/edit-product-button'
|
||||||
|
|
||||||
interface Product {
|
interface Product {
|
||||||
id: string
|
id: string
|
||||||
|
|
@ -17,6 +18,8 @@ interface Product {
|
||||||
code: string | null
|
code: string | null
|
||||||
description: string | null
|
description: string | null
|
||||||
repo_url: string | null
|
repo_url: string | null
|
||||||
|
definition_of_done: string | null
|
||||||
|
auto_pr: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProductListProps {
|
interface ProductListProps {
|
||||||
|
|
@ -100,19 +103,23 @@ export function ProductList({ products, isDemo, showArchived = false, activeProd
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
{!showArchived && (
|
{!showArchived && (
|
||||||
product.id === activeProductId
|
<>
|
||||||
? <Badge className="bg-primary-container text-primary-container-foreground text-xs px-2 py-0">Actief</Badge>
|
<EditProductButton product={product} isDemo={isDemo} />
|
||||||
: (
|
{product.id === activeProductId
|
||||||
<DemoTooltip show={isDemo}>
|
? <Badge className="bg-primary-container text-primary-container-foreground text-xs px-2 py-0">Actief</Badge>
|
||||||
<button
|
: (
|
||||||
onClick={(e) => { e.stopPropagation(); if (!isDemo) handleActivate(product.id) }}
|
<DemoTooltip show={isDemo}>
|
||||||
className="text-xs text-primary hover:underline disabled:opacity-40 disabled:cursor-not-allowed disabled:no-underline"
|
<button
|
||||||
disabled={isDemo}
|
onClick={(e) => { e.stopPropagation(); if (!isDemo) handleActivate(product.id) }}
|
||||||
>
|
className="text-xs text-primary hover:underline disabled:opacity-40 disabled:cursor-not-allowed disabled:no-underline"
|
||||||
Activeer
|
disabled={isDemo}
|
||||||
</button>
|
>
|
||||||
</DemoTooltip>
|
Activeer
|
||||||
)
|
</button>
|
||||||
|
</DemoTooltip>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
</>
|
||||||
)}
|
)}
|
||||||
{showArchived && (
|
{showArchived && (
|
||||||
<DemoTooltip show={isDemo}>
|
<DemoTooltip show={isDemo}>
|
||||||
|
|
|
||||||
|
|
@ -2,25 +2,37 @@
|
||||||
|
|
||||||
import { useState } from 'react'
|
import { useState } from 'react'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { DemoTooltip } from '@/components/shared/demo-tooltip'
|
||||||
import { ProductDialog, type ProductDialogProduct } from '@/components/dialogs/product-dialog'
|
import { ProductDialog, type ProductDialogProduct } from '@/components/dialogs/product-dialog'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
product: ProductDialogProduct
|
product: ProductDialogProduct
|
||||||
|
isDemo?: boolean
|
||||||
|
size?: 'sm' | 'default'
|
||||||
|
variant?: 'outline' | 'ghost'
|
||||||
}
|
}
|
||||||
|
|
||||||
export function EditProductButton({ product }: Props) {
|
export function EditProductButton({ product, isDemo = false, size = 'sm', variant = 'outline' }: Props) {
|
||||||
const [open, setOpen] = useState(false)
|
const [open, setOpen] = useState(false)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Button variant="outline" size="sm" onClick={() => setOpen(true)}>
|
<DemoTooltip show={isDemo}>
|
||||||
Bewerken
|
<Button
|
||||||
</Button>
|
variant={variant}
|
||||||
|
size={size}
|
||||||
|
onClick={(e) => { e.stopPropagation(); if (!isDemo) setOpen(true) }}
|
||||||
|
disabled={isDemo}
|
||||||
|
>
|
||||||
|
Bewerken
|
||||||
|
</Button>
|
||||||
|
</DemoTooltip>
|
||||||
<ProductDialog
|
<ProductDialog
|
||||||
mode="edit"
|
mode="edit"
|
||||||
open={open}
|
open={open}
|
||||||
onOpenChange={setOpen}
|
onOpenChange={setOpen}
|
||||||
product={product}
|
product={product}
|
||||||
|
isDemo={isDemo}
|
||||||
/>
|
/>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -51,9 +51,11 @@ export function NavBar({
|
||||||
const result = await setActiveProductAction(productId)
|
const result = await setActiveProductAction(productId)
|
||||||
if (result?.error) {
|
if (result?.error) {
|
||||||
toast.error(typeof result.error === 'string' ? result.error : 'Wisselen mislukt')
|
toast.error(typeof result.error === 'string' ? result.error : 'Wisselen mislukt')
|
||||||
} else {
|
return
|
||||||
router.push(`/products/${productId}`)
|
|
||||||
}
|
}
|
||||||
|
const next = products.find(p => p.id === productId)
|
||||||
|
toast.success(`Actief product: ${next?.name ?? 'gewijzigd'}`)
|
||||||
|
router.refresh()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue