SupportLink.tsx28 lines · main
| 1 | import Link from 'next/link' |
| 2 | import type { ComponentProps, PropsWithChildren } from 'react' |
| 3 | |
| 4 | import { createSupportFormUrl, type SupportFormUrlKeys } from './SupportForm.utils' |
| 5 | import { takeBreadcrumbSnapshot } from '@/lib/breadcrumbs' |
| 6 | |
| 7 | export const SupportLink = ({ |
| 8 | children, |
| 9 | queryParams, |
| 10 | ...props |
| 11 | }: PropsWithChildren< |
| 12 | { queryParams?: Partial<SupportFormUrlKeys> } & Omit<ComponentProps<typeof Link>, 'href'> |
| 13 | >) => { |
| 14 | const href = createSupportFormUrl(queryParams ?? {}) |
| 15 | |
| 16 | return ( |
| 17 | <Link |
| 18 | {...props} |
| 19 | href={href} |
| 20 | onClick={(event) => { |
| 21 | takeBreadcrumbSnapshot() |
| 22 | props.onClick?.(event) |
| 23 | }} |
| 24 | > |
| 25 | {children} |
| 26 | </Link> |
| 27 | ) |
| 28 | } |