Scrum4Me/components/shared/alert-toast.tsx
Scrum4Me Agent f555cb547b refactor(PBI-49): migrate 17 shared/ components to debugProps helper
Replace hardcoded data-debug-id + data-debug-label attribute pairs with
{...debugProps(id, component, file)} spread in all 17 components/shared/
files. Existing debug-ids preserved unchanged.
2026-05-09 20:47:51 +02:00

29 lines
961 B
TypeScript

'use client'
import { useEffect } from 'react'
import { useSearchParams, useRouter, usePathname } from 'next/navigation'
import { toast } from 'sonner'
import { debugProps } from '@/lib/debug'
const ALERT_MESSAGES: Record<string, string> = {
product_unavailable: 'Je actieve product is niet meer beschikbaar',
}
export function AlertToast() {
const searchParams = useSearchParams()
const router = useRouter()
const pathname = usePathname()
const alert = searchParams.get('alert')
useEffect(() => {
if (!alert || !ALERT_MESSAGES[alert]) return
toast.error(ALERT_MESSAGES[alert])
const params = new URLSearchParams(searchParams.toString())
params.delete('alert')
const next = params.toString() ? `${pathname}?${params}` : pathname
router.replace(next)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [alert])
return <span {...debugProps('alert-toast', 'AlertToast', 'shared/alert-toast.tsx')} hidden />
}