SupportLink.tsx 681 B

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