Merge pull request #71 from madhura68/feat/dashboard-edit-and-switch-fix
feat: navbar product-switch zichtbaar + edit-knop op dashboard
This commit is contained in:
commit
bf753af1cd
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,7 +103,9 @@ export function ProductList({ products, isDemo, showArchived = false, activeProd
|
||||||
</a>
|
</a>
|
||||||
)}
|
)}
|
||||||
{!showArchived && (
|
{!showArchived && (
|
||||||
product.id === activeProductId
|
<>
|
||||||
|
<EditProductButton product={product} isDemo={isDemo} />
|
||||||
|
{product.id === activeProductId
|
||||||
? <Badge className="bg-primary-container text-primary-container-foreground text-xs px-2 py-0">Actief</Badge>
|
? <Badge className="bg-primary-container text-primary-container-foreground text-xs px-2 py-0">Actief</Badge>
|
||||||
: (
|
: (
|
||||||
<DemoTooltip show={isDemo}>
|
<DemoTooltip show={isDemo}>
|
||||||
|
|
@ -113,6 +118,8 @@ export function ProductList({ products, isDemo, showArchived = false, activeProd
|
||||||
</button>
|
</button>
|
||||||
</DemoTooltip>
|
</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}>
|
||||||
|
<Button
|
||||||
|
variant={variant}
|
||||||
|
size={size}
|
||||||
|
onClick={(e) => { e.stopPropagation(); if (!isDemo) setOpen(true) }}
|
||||||
|
disabled={isDemo}
|
||||||
|
>
|
||||||
Bewerken
|
Bewerken
|
||||||
</Button>
|
</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