2022-10-27 13:34:45 +00:00
|
|
|
import React from "react";
|
2023-08-23 12:56:32 +00:00
|
|
|
import { browserHistory, Link } from "react-router";
|
|
|
|
|
|
2022-10-27 13:34:45 +00:00
|
|
|
import Icon from "components/Icon";
|
|
|
|
|
import classnames from "classnames";
|
|
|
|
|
|
|
|
|
|
interface IBackLinkProps {
|
|
|
|
|
text: string;
|
|
|
|
|
path?: string;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const baseClass = "back-link";
|
|
|
|
|
|
|
|
|
|
const BackLink = ({ text, path, className }: IBackLinkProps): JSX.Element => {
|
|
|
|
|
const onClick = (): void => {
|
|
|
|
|
if (path) {
|
|
|
|
|
browserHistory.push(path);
|
|
|
|
|
} else browserHistory.goBack();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2023-12-09 00:54:24 +00:00
|
|
|
<Link
|
|
|
|
|
className={classnames(baseClass, className)}
|
|
|
|
|
to={path || ""}
|
|
|
|
|
onClick={onClick}
|
|
|
|
|
>
|
2022-10-27 13:34:45 +00:00
|
|
|
<>
|
2023-12-09 00:54:24 +00:00
|
|
|
<Icon name="chevron-left" color="core-fleet-blue" />
|
2022-11-01 16:51:05 +00:00
|
|
|
<span>{text}</span>
|
2022-10-27 13:34:45 +00:00
|
|
|
</>
|
2023-08-23 12:56:32 +00:00
|
|
|
</Link>
|
2022-10-27 13:34:45 +00:00
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
export default BackLink;
|