Use TextLink

This commit is contained in:
Krzysztof Wolski 2023-05-24 16:04:40 +02:00
parent 767d7fb4d3
commit f0a62fe580
2 changed files with 2 additions and 37 deletions

View file

@ -1,35 +0,0 @@
import { actions, useAppBridge } from "@saleor/app-sdk/app-bridge";
import { TextProps, Text } from "@saleor/macaw-ui/next";
import Link from "next/link";
interface TextLinkProps extends TextProps {
href: string;
openNewTab?: boolean;
}
export const TextLink = ({ href, openNewTab, children, props }: TextLinkProps) => {
const { appBridge } = useAppBridge();
const onClick = (event: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
event.preventDefault();
appBridge?.dispatch(
actions.Redirect({
to: href,
newContext: true,
})
);
};
return (
<Text textDecoration="underline" variant="bodyStrong" {...props}>
{openNewTab ? (
<a href={href} target="_blank" rel="noopener noreferrer" onClick={onClick}>
{children}
</a>
) : (
<Link href={href}>{children}</Link>
)}
</Text>
);
};

View file

@ -8,7 +8,7 @@ import { parseMessageEventType } from "../../../../../modules/event-handlers/par
import { appUrls } from "../../../../../modules/app-configuration/urls"; import { appUrls } from "../../../../../modules/app-configuration/urls";
import { EventForm } from "../../../../../modules/smtp/ui/event-form"; import { EventForm } from "../../../../../modules/smtp/ui/event-form";
import { smtpUrls } from "../../../../../modules/smtp/urls"; import { smtpUrls } from "../../../../../modules/smtp/urls";
import { TextLink } from "../../../../../components/text-link"; import { TextLink } from "@saleor/apps-ui";
const LoadingView = () => { const LoadingView = () => {
return ( return (
@ -84,7 +84,7 @@ const EditSmtpEventPage: NextPage = () => {
<Box display="flex" flexDirection="column" gap={13}> <Box display="flex" flexDirection="column" gap={13}>
<Text as="p"> <Text as="p">
Edit template for {eventType} event. You can learn more about MJML{" "} Edit template for {eventType} event. You can learn more about MJML{" "}
<TextLink href="https://mjml.io/" openNewTab={true}> <TextLink href="https://mjml.io/" newTab={true}>
here here
</TextLink> </TextLink>
. .