Saleor Core: the high performance, composable, headless commerce API.
Python cartcheckoutcommercecomposablee-commerceecommercegraphqlheadlessheadless-commercemultichannelomsorder-managementpaymentspimpythonshopshopping-cartstore
Enable address editing
dominik-zeglencd74991b5840
diff --git a/saleor/static/dashboard-next/components/AddressEdit/AddressEdit.tsx b/saleor/static/dashboard-next/components/AddressEdit/AddressEdit.tsxindex 39edcedd06..fa7bc8f887 100644--- a/saleor/static/dashboard-next/components/AddressEdit/AddressEdit.tsx+++ b/saleor/static/dashboard-next/components/AddressEdit/AddressEdit.tsx@@ -13,6 +13,7 @@ interface AddressEditProps {label: string;}>;data: AddressTypeInput;+ errors: { [T in keyof AddressTypeInput]?: string };onChange(event: React.ChangeEvent<any>);}@@ -24,11 +25,13 @@ const decorate = withStyles(theme => ({}}));const AddressEdit = decorate<AddressEditProps>(- ({ classes, countries, data, onChange }) => (+ ({ classes, countries, data, errors, onChange }) => (<><div className={classes.root}><div><TextField+ error={!!errors.firstName}+ helperText={errors.firstName}label={i18n.t("First name")}name="firstName"onChange={onChange}@@ -38,6 +41,8 @@ const AddressEdit = decorate<AddressEditProps>(</div><div><TextField+ error={!!errors.lastName}+ helperText={errors.lastName}label={i18n.t("Last name")}name="lastName"onChange={onChange}@@ -48,6 +53,8 @@ const AddressEdit = decorate<AddressEditProps>(</div><FormSpacer /><TextField+ error={!!errors.companyName}+ helperText={errors.companyName}label={i18n.t("Company")}name="companyName"onChange={onChange}@@ -56,6 +63,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.streetAddress1}+ helperText={errors.streetAddress1}label={i18n.t("Address")}name="streetAddress1"onChange={onChange}@@ -64,6 +73,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.streetAddress2}+ helperText={errors.streetAddress2}label={i18n.t("Address")}name="streetAddress2"onChange={onChange}@@ -72,6 +83,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.city}+ helperText={errors.city}label={i18n.t("City")}name="city"onChange={onChange}@@ -80,6 +93,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.cityArea}+ helperText={errors.cityArea}label={i18n.t("City area")}name="cityArea"onChange={onChange}@@ -88,6 +103,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.postalCode}+ helperText={errors.postalCode}label={i18n.t("Postal code")}name="postalCode"onChange={onChange}@@ -96,6 +113,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><SingleSelectField+ error={!!errors.country}+ hint={errors.country}label={i18n.t("Country")}name="country"onChange={onChange}@@ -104,6 +123,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.countryArea}+ helperText={errors.countryArea}label={i18n.t("Country area")}name="countryArea"onChange={onChange}@@ -112,6 +133,8 @@ const AddressEdit = decorate<AddressEditProps>(/><FormSpacer /><TextField+ error={!!errors.phone}+ helperText={errors.phone}label={i18n.t("Phone")}name="phone"value={data.phone}diff --git a/saleor/static/dashboard-next/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx b/saleor/static/dashboard-next/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsxindex 12c4f9a212..620f4f5a34 100644--- a/saleor/static/dashboard-next/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx@@ -6,12 +6,13 @@ import DialogTitle from "@material-ui/core/DialogTitle";import * as React from "react";import AddressEdit from "../../../components/AddressEdit/AddressEdit";-import { AddressType } from "../../../customers/";+import { AddressTypeInput } from "../../../customers/";import i18n from "../../../i18n";interface OrderAddressEditDialogProps {open: boolean;- data: AddressType;+ data: AddressTypeInput;+ errors: { [T in keyof AddressTypeInput]?: string };variant: "billing" | "shipping" | string;countries?: Array<{code: string;@@ -24,7 +25,16 @@ interface OrderAddressEditDialogProps {const OrderAddressEditDialog: React.StatelessComponent<OrderAddressEditDialogProps-> = ({ open, variant, countries, data, onConfirm, onClose, onChange }) => (+> = ({+ open,+ errors,+ variant,+ countries,+ data,+ onClose,+ onChange,+ onConfirm+}) => (<Dialog open={open}><DialogTitle>{variant === "billing"@@ -32,13 +42,23 @@ const OrderAddressEditDialog: React.StatelessComponent<: i18n.t("Edit shipping address", { context: "title" })}</DialogTitle><DialogContent>- <AddressEdit countries={countries} data={data} onChange={onChange} />+ <AddressEdit+ countries={countries}+ data={data}+ errors={errors}+ onChange={onChange}+ /></DialogContent><DialogActions><Button onClick={onClose}>{i18n.t("Cancel", { context: "button" })}</Button>- <Button color="primary" variant="raised" onClick={onConfirm}>+ <Button+ color="primary"+ variant="raised"+ onClick={onConfirm}+ type="submit"+ >{i18n.t("Confirm", { context: "button" })}</Button></DialogActions>diff --git a/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx b/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsxindex d26c98b235..b329580a0f 100644--- a/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderCustomer/OrderCustomer.tsx@@ -31,7 +31,7 @@ interface OrderCustomerProps {};shippingAddress?: AddressType;billingAddress?: AddressType;- editCustomer?: boolean;+ canEditCustomer?: boolean;onCustomerEditClick?();onBillingAddressEdit?();onShippingAddressEdit?();@@ -54,7 +54,7 @@ const OrderCustomer = decorate<OrderCustomerProps>(classes,client,billingAddress,- editCustomer,+ canEditCustomer,shippingAddress,onCustomerEditClick,onBillingAddressEdit,@@ -64,7 +64,7 @@ const OrderCustomer = decorate<OrderCustomerProps>(<CardTitletitle={i18n.t("Customer")}toolbar={- !!editCustomer && (+ !!canEditCustomer && (<Buttoncolor="secondary"variant="flat"@@ -95,23 +95,21 @@ const OrderCustomer = decorate<OrderCustomerProps>(<CardTitletitle={i18n.t("Shipping Address")}toolbar={- !!editCustomer && (- <Button- color="secondary"- variant="flat"- onClick={onShippingAddressEdit}- disabled={!onShippingAddressEdit && client === undefined}- >- {i18n.t("Edit")}- </Button>- )+ <Button+ color="secondary"+ variant="flat"+ onClick={onShippingAddressEdit}+ disabled={!onShippingAddressEdit && client === undefined}+ >+ {i18n.t("Edit")}+ </Button>}/><CardContent>- {!shippingAddress ? (- <>- <Skeleton />- </>+ {shippingAddress === undefined ? (+ <Skeleton />+ ) : shippingAddress === null ? (+ <Typography>{i18n.t("Not set")}</Typography>) : (<>{shippingAddress.companyName && (@@ -142,23 +140,21 @@ const OrderCustomer = decorate<OrderCustomerProps>(<CardTitletitle={i18n.t("Billing Address")}toolbar={- !!editCustomer && (- <Button- color="secondary"- variant="flat"- onClick={onBillingAddressEdit}- disabled={!onBillingAddressEdit && client === undefined}- >- {i18n.t("Edit")}- </Button>- )+ <Button+ color="secondary"+ variant="flat"+ onClick={onBillingAddressEdit}+ disabled={!onBillingAddressEdit && client === undefined}+ >+ {i18n.t("Edit")}+ </Button>}/><CardContent>- {!billingAddress ? (- <>- <Skeleton />- </>+ {billingAddress === undefined ? (+ <Skeleton />+ ) : billingAddress === null ? (+ <Typography>{i18n.t("Not set")}</Typography>) : shippingAddress.id === billingAddress.id ? (<Typography>{i18n.t("Same as shipping address")}</Typography>) : (diff --git a/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx b/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsxindex a368da15f3..edf93bf170 100644--- a/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx+++ b/saleor/static/dashboard-next/orders/components/OrderDetailsPage/OrderDetailsPage.tsx@@ -8,6 +8,7 @@ import Form from "../../../components/Form";import PageHeader from "../../../components/PageHeader";import Skeleton from "../../../components/Skeleton";import Toggle from "../../../components/Toggle";+import { AddressTypeInput } from "../../../customers";import i18n from "../../../i18n";import { maybe } from "../../../misc";import { OrderEvents, OrderStatus } from "../../../types/globalTypes";@@ -31,6 +32,7 @@ import OrderProductAddDialog, {} from "../OrderProductAddDialog";import OrderShippingMethodEditDialog from "../OrderShippingMethodEditDialog";import OrderSummary from "../OrderSummary";+import { UserError } from "../../..";interface TaxedMoneyType {gross: {@@ -137,10 +139,12 @@ interface OrderDetailsPageProps {stockQuantity: number;}>;variantsLoading?: boolean;+ errors: UserError[];fetchUsers?(value: string);fetchShippingMethods?(value: string);fetchVariants?(value: string);onBack();+ onBillingAddressEdit(data: AddressTypeInput);onCreate?();onOrderFulfill(data: OrderFulfillFormData);onOrderLineChange?(id: string): (value: string) => () => void;@@ -151,6 +155,7 @@ interface OrderDetailsPageProps {onPaymentCapture(data: OrderPaymentFormData);onPaymentRefund(data: OrderPaymentFormData);onPaymentRelease?();+ onShippingAddressEdit(data: AddressTypeInput);onOrderCancel?();onNoteAdd(data: HistoryFormData);}@@ -240,6 +245,7 @@ class OrderDetailsPageComponent extends React.Component<const {classes,countries,+ errors,order,shippingMethods,user,@@ -250,6 +256,7 @@ class OrderDetailsPageComponent extends React.Component<fetchUsers,fetchVariants,onBack,+ onBillingAddressEdit,onCreate,onNoteAdd,onOrderCancel,@@ -261,7 +268,8 @@ class OrderDetailsPageComponent extends React.Component<onPaymentRefund,onPaymentRelease,onProductAdd,- onProductClick+ onProductClick,+ onShippingAddressEdit} = this.props;const {openedBillingAddressEditDialog,@@ -457,7 +465,7 @@ class OrderDetailsPageComponent extends React.Component<<OrderCustomerbillingAddress={maybe(() => order.billingAddress)}client={maybe(() => order.user)}- editCustomer={isDraft}+ canEditCustomer={isDraft}shippingAddress={maybe(() => order.shippingAddress)}onBillingAddressEdit={this.toggleBillingAddressEditDialog}onCustomerEditClick={this.toggleCustomerEditDialog}@@ -484,39 +492,40 @@ class OrderDetailsPageComponent extends React.Component<)}</Form><Form- initial={- order &&- order.shippingAddress &&- transformAddressToForm(order.shippingAddress)- }+ initial={transformAddressToForm(+ maybe(() => order.shippingAddress)+ )}+ errors={errors}+ onSubmit={onShippingAddressEdit}>- {({ change, data, submit }) => (+ {({ change, data, errors: formErrors, submit }) => (<OrderAddressEditDialogcountries={countries}data={data}+ errors={formErrors}open={openedShippingAddressEditDialog}variant="shipping"+ onChange={change}onClose={this.toggleShippingAddressEditDialog}onConfirm={submit}- onChange={change}/>)}</Form><Form- initial={- order.billingAddress &&- transformAddressToForm(order.billingAddress)- }+ initial={transformAddressToForm(order.billingAddress)}+ errors={errors}+ onSubmit={onBillingAddressEdit}>- {({ change, data, submit }) => (+ {({ change, data, errors: formErrors, submit }) => (<OrderAddressEditDialogcountries={countries}data={data}+ errors={formErrors}open={openedBillingAddressEditDialog}variant="billing"+ onChange={change}onClose={this.toggleBillingAddressEditDialog}onConfirm={submit}- onChange={change}/>)}</Form>diff --git a/saleor/static/dashboard-next/orders/containers/OrderOperations.tsx b/saleor/static/dashboard-next/orders/containers/OrderOperations.tsxindex ee42cd2d02..658fcf5864 100644--- a/saleor/static/dashboard-next/orders/containers/OrderOperations.tsx+++ b/saleor/static/dashboard-next/orders/containers/OrderOperations.tsx@@ -19,12 +19,14 @@ import {} from "../../gql-types";import { maybe } from "../../misc";import { OrderAddNote, OrderAddNoteVariables } from "../types/OrderAddNote";+import { OrderUpdate, OrderUpdateVariables } from "../types/OrderUpdate";import OrderCancelMutationProvider from "./OrderCancel";import OrderCreateFulfillmentProvider from "./OrderCreateFulfillment";import OrderNoteAddProvider from "./OrderNoteAdd";import OrderPaymentCaptureProvider from "./OrderPaymentCapture";import OrderPaymentRefundProvider from "./OrderPaymentRefund";import OrderReleaseMutationProvider from "./OrderRelease";+import OrderUpdateProvider from "./OrderUpdate";interface OrderOperationsProps extends MutationProviderProps {order: string;@@ -53,6 +55,10 @@ interface OrderOperationsProps extends MutationProviderProps {OrderReleaseMutation,OrderReleaseMutationVariables>;+ orderUpdate: PartialMutationProviderOutput<+ OrderUpdate,+ OrderUpdateVariables+ >;}>;onFulfillmentCreate: (data: OrderCreateFulfillmentMutation) => void;onOrderCancel: (data: OrderCancelMutation) => void;@@ -60,6 +66,7 @@ interface OrderOperationsProps extends MutationProviderProps {onNoteAdd: (data: OrderAddNote) => void;onPaymentCapture: (data: OrderCaptureMutation) => void;onPaymentRefund: (data: OrderRefundMutation) => void;+ onUpdate: (data: OrderUpdate) => void;}const OrderOperations: React.StatelessComponent<OrderOperationsProps> = ({@@ -69,7 +76,8 @@ const OrderOperations: React.StatelessComponent<OrderOperationsProps> = ({onFulfillmentCreate,onNoteAdd,onPaymentCapture,- onPaymentRefund+ onPaymentRefund,+ onUpdate}) => (<OrderReleaseMutationProvider>{orderRelease => (@@ -97,70 +105,89 @@ const OrderOperations: React.StatelessComponent<OrderOperationsProps> = ({onError={onError}onSuccess={onNoteAdd}>- {addNote =>- children({- errors: [- ...maybe(- () =>- createFulfillment.data.fulfillmentCreate- .errors,- []- ),- ...maybe(- () => paymentCapture.data.orderCapture.errors,- []- ),- ...maybe(- () => paymentRefund.data.orderRefund.errors,- []- ),- ...maybe(- () => addNote.data.orderAddNote.errors,- []- )- ],- orderAddNote: {- data: addNote.data,- loading: addNote.loading,- mutate: variables => addNote.mutate({ variables })- },- orderCancel: {- data: orderCancel.data,- loading: orderCancel.loading,- mutate: variables =>- orderCancel.mutate({ variables })- },- orderCreateFulfillment: {- data: createFulfillment.data,- loading: createFulfillment.loading,- mutate: variables =>- createFulfillment.mutate({- variables: {- ...variables,- input: { ...variables.input, order }- }- })- },- orderPaymentCapture: {- data: paymentCapture.data,- loading: paymentCapture.loading,- mutate: variables =>- paymentCapture.mutate({ variables })- },- orderPaymentRefund: {- data: paymentRefund.data,- loading: paymentRefund.loading,- mutate: variables =>- paymentRefund.mutate({ variables })- },- orderRelease: {- data: orderRelease.data,- loading: orderRelease.loading,- mutate: variables =>- orderRelease.mutate({ variables })+ {addNote => (+ <OrderUpdateProvider+ onError={onError}+ onSuccess={onUpdate}+ >+ {update =>+ children({+ errors: [+ ...maybe(+ () =>+ createFulfillment.data.fulfillmentCreate+ .errors,+ []+ ),+ ...maybe(+ () =>+ paymentCapture.data.orderCapture.errors,+ []+ ),+ ...maybe(+ () => paymentRefund.data.orderRefund.errors,+ []+ ),+ ...maybe(+ () => addNote.data.orderAddNote.errors,+ []+ ),+ ...maybe(+ () => update.data.orderUpdate.errors,+ []+ )+ ],+ orderAddNote: {+ data: addNote.data,+ loading: addNote.loading,+ mutate: variables =>+ addNote.mutate({ variables })+ },+ orderCancel: {+ data: orderCancel.data,+ loading: orderCancel.loading,+ mutate: variables =>+ orderCancel.mutate({ variables })+ },+ orderCreateFulfillment: {+ data: createFulfillment.data,+ loading: createFulfillment.loading,+ mutate: variables =>+ createFulfillment.mutate({+ variables: {+ ...variables,+ input: { ...variables.input, order }+ }+ })+ },+ orderPaymentCapture: {+ data: paymentCapture.data,+ loading: paymentCapture.loading,+ mutate: variables =>+ paymentCapture.mutate({ variables })+ },+ orderPaymentRefund: {+ data: paymentRefund.data,+ loading: paymentRefund.loading,+ mutate: variables =>+ paymentRefund.mutate({ variables })+ },+ orderRelease: {+ data: orderRelease.data,+ loading: orderRelease.loading,+ mutate: variables =>+ orderRelease.mutate({ variables })+ },+ orderUpdate: {+ data: update.data,+ loading: update.loading,+ mutate: variables =>+ update.mutate({ variables })+ }+ })}- })- }+ </OrderUpdateProvider>+ )}</OrderNoteAddProvider>)}</OrderCreateFulfillmentProvider>diff --git a/saleor/static/dashboard-next/orders/containers/OrderUpdate.tsx b/saleor/static/dashboard-next/orders/containers/OrderUpdate.tsxnew file mode 100644index 0000000000..962e30b3c6--- /dev/null+++ b/saleor/static/dashboard-next/orders/containers/OrderUpdate.tsx@@ -0,0 +1,34 @@+import * as React from "react";++import { TypedOrderUpdateMutation } from "../mutations";+import { OrderUpdate, OrderUpdateVariables } from "../types/OrderUpdate";++import {+ PartialMutationProviderProps,+ PartialMutationProviderRenderProps+} from "../..";++interface OrderUpdateProviderProps+ extends PartialMutationProviderProps<OrderUpdate> {+ children: PartialMutationProviderRenderProps<+ OrderUpdate,+ OrderUpdateVariables+ >;+}++const OrderUpdateProvider: React.StatelessComponent<+ OrderUpdateProviderProps+> = ({ children, onError, onSuccess }) => (+ <TypedOrderUpdateMutation onCompleted={onSuccess} onError={onError}>+ {(mutate, { data, error, loading }) =>+ children({+ data,+ error,+ loading,+ mutate+ })+ }+ </TypedOrderUpdateMutation>+);++export default OrderUpdateProvider;diff --git a/saleor/static/dashboard-next/orders/index.tsx b/saleor/static/dashboard-next/orders/index.tsxindex 5750ff1142..ac732e7021 100644--- a/saleor/static/dashboard-next/orders/index.tsx+++ b/saleor/static/dashboard-next/orders/index.tsx@@ -3,6 +3,7 @@ import * as React from "react";import { Route, RouteComponentProps, Switch } from "react-router-dom";import i18n from "../i18n";+import { maybe } from "../misc";import { FulfillmentStatus, OrderStatus } from "../types/globalTypes";import OrderDetailsComponent from "./views/OrderDetails";import OrderListComponent from "./views/OrderList";@@ -118,8 +119,17 @@ export const transformFulfillmentStatus = (status: string) => {};export const transformAddressToForm = (data: AddressType) => ({- ...data,- phone: data.phone+ city: maybe(() => data.city, ""),+ cityArea: maybe(() => data.cityArea, ""),+ companyName: maybe(() => data.companyName, ""),+ country: maybe(() => data.country, ""),+ countryArea: maybe(() => data.countryArea, ""),+ firstName: maybe(() => data.firstName, ""),+ lastName: maybe(() => data.lastName, ""),+ phone: maybe(() => data.phone, ""),+ postalCode: maybe(() => data.postalCode, ""),+ streetAddress1: maybe(() => data.streetAddress1, ""),+ streetAddress2: maybe(() => data.streetAddress2, "")});export const orderListUrl = "/orders/";diff --git a/saleor/static/dashboard-next/orders/mutations.ts b/saleor/static/dashboard-next/orders/mutations.tsindex 8de9b4299c..584bbac9e7 100644--- a/saleor/static/dashboard-next/orders/mutations.ts+++ b/saleor/static/dashboard-next/orders/mutations.ts@@ -1,7 +1,11 @@import gql from "graphql-tag";import { TypedMutation } from "../mutations";-import { fragmentOrderDetails, fragmentOrderEvent } from "./queries";+import {+ fragmentAddress,+ fragmentOrderDetails,+ fragmentOrderEvent+} from "./queries";import { OrderAddNote, OrderAddNoteVariables } from "./types/OrderAddNote";import { OrderCancel, OrderCancelVariables } from "./types/OrderCancel";import { OrderCapture, OrderCaptureVariables } from "./types/OrderCapture";@@ -11,6 +15,7 @@ import {} from "./types/OrderCreateFulfillment";import { OrderRefund, OrderRefundVariables } from "./types/OrderRefund";import { OrderRelease, OrderReleaseVariables } from "./types/OrderRelease";+import { OrderUpdate, OrderUpdateVariables } from "./types/OrderUpdate";const orderCancelMutation = gql`${fragmentOrderDetails}@@ -112,7 +117,33 @@ const orderAddNoteMutation = gql`}}`;++const orderUpdateMutation = gql`+ ${fragmentAddress}+ mutation OrderUpdate($id: ID!, $input: OrderUpdateInput!) {+ orderUpdate(id: $id, input: $input) {+ errors {+ field+ message+ }+ order {+ id+ userEmail+ billingAddress {+ ...AddressFragment+ }+ shippingAddress {+ ...AddressFragment+ }+ }+ }+ }+`;export const TypedOrderAddNoteMutation = TypedMutation<OrderAddNote,OrderAddNoteVariables>(orderAddNoteMutation);+export const TypedOrderUpdateMutation = TypedMutation<+ OrderUpdate,+ OrderUpdateVariables+>(orderUpdateMutation);diff --git a/saleor/static/dashboard-next/orders/queries.ts b/saleor/static/dashboard-next/orders/queries.tsindex 92ca96f5ff..f731072083 100644--- a/saleor/static/dashboard-next/orders/queries.ts+++ b/saleor/static/dashboard-next/orders/queries.ts@@ -57,23 +57,30 @@ export const fragmentOrderEvent = gql`}}`;+export const fragmentAddress = gql`+ fragment AddressFragment on Address {+ id+ city+ cityArea+ companyName+ country+ countryArea+ firstName+ lastName+ phone+ postalCode+ streetAddress1+ streetAddress2+ }+`;+export const fragmentOrderDetails = gql`+ ${fragmentAddress}${fragmentOrderEvent}fragment OrderDetailsFragment on Order {idbillingAddress {- id- city- cityArea- companyName- country- countryArea- firstName- lastName- phone- postalCode- streetAddress1- streetAddress2+ ...AddressFragment}createdevents {@@ -120,18 +127,7 @@ export const fragmentOrderDetails = gql`numberpaymentStatusshippingAddress {- id- city- cityArea- companyName- country- countryArea- firstName- lastName- phone- postalCode- streetAddress1- streetAddress2+ ...AddressFragment}shippingMethod {id@@ -181,6 +177,12 @@ export const orderDetailsQuery = gql`order(id: $id) {...OrderDetailsFragment}+ shop {+ countries {+ code+ country+ }+ }}`;export const TypedOrderDetailsQuery = TypedQuery<diff --git a/saleor/static/dashboard-next/orders/types/AddressFragment.ts b/saleor/static/dashboard-next/orders/types/AddressFragment.tsnew file mode 100644index 0000000000..84c6c1df1c--- /dev/null+++ b/saleor/static/dashboard-next/orders/types/AddressFragment.ts@@ -0,0 +1,24 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { AddressCountry } from "./../../types/globalTypes";++// ====================================================+// GraphQL fragment: AddressFragment+// ====================================================++export interface AddressFragment {+ __typename: "Address";+ id: string;+ city: string;+ cityArea: string;+ companyName: string;+ country: AddressCountry;+ countryArea: string;+ firstName: string;+ lastName: string;+ phone: string | null;+ postalCode: string;+ streetAddress1: string;+ streetAddress2: string;+}diff --git a/saleor/static/dashboard-next/orders/types/OrderDetails.ts b/saleor/static/dashboard-next/orders/types/OrderDetails.tsindex 1a9ae53f12..757388cf9f 100644--- a/saleor/static/dashboard-next/orders/types/OrderDetails.ts+++ b/saleor/static/dashboard-next/orders/types/OrderDetails.ts@@ -211,8 +211,20 @@ export interface OrderDetails_order {user: OrderDetails_order_user | null;}+export interface OrderDetails_shop_countries {+ __typename: "CountryDisplay";+ code: string;+ country: string;+}++export interface OrderDetails_shop {+ __typename: "Shop";+ countries: (OrderDetails_shop_countries | null)[];+}+export interface OrderDetails {order: OrderDetails_order | null;+ shop: OrderDetails_shop | null;}export interface OrderDetailsVariables {diff --git a/saleor/static/dashboard-next/orders/types/OrderUpdate.ts b/saleor/static/dashboard-next/orders/types/OrderUpdate.tsnew file mode 100644index 0000000000..46523a9f05--- /dev/null+++ b/saleor/static/dashboard-next/orders/types/OrderUpdate.ts@@ -0,0 +1,69 @@+/* tslint:disable */+// This file was automatically generated and should not be edited.++import { OrderUpdateInput, AddressCountry } from "./../../types/globalTypes";++// ====================================================+// GraphQL mutation operation: OrderUpdate+// ====================================================++export interface OrderUpdate_orderUpdate_errors {+ __typename: "Error";+ field: string | null;+ message: string | null;+}++export interface OrderUpdate_orderUpdate_order_billingAddress {+ __typename: "Address";+ id: string;+ city: string;+ cityArea: string;+ companyName: string;+ country: AddressCountry;+ countryArea: string;+ firstName: string;+ lastName: string;+ phone: string | null;+ postalCode: string;+ streetAddress1: string;+ streetAddress2: string;+}++export interface OrderUpdate_orderUpdate_order_shippingAddress {+ __typename: "Address";+ id: string;+ city: string;+ cityArea: string;+ companyName: string;+ country: AddressCountry;+ countryArea: string;+ firstName: string;+ lastName: string;+ phone: string | null;+ postalCode: string;+ streetAddress1: string;+ streetAddress2: string;+}++export interface OrderUpdate_orderUpdate_order {+ __typename: "Order";+ id: string;+ userEmail: string | null;+ billingAddress: OrderUpdate_orderUpdate_order_billingAddress | null;+ shippingAddress: OrderUpdate_orderUpdate_order_shippingAddress | null;+}++export interface OrderUpdate_orderUpdate {+ __typename: "OrderUpdate";+ errors: (OrderUpdate_orderUpdate_errors | null)[] | null;+ order: OrderUpdate_orderUpdate_order | null;+}++export interface OrderUpdate {+ orderUpdate: OrderUpdate_orderUpdate | null;+}++export interface OrderUpdateVariables {+ id: string;+ input: OrderUpdateInput;+}diff --git a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx b/saleor/static/dashboard-next/orders/views/OrderDetails.tsxindex 881161dd6f..411b88cc9b 100644--- a/saleor/static/dashboard-next/orders/views/OrderDetails.tsx+++ b/saleor/static/dashboard-next/orders/views/OrderDetails.tsx@@ -21,6 +21,7 @@ import {TypedOrderShippingMethodsQuery} from "../queries";import { OrderAddNote } from "../types/OrderAddNote";+import { OrderUpdate } from "../types/OrderUpdate";interface OrderDetailsProps {id: string;@@ -115,6 +116,17 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({});}};+ const handleUpdate = (data: OrderUpdate) => {+ if (+ !maybe(() => data.orderUpdate.errors.length)+ ) {+ pushMessage({+ text: i18n.t("Order succesfully updated", {+ context: "notification"+ })+ });+ }+ };return (<OrderOperationsorder={id}@@ -125,16 +137,20 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({onOrderRelease={handleOrderRelease}onPaymentCapture={handlePaymentCapture}onPaymentRefund={handlePaymentRefund}+ onUpdate={handleUpdate}>{({+ errors,+ orderAddNote,+ orderCancel,orderCreateFulfillment,orderPaymentCapture,orderPaymentRefund,- orderCancel,orderRelease,- orderAddNote+ orderUpdate}) => (<OrderDetailsPage+ errors={errors}onNoteAdd={variables =>orderAddNote.mutate({input: variables,@@ -166,6 +182,13 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({)}onBack={() => navigate(orderListUrl)}order={order}+ countries={maybe(+ () => data.shop.countries,+ []+ ).map(country => ({+ code: country.code,+ label: country.country+ }))}shippingMethods={maybe(() =>([] as Array<{id: string;@@ -224,6 +247,22 @@ export const OrderDetails: React.StatelessComponent<OrderDetailsProps> = ({onProductAdd={() => undefined}onProductClick={id => () =>navigate(productUrl(id))}+ onBillingAddressEdit={variables =>+ orderUpdate.mutate({+ id,+ input: {+ billingAddress: variables+ }+ })+ }+ onShippingAddressEdit={variables =>+ orderUpdate.mutate({+ id,+ input: {+ shippingAddress: variables+ }+ })+ }/>)}</OrderOperations>diff --git a/saleor/static/dashboard-next/types/globalTypes.ts b/saleor/static/dashboard-next/types/globalTypes.tsindex c01c67fac0..ed55b00263 100644--- a/saleor/static/dashboard-next/types/globalTypes.ts+++ b/saleor/static/dashboard-next/types/globalTypes.ts@@ -333,6 +333,20 @@ export enum TaxRateType {WATER = "WATER",}+export interface AddressInput {+ firstName?: string | null;+ lastName?: string | null;+ companyName?: string | null;+ streetAddress1?: string | null;+ streetAddress2?: string | null;+ city?: string | null;+ cityArea?: string | null;+ postalCode?: string | null;+ country?: string | null;+ countryArea?: string | null;+ phone?: string | null;+}+export interface AttributeValueInput {slug: string;value: string;@@ -354,6 +368,12 @@ export interface OrderAddNoteInput {message?: string | null;}+export interface OrderUpdateInput {+ billingAddress?: AddressInput | null;+ userEmail?: string | null;+ shippingAddress?: AddressInput | null;+}+export interface ProductTypeInput {name?: string | null;hasVariants?: boolean | null;