* feat(PBI-ll): voeg lib/product-switch-path.ts toe met resolveProductSwitchTarget Pure helper die doel-URL bij product-wissel bepaalt; unit-tests dekken alle pad-gevallen. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(product-switch-path): dek alle pad-categorieën en null-terugval af * feat(nav-bar): gebruik resolveProductSwitchTarget bij product-wissel Vervang router.refresh() door gerichte navigatie via resolveProductSwitchTarget, zodat product/sprint/solo-pagina's direct naar het nieuwe product navigeren. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * test(nav-bar): voeg navigatie-assertions toe voor product-wissel Voeg 4 tests toe die verifiëren dat NavBar na product-wissel naar de juiste URL navigeert: /products/B, /products/B/sprint, /products/B/solo, en router.refresh() op niet-product-pagina's. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
14 lines
479 B
TypeScript
14 lines
479 B
TypeScript
export function resolveProductSwitchTarget(
|
|
pathname: string,
|
|
newProductId: string,
|
|
): string | null {
|
|
const match = pathname.match(/^\/products\/([^/]+)(\/.*)?$/)
|
|
if (!match) return null
|
|
|
|
const rest = match[2] ?? ''
|
|
|
|
if (!rest || rest === '/') return `/products/${newProductId}`
|
|
if (rest.startsWith('/sprint')) return `/products/${newProductId}/sprint`
|
|
if (rest.startsWith('/solo')) return `/products/${newProductId}/solo`
|
|
return `/products/${newProductId}`
|
|
}
|