Skip to content

Commit

Permalink
Fix alert issue in order creation (#5136)
Browse files Browse the repository at this point in the history
* fix alert type issue

* improve alert text

* changesets
  • Loading branch information
Cloud11PL committed Sep 4, 2024
1 parent 330012e commit 331af39
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/gold-spies-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"saleor-dashboard": patch
---

You can now see draft order alert messages when channel is inactive or has no products
8 changes: 6 additions & 2 deletions src/orders/components/OrderAlerts/OrderAlerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,19 @@ export const OrderAlerts: React.FC<OrderAlertsProps> = ({ alertsHeader, alerts,

if (formattedAlerts.length === 1) {
return (
<Text size={2} fontWeight="bold">
<Text size={3} fontWeight="bold">
{formattedAlerts[0].text}
</Text>
);
}

return (
<>
{!!alertsHeader && alertsHeader}
{!!alertsHeader && (
<Text size={4} fontWeight="bold">
{alertsHeader}
</Text>
)}
<ul>
{formattedAlerts.map(alert => (
<li key={alert.id}>{alert.text}</li>
Expand Down
5 changes: 2 additions & 3 deletions src/orders/components/OrderDraftPage/OrderDraftAlert.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-strict-ignore
import { ChannelUsabilityDataQuery, OrderDetailsFragment } from "@dashboard/graphql";
import { Alert, AlertProps } from "@saleor/macaw-ui";
import { Box } from "@saleor/macaw-ui-next";
Expand All @@ -17,7 +16,7 @@ const getAlerts = (
const canDetermineShippingMethods =
order?.shippingAddress?.country.code && !!order?.lines?.length;
const isChannelInactive = order && !order.channel.isActive;
const noProductsInChannel = channelUsabilityData?.products.totalCount === 0;
const noProductsInChannel = channelUsabilityData?.products?.totalCount === 0;
const noShippingMethodsInChannel =
canDetermineShippingMethods && order?.shippingMethods.length === 0;

Expand Down Expand Up @@ -64,7 +63,7 @@ const OrderDraftAlert: React.FC<OrderDraftAlertProps> = props => {
alerts={alerts}
alertsHeader={intl.formatMessage(alertMessages.manyAlerts)}
values={{
country: order.shippingAddress.country.country,
country: order?.shippingAddress?.country.country,
configLink: (
<Box as="a" textDecoration="underline" href="/shipping" color="accent1" target="_blank">
<FormattedMessage
Expand Down
5 changes: 1 addition & 4 deletions src/orders/components/OrderDraftPage/OrderDraftPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,7 @@ const OrderDraftPage: React.FC<OrderDraftPageProps> = props => {
/>
</TopNav>
<DetailPageLayout.Content>
<OrderDraftAlert
order={order as OrderDetailsFragment}
channelUsabilityData={channelUsabilityData}
/>
<OrderDraftAlert order={order} channelUsabilityData={channelUsabilityData} />
<OrderDraftDetails
order={order as OrderDetailsFragment}
channelUsabilityData={channelUsabilityData}
Expand Down

0 comments on commit 331af39

Please sign in to comment.