saleor-dashboard/src/components/Button/Button.tsx
Jonatan Witoszek 1e38c14116
Use links instead of onClick navigate function (#1969)
Add links instead of navigate + onClick in:
* Lists - ex. product list (except Plugins, see below)
* SortableTables - ex. product variants
* Sidebar
* Buttons that open new page - ex. "Create product"
* Backlinks
* Menus - ex. "Account Settings"
* Links that actually used onClick - ex. warehouse shipping zone, reset password
2022-05-06 10:59:55 +02:00

16 lines
637 B
TypeScript

import { OverridableComponent } from "@material-ui/core/OverridableComponent";
import { Button as MacawButton, ButtonTypeMap } from "@saleor/macaw-ui";
import { isExternalURL } from "@saleor/utils/urls";
import React from "react";
import { Link } from "react-router-dom";
const _Button: React.FC<any> = React.forwardRef(({ href, ...props }, ref) => {
if (href && !isExternalURL(href)) {
return <MacawButton {...props} to={href} component={Link} ref={ref} />;
}
return <MacawButton href={href} {...props} ref={ref} />;
});
_Button.displayName = "Button";
export const Button = _Button as OverridableComponent<ButtonTypeMap>;