Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add pricing to shipping method choice dialog

dominik-zeglen9aa37603df4a
diff --git a/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx b/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx
index 850dcd89e5..ef951771a4 100644
--- a/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx
+++ b/saleor/static/dashboard-next/components/SingleSelectField/SingleSelectField.tsx
@@ -17,7 +17,7 @@ const decorate = withStyles({
interface SingleSelectFieldProps {
choices: Array<{
value: string;
- label: string;
+ label: string | React.ReactNode;
}>;
disabled?: boolean;
error?: boolean;
diff --git a/saleor/static/dashboard-next/orders/components/OrderDraftPage/OrderDraftPage.tsx b/saleor/static/dashboard-next/orders/components/OrderDraftPage/OrderDraftPage.tsx
index ae1a359833..597478d81b 100644
--- a/saleor/static/dashboard-next/orders/components/OrderDraftPage/OrderDraftPage.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderDraftPage/OrderDraftPage.tsx
@@ -34,10 +34,6 @@ import OrderShippingMethodEditDialog, {
export interface OrderDraftPageProps {
disabled: boolean;
order: OrderDetails_order;
- shippingMethods: Array<{
- id: string;
- name: string;
- }>;
users: UserSearch_customers_edges_node[];
usersLoading: boolean;
countries: Array<{
@@ -141,7 +137,6 @@ class OrderDraftPageComponent extends React.Component<
disabled,
errors,
order,
- shippingMethods,
users,
usersLoading,
variants,
@@ -212,7 +207,7 @@ class OrderDraftPageComponent extends React.Component<
<OrderShippingMethodEditDialog
open={openedShippingMethodEditDialog}
shippingMethod={maybe(() => order.shippingMethod.id, "")}
- shippingMethods={shippingMethods}
+ shippingMethods={maybe(() => order.availableShippingMethods)}
onClose={this.toggleShippingMethodEditDialog}
onSubmit={onShippingMethodEdit}
/>
diff --git a/saleor/static/dashboard-next/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx b/saleor/static/dashboard-next/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx
index bcd6bbda91..f47fae1fb0 100644
--- a/saleor/static/dashboard-next/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderShippingMethodEditDialog/OrderShippingMethodEditDialog.tsx
@@ -7,8 +7,10 @@ import { withStyles } from "@material-ui/core/styles";
import * as React from "react";
import Form from "../../../components/Form";
+import Money from "../../../components/Money";
import { SingleSelectField } from "../../../components/SingleSelectField";
import i18n from "../../../i18n";
+import { OrderDetails_order_availableShippingMethods } from "../../types/OrderDetails";
export interface FormData {
shippingMethod: string;
@@ -17,10 +19,7 @@ export interface FormData {
interface OrderShippingMethodEditDialogProps {
open: boolean;
shippingMethod: string;
- shippingMethods?: Array<{
- id: string;
- name: string;
- }>;
+ shippingMethods?: OrderDetails_order_availableShippingMethods[];
onClose();
onSubmit?(data: FormData);
}
@@ -30,16 +29,18 @@ const decorate = withStyles(
dialog: {
overflowY: "visible" as "visible"
},
+ menuItem: {
+ display: "flex" as "flex",
+ width: "100%"
+ },
root: {
overflowY: "visible" as "visible",
width: theme.breakpoints.values.sm
},
- select: {
+ shippingMethodName: {
flex: 1,
- marginRight: theme.spacing.unit * 2
- },
- textRight: {
- textAlign: "right" as "right"
+ overflowX: "hidden" as "hidden",
+ textOverflow: "ellipsis" as "ellipsis"
}
}),
{ name: "OrderShippingMethodEditDialog" }
@@ -49,7 +50,15 @@ const OrderShippingMethodEditDialog = decorate<
>(({ classes, open, shippingMethod, shippingMethods, onClose, onSubmit }) => {
const choices = shippingMethods
? shippingMethods.map(s => ({
- label: s.name,
+ label: (
+ <div className={classes.menuItem}>
+ <span className={classes.shippingMethodName}>{s.name}</span>
+ &nbsp;
+ <span>
+ <Money {...s.price} />
+ </span>
+ </div>
+ ),
value: s.id
}))
: [];
diff --git a/saleor/static/dashboard-next/orders/queries.ts b/saleor/static/dashboard-next/orders/queries.ts
index 4ea3f5c394..6d41692a83 100644
--- a/saleor/static/dashboard-next/orders/queries.ts
+++ b/saleor/static/dashboard-next/orders/queries.ts
@@ -146,6 +146,10 @@ export const fragmentOrderDetails = gql`
availableShippingMethods {
id
name
+ price {
+ amount
+ currency
+ }
}
}
`;
diff --git a/saleor/static/dashboard-next/orders/types/OrderCancel.ts b/saleor/static/dashboard-next/orders/types/OrderCancel.ts
index 14c6131b0a..cc67f2b9be 100644
--- a/saleor/static/dashboard-next/orders/types/OrderCancel.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderCancel.ts
@@ -216,10 +216,17 @@ export interface OrderCancel_orderCancel_order_user {
email: string;
}
+export interface OrderCancel_orderCancel_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderCancel_orderCancel_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderCancel_orderCancel_order_availableShippingMethods_price | null;
}
export interface OrderCancel_orderCancel_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderCapture.ts b/saleor/static/dashboard-next/orders/types/OrderCapture.ts
index 3bfdbe934a..75dd96d82f 100644
--- a/saleor/static/dashboard-next/orders/types/OrderCapture.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderCapture.ts
@@ -222,10 +222,17 @@ export interface OrderCapture_orderCapture_order_user {
email: string;
}
+export interface OrderCapture_orderCapture_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderCapture_orderCapture_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderCapture_orderCapture_order_availableShippingMethods_price | null;
}
export interface OrderCapture_orderCapture_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts b/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts
index f9af2deb67..a8e5ce3f28 100644
--- a/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts
@@ -222,10 +222,17 @@ export interface OrderCreateFulfillment_orderFulfillmentCreate_order_user {
email: string;
}
+export interface OrderCreateFulfillment_orderFulfillmentCreate_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderCreateFulfillment_orderFulfillmentCreate_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderCreateFulfillment_orderFulfillmentCreate_order_availableShippingMethods_price | null;
}
export interface OrderCreateFulfillment_orderFulfillmentCreate_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderDetails.ts b/saleor/static/dashboard-next/orders/types/OrderDetails.ts
index 4df8ccbedc..8d78a2372f 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDetails.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDetails.ts
@@ -216,10 +216,17 @@ export interface OrderDetails_order_user {
email: string;
}
+export interface OrderDetails_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderDetails_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderDetails_order_availableShippingMethods_price | null;
}
export interface OrderDetails_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts b/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts
index 044d7cd55f..25c40b0025 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts
@@ -216,10 +216,17 @@ export interface OrderDetailsFragment_user {
email: string;
}
+export interface OrderDetailsFragment_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderDetailsFragment_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderDetailsFragment_availableShippingMethods_price | null;
}
export interface OrderDetailsFragment {
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts b/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts
index 78f4ea247f..822d8b1013 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts
@@ -216,10 +216,17 @@ export interface OrderDraftCancel_draftOrderDelete_order_user {
email: string;
}
+export interface OrderDraftCancel_draftOrderDelete_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderDraftCancel_draftOrderDelete_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderDraftCancel_draftOrderDelete_order_availableShippingMethods_price | null;
}
export interface OrderDraftCancel_draftOrderDelete_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts b/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts
index 01fee6340c..0923143d6a 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts
@@ -222,10 +222,17 @@ export interface OrderDraftFinalize_draftOrderComplete_order_user {
email: string;
}
+export interface OrderDraftFinalize_draftOrderComplete_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderDraftFinalize_draftOrderComplete_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderDraftFinalize_draftOrderComplete_order_availableShippingMethods_price | null;
}
export interface OrderDraftFinalize_draftOrderComplete_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts b/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts
index 09900fc2f0..3225e3441b 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts
@@ -222,10 +222,17 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_user {
email: string;
}
+export interface OrderDraftUpdate_draftOrderUpdate_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderDraftUpdate_draftOrderUpdate_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderDraftUpdate_draftOrderUpdate_order_availableShippingMethods_price | null;
}
export interface OrderDraftUpdate_draftOrderUpdate_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts b/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts
index df5b8c0f1f..37e1d5defd 100644
--- a/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts
@@ -222,10 +222,17 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_user {
email: string;
}
+export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderFulfillmentCancel_orderFulfillmentCancel_order_availableShippingMethods_price | null;
}
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts b/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts
index 72e0a4d196..fdb0add049 100644
--- a/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts
@@ -222,10 +222,17 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
email: string;
}
+export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_availableShippingMethods_price | null;
}
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderLineAdd.ts b/saleor/static/dashboard-next/orders/types/OrderLineAdd.ts
index f1b1149aa9..db0a26c4eb 100644
--- a/saleor/static/dashboard-next/orders/types/OrderLineAdd.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderLineAdd.ts
@@ -222,10 +222,17 @@ export interface OrderLineAdd_draftOrderLineCreate_order_user {
email: string;
}
+export interface OrderLineAdd_draftOrderLineCreate_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderLineAdd_draftOrderLineCreate_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderLineAdd_draftOrderLineCreate_order_availableShippingMethods_price | null;
}
export interface OrderLineAdd_draftOrderLineCreate_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts b/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts
index f81c2bf847..750270e823 100644
--- a/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts
@@ -222,10 +222,17 @@ export interface OrderLineDelete_draftOrderLineDelete_order_user {
email: string;
}
+export interface OrderLineDelete_draftOrderLineDelete_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderLineDelete_draftOrderLineDelete_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderLineDelete_draftOrderLineDelete_order_availableShippingMethods_price | null;
}
export interface OrderLineDelete_draftOrderLineDelete_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts b/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts
index 27a79d6f8d..c1cb2b1019 100644
--- a/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts
@@ -222,10 +222,17 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_user {
email: string;
}
+export interface OrderLineUpdate_draftOrderLineUpdate_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderLineUpdate_draftOrderLineUpdate_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderLineUpdate_draftOrderLineUpdate_order_availableShippingMethods_price | null;
}
export interface OrderLineUpdate_draftOrderLineUpdate_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderRefund.ts b/saleor/static/dashboard-next/orders/types/OrderRefund.ts
index 4e3b2c56d8..08065691e0 100644
--- a/saleor/static/dashboard-next/orders/types/OrderRefund.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderRefund.ts
@@ -222,10 +222,17 @@ export interface OrderRefund_orderRefund_order_user {
email: string;
}
+export interface OrderRefund_orderRefund_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderRefund_orderRefund_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderRefund_orderRefund_order_availableShippingMethods_price | null;
}
export interface OrderRefund_orderRefund_order {
diff --git a/saleor/static/dashboard-next/orders/types/OrderRelease.ts b/saleor/static/dashboard-next/orders/types/OrderRelease.ts
index 4f7077f5e0..02152da2d3 100644
--- a/saleor/static/dashboard-next/orders/types/OrderRelease.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderRelease.ts
@@ -216,10 +216,17 @@ export interface OrderRelease_orderRelease_order_user {
email: string;
}
+export interface OrderRelease_orderRelease_order_availableShippingMethods_price {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
export interface OrderRelease_orderRelease_order_availableShippingMethods {
__typename: "ShippingMethod";
id: string;
name: string;
+ price: OrderRelease_orderRelease_order_availableShippingMethods_price | null;
}
export interface OrderRelease_orderRelease_order {
diff --git a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
index 7045bcf830..d93256a575 100644
--- a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
+++ b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx
@@ -534,10 +534,6 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({
code: country.code,
label: country.country
}))}
- shippingMethods={maybe(
- () => data.order.availableShippingMethods,
- []
- )}
onProductClick={id => () =>
navigate(productUrl(id))}
onBillingAddressEdit={variables =>