Skip to content

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

Update props

dominik-zeglen5ac21e3e8d82
diff --git a/saleor/static/dashboard-next/components/EditableTableCell/EditableTableCell.tsx b/saleor/static/dashboard-next/components/EditableTableCell/EditableTableCell.tsx
index 2bc5d71c96..278e530912 100644
--- a/saleor/static/dashboard-next/components/EditableTableCell/EditableTableCell.tsx
+++ b/saleor/static/dashboard-next/components/EditableTableCell/EditableTableCell.tsx
@@ -41,7 +41,8 @@ const decorate = withStyles(theme => ({
zIndex: 2
},
text: {
- cursor: "pointer"
+ cursor: "pointer",
+ fontSize: "0.8125rem"
}
}));
export const EditableTableCell = decorate<EditableTableCellProps>(
diff --git a/saleor/static/dashboard-next/components/Timeline/Timeline.tsx b/saleor/static/dashboard-next/components/Timeline/Timeline.tsx
index 4d7fef6be9..ac0f2984b3 100644
--- a/saleor/static/dashboard-next/components/Timeline/Timeline.tsx
+++ b/saleor/static/dashboard-next/components/Timeline/Timeline.tsx
@@ -37,9 +37,6 @@ interface TimelineNoteProps {
};
}
interface TimelineAddNoteProps {
- user: {
- email: string;
- };
message: string;
onChange(event: React.ChangeEvent<any>);
onSubmit(event: React.FormEvent<any>);
@@ -205,13 +202,10 @@ export const TimelineNote = decorate<TimelineNoteProps>(
)
);
export const TimelineAddNote = decorate<TimelineAddNoteProps>(
- ({ classes, user, message, onChange, onSubmit }) => (
+ ({ classes, message, onChange, onSubmit }) => (
<div className={classes.noteRoot}>
<CardContent className={classes.noteTitle}>
- <Avatar
- style={{ background: palette[CRC.str(user.email) % palette.length] }}
- className={classes.avatar}
- >
+ <Avatar style={{ background: palette[0] }} className={classes.avatar}>
<PersonIcon />
</Avatar>
<TextField
diff --git a/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx b/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx
index 8436857e2e..42f836403b 100644
--- a/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx
@@ -27,8 +27,8 @@ interface AddressType {
streetAddress1: string;
streetAddress2: string;
}
-interface OrderCustomerProps {
- client?: {
+export interface OrderCustomerProps {
+ customer: {
id: string;
email: string;
};
@@ -55,7 +55,7 @@ const decorate = withStyles(
const OrderCustomer = decorate<OrderCustomerProps>(
({
classes,
- client,
+ customer,
billingAddress,
canEditCustomer,
shippingAddress,
@@ -80,16 +80,16 @@ const OrderCustomer = decorate<OrderCustomerProps>(
}
/>
<CardContent>
- {client === undefined ? (
+ {customer === undefined ? (
<>
<Skeleton />
<Skeleton />
</>
- ) : client === null ? (
+ ) : customer === null ? (
<Typography>{i18n.t("Anonymous customer")}</Typography>
) : (
- <ExternalLink href={`mailto:${client.email}`}>
- {client.email}
+ <ExternalLink href={`mailto:${customer.email}`}>
+ {customer.email}
</ExternalLink>
)}
</CardContent>
@@ -102,7 +102,7 @@ const OrderCustomer = decorate<OrderCustomerProps>(
color="secondary"
variant="flat"
onClick={onShippingAddressEdit}
- disabled={!onShippingAddressEdit && client === undefined}
+ disabled={!onShippingAddressEdit && customer === undefined}
>
{i18n.t("Edit")}
</Button>
@@ -149,7 +149,7 @@ const OrderCustomer = decorate<OrderCustomerProps>(
color="secondary"
variant="flat"
onClick={onBillingAddressEdit}
- disabled={!onBillingAddressEdit && client === undefined}
+ disabled={!onBillingAddressEdit && customer === undefined}
>
{i18n.t("Edit")}
</Button>
diff --git a/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx b/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx
index d4252fcd2a..180ad084d4 100644
--- a/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx
@@ -2,7 +2,7 @@ import { withStyles, WithStyles } from "@material-ui/core/styles";
import Typography from "@material-ui/core/Typography";
import * as React from "react";
-import { AddressType, transformAddressToForm } from "../..";
+import { transformAddressToForm } from "../..";
import { UserError } from "../../..";
import { Container } from "../../../components/Container";
import DateFormatter from "../../../components/DateFormatter";
@@ -13,7 +13,8 @@ import Toggle from "../../../components/Toggle";
import { AddressTypeInput } from "../../../customers";
import i18n from "../../../i18n";
import { maybe } from "../../../misc";
-import { OrderEvents, OrderStatus } from "../../../types/globalTypes";
+import { OrderStatus } from "../../../types/globalTypes";
+import { OrderDetails_order } from "../../types/OrderDetails";
import OrderAddressEditDialog from "../OrderAddressEditDialog";
import OrderCancelDialog, {
FormData as OrderCancelFormData
@@ -39,92 +40,12 @@ import OrderShippingMethodEditDialog, {
} from "../OrderShippingMethodEditDialog";
import OrderSummary from "../OrderSummary";
-interface TaxedMoneyType {
- gross: {
- amount: number;
- currency: string;
- };
-}
-interface MoneyType {
- amount: number;
- currency: string;
-}
-interface OrderDetailsPageProps {
- order?: {
- id: string;
- billingAddress?: AddressType;
- created: string;
- fulfillments: Array<{
- id: string;
- lines: {
- edges: Array<{
- node: {
- quantity: number;
- orderLine: {
- id: string;
- productName: string;
- thumbnailUrl?: string;
- };
- };
- }>;
- };
- status: string;
- trackingNumber: string;
- }>;
- events: Array<{
- amount?: number;
- date: string;
- email?: string;
- emailType?: string;
- id: string;
- message?: string;
- quantity?: number;
- type: OrderEvents;
- user: {
- email: string;
- };
- }>;
- lines: Array<{
- id: string;
- productName: string;
- productSku: string;
- thumbnailUrl: string;
- unitPrice: TaxedMoneyType;
- quantity: number;
- quantityFulfilled: number;
- }>;
- number: string;
- paymentStatus: string;
- shippingAddress?: AddressType;
- shippingMethod?: {
- id: string;
- };
- shippingMethodName?: string;
- shippingPrice?: {
- gross: MoneyType;
- };
- status: OrderStatus;
- subtotal: {
- gross: MoneyType;
- };
- total: {
- gross: MoneyType;
- tax: MoneyType;
- };
- totalAuthorized: MoneyType;
- totalCaptured: MoneyType;
- user: {
- id: string;
- email: string;
- };
- };
+export interface OrderDetailsPageProps {
+ order: OrderDetails_order;
shippingMethods?: Array<{
id: string;
name: string;
}>;
- user?: {
- email: string;
- };
users?: Array<{
id: string;
email: string;
@@ -249,7 +170,6 @@ class OrderDetailsPageComponent extends React.Component<
errors,
order,
shippingMethods,
- user,
users,
variants,
variantsLoading,
@@ -445,14 +365,13 @@ class OrderDetailsPageComponent extends React.Component<
)}
<OrderHistory
history={maybe(() => order.events)}
- user={user}
onNoteAdd={onNoteAdd}
/>
</div>
<div>
<OrderCustomer
billingAddress={maybe(() => order.billingAddress)}
- client={maybe(() => order.user)}
+ customer={maybe(() => order.user)}
canEditCustomer={isDraft}
shippingAddress={maybe(() => order.shippingAddress)}
onBillingAddressEdit={this.toggleBillingAddressEditDialog}
diff --git a/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx b/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx
index b1ef979f27..18c5f0ce1a 100644
--- a/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderFulfillmentDialog/OrderFulfillmentDialog.tsx
@@ -15,21 +15,15 @@ import Form from "../../../components/Form";
import TableCellAvatar from "../../../components/TableCellAvatar";
import i18n from "../../../i18n";
import { maybe } from "../../../misc";
+import { OrderDetails_order_lines_edges_node } from "../../types/OrderDetails";
export interface FormData {
lines: number[];
}
-interface OrderFulfillmentDialogProps {
+export interface OrderFulfillmentDialogProps {
open: boolean;
- lines: Array<{
- id: string;
- productName: string;
- productSku: string;
- quantity: number;
- quantityFulfilled: number;
- thumbnailUrl?: string;
- }>;
+ lines: OrderDetails_order_lines_edges_node[];
onClose();
onSubmit(data: FormData);
}
diff --git a/saleor/static/dashboard-next/orders/components/OrderHistory/OrderHistory.tsx b/saleor/static/dashboard-next/orders/components/OrderHistory/OrderHistory.tsx
index 2864d89ec6..3490cfcff7 100644
--- a/saleor/static/dashboard-next/orders/components/OrderHistory/OrderHistory.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderHistory/OrderHistory.tsx
@@ -32,9 +32,6 @@ interface OrderHistoryProps {
email: string;
};
}>;
- user?: {
- email: string;
- };
onNoteAdd: (data: FormData) => void;
}
@@ -48,25 +45,20 @@ const decorate = withStyles(
{ name: "OrderHistory" }
);
const OrderHistory = decorate<OrderHistoryProps>(
- ({ classes, history, user, onNoteAdd }) => (
+ ({ classes, history, onNoteAdd }) => (
<div className={classes.root}>
<PageHeader title={i18n.t("Order history")} />
{history ? (
<Timeline>
- {user ? (
- <Form initial={{ message: "" }} onSubmit={onNoteAdd}>
- {({ change, data, submit }) => (
- <TimelineAddNote
- message={data.message}
- onChange={change}
- onSubmit={submit}
- user={user}
- />
- )}
- </Form>
- ) : (
- undefined
- )}
+ <Form initial={{ message: "" }} onSubmit={onNoteAdd}>
+ {({ change, data, submit }) => (
+ <TimelineAddNote
+ message={data.message}
+ onChange={change}
+ onSubmit={submit}
+ />
+ )}
+ </Form>
{history
.slice()
.reverse()
diff --git a/saleor/static/dashboard-next/orders/components/OrderSummary/OrderSummary.tsx b/saleor/static/dashboard-next/orders/components/OrderSummary/OrderSummary.tsx
index 9983f87467..4f22f66eb0 100644
--- a/saleor/static/dashboard-next/orders/components/OrderSummary/OrderSummary.tsx
+++ b/saleor/static/dashboard-next/orders/components/OrderSummary/OrderSummary.tsx
@@ -12,7 +12,7 @@ import OrderProducts, {
OrderProductsProps
} from "../OrderProducts/OrderProducts";
-interface OrderSummaryProps extends OrderProductsProps {
+export interface OrderSummaryProps extends OrderProductsProps {
paymentStatus?: string;
paymentVariant?: string;
status?: OrderStatus;
diff --git a/saleor/static/dashboard-next/orders/fixtures.ts b/saleor/static/dashboard-next/orders/fixtures.ts
index 7154d944a4..8202299db3 100644
--- a/saleor/static/dashboard-next/orders/fixtures.ts
+++ b/saleor/static/dashboard-next/orders/fixtures.ts
@@ -1,6 +1,13 @@
-import { OrderStatus, PaymentStatusEnum } from "../types/globalTypes";
+import {
+ FulfillmentStatus,
+ OrderEvents,
+ OrderStatus,
+ PaymentStatusEnum
+} from "../types/globalTypes";
import { transformOrderStatus, transformPaymentStatus } from "./";
+import { OrderDetails_order } from "./types/OrderDetails";
import { OrderList_orders_edges_node } from "./types/OrderList";
+
export const clients = [
{
@@ -723,208 +730,232 @@ export const orders: OrderList_orders_edges_node[] = [
userEmail: "[email protected]"
}
];
-export const order = (placeholder, args?) => ({
+export const order = (placeholder: string): OrderDetails_order => ({
+ __typename: "Order",
+ availableShippingMethods: [
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6NQ==",
+ name: "FBA"
+ },
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6Nw==",
+ name: "Oceania Air Mail"
+ },
+ {
+ __typename: "ShippingMethod",
+ id: "U2hpcHBpbmdNZXRob2Q6Ng==",
+ name: "FedEx Express"
+ }
+ ],
billingAddress: {
- city: "Keithport",
+ __typename: "Address",
+ city: "West Patriciastad",
cityArea: "",
companyName: "",
- country: "Cyprus",
+ country: {
+ __typename: "CountryDisplay",
+ code: "SB",
+ country: "Wyspy Salomona"
+ },
countryArea: "",
- firstName: "Test",
- id: "a1",
- lastName: "Client",
+ firstName: "Melissa",
+ id: "QWRkcmVzczoyNQ==",
+ lastName: "Simon",
phone: "",
- postalCode: "95393-6818",
- streetAddress_1: "9297 Barker Extension",
- streetAddress_2: ""
+ postalCode: "66272",
+ streetAddress1: "487 Roberto Shores",
+ streetAddress2: ""
},
- client: {
- email: "[email protected]",
- id: "c1",
- name: "Test Client"
- },
- created: "2018-04-07T11:18:19+00:00",
+ created: "2018-09-11T09:37:28.185874+00:00",
events: [
{
+ __typename: "OrderEvent",
amount: null,
- date: "2018-09-13T16:22:46.997106+00:00",
+ date: "2018-09-17T13:22:24.376193+00:00",
email: null,
emailType: null,
- id: "T3JkZXJFdmVudDoxMw==",
+ id: "T3JkZXJFdmVudDoyMQ==",
message: null,
- quantity: 3,
- type: "FULFILLMENT_FULFILLED_ITEMS",
- user: {
- }
- },
- {
- amount: null,
- date: "2018-09-13T16:39:54.172431+00:00",
- email: null,
- emailType: null,
- id: "T3JkZXJFdmVudDoxNA==",
- message: null,
- quantity: null,
- type: "FULFILLMENT_FULFILLED_ITEMS",
+ quantity: 1,
+ type: OrderEvents.FULFILLMENT_FULFILLED_ITEMS,
user: {
+ __typename: "User",
}
}
],
fulfillments: [
{
- id: "f1",
- lines: [
- {
- product: {
- id: "UHJvZHVjdDoy",
- name: "Gardner and Graham",
- thumbnailUrl: placeholder
- },
- quantity: 1
- },
- {
- product: {
- id: "UHJvZHVjdDox",
- name: "Gardner, Graham and King",
- thumbnailUrl: placeholder
- },
- quantity: 1
- }
- ],
- status: "fulfilled",
- trackingCode: "012391230412131239052"
- },
- {
- id: "f2",
- lines: [
- {
- product: {
- id: "UHJvZHVjdDoy",
- name: "Gardner and Graham",
- thumbnailUrl: placeholder
- },
- quantity: 1
- }
- ],
- status: "cancelled",
- trackingCode: "012391230412131239052"
- }
- ],
- id: "o1",
- lines: [
- {
- id: "UHJvZHVjdDox",
- price: {
- gross: {
- amount: 12.4,
- currency: "USD"
- }
+ __typename: "Fulfillment",
+ id: "RnVsZmlsbG1lbnQ6MjQ=",
+ lines: {
+ __typename: "FulfillmentLineCountableConnection",
+ edges: [
+ {
+ __typename: "FulfillmentLineCountableEdge",
+ node: {
+ __typename: "FulfillmentLine",
+ id: "RnVsZmlsbG1lbnRMaW5lOjM5",
+ orderLine: {
+ __typename: "OrderLine",
+ id: "T3JkZXJMaW5lOjIz",
+ productName: "Williams, Garcia and Walker (XS)"
+ },
+ quantity: 1
+ }
+ }
+ ]
},
- productName: "Gardner, Graham and King",
- productSku: "9123021",
- quantity: 1,
- quantityFulfilled: 0,
- thumbnailUrl: placeholder
+ status: FulfillmentStatus.FULFILLED,
+ trackingNumber: ""
},
{
- id: "UHJvZHVjdDoy",
- price: {
- gross: {
- amount: 11.6,
- currency: "USD"
- }
+ __typename: "Fulfillment",
+ id: "RnVsZmlsbG1lbnQ6OQ==",
+ lines: {
+ __typename: "FulfillmentLineCountableConnection",
+ edges: [
+ {
+ __typename: "FulfillmentLineCountableEdge",
+ node: {
+ __typename: "FulfillmentLine",
+ id: "RnVsZmlsbG1lbnRMaW5lOjE1",
+ orderLine: {
+ __typename: "OrderLine",
+ id: "T3JkZXJMaW5lOjIz",
+ productName: "Williams, Garcia and Walker (XS)"
+ },
+ quantity: 1
+ }
+ }
+ ]
},
- productName: "Gardner and Graham",
- productSku: "9123022",
- quantity: 2,
- quantityFulfilled: 1,
- thumbnailUrl: placeholder
- },
- {
- id: "UHJvZHVjdDoz",
- price: {
- gross: {
- amount: 22.4,
- currency: "USD"
+ status: FulfillmentStatus.FULFILLED,
+ trackingNumber: ""
+ }
+ ],
+ id: "T3JkZXI6OQ==",
+ lines: {
+ __typename: "OrderLineCountableConnection",
+ edges: [
+ {
+ __typename: "OrderLineCountableEdge",
+ node: {
+ __typename: "OrderLine",
+ id: "T3JkZXJMaW5lOjIy",
+ productName: "Watkins-Gonzalez (Soft)",
+ productSku: "59-1337",
+ quantity: 3,
+ quantityFulfilled: 0,
+ thumbnailUrl: placeholder,
+ unitPrice: {
+ __typename: "TaxedMoney",
+ gross: {
+ __typename: "Money",
+ amount: 18.51,
+ currency: "USD"
+ },
+ net: {
+ __typename: "Money",
+ amount: 18.51,
+ currency: "USD"
+ }
+ }
}
},
- productName: "Gardner and King",
- productSku: "9123023",
- quantity: 7,
- quantityFulfilled: 5,
- thumbnailUrl: placeholder
- },
- {
- id: "UHJvZHVjdDoa",
- price: {
- gross: {
- amount: 9.9,
- currency: "USD"
+ {
+ __typename: "OrderLineCountableEdge",
+ node: {
+ __typename: "OrderLine",
+ id: "T3JkZXJMaW5lOjIz",
+ productName: "Williams, Garcia and Walker (XS)",
+ productSku: "5-1337",
+ quantity: 2,
+ quantityFulfilled: 2,
+ thumbnailUrl: placeholder,
+ unitPrice: {
+ __typename: "TaxedMoney",
+ gross: {
+ __typename: "Money",
+ amount: 79.71,
+ currency: "USD"
+ },
+ net: {
+ __typename: "Money",
+ amount: 79.71,
+ currency: "USD"
+ }
+ }
}
- },
- productName: "Graham and King",
- productSku: "9123024",
- quantity: 3,
- quantityFulfilled: 0,
- thumbnailUrl: placeholder
- }
- ],
- number: "11",
- payment: {
- net: {
- amount: 6,
- currency: "USD"
- },
- paid: {
- amount: 19.2,
- currency: "USD"
- },
- refunded: {
- amount: 13.2,
- currency: "USD"
- }
- },
- paymentStatus: "confirmed",
- price: {
- amount: 19.2,
- currency: "USD"
+ }
+ ]
},
+ number: "9",
+ paymentStatus: PaymentStatusEnum.PREAUTH,
shippingAddress: {
- city: "Keithport",
+ __typename: "Address",
+ city: "West Patriciastad",
cityArea: "",
companyName: "",
- country: "Cyprus",
+ country: {
+ __typename: "CountryDisplay",
+ code: "SB",
+ country: "Wyspy Salomona"
+ },
countryArea: "",
- firstName: "Test",
- id: "a1",
- lastName: "Client",
+ firstName: "Melissa",
+ id: "QWRkcmVzczoyNQ==",
+ lastName: "Simon",
phone: "",
- postalCode: "95393-6818",
- streetAddress_1: "9297 Barker Extension",
- streetAddress_2: ""
+ postalCode: "66272",
+ streetAddress1: "487 Roberto Shores",
+ streetAddress2: ""
},
- shippingMethod: {
- id: "s1"
- },
- shippingMethodName: "DHL",
+ shippingMethod: null,
+ shippingMethodName: "Registred priority",
shippingPrice: {
+ __typename: "TaxedMoney",
gross: {
- amount: 5.5,
+ __typename: "Money",
+ amount: 19.98,
currency: "USD"
}
},
- status: "partially fulfilled",
+ status: OrderStatus.PARTIALLY_FULFILLED,
subtotal: {
- amount: 160.2,
- currency: "USD"
+ __typename: "TaxedMoney",
+ gross: {
+ __typename: "Money",
+ amount: 214.95,
+ currency: "USD"
+ }
},
total: {
- amount: 165.7,
+ __typename: "TaxedMoney",
+ gross: {
+ __typename: "Money",
+ amount: 234.93,
+ currency: "USD"
+ },
+ tax: {
+ __typename: "Money",
+ amount: 0,
+ currency: "USD"
+ }
+ },
+ totalAuthorized: {
+ __typename: "Money",
+ amount: 234.93,
+ currency: "USD"
+ },
+ totalCaptured: {
+ __typename: "Money",
+ amount: 0,
currency: "USD"
},
- ...args
+ user: null
});
export const flatOrders = orders.map(order => ({
...order,
diff --git a/saleor/static/dashboard-next/storybook/stories/orders/OrderCustomer.tsx b/saleor/static/dashboard-next/storybook/stories/orders/OrderCustomer.tsx
index 6943e47a03..32a3122585 100644
--- a/saleor/static/dashboard-next/storybook/stories/orders/OrderCustomer.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/orders/OrderCustomer.tsx
@@ -1,30 +1,28 @@
import { storiesOf } from "@storybook/react";
import * as React from "react";
-import OrderCustomer from "../../../orders/components/OrderCustomer";
+import OrderCustomer, {
+ OrderCustomerProps
+} from "../../../orders/components/OrderCustomer";
import { order } from "../../../orders/fixtures";
import Decorator from "../../Decorator";
const differentAddress = { ...order("").billingAddress, id: "a2" };
+const props: OrderCustomerProps = {
+ billingAddress: order("").billingAddress,
+ customer: order("").user,
+ onBillingAddressEdit: undefined,
+ onShippingAddressEdit: undefined,
+ shippingAddress: order("").shippingAddress
+};
+
storiesOf("Orders / OrderCustomer", module)
.addDecorator(Decorator)
- .add("when loading data", () => <OrderCustomer />)
- .add("when loaded data", () => (
- <OrderCustomer
- client={order("").client}
- shippingAddress={order("").shippingAddress}
- billingAddress={order("").billingAddress}
- onBillingAddressEdit={undefined}
- onShippingAddressEdit={undefined}
- />
+ .add("when loading data", () => (
+ <OrderCustomer {...props} customer={undefined} />
))
+ .add("when loaded data", () => <OrderCustomer {...props} />)
.add("with different addresses", () => (
- <OrderCustomer
- client={order("").client}
- shippingAddress={order("").shippingAddress}
- billingAddress={differentAddress}
- onBillingAddressEdit={undefined}
- onShippingAddressEdit={undefined}
- />
+ <OrderCustomer {...props} billingAddress={differentAddress} />
));
diff --git a/saleor/static/dashboard-next/storybook/stories/orders/OrderDetailsPage.tsx b/saleor/static/dashboard-next/storybook/stories/orders/OrderDetailsPage.tsx
index 788f899d77..7ac9ed2d71 100644
--- a/saleor/static/dashboard-next/storybook/stories/orders/OrderDetailsPage.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/orders/OrderDetailsPage.tsx
@@ -2,7 +2,9 @@ import { storiesOf } from "@storybook/react";
import * as React from "react";
import * as placeholderImage from "../../../../images/placeholder60x60.png";
-import OrderDetailsPage from "../../../orders/components/OrderDetailsPage";
+import OrderDetailsPage, {
+ OrderDetailsPageProps
+} from "../../../orders/components/OrderDetailsPage";
import {
clients,
countries,
@@ -14,14 +16,10 @@ import { OrderStatus, PaymentStatusEnum } from "../../../types/globalTypes";
import Decorator from "../../Decorator";
const order = orderFixture(placeholderImage);
-const orderDraft = orderFixture(placeholderImage, {
- status: OrderStatus.DRAFT
-});
-const orderWithoutPayment = orderFixture(placeholderImage, {
- paymentStatus: PaymentStatusEnum.PREAUTH
-});
-const callbacks = {
+const props: OrderDetailsPageProps = {
+ countries,
+ errors: [],
onBack: () => undefined,
onBillingAddressEdit: undefined,
onCreate: undefined,
@@ -34,54 +32,38 @@ const callbacks = {
onPaymentCapture: undefined,
onPaymentRefund: undefined,
onPaymentRelease: undefined,
- onPrintClick: undefined,
onProductAdd: undefined,
onProductClick: undefined,
onShippingAddressEdit: undefined,
- onShippingMethodEdit: undefined
+ onShippingMethodEdit: undefined,
+ order,
+ shippingMethods,
+ users: clients,
+ variants,
+ variantsLoading: false
};
storiesOf("Views / Orders / Order details", module)
.addDecorator(Decorator)
.add("when loading data", () => (
- <OrderDetailsPage errors={[]} {...callbacks} />
- ))
- .add("when loaded data", () => (
- <OrderDetailsPage
- errors={[]}
- countries={countries}
- order={order}
- user={{ email: "[email protected]" }}
- {...callbacks}
- />
+ <OrderDetailsPage {...props} order={undefined} />
))
+ .add("when loaded data", () => <OrderDetailsPage {...props} />)
.add("as a draft", () => (
<OrderDetailsPage
- errors={[]}
- countries={countries}
- order={orderDraft}
- shippingMethods={shippingMethods}
- user={{ email: "[email protected]" }}
- users={clients}
- variants={variants}
- variantsLoading={false}
- fetchUsers={undefined}
- fetchVariants={undefined}
- {...callbacks}
+ {...props}
+ order={{
+ ...props.order,
+ status: OrderStatus.DRAFT
+ }}
/>
))
.add("as a unpaid order", () => (
<OrderDetailsPage
- errors={[]}
- countries={countries}
- order={orderWithoutPayment}
- shippingMethods={shippingMethods}
- user={{ email: "[email protected]" }}
- users={clients}
- variants={variants}
- variantsLoading={false}
- fetchUsers={undefined}
- fetchVariants={undefined}
- {...callbacks}
+ {...props}
+ order={{
+ ...props.order,
+ paymentStatus: PaymentStatusEnum.PREAUTH
+ }}
/>
));
diff --git a/saleor/static/dashboard-next/storybook/stories/orders/OrderFulfillmentDialog.tsx b/saleor/static/dashboard-next/storybook/stories/orders/OrderFulfillmentDialog.tsx
index aa6e0c29a9..27f1fe2a24 100644
--- a/saleor/static/dashboard-next/storybook/stories/orders/OrderFulfillmentDialog.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/orders/OrderFulfillmentDialog.tsx
@@ -2,19 +2,21 @@ import { storiesOf } from "@storybook/react";
import * as React from "react";
import * as placeholderImage from "../../../../images/placeholder60x60.png";
-import OrderFulfillmentDialog from "../../../orders/components/OrderFulfillmentDialog";
+import OrderFulfillmentDialog, {
+ OrderFulfillmentDialogProps
+} from "../../../orders/components/OrderFulfillmentDialog";
import { order as orderFixture } from "../../../orders/fixtures";
import Decorator from "../../Decorator";
const order = orderFixture(placeholderImage);
+const props: OrderFulfillmentDialogProps = {
+ lines: order.lines.edges.map(edge => edge.node),
+ onClose: undefined,
+ onSubmit: undefined,
+ open: true
+};
+
storiesOf("Orders / OrderFulfillmentDialog", module)
.addDecorator(Decorator)
- .add("default", () => (
- <OrderFulfillmentDialog
- open={true}
- lines={order.lines}
- onClose={undefined}
- onSubmit={undefined}
- />
- ));
+ .add("default", () => <OrderFulfillmentDialog {...props} />);
diff --git a/saleor/static/dashboard-next/storybook/stories/orders/OrderSummary.tsx b/saleor/static/dashboard-next/storybook/stories/orders/OrderSummary.tsx
index b9f36f229e..102239e46f 100644
--- a/saleor/static/dashboard-next/storybook/stories/orders/OrderSummary.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/orders/OrderSummary.tsx
@@ -2,13 +2,18 @@ import { storiesOf } from "@storybook/react";
import * as React from "react";
import * as placeholderImage from "../../../../images/placeholder60x60.png";
-import OrderSummary from "../../../orders/components/OrderSummary";
+import OrderSummary, {
+ OrderSummaryProps
+} from "../../../orders/components/OrderSummary";
import { order as orderFixture } from "../../../orders/fixtures";
-import { OrderStatus } from "../../../types/globalTypes";
+import { OrderStatus, PaymentStatusEnum } from "../../../types/globalTypes";
import Decorator from "../../Decorator";
const order = orderFixture(placeholderImage);
-const callbacks = {
+const props: OrderSummaryProps = {
+ authorized: order.totalAuthorized,
+ isDraft: order.status === OrderStatus.DRAFT,
+ lines: order.lines.edges.map(edge => edge.node),
onCapture: undefined,
onCreate: undefined,
onFulfill: undefined,
@@ -17,172 +22,52 @@ const callbacks = {
onOrderLineRemove: () => undefined,
onRefund: undefined,
onRelease: undefined,
- onRowClick: () => undefined
-};
-
-const shippingPrice = {
- gross: {
- amount: 9123.12,
- currency: "USD"
- }
+ onRowClick: () => undefined,
+ paid: order.totalCaptured,
+ paymentStatus: order.paymentStatus,
+ shippingMethodName: order.shippingMethodName,
+ shippingPrice: order.shippingPrice,
+ status: order.status,
+ subtotal: order.subtotal.gross,
+ total: order.total.gross
};
storiesOf("Orders / OrderSummary", module)
.addDecorator(Decorator)
- .add("when loading data", () => <OrderSummary {...callbacks} />)
+ .add("when loading data", () => <OrderSummary {...props} />)
.add("order unfulfilled", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus={order.paymentStatus}
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={OrderStatus.UNFULFILLED}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} status={OrderStatus.UNFULFILLED} />
))
.add("order partially fulfilled", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus={order.paymentStatus}
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={OrderStatus.PARTIALLY_FULFILLED}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} status={OrderStatus.PARTIALLY_FULFILLED} />
))
.add("order fulfilled", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus={order.paymentStatus}
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={OrderStatus.FULFILLED}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} status={OrderStatus.FULFILLED} />
))
.add("order cancelled", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus={order.paymentStatus}
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={OrderStatus.CANCELED}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} status={OrderStatus.CANCELED} />
))
.add("order draft", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus={order.paymentStatus}
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={OrderStatus.DRAFT}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} status={OrderStatus.DRAFT} />
))
.add("payment confirmed", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="confirmed"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.CONFIRMED} />
))
.add("payment error", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="error"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.ERROR} />
))
.add("payment input", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="input"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.INPUT} />
))
.add("payment preauth", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="preauth"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.PREAUTH} />
))
.add("payment refunded", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="refunded"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.REFUNDED} />
))
.add("payment rejected", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="rejected"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.REJECTED} />
))
.add("payment waiting", () => (
- <OrderSummary
- paid={order.payment.paid}
- paymentStatus="waiting"
- lines={order.products}
- shippingMethodName="DHL"
- shippingPrice={shippingPrice}
- status={order.status}
- subtotal={order.subtotal}
- total={order.total}
- {...callbacks}
- />
+ <OrderSummary {...props} paymentStatus={PaymentStatusEnum.WAITING} />
));