mirror of
https://github.com/empayre/fleet.git
synced 2024-11-06 17:05:18 +00:00
27 lines
594 B
TypeScript
27 lines
594 B
TypeScript
import React, { useContext } from "react";
|
|
import { Link } from "react-router";
|
|
|
|
import { AppContext } from "context/app";
|
|
|
|
interface ILinkWithContextProps {
|
|
className: string;
|
|
children: React.ReactChild | React.ReactChild[];
|
|
to: string;
|
|
}
|
|
|
|
const LinkWithContext = ({
|
|
className,
|
|
children,
|
|
to,
|
|
}: ILinkWithContextProps): JSX.Element => {
|
|
const { currentTeam } = useContext(AppContext);
|
|
const url = currentTeam?.id ? `${to}?team_id=${currentTeam.id}` : to;
|
|
|
|
return (
|
|
<Link className={className} to={url}>
|
|
{children}
|
|
</Link>
|
|
);
|
|
};
|
|
export default LinkWithContext;
|