Skip to content

Commit

Permalink
Fix link in shipping destination alert box (#5148)
Browse files Browse the repository at this point in the history
* fix shipping alert box link

* fix url

* fix link

* remove urljoin

* fix test

---------

Co-authored-by: Patryk Andrzejewski <vox3r69@gmail.com>
  • Loading branch information
Cloud11PL and andrzejewsky committed Sep 12, 2024
1 parent 73387c1 commit 55d5a5f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/olive-spies-camp.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

Shipping destination alert when creating a new order now has a correct link to shipping settings.
4 changes: 4 additions & 0 deletions src/orders/components/OrderDraftPage/OrderDraftAlert.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import * as React from "react";

import OrderDraftAlert, { OrderDraftAlertProps } from "./OrderDraftAlert";

jest.mock("react-router-dom", () => ({
Link: jest.fn(({ to, ...props }) => <a href={to} {...props} />),
}));

describe("OrderDraftAlert", () => {
const alertProps: OrderDraftAlertProps = {
order: order("--url--"),
Expand Down
15 changes: 12 additions & 3 deletions src/orders/components/OrderDraftPage/OrderDraftAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ChannelUsabilityDataQuery, OrderDetailsFragment } from "@dashboard/graphql";
import { shippingZonesListPath } from "@dashboard/shipping/urls";
import { Alert, AlertProps } from "@saleor/macaw-ui";
import { Box } from "@saleor/macaw-ui-next";
import { sprinkles } from "@saleor/macaw-ui-next";
import clsx from "clsx";
import React from "react";
import { FormattedMessage, MessageDescriptor, useIntl } from "react-intl";
import { Link } from "react-router-dom";

import OrderAlerts from "../OrderAlerts";
import { alertMessages } from "./messages";
Expand Down Expand Up @@ -65,13 +67,20 @@ const OrderDraftAlert: React.FC<OrderDraftAlertProps> = props => {
values={{
country: order?.shippingAddress?.country.country,
configLink: (
<Box as="a" textDecoration="underline" href="/shipping" color="accent1" target="_blank">
<Link
to={shippingZonesListPath}
target="_blank"
className={sprinkles({
textDecoration: "underline",
color: "accent1",
})}
>
<FormattedMessage
defaultMessage="shipping zones configuration"
id="T3cLGs"
description="alert link message"
/>
</Box>
</Link>
),
}}
/>
Expand Down

0 comments on commit 55d5a5f

Please # to comment.