feat: active PB indicator, Maak actief button and new product link in settings

This commit is contained in:
Janpeter Visser 2026-04-27 19:36:25 +02:00
parent 89c6896f5a
commit 7887c2c24f
3 changed files with 79 additions and 37 deletions

View file

@ -8,9 +8,12 @@ import { setActiveProductAction } from '@/actions/active-product'
interface Props {
productId: string
isDemo: boolean
/** Navigate here after activation. Omit to refresh the current page in place. */
redirectTo?: string
label?: string
}
export function ActivateProductButton({ productId, isDemo }: Props) {
export function ActivateProductButton({ productId, isDemo, redirectTo, label = 'Activeer' }: Props) {
const router = useRouter()
const [isPending, startTransition] = useTransition()
@ -19,7 +22,8 @@ export function ActivateProductButton({ productId, isDemo }: Props) {
startTransition(async () => {
const result = await setActiveProductAction(productId)
if (result?.error) toast.error(typeof result.error === 'string' ? result.error : 'Activeren mislukt')
else router.push(`/products/${productId}`)
else if (redirectTo) router.push(redirectTo)
else router.refresh()
})
}
@ -29,7 +33,7 @@ export function ActivateProductButton({ productId, isDemo }: Props) {
disabled={isPending}
className="text-xs text-primary hover:underline font-medium disabled:opacity-50"
>
Activeer
{label}
</button>
)
}