2022-09-21 04:49:42 +00:00
|
|
|
import { PropsWithChildren, AnchorHTMLAttributes } from 'react';
|
2024-04-08 14:21:41 +00:00
|
|
|
import { UISrefProps, useSref } from '@uirouter/react';
|
2021-11-03 10:41:59 +00:00
|
|
|
|
2021-12-14 19:14:53 +00:00
|
|
|
interface Props {
|
|
|
|
title?: string;
|
2022-09-21 04:49:42 +00:00
|
|
|
target?: AnchorHTMLAttributes<HTMLAnchorElement>['target'];
|
2023-05-31 05:58:41 +00:00
|
|
|
rel?: AnchorHTMLAttributes<HTMLAnchorElement>['rel'];
|
2024-04-11 00:11:38 +00:00
|
|
|
'data-cy': AnchorHTMLAttributes<HTMLAnchorElement>['data-cy'];
|
2021-12-14 19:14:53 +00:00
|
|
|
}
|
|
|
|
|
2021-11-03 10:41:59 +00:00
|
|
|
export function Link({
|
|
|
|
children,
|
2024-04-11 00:11:38 +00:00
|
|
|
'data-cy': dataCy,
|
2024-04-08 14:21:41 +00:00
|
|
|
to,
|
|
|
|
params,
|
|
|
|
options,
|
2021-11-03 10:41:59 +00:00
|
|
|
...props
|
2021-12-14 19:14:53 +00:00
|
|
|
}: PropsWithChildren<Props> & UISrefProps) {
|
2024-04-08 14:21:41 +00:00
|
|
|
const { onClick, href } = useSref(to, params, options);
|
|
|
|
|
2021-11-03 10:41:59 +00:00
|
|
|
return (
|
|
|
|
// eslint-disable-next-line react/jsx-props-no-spreading
|
2024-04-11 00:11:38 +00:00
|
|
|
<a onClick={onClick} href={href} data-cy={dataCy} {...props}>
|
2024-04-08 14:21:41 +00:00
|
|
|
{children}
|
|
|
|
</a>
|
2021-11-03 10:41:59 +00:00
|
|
|
);
|
|
|
|
}
|