Skip to content

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

Add missing id prop

dominik-zeglena399b6173b93
diff --git a/saleor/static/dashboard-next/orders/queries.ts b/saleor/static/dashboard-next/orders/queries.ts
index d162769830..c16a256402 100644
--- a/saleor/static/dashboard-next/orders/queries.ts
+++ b/saleor/static/dashboard-next/orders/queries.ts
@@ -2,6 +2,10 @@ import gql from "graphql-tag";
import { TypedQuery } from "../queries";
import { OrderDetails, OrderDetailsVariables } from "./types/OrderDetails";
+import {
+ OrderDraftList,
+ OrderDraftListVariables
+} from "./types/OrderDraftList";
import { OrderList, OrderListVariables } from "./types/OrderList";
import {
OrderVariantSearch,
@@ -20,6 +24,7 @@ export const fragmentOrderEvent = gql`
quantity
type
user {
+ id
email
}
}
@@ -205,6 +210,51 @@ export const TypedOrderListQuery = TypedQuery<OrderList, OrderListVariables>(
orderListQuery
);
+export const orderDraftListQuery = gql`
+ ${fragmentAddress}
+ query OrderDraftList(
+ $first: Int
+ $after: String
+ $last: Int
+ $before: String
+ ) {
+ draftOrders(before: $before, after: $after, first: $first, last: $last) {
+ edges {
+ node {
+ __typename
+ billingAddress {
+ ...AddressFragment
+ }
+ created
+ id
+ number
+ paymentStatus
+ status
+ total {
+ __typename
+ gross {
+ __typename
+ amount
+ currency
+ }
+ }
+ userEmail
+ }
+ }
+ pageInfo {
+ hasPreviousPage
+ hasNextPage
+ startCursor
+ endCursor
+ }
+ }
+ }
+`;
+export const TypedOrderDraftListQuery = TypedQuery<
+ OrderDraftList,
+ OrderDraftListVariables
+>(orderDraftListQuery);
+
export const orderDetailsQuery = gql`
${fragmentOrderDetails}
query OrderDetails($id: ID!) {
diff --git a/saleor/static/dashboard-next/orders/types/OrderAddNote.ts b/saleor/static/dashboard-next/orders/types/OrderAddNote.ts
index a077b9e0ed..36f769be40 100644
--- a/saleor/static/dashboard-next/orders/types/OrderAddNote.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderAddNote.ts
@@ -16,6 +16,7 @@ export interface OrderAddNote_orderAddNote_errors {
export interface OrderAddNote_orderAddNote_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderCancel.ts b/saleor/static/dashboard-next/orders/types/OrderCancel.ts
index 5c2fd62245..5e1cd5e78d 100644
--- a/saleor/static/dashboard-next/orders/types/OrderCancel.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderCancel.ts
@@ -38,6 +38,7 @@ export interface OrderCancel_orderCancel_order_billingAddress {
export interface OrderCancel_orderCancel_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderCapture.ts b/saleor/static/dashboard-next/orders/types/OrderCapture.ts
index a970265ef2..04b03fb91f 100644
--- a/saleor/static/dashboard-next/orders/types/OrderCapture.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderCapture.ts
@@ -38,6 +38,7 @@ export interface OrderCapture_orderCapture_order_billingAddress {
export interface OrderCapture_orderCapture_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts b/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts
index c2f0df3621..316c389e5e 100644
--- a/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderCreateFulfillment.ts
@@ -38,6 +38,7 @@ export interface OrderCreateFulfillment_orderFulfillmentCreate_order_billingAddr
export interface OrderCreateFulfillment_orderFulfillmentCreate_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderDetails.ts b/saleor/static/dashboard-next/orders/types/OrderDetails.ts
index 320143a4a3..84f20b9fd4 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDetails.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDetails.ts
@@ -32,6 +32,7 @@ export interface OrderDetails_order_billingAddress {
export interface OrderDetails_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts b/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts
index 9dfe09c5c6..b38e857e3c 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDetailsFragment.ts
@@ -32,6 +32,7 @@ export interface OrderDetailsFragment_billingAddress {
export interface OrderDetailsFragment_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts b/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts
index 9d411c5c6a..ed36d52344 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftCancel.ts
@@ -38,6 +38,7 @@ export interface OrderDraftCancel_draftOrderDelete_order_billingAddress {
export interface OrderDraftCancel_draftOrderDelete_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts b/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts
index fb78c263af..ca4dd8e2d9 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftFinalize.ts
@@ -38,6 +38,7 @@ export interface OrderDraftFinalize_draftOrderComplete_order_billingAddress {
export interface OrderDraftFinalize_draftOrderComplete_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftList.ts b/saleor/static/dashboard-next/orders/types/OrderDraftList.ts
new file mode 100644
index 0000000000..c3567edca4
--- /dev/null
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftList.ts
@@ -0,0 +1,84 @@
+/* tslint:disable */
+/* eslint-disable */
+// This file was automatically generated and should not be edited.
+
+import { PaymentChargeStatusEnum, OrderStatus } from "./../../types/globalTypes";
+
+// ====================================================
+// GraphQL query operation: OrderDraftList
+// ====================================================
+
+export interface OrderDraftList_draftOrders_edges_node_billingAddress_country {
+ __typename: "CountryDisplay";
+ code: string;
+ country: string;
+}
+
+export interface OrderDraftList_draftOrders_edges_node_billingAddress {
+ __typename: "Address";
+ city: string;
+ cityArea: string;
+ companyName: string;
+ country: OrderDraftList_draftOrders_edges_node_billingAddress_country;
+ countryArea: string;
+ firstName: string;
+ id: string;
+ lastName: string;
+ phone: string | null;
+ postalCode: string;
+ streetAddress1: string;
+ streetAddress2: string;
+}
+
+export interface OrderDraftList_draftOrders_edges_node_total_gross {
+ __typename: "Money";
+ amount: number;
+ currency: string;
+}
+
+export interface OrderDraftList_draftOrders_edges_node_total {
+ __typename: "TaxedMoney";
+ gross: OrderDraftList_draftOrders_edges_node_total_gross;
+}
+
+export interface OrderDraftList_draftOrders_edges_node {
+ __typename: "Order";
+ billingAddress: OrderDraftList_draftOrders_edges_node_billingAddress | null;
+ created: any;
+ id: string;
+ number: string | null;
+ paymentStatus: PaymentChargeStatusEnum | null;
+ status: OrderStatus;
+ total: OrderDraftList_draftOrders_edges_node_total | null;
+ userEmail: string | null;
+}
+
+export interface OrderDraftList_draftOrders_edges {
+ __typename: "OrderCountableEdge";
+ node: OrderDraftList_draftOrders_edges_node;
+}
+
+export interface OrderDraftList_draftOrders_pageInfo {
+ __typename: "PageInfo";
+ hasPreviousPage: boolean;
+ hasNextPage: boolean;
+ startCursor: string | null;
+ endCursor: string | null;
+}
+
+export interface OrderDraftList_draftOrders {
+ __typename: "OrderCountableConnection";
+ edges: OrderDraftList_draftOrders_edges[];
+ pageInfo: OrderDraftList_draftOrders_pageInfo;
+}
+
+export interface OrderDraftList {
+ draftOrders: OrderDraftList_draftOrders | null;
+}
+
+export interface OrderDraftListVariables {
+ first?: number | null;
+ after?: string | null;
+ last?: number | null;
+ before?: string | null;
+}
diff --git a/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts b/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts
index b7b0f780dd..1a4410e87c 100644
--- a/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderDraftUpdate.ts
@@ -38,6 +38,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_order_billingAddress {
export interface OrderDraftUpdate_draftOrderUpdate_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderEventFragment.ts b/saleor/static/dashboard-next/orders/types/OrderEventFragment.ts
index 0eaddb73ed..d02de1ccb2 100644
--- a/saleor/static/dashboard-next/orders/types/OrderEventFragment.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderEventFragment.ts
@@ -10,6 +10,7 @@ import { OrderEventsEmails, OrderEvents } from "./../../types/globalTypes";
export interface OrderEventFragment_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts b/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts
index ebaab635ef..288e19ceb3 100644
--- a/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderFulfillmentCancel.ts
@@ -38,6 +38,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_billingAddr
export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts b/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts
index 7c164090f0..c4e876424b 100644
--- a/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderFulfillmentUpdateTracking.ts
@@ -38,6 +38,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_o
export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts b/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts
index 3ff542fd19..dd9f5770e4 100644
--- a/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderLineDelete.ts
@@ -38,6 +38,7 @@ export interface OrderLineDelete_draftOrderLineDelete_order_billingAddress {
export interface OrderLineDelete_draftOrderLineDelete_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts b/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts
index c41a306a99..92b5c76c98 100644
--- a/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderLineUpdate.ts
@@ -38,6 +38,7 @@ export interface OrderLineUpdate_draftOrderLineUpdate_order_billingAddress {
export interface OrderLineUpdate_draftOrderLineUpdate_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderLinesAdd.ts b/saleor/static/dashboard-next/orders/types/OrderLinesAdd.ts
index 143d86eac1..de35d1d3b8 100644
--- a/saleor/static/dashboard-next/orders/types/OrderLinesAdd.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderLinesAdd.ts
@@ -38,6 +38,7 @@ export interface OrderLinesAdd_draftOrderLinesCreate_order_billingAddress {
export interface OrderLinesAdd_draftOrderLinesCreate_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderMarkAsPaid.ts b/saleor/static/dashboard-next/orders/types/OrderMarkAsPaid.ts
index 6e37984e02..145a62eab8 100644
--- a/saleor/static/dashboard-next/orders/types/OrderMarkAsPaid.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderMarkAsPaid.ts
@@ -38,6 +38,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_order_billingAddress {
export interface OrderMarkAsPaid_orderMarkAsPaid_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderRefund.ts b/saleor/static/dashboard-next/orders/types/OrderRefund.ts
index 38b81572ae..0a87e4795f 100644
--- a/saleor/static/dashboard-next/orders/types/OrderRefund.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderRefund.ts
@@ -38,6 +38,7 @@ export interface OrderRefund_orderRefund_order_billingAddress {
export interface OrderRefund_orderRefund_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/types/OrderVoid.ts b/saleor/static/dashboard-next/orders/types/OrderVoid.ts
index 9c01f6ec28..24f262c195 100644
--- a/saleor/static/dashboard-next/orders/types/OrderVoid.ts
+++ b/saleor/static/dashboard-next/orders/types/OrderVoid.ts
@@ -38,6 +38,7 @@ export interface OrderVoid_orderVoid_order_billingAddress {
export interface OrderVoid_orderVoid_order_events_user {
__typename: "User";
+ id: string;
email: string;
}
diff --git a/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx b/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx
new file mode 100644
index 0000000000..0231133818
--- /dev/null
+++ b/saleor/static/dashboard-next/orders/views/OrderDraftList.tsx
@@ -0,0 +1,101 @@
+import { stringify as stringifyQs } from "qs";
+import * as React from "react";
+
+import Messages from "../../components/messages";
+import Navigator from "../../components/Navigator";
+import { createPaginationState, Paginator } from "../../components/Paginator";
+import i18n from "../../i18n";
+import { maybe } from "../../misc";
+import OrderListPage from "../components/OrderListPage/OrderListPage";
+import { getTabName } from "../misc";
+import { TypedOrderDraftCreateMutation } from "../mutations";
+import { TypedOrderDraftListQuery } from "../queries";
+import { OrderDraftCreate } from "../types/OrderDraftCreate";
+import { orderUrl } from "../urls";
+
+export type OrderDraftListQueryParams = Partial<{
+ after: string;
+ before: string;
+}>;
+
+interface OrderDraftListProps {
+ params: OrderDraftListQueryParams;
+}
+
+const PAGINATE_BY = 20;
+
+export const OrderDraftList: React.StatelessComponent<OrderDraftListProps> = ({
+ params
+}) => (
+ <Navigator>
+ {navigate => (
+ <Messages>
+ {pushMessage => {
+ const handleCreateOrderCreateSuccess = (data: OrderDraftCreate) => {
+ pushMessage({
+ text: i18n.t("Order draft succesfully created")
+ });
+ navigate(orderUrl(data.draftOrderCreate.order.id));
+ };
+
+ const changeFilters = (newParams: OrderDraftListQueryParams) =>
+ navigate(
+ "?" +
+ stringifyQs({
+ ...params,
+ ...newParams
+ })
+ );
+
+ return (
+ <TypedOrderDraftCreateMutation
+ onCompleted={handleCreateOrderCreateSuccess}
+ >
+ {createOrder => {
+ const paginationState = createPaginationState(
+ PAGINATE_BY,
+ params
+ );
+ const currentTab = getTabName(params);
+
+ return (
+ <TypedOrderDraftListQuery
+ displayLoader
+ variables={paginationState}
+ >
+ {({ data, loading }) => (
+ <Paginator
+ pageInfo={maybe(() => data.draftOrders.pageInfo)}
+ paginationState={paginationState}
+ queryString={params}
+ >
+ {({ loadNextPage, loadPreviousPage, pageInfo }) => (
+ <OrderListPage
+ filtersList={[]}
+ currentTab={currentTab}
+ disabled={loading}
+ orders={maybe(() =>
+ data.draftOrders.edges.map(edge => edge.node)
+ )}
+ pageInfo={pageInfo}
+ onAdd={createOrder}
+ onNextPage={loadNextPage}
+ onPreviousPage={loadPreviousPage}
+ onRowClick={id => () => navigate(orderUrl(id))}
+ onCustomFilter={() => undefined}
+ />
+ )}
+ </Paginator>
+ )}
+ </TypedOrderDraftListQuery>
+ );
+ }}
+ </TypedOrderDraftCreateMutation>
+ );
+ }}
+ </Messages>
+ )}
+ </Navigator>
+);
+
+export default OrderDraftList;