From 0e054cc1e47ca98fbff6ed25893fd1a8dadc1e7a Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Thu, 6 May 2021 13:38:15 +0200 Subject: [PATCH] Saleor 2798 user addresses selection for draft order (#1082) * Create user addresses select modal * Prepare user addresses select modal form * Add user addresses select modal to order draft details page * Update draft order validation of adresses in edit modal * Add Customer Change modal * Update snapshots and messages * Indication of address form errors by address type * Refactor addresses submiting * Refactor address transform functions * Add data-testids to addresses change dialog * Update customer address choice style * Trigger CI * Update customer addresses edit flow * Move styles outside of component files * Refactor after review * Refactor after review * Do not update customer if the same selected * Handle setting adress after edit customer with no addresses * Trigger CI --- CHANGELOG.md | 1 + locale/defaultMessages.json | 60 +++- schema.graphql | 7 +- .../NewPasswordPage.stories.tsx | 3 +- src/auth/types/ExternalAuthenticationUrl.ts | 3 +- src/auth/types/ExternalObtainAccessTokens.ts | 3 +- src/auth/types/RequestPasswordReset.ts | 3 +- src/auth/types/SetPassword.ts | 3 +- src/components/AddressEdit/AddressEdit.tsx | 1 + .../CustomerAddressChoiceCard.tsx | 34 +++ .../CustomerAddressChoiceCard/index.ts | 2 + .../CustomerAddressChoiceCard/styles.ts | 16 ++ .../CustomerAddressDialog.tsx | 13 +- .../CustomerCreatePage/CustomerCreatePage.tsx | 6 +- src/customers/queries.ts | 4 + src/customers/types.ts | 1 + src/customers/types/BulkRemoveCustomers.ts | 3 +- src/customers/types/CreateCustomer.ts | 3 +- src/customers/types/CreateCustomerAddress.ts | 3 +- src/customers/types/RemoveCustomer.ts | 3 +- src/customers/types/RemoveCustomerAddress.ts | 3 +- .../types/SetCustomerDefaultAddress.ts | 1 + src/customers/types/UpdateCustomer.ts | 3 +- src/customers/types/UpdateCustomerAddress.ts | 3 +- src/customers/views/CustomerAddresses.tsx | 6 +- src/fragments/errors.ts | 2 + src/fragments/types/AccountErrorFragment.ts | 3 +- src/fragments/types/OrderErrorFragment.ts | 3 +- src/hooks/useAddressValidation.ts | 16 +- src/intl.ts | 8 + src/misc.ts | 18 +- .../OrderAddressEditDialog.tsx | 17 +- .../OrderCustomer/OrderCustomer.tsx | 11 +- .../OrderCustomerAddressEdit.tsx | 141 ++++++++++ ...derCustomerAddressesEditDialog.stories.tsx | 46 +++ .../OrderCustomerAddressesEditDialog.tsx | 262 ++++++++++++++++++ .../OrderCustomerAddressesEditDialog/form.tsx | 202 ++++++++++++++ .../OrderCustomerAddressesEditDialog/index.ts | 2 + .../messages.ts | 41 +++ .../styles.ts | 16 ++ .../OrderCustomerChangeDialog.stories.tsx | 24 ++ .../OrderCustomerChangeDialog.tsx | 85 ++++++ .../OrderCustomerChangeDialog/form.tsx | 72 +++++ .../OrderCustomerChangeDialog/messages.ts | 23 ++ .../OrderCustomerChangeDialog/styles.ts | 16 ++ .../OrderDetailsPage/OrderDetailsPage.tsx | 4 - .../OrderDraftPage/OrderDraftPage.tsx | 9 +- .../OrderFulfillPage.stories.tsx | 3 +- src/orders/fixtures.ts | 13 +- src/orders/types/FulfillOrder.ts | 3 +- src/orders/types/FulfillmentReturnProducts.ts | 3 +- src/orders/types/OrderAddNote.ts | 3 +- src/orders/types/OrderCancel.ts | 3 +- src/orders/types/OrderCapture.ts | 3 +- src/orders/types/OrderConfirm.ts | 3 +- src/orders/types/OrderDiscountAdd.ts | 3 +- src/orders/types/OrderDiscountDelete.ts | 3 +- src/orders/types/OrderDiscountUpdate.ts | 3 +- src/orders/types/OrderDraftBulkCancel.ts | 3 +- src/orders/types/OrderDraftCancel.ts | 3 +- src/orders/types/OrderDraftCreate.ts | 3 +- src/orders/types/OrderDraftFinalize.ts | 3 +- src/orders/types/OrderDraftUpdate.ts | 3 +- src/orders/types/OrderFulfillmentCancel.ts | 3 +- .../types/OrderFulfillmentRefundProducts.ts | 3 +- .../types/OrderFulfillmentUpdateTracking.ts | 3 +- src/orders/types/OrderLineDelete.ts | 3 +- src/orders/types/OrderLineDiscountRemove.ts | 3 +- src/orders/types/OrderLineDiscountUpdate.ts | 3 +- src/orders/types/OrderLineUpdate.ts | 3 +- src/orders/types/OrderLinesAdd.ts | 3 +- src/orders/types/OrderMarkAsPaid.ts | 3 +- src/orders/types/OrderRefund.ts | 3 +- src/orders/types/OrderShippingMethodUpdate.ts | 3 +- src/orders/types/OrderUpdate.ts | 3 +- src/orders/types/OrderVoid.ts | 3 +- src/orders/urls.ts | 2 + .../views/OrderDetails/OrderAddressFields.tsx | 5 +- .../OrderDetails/OrderDetailsMessages.tsx | 2 +- .../OrderDetails/OrderDraftDetails/index.tsx | 107 ++++++- .../ProductExportDialog/messages.ts | 5 - .../ShippingZoneAddWarehouseDialog.tsx | 6 +- src/staff/types/ChangeStaffPassword.ts | 3 +- src/staff/types/StaffAvatarDelete.ts | 3 +- src/staff/types/StaffAvatarUpdate.ts | 3 +- .../__snapshots__/Stories.test.ts.snap | 24 ++ .../stories/components/AddressEdit.tsx | 6 +- .../customers/CustomerAddressDialog.tsx | 3 +- .../stories/customers/CustomerCreatePage.tsx | 3 +- .../stories/customers/CustomerDetailsPage.tsx | 3 +- .../stories/orders/OrderCancelDialog.tsx | 3 +- .../stories/orders/OrderDetailsPage.tsx | 3 +- .../stories/orders/OrderDraftCancelDialog.tsx | 3 +- .../orders/OrderDraftPage/OrderDraftPage.tsx | 3 +- .../orders/OrderFulfillmentCancelDialog.tsx | 3 +- .../stories/orders/OrderFulfillmentDialog.tsx | 6 +- .../orders/OrderFulfillmentTrackingDialog.tsx | 6 +- .../stories/orders/OrderMarkAsPaidDialog.tsx | 3 +- .../stories/orders/OrderPaymentDialog.tsx | 6 +- .../stories/orders/OrderPaymentVoidDialog.tsx | 3 +- .../stories/orders/OrderProductAddDialog.tsx | 3 +- .../orders/OrderShippingMethodEditDialog.tsx | 6 +- src/types/globalTypes.ts | 1 - src/utils/errors/staff.ts | 3 +- 104 files changed, 1373 insertions(+), 160 deletions(-) create mode 100644 src/customers/components/CustomerAddressChoiceCard/CustomerAddressChoiceCard.tsx create mode 100644 src/customers/components/CustomerAddressChoiceCard/index.ts create mode 100644 src/customers/components/CustomerAddressChoiceCard/styles.ts create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressEdit.tsx create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.stories.tsx create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/form.tsx create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/index.ts create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/messages.ts create mode 100644 src/orders/components/OrderCustomerAddressesEditDialog/styles.ts create mode 100644 src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.stories.tsx create mode 100644 src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.tsx create mode 100644 src/orders/components/OrderCustomerChangeDialog/form.tsx create mode 100644 src/orders/components/OrderCustomerChangeDialog/messages.ts create mode 100644 src/orders/components/OrderCustomerChangeDialog/styles.ts diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ad7aadd5d9..0ae3b6e467c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ All notable, unreleased changes to this project will be documented in this file. - useFormset.setItemValue wrong updates, - Drop deprecated fields - #1071 by @jwm0 - Add service worker - #1073 by @dominik-zeglen +- Choosing user shipping and billing addresses for draft order - #1082 by @orzechdev # 2.11.1 diff --git a/locale/defaultMessages.json b/locale/defaultMessages.json index 805fb21fe75..3447035fe60 100644 --- a/locale/defaultMessages.json +++ b/locale/defaultMessages.json @@ -370,10 +370,6 @@ "context": "product field", "string": "Export Variant Weight" }, - "productExportFieldVisibility": { - "context": "product field", - "string": "Visibility" - }, "productStockHeader": { "context": "product stock, section header", "string": "Inventory" @@ -2460,6 +2456,10 @@ "context": "button", "string": "Refresh" }, + "src_dot_continue": { + "context": "button", + "string": "Continue" + }, "src_dot_create": { "context": "button", "string": "Create" @@ -3377,6 +3377,54 @@ "context": "section header", "string": "Sales channel" }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_billingAddressDescription": { + "context": "dialog content", + "string": "Add a new address:" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_billingSameAsShipping": { + "context": "checkbox label", + "string": "Billing address same as shipping address" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_customerAddress": { + "context": "address type", + "string": "Use one of customer addresses" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_customerBillingAddressDescription": { + "context": "dialog content", + "string": "Select one of customer addresses or add a new address:" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_customerShippingAddressDescription": { + "context": "dialog content", + "string": "Which address would you like to use as shipping address for selected customer:" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_newAddress": { + "context": "address type", + "string": "Add new address" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_shippingAddressDescription": { + "context": "dialog content", + "string": "This customer doesn’t have any shipping addresses. Provide address for order:" + }, + "src_dot_orders_dot_components_dot_OrderCustomerAddressesEditDialog_dot_title": { + "context": "dialog header", + "string": "Shipping address for order" + }, + "src_dot_orders_dot_components_dot_OrderCustomerChangeDialog_dot_changeAddress": { + "context": "option label", + "string": "Change address" + }, + "src_dot_orders_dot_components_dot_OrderCustomerChangeDialog_dot_description": { + "context": "dialog description", + "string": "You have changed customer assigned to this order. What would you like to do with the shipping address?" + }, + "src_dot_orders_dot_components_dot_OrderCustomerChangeDialog_dot_keepAddress": { + "context": "option label", + "string": "Keep address" + }, + "src_dot_orders_dot_components_dot_OrderCustomerChangeDialog_dot_title": { + "context": "dialog header", + "string": "Changed Customer" + }, "src_dot_orders_dot_components_dot_OrderCustomerNote_dot_1505053535": { "string": "No notes from customer" }, @@ -5802,6 +5850,10 @@ "src_dot_savedChanges": { "string": "Saved changes" }, + "src_dot_select": { + "context": "select option, button", + "string": "Select" + }, "src_dot_selectAll": { "context": "select all options, button", "string": "Select All" diff --git a/schema.graphql b/schema.graphql index 8cf7476336c..928c5a8c6ae 100644 --- a/schema.graphql +++ b/schema.graphql @@ -34,6 +34,7 @@ type AccountError { field: String message: String code: AccountErrorCode! + addressType: AddressTypeEnum } enum AccountErrorCode { @@ -982,6 +983,7 @@ type CheckoutError { message: String code: CheckoutErrorCode! variants: [ID!] + addressType: AddressTypeEnum } enum CheckoutErrorCode { @@ -3105,6 +3107,7 @@ type OrderError { warehouse: ID orderLine: ID variants: [ID!] + addressType: AddressTypeEnum } enum OrderErrorCode { @@ -4198,7 +4201,6 @@ enum ProductFieldEnum { DESCRIPTION PRODUCT_TYPE CATEGORY - VISIBLE PRODUCT_WEIGHT COLLECTIONS CHARGE_TAXES @@ -5305,6 +5307,7 @@ type StaffError { field: String message: String code: AccountErrorCode! + addressType: AddressTypeEnum permissions: [PermissionEnum!] groups: [ID!] users: [ID!] @@ -6128,4 +6131,4 @@ union _Entity = Address | User | Group | App | ProductVariant | Product | Produc type _Service { sdl: String -} \ No newline at end of file +} diff --git a/src/auth/components/NewPasswordPage/NewPasswordPage.stories.tsx b/src/auth/components/NewPasswordPage/NewPasswordPage.stories.tsx index 293200bc1bd..83fec54f512 100644 --- a/src/auth/components/NewPasswordPage/NewPasswordPage.stories.tsx +++ b/src/auth/components/NewPasswordPage/NewPasswordPage.stories.tsx @@ -20,7 +20,8 @@ storiesOf("Views / Authentication / Set up a new password", module) errors={["password"].map(field => ({ __typename: "AccountError", code: AccountErrorCode.PASSWORD_TOO_SHORT, - field + field, + addressType: null }))} disabled={false} onSubmit={() => undefined} diff --git a/src/auth/types/ExternalAuthenticationUrl.ts b/src/auth/types/ExternalAuthenticationUrl.ts index 23f920d729b..fe25b21ecdb 100644 --- a/src/auth/types/ExternalAuthenticationUrl.ts +++ b/src/auth/types/ExternalAuthenticationUrl.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: ExternalAuthenticationUrl @@ -13,6 +13,7 @@ export interface ExternalAuthenticationUrl_externalAuthenticationUrl_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface ExternalAuthenticationUrl_externalAuthenticationUrl { diff --git a/src/auth/types/ExternalObtainAccessTokens.ts b/src/auth/types/ExternalObtainAccessTokens.ts index b75ea06607c..13523652967 100644 --- a/src/auth/types/ExternalObtainAccessTokens.ts +++ b/src/auth/types/ExternalObtainAccessTokens.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { PermissionEnum, AccountErrorCode } from "./../../types/globalTypes"; +import { PermissionEnum, AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: ExternalObtainAccessTokens @@ -35,6 +35,7 @@ export interface ExternalObtainAccessTokens_externalObtainAccessTokens_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface ExternalObtainAccessTokens_externalObtainAccessTokens { diff --git a/src/auth/types/RequestPasswordReset.ts b/src/auth/types/RequestPasswordReset.ts index 97701fd504d..a36fbe7adfe 100644 --- a/src/auth/types/RequestPasswordReset.ts +++ b/src/auth/types/RequestPasswordReset.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: RequestPasswordReset @@ -13,6 +13,7 @@ export interface RequestPasswordReset_requestPasswordReset_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface RequestPasswordReset_requestPasswordReset { diff --git a/src/auth/types/SetPassword.ts b/src/auth/types/SetPassword.ts index 23881edeb66..850e2d747dc 100644 --- a/src/auth/types/SetPassword.ts +++ b/src/auth/types/SetPassword.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode, PermissionEnum } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum, PermissionEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: SetPassword @@ -13,6 +13,7 @@ export interface SetPassword_setPassword_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface SetPassword_setPassword_user_userPermissions { diff --git a/src/components/AddressEdit/AddressEdit.tsx b/src/components/AddressEdit/AddressEdit.tsx index 287881a4124..60636993ac5 100644 --- a/src/components/AddressEdit/AddressEdit.tsx +++ b/src/components/AddressEdit/AddressEdit.tsx @@ -74,6 +74,7 @@ const AddressEdit: React.FC = props => { "streetAddress1", "streetAddress2" ]; + const formErrors = getFormErrors< keyof AddressTypeInput, AccountErrorFragment | OrderErrorFragment diff --git a/src/customers/components/CustomerAddressChoiceCard/CustomerAddressChoiceCard.tsx b/src/customers/components/CustomerAddressChoiceCard/CustomerAddressChoiceCard.tsx new file mode 100644 index 00000000000..88aa79f1237 --- /dev/null +++ b/src/customers/components/CustomerAddressChoiceCard/CustomerAddressChoiceCard.tsx @@ -0,0 +1,34 @@ +import Card from "@material-ui/core/Card"; +import CardContent from "@material-ui/core/CardContent"; +import AddressFormatter from "@saleor/components/AddressFormatter"; +import classNames from "classnames"; +import React from "react"; + +import { CustomerAddresses_user_addresses } from "../../types/CustomerAddresses"; +import { useStyles } from "./styles"; + +export interface CustomerAddressChoiceCardProps { + address: CustomerAddresses_user_addresses; + selected: boolean; + onSelect: () => void; +} + +const CustomerAddressChoiceCard: React.FC = props => { + const { address, selected, onSelect } = props; + const classes = useStyles(props); + + return ( + + + + + + ); +}; +CustomerAddressChoiceCard.displayName = "CustomerAddressChoiceCard"; +export default CustomerAddressChoiceCard; diff --git a/src/customers/components/CustomerAddressChoiceCard/index.ts b/src/customers/components/CustomerAddressChoiceCard/index.ts new file mode 100644 index 00000000000..bfc9b2554c2 --- /dev/null +++ b/src/customers/components/CustomerAddressChoiceCard/index.ts @@ -0,0 +1,2 @@ +export { default } from "./CustomerAddressChoiceCard"; +export * from "./CustomerAddressChoiceCard"; diff --git a/src/customers/components/CustomerAddressChoiceCard/styles.ts b/src/customers/components/CustomerAddressChoiceCard/styles.ts new file mode 100644 index 00000000000..2bc78adff3b --- /dev/null +++ b/src/customers/components/CustomerAddressChoiceCard/styles.ts @@ -0,0 +1,16 @@ +import { makeStyles } from "@saleor/theme"; + +export const useStyles = makeStyles( + theme => ({ + card: { + cursor: "pointer", + padding: "1px" + }, + cardSelected: { + borderColor: theme.palette.primary.main, + borderWidth: "2px", + padding: "0" + } + }), + { name: "CustomerAddressChoiceCard" } +); diff --git a/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx b/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx index f82f96fce2e..b98d2e1fb28 100644 --- a/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx +++ b/src/customers/components/CustomerAddressDialog/CustomerAddressDialog.tsx @@ -8,6 +8,7 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; +import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; @@ -16,6 +17,7 @@ import { buttonMessages } from "@saleor/intl"; import { createStyles, WithStyles, withStyles } from "@saleor/theme"; import { AddressInput } from "@saleor/types/globalTypes"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; +import { mapCountriesToChoices } from "@saleor/utils/maps"; import React from "react"; import { FormattedMessage } from "react-intl"; @@ -25,10 +27,7 @@ import { CustomerAddresses_user_addresses } from "../../types/CustomerAddresses" export interface CustomerAddressDialogProps { address: CustomerAddresses_user_addresses; confirmButtonState: ConfirmButtonTransitionState; - countries: Array<{ - code: string; - label: string; - }>; + countries: ShopInfo_shop_countries[]; errors: AccountErrorFragment[]; open: boolean; variant: "create" | "edit"; @@ -83,11 +82,7 @@ const CustomerAddressDialog = withStyles( streetAddress2: address?.streetAddress2 || "" }; - const countryChoices = - countries?.map(country => ({ - label: country.label, - value: country.code - })) || []; + const countryChoices = mapCountriesToChoices(countries || []); return ( = ({ const intl = useIntl(); const [countryDisplayName, setCountryDisplayName] = React.useState(""); - const countryChoices = countries.map(country => ({ - label: country.country, - value: country.code - })); + const countryChoices = mapCountriesToChoices(countries); const { errors: validationErrors, submit: handleSubmitWithAddress diff --git a/src/customers/queries.ts b/src/customers/queries.ts index 3bc3058faf4..ea45c37a96f 100644 --- a/src/customers/queries.ts +++ b/src/customers/queries.ts @@ -107,6 +107,10 @@ export const TypedCustomerAddressesQuery = TypedQuery< CustomerAddresses, CustomerAddressesVariables >(customerAddresses); +export const useCustomerAddressesQuery = makeQuery< + CustomerAddresses, + CustomerAddressesVariables +>(customerAddresses); const customerCreateData = gql` query CustomerCreateData { diff --git a/src/customers/types.ts b/src/customers/types.ts index a0398abbb0e..f7b7e8d5520 100644 --- a/src/customers/types.ts +++ b/src/customers/types.ts @@ -11,6 +11,7 @@ export interface AddressTypeInput { streetAddress1: string; streetAddress2?: string; } + export interface AddressType { id: string; city: string; diff --git a/src/customers/types/BulkRemoveCustomers.ts b/src/customers/types/BulkRemoveCustomers.ts index ebaf85ab397..f9b2c487f7d 100644 --- a/src/customers/types/BulkRemoveCustomers.ts +++ b/src/customers/types/BulkRemoveCustomers.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: BulkRemoveCustomers @@ -13,6 +13,7 @@ export interface BulkRemoveCustomers_customerBulkDelete_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface BulkRemoveCustomers_customerBulkDelete { diff --git a/src/customers/types/CreateCustomer.ts b/src/customers/types/CreateCustomer.ts index 187a7a584af..274f0362ae3 100644 --- a/src/customers/types/CreateCustomer.ts +++ b/src/customers/types/CreateCustomer.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { UserCreateInput, AccountErrorCode } from "./../../types/globalTypes"; +import { UserCreateInput, AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateCustomer @@ -13,6 +13,7 @@ export interface CreateCustomer_customerCreate_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface CreateCustomer_customerCreate_user { diff --git a/src/customers/types/CreateCustomerAddress.ts b/src/customers/types/CreateCustomerAddress.ts index 50a60f156a9..7df74ca3bfc 100644 --- a/src/customers/types/CreateCustomerAddress.ts +++ b/src/customers/types/CreateCustomerAddress.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AddressInput, AccountErrorCode } from "./../../types/globalTypes"; +import { AddressInput, AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateCustomerAddress @@ -13,6 +13,7 @@ export interface CreateCustomerAddress_addressCreate_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface CreateCustomerAddress_addressCreate_address_country { diff --git a/src/customers/types/RemoveCustomer.ts b/src/customers/types/RemoveCustomer.ts index 6217b2034c4..4b38af95207 100644 --- a/src/customers/types/RemoveCustomer.ts +++ b/src/customers/types/RemoveCustomer.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: RemoveCustomer @@ -13,6 +13,7 @@ export interface RemoveCustomer_customerDelete_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface RemoveCustomer_customerDelete { diff --git a/src/customers/types/RemoveCustomerAddress.ts b/src/customers/types/RemoveCustomerAddress.ts index 64833f9a9ec..7811a61f496 100644 --- a/src/customers/types/RemoveCustomerAddress.ts +++ b/src/customers/types/RemoveCustomerAddress.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: RemoveCustomerAddress @@ -13,6 +13,7 @@ export interface RemoveCustomerAddress_addressDelete_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface RemoveCustomerAddress_addressDelete_user_addresses_country { diff --git a/src/customers/types/SetCustomerDefaultAddress.ts b/src/customers/types/SetCustomerDefaultAddress.ts index c53179a6172..e48fce58caa 100644 --- a/src/customers/types/SetCustomerDefaultAddress.ts +++ b/src/customers/types/SetCustomerDefaultAddress.ts @@ -13,6 +13,7 @@ export interface SetCustomerDefaultAddress_addressSetDefault_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface SetCustomerDefaultAddress_addressSetDefault_user_addresses_country { diff --git a/src/customers/types/UpdateCustomer.ts b/src/customers/types/UpdateCustomer.ts index c62a7f8b62c..80ea149ce59 100644 --- a/src/customers/types/UpdateCustomer.ts +++ b/src/customers/types/UpdateCustomer.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { CustomerInput, AccountErrorCode } from "./../../types/globalTypes"; +import { CustomerInput, AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCustomer @@ -13,6 +13,7 @@ export interface UpdateCustomer_customerUpdate_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface UpdateCustomer_customerUpdate_user_metadata { diff --git a/src/customers/types/UpdateCustomerAddress.ts b/src/customers/types/UpdateCustomerAddress.ts index da56ad532b3..2e6aa1b6900 100644 --- a/src/customers/types/UpdateCustomerAddress.ts +++ b/src/customers/types/UpdateCustomerAddress.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AddressInput, AccountErrorCode } from "./../../types/globalTypes"; +import { AddressInput, AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCustomerAddress @@ -13,6 +13,7 @@ export interface UpdateCustomerAddress_addressUpdate_errors { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface UpdateCustomerAddress_addressUpdate_address_country { diff --git a/src/customers/views/CustomerAddresses.tsx b/src/customers/views/CustomerAddresses.tsx index ef971ddcec2..e6da862a284 100644 --- a/src/customers/views/CustomerAddresses.tsx +++ b/src/customers/views/CustomerAddresses.tsx @@ -101,11 +101,7 @@ const CustomerAddresses: React.FC = ({ {(removeCustomerAddress, removeCustomerAddressOpts) => ( {customerData => { - const countryChoices = - shop?.countries?.map(country => ({ - code: country.code, - label: country.country - })) || []; + const countryChoices = shop?.countries || []; return ( <> diff --git a/src/fragments/errors.ts b/src/fragments/errors.ts index b979a768b25..11ae6cf0e6f 100644 --- a/src/fragments/errors.ts +++ b/src/fragments/errors.ts @@ -44,6 +44,7 @@ export const accountErrorFragment = gql` fragment AccountErrorFragment on AccountError { code field + addressType } `; @@ -66,6 +67,7 @@ export const orderErrorFragment = gql` fragment OrderErrorFragment on OrderError { code field + addressType } `; diff --git a/src/fragments/types/AccountErrorFragment.ts b/src/fragments/types/AccountErrorFragment.ts index 856e377d851..8a12c6a26e2 100644 --- a/src/fragments/types/AccountErrorFragment.ts +++ b/src/fragments/types/AccountErrorFragment.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { AccountErrorCode } from "./../../types/globalTypes"; +import { AccountErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL fragment: AccountErrorFragment @@ -13,4 +13,5 @@ export interface AccountErrorFragment { __typename: "AccountError"; code: AccountErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } diff --git a/src/fragments/types/OrderErrorFragment.ts b/src/fragments/types/OrderErrorFragment.ts index bb4162d233c..dc8fb21d781 100644 --- a/src/fragments/types/OrderErrorFragment.ts +++ b/src/fragments/types/OrderErrorFragment.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL fragment: OrderErrorFragment @@ -13,4 +13,5 @@ export interface OrderErrorFragment { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } diff --git a/src/hooks/useAddressValidation.ts b/src/hooks/useAddressValidation.ts index 8a042bed852..5385dfce036 100644 --- a/src/hooks/useAddressValidation.ts +++ b/src/hooks/useAddressValidation.ts @@ -1,7 +1,11 @@ import { AddressTypeInput } from "@saleor/customers/types"; import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; -import { transformFormToAddress } from "@saleor/misc"; -import { AccountErrorCode, AddressInput } from "@saleor/types/globalTypes"; +import { transformFormToAddressInput } from "@saleor/misc"; +import { + AccountErrorCode, + AddressInput, + AddressTypeEnum +} from "@saleor/types/globalTypes"; import { add, remove } from "@saleor/utils/lists"; import { useState } from "react"; @@ -11,7 +15,8 @@ interface UseAddressValidation { } function useAddressValidation( - onSubmit: (address: TInput & AddressInput) => TOutput + onSubmit: (address: TInput & AddressInput) => TOutput, + addressType?: AddressTypeEnum ): UseAddressValidation { const [validationErrors, setValidationErrors] = useState< AccountErrorFragment[] @@ -20,7 +25,8 @@ function useAddressValidation( const countryRequiredError: AccountErrorFragment = { __typename: "AccountError", code: AccountErrorCode.REQUIRED, - field: "country" + field: "country", + addressType }; return { @@ -34,7 +40,7 @@ function useAddressValidation( (a, b) => a.field === b.field ) ); - return onSubmit(transformFormToAddress(data)); + return onSubmit(transformFormToAddressInput(data)); } catch { setValidationErrors(add(countryRequiredError, validationErrors)); } diff --git a/src/intl.ts b/src/intl.ts index 23ba6251459..5420f009f1f 100644 --- a/src/intl.ts +++ b/src/intl.ts @@ -128,6 +128,10 @@ export const buttonMessages = defineMessages({ defaultMessage: "Confirm", description: "button" }, + continue: { + defaultMessage: "Continue", + description: "button" + }, create: { defaultMessage: "Create", description: "button" @@ -164,6 +168,10 @@ export const buttonMessages = defineMessages({ defaultMessage: "Save", description: "button" }, + select: { + defaultMessage: "Select", + description: "select option, button" + }, selectAll: { defaultMessage: "Select All", description: "select all options, button" diff --git a/src/misc.ts b/src/misc.ts index 6dc430f5331..875acea6ba7 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -215,7 +215,7 @@ export const transformOrderStatus = ( }; }; -export const transformAddressToForm = (data: AddressType) => ({ +export const transformAddressToForm = (data?: AddressType) => ({ city: data?.city || "", cityArea: data?.cityArea || "", companyName: data?.companyName || "", @@ -410,7 +410,7 @@ export function capitalize(s: string) { return s.charAt(0).toLocaleUpperCase() + s.slice(1); } -export function transformFormToAddress( +export function transformFormToAddressInput( address: T & AddressTypeInput ): T & AddressInput { return { @@ -437,3 +437,17 @@ export const getDatePeriod = (days: number): DateRangeInput => { lte: end.format(format) }; }; + +export const transformAddressToAddressInput = (data?: AddressType) => ({ + city: data?.city || "", + cityArea: data?.cityArea || "", + companyName: data?.companyName || "", + country: findInEnum(data?.country?.code || "", CountryCode), + countryArea: data?.countryArea || "", + firstName: data?.firstName || "", + lastName: data?.lastName || "", + phone: data?.phone || "", + postalCode: data?.postalCode || "", + streetAddress1: data?.streetAddress1 || "", + streetAddress2: data?.streetAddress2 || "" +}); diff --git a/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx b/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx index c213d9a7e93..4f91356469f 100644 --- a/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx +++ b/src/orders/components/OrderAddressEditDialog/OrderAddressEditDialog.tsx @@ -8,16 +8,17 @@ import ConfirmButton, { ConfirmButtonTransitionState } from "@saleor/components/ConfirmButton"; import Form from "@saleor/components/Form"; +import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { AddressTypeInput } from "@saleor/customers/types"; import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; import useAddressValidation from "@saleor/hooks/useAddressValidation"; import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; import useStateFromProps from "@saleor/hooks/useStateFromProps"; import { buttonMessages } from "@saleor/intl"; -import { maybe } from "@saleor/misc"; import { makeStyles } from "@saleor/theme"; import { AddressInput } from "@saleor/types/globalTypes"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; +import { mapCountriesToChoices } from "@saleor/utils/maps"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; @@ -36,10 +37,7 @@ interface OrderAddressEditDialogProps { open: boolean; errors: OrderErrorFragment[]; variant: "billing" | "shipping" | string; - countries?: Array<{ - code: string; - label: string; - }>; + countries?: ShopInfo_shop_countries[]; onClose(); onConfirm(data: AddressInput); } @@ -59,9 +57,7 @@ const OrderAddressEditDialog: React.FC = props => { const classes = useStyles(props); const intl = useIntl(); const [countryDisplayName, setCountryDisplayName] = useStateFromProps( - maybe( - () => countries.find(country => address.country === country.code).label - ) + countries.find(country => address?.country === country.code)?.country ); const { errors: validationErrors, @@ -72,10 +68,7 @@ const OrderAddressEditDialog: React.FC = props => { open ); - const countryChoices = countries.map(country => ({ - label: country.label, - value: country.code - })); + const countryChoices = mapCountriesToChoices(countries); return ( diff --git a/src/orders/components/OrderCustomer/OrderCustomer.tsx b/src/orders/components/OrderCustomer/OrderCustomer.tsx index 62ad504cba2..4f79e1aeb16 100644 --- a/src/orders/components/OrderCustomer/OrderCustomer.tsx +++ b/src/orders/components/OrderCustomer/OrderCustomer.tsx @@ -48,6 +48,13 @@ const useStyles = makeStyles( { name: "OrderCustomer" } ); +export interface CustomerEditData { + user?: string; + userEmail?: string; + prevUser?: string; + prevUserEmail?: string; +} + export interface OrderCustomerProps extends Partial, UserPermissionProps { @@ -57,7 +64,7 @@ export interface OrderCustomerProps canEditAddresses: boolean; canEditCustomer: boolean; fetchUsers?: (query: string) => void; - onCustomerEdit?: (data: { user?: string; userEmail?: string }) => void; + onCustomerEdit?: (data: CustomerEditData) => void; onProfileView: () => void; onBillingAddressEdit?: () => void; onShippingAddressEdit?: () => void; @@ -132,6 +139,8 @@ const OrderCustomer: React.FC = props => { const value = event.target.value; onCustomerEdit({ + prevUser: user?.id, + prevUserEmail: userEmail, [value.includes("@") ? "userEmail" : "user"]: value }); toggleEditMode(); diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressEdit.tsx b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressEdit.tsx new file mode 100644 index 00000000000..e81f4f7476c --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressEdit.tsx @@ -0,0 +1,141 @@ +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import Radio from "@material-ui/core/Radio"; +import RadioGroup from "@material-ui/core/RadioGroup"; +import AddressEdit from "@saleor/components/AddressEdit"; +import CardSpacer from "@saleor/components/CardSpacer"; +import FormSpacer from "@saleor/components/FormSpacer"; +import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; +import Skeleton from "@saleor/components/Skeleton"; +import CustomerAddressChoiceCard from "@saleor/customers/components/CustomerAddressChoiceCard"; +import { AddressTypeInput } from "@saleor/customers/types"; +import { CustomerAddresses_user_addresses } from "@saleor/customers/types/CustomerAddresses"; +import { AccountErrorFragment } from "@saleor/fragments/types/AccountErrorFragment"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; +import { FormChange } from "@saleor/hooks/useForm"; +import React from "react"; +import { useIntl } from "react-intl"; + +import { AddressInputOptionEnum } from "./form"; +import { addressEditMessages } from "./messages"; +import { useStyles } from "./styles"; + +export interface OrderCustomerAddressEditProps { + loading: boolean; + customerAddresses: CustomerAddresses_user_addresses[]; + countryChoices: SingleAutocompleteChoiceType[]; + addressInputOption: AddressInputOptionEnum; + addressInputName: string; + onChangeAddressInputOption: FormChange; + customerAddressId: string; + formAddress: AddressTypeInput; + formAddressCountryDisplayName: string; + formErrors: Array; + onChangeCustomerAddress: ( + customerAddress: CustomerAddresses_user_addresses + ) => void; + onChangeFormAddress: (event: React.ChangeEvent) => void; + onChangeFormAddressCountry: (event: React.ChangeEvent) => void; +} + +const OrderCustomerAddressEdit: React.FC = props => { + const { + loading, + customerAddresses, + countryChoices, + addressInputOption, + addressInputName, + onChangeAddressInputOption, + customerAddressId, + formAddress, + formAddressCountryDisplayName, + formErrors, + onChangeCustomerAddress, + onChangeFormAddress, + onChangeFormAddressCountry + } = props; + + const classes = useStyles(props); + const intl = useIntl(); + + if (loading) { + return ; + } + + if (!customerAddresses.length) { + return ( + + ); + } + + return ( + onChangeAddressInputOption(event)} + > + + } + label={intl.formatMessage(addressEditMessages.customerAddress)} + className={classes.optionLabel} + /> + {addressInputOption === AddressInputOptionEnum.CUSTOMER_ADDRESS && ( + <> + {customerAddresses.map(customerAddress => ( + + + onChangeCustomerAddress(customerAddress)} + /> + + ))} + + + )} + + } + label={intl.formatMessage(addressEditMessages.newAddress)} + className={classes.optionLabel} + /> + {addressInputOption === AddressInputOptionEnum.NEW_ADDRESS && ( + <> + + + + )} + + ); +}; + +OrderCustomerAddressEdit.displayName = "OrderCustomerAddressEdit"; +export default OrderCustomerAddressEdit; diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.stories.tsx b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.stories.tsx new file mode 100644 index 00000000000..3a69544b284 --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.stories.tsx @@ -0,0 +1,46 @@ +import Decorator from "@saleor/storybook/Decorator"; +import { storiesOf } from "@storybook/react"; +import React from "react"; + +import { countries, order as orderFixture } from "../../fixtures"; +import OrderCustomerAddressesEditDialog, { + OrderCustomerAddressesEditDialogProps +} from "./OrderCustomerAddressesEditDialog"; + +const order = orderFixture(""); + +const props: OrderCustomerAddressesEditDialogProps = { + confirmButtonState: "default", + loading: false, + onClose: () => undefined, + onConfirm: () => undefined, + open: true, + errors: undefined +}; + +storiesOf("Orders / OrderCustomerAddressesEditDialog", module) + .addDecorator(Decorator) + .add("default", () => ( + + )) + .add("no customer addresses", () => ( + + )) + .add("loading", () => ( + + )); diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx new file mode 100644 index 00000000000..fb4c7eddb42 --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/OrderCustomerAddressesEditDialog.tsx @@ -0,0 +1,262 @@ +import Dialog from "@material-ui/core/Dialog"; +import DialogActions from "@material-ui/core/DialogActions"; +import DialogContent from "@material-ui/core/DialogContent"; +import DialogTitle from "@material-ui/core/DialogTitle"; +import Divider from "@material-ui/core/Divider"; +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import Typography from "@material-ui/core/Typography"; +import Checkbox from "@saleor/components/Checkbox"; +import ConfirmButton, { + ConfirmButtonTransitionState +} from "@saleor/components/ConfirmButton"; +import FormSpacer from "@saleor/components/FormSpacer"; +import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; +import { + CustomerAddresses_user_addresses, + CustomerAddresses_user_defaultBillingAddress, + CustomerAddresses_user_defaultShippingAddress +} from "@saleor/customers/types/CustomerAddresses"; +import { OrderErrorFragment } from "@saleor/fragments/types/OrderErrorFragment"; +import useAddressValidation from "@saleor/hooks/useAddressValidation"; +import { SubmitPromise } from "@saleor/hooks/useForm"; +import useModalDialogErrors from "@saleor/hooks/useModalDialogErrors"; +import { buttonMessages } from "@saleor/intl"; +import { transformAddressToAddressInput } from "@saleor/misc"; +import { AddressInput, AddressTypeEnum } from "@saleor/types/globalTypes"; +import { mapCountriesToChoices } from "@saleor/utils/maps"; +import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; + +import { getById } from "../OrderReturnPage/utils"; +import OrderCustomerAddressesEditForm, { + AddressInputOptionEnum, + OrderCustomerAddressesEditFormData +} from "./form"; +import { dialogMessages } from "./messages"; +import OrderCustomerAddressEdit from "./OrderCustomerAddressEdit"; +import { useStyles } from "./styles"; + +export interface OrderCustomerAddressesEditDialogOutput { + shippingAddress: AddressInput; + billingAddress: AddressInput; +} + +export interface OrderCustomerAddressesEditDialogProps { + open: boolean; + loading: boolean; + confirmButtonState: ConfirmButtonTransitionState; + errors: OrderErrorFragment[]; + countries?: ShopInfo_shop_countries[]; + customerAddresses?: CustomerAddresses_user_addresses[]; + defaultShippingAddress?: CustomerAddresses_user_defaultShippingAddress; + defaultBillingAddress?: CustomerAddresses_user_defaultBillingAddress; + onClose(); + onConfirm(data: OrderCustomerAddressesEditDialogOutput): SubmitPromise; +} + +const OrderCustomerAddressesEditDialog: React.FC = props => { + const { + open, + loading, + confirmButtonState, + errors = [], + countries = [], + customerAddresses = [], + defaultShippingAddress, + defaultBillingAddress, + onClose, + onConfirm + } = props; + + const classes = useStyles(props); + const intl = useIntl(); + const { + errors: shippingValidationErrors, + submit: handleShippingSubmit + } = useAddressValidation(address => address, AddressTypeEnum.SHIPPING); + const { + errors: billingValidationErrors, + submit: handleBillingSubmit + } = useAddressValidation(address => address, AddressTypeEnum.BILLING); + const dialogErrors = useModalDialogErrors( + [...errors, ...shippingValidationErrors, ...billingValidationErrors], + open + ); + + const getCustomerAddress = (customerAddressId: string): AddressInput => + transformAddressToAddressInput( + customerAddresses.find(getById(customerAddressId)) + ); + + const handleAddressesSubmit = (data: OrderCustomerAddressesEditFormData) => { + const shippingAddress = + customerAddresses.length > 0 && + data.shippingAddressInputOption === + AddressInputOptionEnum.CUSTOMER_ADDRESS + ? getCustomerAddress(data.customerShippingAddress.id) + : handleShippingSubmit(data.shippingAddress); + + if (data.billingSameAsShipping) { + return { + shippingAddress, + billingAddress: shippingAddress + }; + } + + const billingAddress = + customerAddresses.length > 0 && + data.billingAddressInputOption === AddressInputOptionEnum.CUSTOMER_ADDRESS + ? getCustomerAddress(data.customerBillingAddress.id) + : handleBillingSubmit(data.billingAddress); + + return { + shippingAddress, + billingAddress + }; + }; + + const handleSubmit = (data: OrderCustomerAddressesEditFormData) => { + const adressesInput = handleAddressesSubmit(data); + + if (adressesInput.shippingAddress && adressesInput.billingAddress) { + onConfirm(adressesInput); + } + }; + + const countryChoices = mapCountriesToChoices(countries); + + return ( + + + {({ change, data, handlers }) => ( + <> + + + + + + {customerAddresses.length > 0 ? ( + + ) : ( + + )} + + + error.addressType === AddressTypeEnum.SHIPPING + )} + onChangeCustomerAddress={customerAddress => + handlers.changeCustomerAddress( + customerAddress, + "customerShippingAddress" + ) + } + onChangeFormAddress={event => + handlers.changeFormAddress(event, "shippingAddress") + } + onChangeFormAddressCountry={handlers.selectShippingCountry} + /> + + + + + change({ + target: { + name: "billingSameAsShipping", + value: !data.billingSameAsShipping + } + }) + } + data-test="billingSameAsShipping" + /> + } + label={intl.formatMessage(dialogMessages.billingSameAsShipping)} + /> + {!data.billingSameAsShipping && ( + <> + + + {customerAddresses.length > 0 ? ( + + ) : ( + + )} + + + error.addressType === AddressTypeEnum.BILLING + )} + onChangeCustomerAddress={customerAddress => + handlers.changeCustomerAddress( + customerAddress, + "customerBillingAddress" + ) + } + onChangeFormAddress={event => + handlers.changeFormAddress(event, "billingAddress") + } + onChangeFormAddressCountry={handlers.selectBillingCountry} + /> + + )} + + + + + + + + )} + + + ); +}; + +OrderCustomerAddressesEditDialog.displayName = + "OrderCustomerAddressesEditDialog"; +export default OrderCustomerAddressesEditDialog; diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/form.tsx b/src/orders/components/OrderCustomerAddressesEditDialog/form.tsx new file mode 100644 index 00000000000..399ed1483c4 --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/form.tsx @@ -0,0 +1,202 @@ +import { SingleAutocompleteChoiceType } from "@saleor/components/SingleAutocompleteSelectField"; +import { AddressTypeInput } from "@saleor/customers/types"; +import { + CustomerAddresses_user_addresses, + CustomerAddresses_user_defaultBillingAddress, + CustomerAddresses_user_defaultShippingAddress +} from "@saleor/customers/types/CustomerAddresses"; +import useForm, { FormChange } from "@saleor/hooks/useForm"; +import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; +import React, { useState } from "react"; + +export enum AddressInputOptionEnum { + CUSTOMER_ADDRESS = "customerAddress", + NEW_ADDRESS = "newAddress" +} + +export interface OrderCustomerAddressesEditFormData { + billingSameAsShipping: boolean; + shippingAddressInputOption: AddressInputOptionEnum; + billingAddressInputOption: AddressInputOptionEnum; + customerShippingAddress: CustomerAddresses_user_defaultShippingAddress; + customerBillingAddress: CustomerAddresses_user_defaultBillingAddress; + shippingAddress: AddressTypeInput; + billingAddress: AddressTypeInput; +} + +export interface OrderCustomerAddressesEditData + extends OrderCustomerAddressesEditFormData { + shippingCountryDisplayName: string; + billingCountryDisplayName: string; +} + +export interface OrderCustomerAddressesEditHandlers { + changeFormAddress: ( + event: React.ChangeEvent, + addressType: "shippingAddress" | "billingAddress" + ) => void; + changeCustomerAddress: ( + customerAddress: CustomerAddresses_user_addresses, + addressType: "customerShippingAddress" | "customerBillingAddress" + ) => void; + selectShippingCountry: FormChange; + selectBillingCountry: FormChange; +} + +interface UseOrderCustomerAddressesEditFormResult { + submit: (event: React.FormEvent) => void; + change: FormChange; + hasChanged: boolean; + data: OrderCustomerAddressesEditData; + handlers: OrderCustomerAddressesEditHandlers; +} + +interface UseOrderCustomerAddressesEditFormOpts { + countryChoices: SingleAutocompleteChoiceType[]; + defaultShippingAddress: CustomerAddresses_user_defaultShippingAddress; + defaultBillingAddress: CustomerAddresses_user_defaultBillingAddress; +} + +export interface OrderCustomerAddressesEditFormProps + extends UseOrderCustomerAddressesEditFormOpts { + children: (props: UseOrderCustomerAddressesEditFormResult) => React.ReactNode; + initial?: Partial; + onSubmit: (data: OrderCustomerAddressesEditData) => void; +} + +function useOrderCustomerAddressesEditForm( + initial: Partial, + onSubmit: (data: OrderCustomerAddressesEditData) => void, + opts: UseOrderCustomerAddressesEditFormOpts +): UseOrderCustomerAddressesEditFormResult { + const initialAddress: AddressTypeInput = { + city: "", + country: "", + phone: "", + postalCode: "", + streetAddress1: "" + }; + const defaultInitialFormData: OrderCustomerAddressesEditFormData = { + billingSameAsShipping: true, + shippingAddressInputOption: AddressInputOptionEnum.CUSTOMER_ADDRESS, + billingAddressInputOption: AddressInputOptionEnum.CUSTOMER_ADDRESS, + customerShippingAddress: opts.defaultShippingAddress, + customerBillingAddress: opts.defaultBillingAddress, + shippingAddress: initialAddress, + billingAddress: initialAddress + }; + + const form = useForm({ + ...initial, + ...defaultInitialFormData + }); + + const [changed, setChanged] = useState(false); + const triggerChange = () => setChanged(true); + + const [shippingCountryDisplayName, setShippingCountryDisplayName] = useState( + "" + ); + const [billingCountryDisplayName, setBillingCountryDisplayName] = useState( + "" + ); + + const handleChange: FormChange = (event, cb) => { + form.change(event, cb); + triggerChange(); + }; + const handleFormAddressChange = ( + event: React.ChangeEvent, + addressType: "shippingAddress" | "billingAddress" + ) => + form.change({ + target: { + name: addressType, + value: { + ...form.data[addressType], + [event.target.name]: event.target.value + } + } + }); + const handleCustomerAddressChange = ( + customerAddress: CustomerAddresses_user_addresses, + addressType: "customerShippingAddress" | "customerBillingAddress" + ) => + form.change({ + target: { + name: addressType, + value: customerAddress + } + }); + const handleShippingCountrySelect = createSingleAutocompleteSelectHandler( + event => + form.change({ + target: { + name: "shippingAddress", + value: { + ...form.data.shippingAddress, + [event.target.name]: event.target.value + } + } + }), + setShippingCountryDisplayName, + opts.countryChoices + ); + const handleBillingCountrySelect = createSingleAutocompleteSelectHandler( + event => + form.change({ + target: { + name: "billingAddress", + value: { + ...form.data.billingAddress, + [event.target.name]: event.target.value + } + } + }), + setBillingCountryDisplayName, + opts.countryChoices + ); + + const data = { + ...form.data, + shippingCountryDisplayName, + billingCountryDisplayName + }; + + const submit = (event: React.FormEvent) => { + event.stopPropagation(); + event.preventDefault(); + return onSubmit(data); + }; + + return { + change: handleChange, + submit, + hasChanged: changed, + data, + handlers: { + changeCustomerAddress: handleCustomerAddressChange, + changeFormAddress: handleFormAddressChange, + selectShippingCountry: handleShippingCountrySelect, + selectBillingCountry: handleBillingCountrySelect + } + }; +} + +const OrderCustomerAddressesEditForm: React.FC = ({ + children, + initial, + onSubmit, + ...rest +}) => { + const props = useOrderCustomerAddressesEditForm( + initial || {}, + onSubmit, + rest + ); + + return
{children(props)}
; +}; + +OrderCustomerAddressesEditForm.displayName = "OrderCustomerAddressesEditForm"; +export default OrderCustomerAddressesEditForm; diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/index.ts b/src/orders/components/OrderCustomerAddressesEditDialog/index.ts new file mode 100644 index 00000000000..a2fc02c26b5 --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/index.ts @@ -0,0 +1,2 @@ +export { default } from "./OrderCustomerAddressesEditDialog"; +export * from "./OrderCustomerAddressesEditDialog"; diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/messages.ts b/src/orders/components/OrderCustomerAddressesEditDialog/messages.ts new file mode 100644 index 00000000000..eefc351dd6f --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/messages.ts @@ -0,0 +1,41 @@ +import { defineMessages } from "react-intl"; + +export const dialogMessages = defineMessages({ + title: { + defaultMessage: "Shipping address for order", + description: "dialog header" + }, + billingSameAsShipping: { + defaultMessage: "Billing address same as shipping address", + description: "checkbox label" + }, + shippingAddressDescription: { + defaultMessage: + "This customer doesn’t have any shipping addresses. Provide address for order:", + description: "dialog content" + }, + billingAddressDescription: { + defaultMessage: "Add a new address:", + description: "dialog content" + }, + customerShippingAddressDescription: { + defaultMessage: + "Which address would you like to use as shipping address for selected customer:", + description: "dialog content" + }, + customerBillingAddressDescription: { + defaultMessage: "Select one of customer addresses or add a new address:", + description: "dialog content" + } +}); + +export const addressEditMessages = defineMessages({ + customerAddress: { + defaultMessage: "Use one of customer addresses", + description: "address type" + }, + newAddress: { + defaultMessage: "Add new address", + description: "address type" + } +}); diff --git a/src/orders/components/OrderCustomerAddressesEditDialog/styles.ts b/src/orders/components/OrderCustomerAddressesEditDialog/styles.ts new file mode 100644 index 00000000000..c7e542d49ee --- /dev/null +++ b/src/orders/components/OrderCustomerAddressesEditDialog/styles.ts @@ -0,0 +1,16 @@ +import { makeStyles } from "@saleor/theme"; + +export const useStyles = makeStyles( + { + container: { + display: "block" + }, + optionLabel: { + display: "block" + }, + overflow: { + overflowY: "visible" + } + }, + { name: "OrderCustomerAddressesEditDialog" } +); diff --git a/src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.stories.tsx b/src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.stories.tsx new file mode 100644 index 00000000000..8c4c07838f4 --- /dev/null +++ b/src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.stories.tsx @@ -0,0 +1,24 @@ +import Decorator from "@saleor/storybook/Decorator"; +import { storiesOf } from "@storybook/react"; +import React from "react"; + +import OrderCustomerChangeDialog, { + OrderCustomerChangeDialogProps +} from "./OrderCustomerChangeDialog"; + +const props: OrderCustomerChangeDialogProps = { + onClose: () => undefined, + onConfirm: () => undefined, + open: true +}; + +storiesOf("Orders / OrderCustomerChangeDialog", module) + .addDecorator(Decorator) + .add("default", () => ( + undefined} + onConfirm={() => undefined} + open={true} + /> + )); diff --git a/src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.tsx b/src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.tsx new file mode 100644 index 00000000000..bbb830173c3 --- /dev/null +++ b/src/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog.tsx @@ -0,0 +1,85 @@ +import Dialog from "@material-ui/core/Dialog"; +import DialogActions from "@material-ui/core/DialogActions"; +import DialogContent from "@material-ui/core/DialogContent"; +import DialogTitle from "@material-ui/core/DialogTitle"; +import FormControlLabel from "@material-ui/core/FormControlLabel"; +import Radio from "@material-ui/core/Radio"; +import RadioGroup from "@material-ui/core/RadioGroup"; +import Typography from "@material-ui/core/Typography"; +import ConfirmButton from "@saleor/components/ConfirmButton"; +import FormSpacer from "@saleor/components/FormSpacer"; +import { buttonMessages } from "@saleor/intl"; +import React from "react"; +import { FormattedMessage, useIntl } from "react-intl"; + +import OrderCustomerChangeForm, { + CustomerChangeActionEnum, + OrderCustomerChangeData +} from "./form"; +import messages from "./messages"; +import { useStyles } from "./styles"; + +export interface OrderCustomerChangeDialogProps { + open: boolean; + onClose(); + onConfirm(data: OrderCustomerChangeData): void; +} + +const OrderCustomerChangeDialog: React.FC = props => { + const { open, onClose, onConfirm } = props; + + const classes = useStyles(props); + const intl = useIntl(); + + return ( + + + {({ change, data }) => ( + <> + + + + + + + + + change(event)} + > + } + label={intl.formatMessage(messages.keepAddress)} + className={classes.optionLabel} + /> + } + label={intl.formatMessage(messages.changeAddress)} + className={classes.optionLabel} + /> + + + + + + + + + )} + + + ); +}; + +OrderCustomerChangeDialog.displayName = "OrderCustomerChangeDialog"; +export default OrderCustomerChangeDialog; diff --git a/src/orders/components/OrderCustomerChangeDialog/form.tsx b/src/orders/components/OrderCustomerChangeDialog/form.tsx new file mode 100644 index 00000000000..dc5168dc892 --- /dev/null +++ b/src/orders/components/OrderCustomerChangeDialog/form.tsx @@ -0,0 +1,72 @@ +import useForm, { FormChange } from "@saleor/hooks/useForm"; +import React, { useState } from "react"; + +export enum CustomerChangeActionEnum { + KEEP_ADDRESS = "keepAddress", + CHANGE_ADDRESS = "changeAddress" +} + +export interface OrderCustomerChangeData { + changeActionOption: CustomerChangeActionEnum; +} + +interface UseOrderCustomerChangeFormResult { + submit: (event: React.FormEvent) => void; + change: FormChange; + hasChanged: boolean; + data: OrderCustomerChangeData; +} + +export interface OrderCustomerChangeFormProps { + children: (props: UseOrderCustomerChangeFormResult) => React.ReactNode; + initial?: Partial; + onSubmit: (data: OrderCustomerChangeData) => void; +} + +function useOrderCustomerChangeForm( + initial: Partial, + onSubmit: (data: OrderCustomerChangeData) => void +): UseOrderCustomerChangeFormResult { + const defaultInitialFormData: OrderCustomerChangeData = { + changeActionOption: CustomerChangeActionEnum.KEEP_ADDRESS + }; + + const form = useForm({ + ...initial, + ...defaultInitialFormData + }); + + const [changed, setChanged] = useState(false); + const triggerChange = () => setChanged(true); + + const handleChange: FormChange = (event, cb) => { + form.change(event, cb); + triggerChange(); + }; + + const submit = (event: React.FormEvent) => { + event.stopPropagation(); + event.preventDefault(); + return onSubmit(form.data); + }; + + return { + change: handleChange, + submit, + hasChanged: changed, + data: form.data + }; +} + +const OrderCustomerChangeForm: React.FC = ({ + children, + initial, + onSubmit +}) => { + const props = useOrderCustomerChangeForm(initial || {}, onSubmit); + + return
{children(props)}
; +}; + +OrderCustomerChangeForm.displayName = "OrderCustomerChangeForm"; +export default OrderCustomerChangeForm; diff --git a/src/orders/components/OrderCustomerChangeDialog/messages.ts b/src/orders/components/OrderCustomerChangeDialog/messages.ts new file mode 100644 index 00000000000..6f96a8b2175 --- /dev/null +++ b/src/orders/components/OrderCustomerChangeDialog/messages.ts @@ -0,0 +1,23 @@ +import { defineMessages } from "react-intl"; + +const messages = defineMessages({ + title: { + defaultMessage: "Changed Customer", + description: "dialog header" + }, + description: { + defaultMessage: + "You have changed customer assigned to this order. What would you like to do with the shipping address?", + description: "dialog description" + }, + keepAddress: { + defaultMessage: "Keep address", + description: "option label" + }, + changeAddress: { + defaultMessage: "Change address", + description: "option label" + } +}); + +export default messages; diff --git a/src/orders/components/OrderCustomerChangeDialog/styles.ts b/src/orders/components/OrderCustomerChangeDialog/styles.ts new file mode 100644 index 00000000000..8713a1a4715 --- /dev/null +++ b/src/orders/components/OrderCustomerChangeDialog/styles.ts @@ -0,0 +1,16 @@ +import { makeStyles } from "@saleor/theme"; + +export const useStyles = makeStyles( + { + container: { + display: "block" + }, + optionLabel: { + display: "block" + }, + overflow: { + overflowY: "visible" + } + }, + { name: "OrderCustomerChangeDialog" } +); diff --git a/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx b/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx index 56e2f8f2160..dd69e58a488 100644 --- a/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx +++ b/src/orders/components/OrderDetailsPage/OrderDetailsPage.tsx @@ -58,10 +58,6 @@ export interface OrderDetailsPageProps extends UserPermissionProps { id: string; name: string; }>; - countries?: Array<{ - code: string; - label: string; - }>; disabled: boolean; saveButtonBarState: ConfirmButtonTransitionState; onOrderLineAdd?: () => void; diff --git a/src/orders/components/OrderDraftPage/OrderDraftPage.tsx b/src/orders/components/OrderDraftPage/OrderDraftPage.tsx index 2632aa898c8..b024e67e971 100644 --- a/src/orders/components/OrderDraftPage/OrderDraftPage.tsx +++ b/src/orders/components/OrderDraftPage/OrderDraftPage.tsx @@ -17,9 +17,8 @@ import { FetchMoreProps, UserPermissionProps } from "@saleor/types"; import React from "react"; import { useIntl } from "react-intl"; -import { DraftOrderInput } from "../../../types/globalTypes"; import { OrderDetails_order } from "../../types/OrderDetails"; -import OrderCustomer from "../OrderCustomer"; +import OrderCustomer, { CustomerEditData } from "../OrderCustomer"; import OrderDraftDetails from "../OrderDraftDetails/OrderDraftDetails"; import { FormData as OrderDraftDetailsProductsFormData } from "../OrderDraftDetailsProducts"; import OrderHistory, { FormData as HistoryFormData } from "../OrderHistory"; @@ -44,15 +43,11 @@ export interface OrderDraftPageProps order: OrderDetails_order; users: SearchCustomers_search_edges_node[]; usersLoading: boolean; - countries: Array<{ - code: string; - label: string; - }>; saveButtonBarState: ConfirmButtonTransitionState; fetchUsers: (query: string) => void; onBack: () => void; onBillingAddressEdit: () => void; - onCustomerEdit: (data: DraftOrderInput) => void; + onCustomerEdit: (data: CustomerEditData) => void; onDraftFinalize: () => void; onDraftRemove: () => void; onNoteAdd: (data: HistoryFormData) => void; diff --git a/src/orders/components/OrderFulfillPage/OrderFulfillPage.stories.tsx b/src/orders/components/OrderFulfillPage/OrderFulfillPage.stories.tsx index 6ff84af931f..a1cb38d0772 100644 --- a/src/orders/components/OrderFulfillPage/OrderFulfillPage.stories.tsx +++ b/src/orders/components/OrderFulfillPage/OrderFulfillPage.stories.tsx @@ -37,7 +37,8 @@ storiesOf("Views / Orders / Fulfill order", module) code: OrderErrorCode.INSUFFICIENT_STOCK, field: null, orderLine: orderToFulfill.lines[0].id, - warehouse: warehouseList[0].id + warehouse: warehouseList[0].id, + addressType: null } ]} /> diff --git a/src/orders/fixtures.ts b/src/orders/fixtures.ts index 642ccd6b511..d7eb4b62a1d 100644 --- a/src/orders/fixtures.ts +++ b/src/orders/fixtures.ts @@ -1,3 +1,4 @@ +import { ShopInfo_shop_countries } from "@saleor/components/Shop/types/ShopInfo"; import { InvoiceFragment } from "@saleor/fragments/types/InvoiceFragment"; import { OrderSettingsFragment } from "@saleor/fragments/types/OrderSettingsFragment"; import { SearchCustomers_search_edges_node } from "@saleor/searches/types/SearchCustomers"; @@ -1587,12 +1588,12 @@ export const variants = [ { id: "p7", name: "Product 5: variant 2", sku: "14345", stockQuantity: 11 } ]; export const prefixes = ["01", "02", "41", "49"]; -export const countries = [ - { code: "AF", label: "Afghanistan" }, - { code: "AX", label: "Åland Islands" }, - { code: "AL", label: "Albania" }, - { code: "DZ", label: "Algeria" }, - { code: "AS", label: "American Samoa" } +export const countries: ShopInfo_shop_countries[] = [ + { __typename: "CountryDisplay", code: "AF", country: "Afghanistan" }, + { __typename: "CountryDisplay", code: "AX", country: "Åland Islands" }, + { __typename: "CountryDisplay", code: "AL", country: "Albania" }, + { __typename: "CountryDisplay", code: "DZ", country: "Algeria" }, + { __typename: "CountryDisplay", code: "AS", country: "American Samoa" } ]; export const shippingMethods = [ { country: "whole world", id: "s1", name: "DHL", price: {} }, diff --git a/src/orders/types/FulfillOrder.ts b/src/orders/types/FulfillOrder.ts index f3f6b0ef34f..5f4419d60dd 100644 --- a/src/orders/types/FulfillOrder.ts +++ b/src/orders/types/FulfillOrder.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderFulfillInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderFulfillInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: FulfillOrder @@ -13,6 +13,7 @@ export interface FulfillOrder_orderFulfill_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; warehouse: string | null; orderLine: string | null; } diff --git a/src/orders/types/FulfillmentReturnProducts.ts b/src/orders/types/FulfillmentReturnProducts.ts index c42d059bc80..56eb51d2740 100644 --- a/src/orders/types/FulfillmentReturnProducts.ts +++ b/src/orders/types/FulfillmentReturnProducts.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderReturnProductsInput, OrderErrorCode } from "./../../types/globalTypes"; +import { OrderReturnProductsInput, OrderErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: FulfillmentReturnProducts @@ -13,6 +13,7 @@ export interface FulfillmentReturnProducts_orderFulfillmentReturnProducts_errors __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface FulfillmentReturnProducts_orderFulfillmentReturnProducts_order { diff --git a/src/orders/types/OrderAddNote.ts b/src/orders/types/OrderAddNote.ts index dfd4fdddc3d..749e8383a2e 100644 --- a/src/orders/types/OrderAddNote.ts +++ b/src/orders/types/OrderAddNote.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderAddNoteInput, OrderErrorCode, OrderEventsEmailsEnum, DiscountValueTypeEnum, OrderEventsEnum } from "./../../types/globalTypes"; +import { OrderAddNoteInput, OrderErrorCode, AddressTypeEnum, OrderEventsEmailsEnum, DiscountValueTypeEnum, OrderEventsEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderAddNote @@ -13,6 +13,7 @@ export interface OrderAddNote_orderAddNote_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderAddNote_orderAddNote_order_events_discount_amount { diff --git a/src/orders/types/OrderCancel.ts b/src/orders/types/OrderCancel.ts index 7d3fb6b4aa7..ee93337aa45 100644 --- a/src/orders/types/OrderCancel.ts +++ b/src/orders/types/OrderCancel.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderCancel @@ -13,6 +13,7 @@ export interface OrderCancel_orderCancel_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderCancel_orderCancel_order_metadata { diff --git a/src/orders/types/OrderCapture.ts b/src/orders/types/OrderCapture.ts index 6a7f6622155..24054ca01e5 100644 --- a/src/orders/types/OrderCapture.ts +++ b/src/orders/types/OrderCapture.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderCapture @@ -13,6 +13,7 @@ export interface OrderCapture_orderCapture_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderCapture_orderCapture_order_metadata { diff --git a/src/orders/types/OrderConfirm.ts b/src/orders/types/OrderConfirm.ts index 4b8ceaeba78..829e37cda78 100644 --- a/src/orders/types/OrderConfirm.ts +++ b/src/orders/types/OrderConfirm.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderConfirm @@ -13,6 +13,7 @@ export interface OrderConfirm_orderConfirm_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderConfirm_orderConfirm_order_metadata { diff --git a/src/orders/types/OrderDiscountAdd.ts b/src/orders/types/OrderDiscountAdd.ts index c8c08dc8687..b50626dc004 100644 --- a/src/orders/types/OrderDiscountAdd.ts +++ b/src/orders/types/OrderDiscountAdd.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderDiscountCommonInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderDiscountCommonInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDiscountAdd @@ -13,6 +13,7 @@ export interface OrderDiscountAdd_orderDiscountAdd_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDiscountAdd_orderDiscountAdd_order_metadata { diff --git a/src/orders/types/OrderDiscountDelete.ts b/src/orders/types/OrderDiscountDelete.ts index 4db8312378f..fa1f8096ede 100644 --- a/src/orders/types/OrderDiscountDelete.ts +++ b/src/orders/types/OrderDiscountDelete.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDiscountDelete @@ -13,6 +13,7 @@ export interface OrderDiscountDelete_orderDiscountDelete_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDiscountDelete_orderDiscountDelete_order_metadata { diff --git a/src/orders/types/OrderDiscountUpdate.ts b/src/orders/types/OrderDiscountUpdate.ts index 05a6306e2e4..3c7895bcfce 100644 --- a/src/orders/types/OrderDiscountUpdate.ts +++ b/src/orders/types/OrderDiscountUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderDiscountCommonInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderDiscountCommonInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDiscountUpdate @@ -13,6 +13,7 @@ export interface OrderDiscountUpdate_orderDiscountUpdate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDiscountUpdate_orderDiscountUpdate_order_metadata { diff --git a/src/orders/types/OrderDraftBulkCancel.ts b/src/orders/types/OrderDraftBulkCancel.ts index 72cae2722e8..65a973a43f2 100644 --- a/src/orders/types/OrderDraftBulkCancel.ts +++ b/src/orders/types/OrderDraftBulkCancel.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDraftBulkCancel @@ -13,6 +13,7 @@ export interface OrderDraftBulkCancel_draftOrderBulkDelete_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDraftBulkCancel_draftOrderBulkDelete { diff --git a/src/orders/types/OrderDraftCancel.ts b/src/orders/types/OrderDraftCancel.ts index 2acdb9509ab..b38cab8415f 100644 --- a/src/orders/types/OrderDraftCancel.ts +++ b/src/orders/types/OrderDraftCancel.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDraftCancel @@ -13,6 +13,7 @@ export interface OrderDraftCancel_draftOrderDelete_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDraftCancel_draftOrderDelete_order_metadata { diff --git a/src/orders/types/OrderDraftCreate.ts b/src/orders/types/OrderDraftCreate.ts index 00508e0d82f..e74ee15ac4c 100644 --- a/src/orders/types/OrderDraftCreate.ts +++ b/src/orders/types/OrderDraftCreate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { DraftOrderCreateInput, OrderErrorCode } from "./../../types/globalTypes"; +import { DraftOrderCreateInput, OrderErrorCode, AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDraftCreate @@ -13,6 +13,7 @@ export interface OrderDraftCreate_draftOrderCreate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDraftCreate_draftOrderCreate_order { diff --git a/src/orders/types/OrderDraftFinalize.ts b/src/orders/types/OrderDraftFinalize.ts index 84d445515a9..97c7efebfbc 100644 --- a/src/orders/types/OrderDraftFinalize.ts +++ b/src/orders/types/OrderDraftFinalize.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDraftFinalize @@ -13,6 +13,7 @@ export interface OrderDraftFinalize_draftOrderComplete_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDraftFinalize_draftOrderComplete_order_metadata { diff --git a/src/orders/types/OrderDraftUpdate.ts b/src/orders/types/OrderDraftUpdate.ts index c83fc5e596c..51a6814469b 100644 --- a/src/orders/types/OrderDraftUpdate.ts +++ b/src/orders/types/OrderDraftUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { DraftOrderInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { DraftOrderInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderDraftUpdate @@ -13,6 +13,7 @@ export interface OrderDraftUpdate_draftOrderUpdate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderDraftUpdate_draftOrderUpdate_order_metadata { diff --git a/src/orders/types/OrderFulfillmentCancel.ts b/src/orders/types/OrderFulfillmentCancel.ts index 9e6a05e4883..061c9f1bee7 100644 --- a/src/orders/types/OrderFulfillmentCancel.ts +++ b/src/orders/types/OrderFulfillmentCancel.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { FulfillmentCancelInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { FulfillmentCancelInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderFulfillmentCancel @@ -13,6 +13,7 @@ export interface OrderFulfillmentCancel_orderFulfillmentCancel_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderFulfillmentCancel_orderFulfillmentCancel_order_metadata { diff --git a/src/orders/types/OrderFulfillmentRefundProducts.ts b/src/orders/types/OrderFulfillmentRefundProducts.ts index 6f6abb7dc41..d9ea059feab 100644 --- a/src/orders/types/OrderFulfillmentRefundProducts.ts +++ b/src/orders/types/OrderFulfillmentRefundProducts.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderRefundProductsInput, OrderErrorCode, DiscountValueTypeEnum, FulfillmentStatus, OrderDiscountType, OrderEventsEmailsEnum, OrderEventsEnum, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderRefundProductsInput, OrderErrorCode, AddressTypeEnum, DiscountValueTypeEnum, FulfillmentStatus, OrderDiscountType, OrderEventsEmailsEnum, OrderEventsEnum, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderFulfillmentRefundProducts @@ -13,6 +13,7 @@ export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_e __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderFulfillmentRefundProducts_orderFulfillmentRefundProducts_fulfillment_lines_orderLine_variant { diff --git a/src/orders/types/OrderFulfillmentUpdateTracking.ts b/src/orders/types/OrderFulfillmentUpdateTracking.ts index 565191c4656..17e0d4e1dbe 100644 --- a/src/orders/types/OrderFulfillmentUpdateTracking.ts +++ b/src/orders/types/OrderFulfillmentUpdateTracking.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { FulfillmentUpdateTrackingInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { FulfillmentUpdateTrackingInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderFulfillmentUpdateTracking @@ -13,6 +13,7 @@ export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_e __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderFulfillmentUpdateTracking_orderFulfillmentUpdateTracking_order_metadata { diff --git a/src/orders/types/OrderLineDelete.ts b/src/orders/types/OrderLineDelete.ts index f4fa4e92b9d..b0f22c4b17c 100644 --- a/src/orders/types/OrderLineDelete.ts +++ b/src/orders/types/OrderLineDelete.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderLineDelete @@ -13,6 +13,7 @@ export interface OrderLineDelete_orderLineDelete_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderLineDelete_orderLineDelete_order_metadata { diff --git a/src/orders/types/OrderLineDiscountRemove.ts b/src/orders/types/OrderLineDiscountRemove.ts index 91dfbf060cc..8b15bfa729c 100644 --- a/src/orders/types/OrderLineDiscountRemove.ts +++ b/src/orders/types/OrderLineDiscountRemove.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderLineDiscountRemove @@ -13,6 +13,7 @@ export interface OrderLineDiscountRemove_orderLineDiscountRemove_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderLineDiscountRemove_orderLineDiscountRemove_order_metadata { diff --git a/src/orders/types/OrderLineDiscountUpdate.ts b/src/orders/types/OrderLineDiscountUpdate.ts index 7283aa8fb03..a7bc512dd5b 100644 --- a/src/orders/types/OrderLineDiscountUpdate.ts +++ b/src/orders/types/OrderLineDiscountUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderDiscountCommonInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderDiscountCommonInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderLineDiscountUpdate @@ -13,6 +13,7 @@ export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderLineDiscountUpdate_orderLineDiscountUpdate_order_metadata { diff --git a/src/orders/types/OrderLineUpdate.ts b/src/orders/types/OrderLineUpdate.ts index da2278fe94c..fdddb41f7b2 100644 --- a/src/orders/types/OrderLineUpdate.ts +++ b/src/orders/types/OrderLineUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderLineInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderLineInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderLineUpdate @@ -13,6 +13,7 @@ export interface OrderLineUpdate_orderLineUpdate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderLineUpdate_orderLineUpdate_order_metadata { diff --git a/src/orders/types/OrderLinesAdd.ts b/src/orders/types/OrderLinesAdd.ts index 24a8a7101f1..c3ff37b1802 100644 --- a/src/orders/types/OrderLinesAdd.ts +++ b/src/orders/types/OrderLinesAdd.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderLineCreateInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderLineCreateInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderLinesAdd @@ -13,6 +13,7 @@ export interface OrderLinesAdd_orderLinesCreate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderLinesAdd_orderLinesCreate_order_metadata { diff --git a/src/orders/types/OrderMarkAsPaid.ts b/src/orders/types/OrderMarkAsPaid.ts index afdd05d38c0..63e481c6fdc 100644 --- a/src/orders/types/OrderMarkAsPaid.ts +++ b/src/orders/types/OrderMarkAsPaid.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderMarkAsPaid @@ -13,6 +13,7 @@ export interface OrderMarkAsPaid_orderMarkAsPaid_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderMarkAsPaid_orderMarkAsPaid_order_metadata { diff --git a/src/orders/types/OrderRefund.ts b/src/orders/types/OrderRefund.ts index b70abc425e5..22eb4aa5054 100644 --- a/src/orders/types/OrderRefund.ts +++ b/src/orders/types/OrderRefund.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderRefund @@ -13,6 +13,7 @@ export interface OrderRefund_orderRefund_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderRefund_orderRefund_order_metadata { diff --git a/src/orders/types/OrderShippingMethodUpdate.ts b/src/orders/types/OrderShippingMethodUpdate.ts index bfdb84d1930..13aaa512c82 100644 --- a/src/orders/types/OrderShippingMethodUpdate.ts +++ b/src/orders/types/OrderShippingMethodUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderUpdateShippingInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderUpdateShippingInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderShippingMethodUpdate @@ -13,6 +13,7 @@ export interface OrderShippingMethodUpdate_orderUpdateShipping_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderShippingMethodUpdate_orderUpdateShipping_order_availableShippingMethods_price { diff --git a/src/orders/types/OrderUpdate.ts b/src/orders/types/OrderUpdate.ts index 3196ff9736e..b521df1cfe6 100644 --- a/src/orders/types/OrderUpdate.ts +++ b/src/orders/types/OrderUpdate.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderUpdateInput, OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderUpdateInput, OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderUpdate @@ -13,6 +13,7 @@ export interface OrderUpdate_orderUpdate_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderUpdate_orderUpdate_order_metadata { diff --git a/src/orders/types/OrderVoid.ts b/src/orders/types/OrderVoid.ts index f8e1962d375..8a520b1b013 100644 --- a/src/orders/types/OrderVoid.ts +++ b/src/orders/types/OrderVoid.ts @@ -3,7 +3,7 @@ // @generated // This file was automatically generated and should not be edited. -import { OrderErrorCode, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; +import { OrderErrorCode, AddressTypeEnum, OrderDiscountType, DiscountValueTypeEnum, OrderEventsEmailsEnum, OrderEventsEnum, FulfillmentStatus, PaymentChargeStatusEnum, OrderStatus, OrderAction, JobStatusEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: OrderVoid @@ -13,6 +13,7 @@ export interface OrderVoid_orderVoid_errors { __typename: "OrderError"; code: OrderErrorCode; field: string | null; + addressType: AddressTypeEnum | null; } export interface OrderVoid_orderVoid_order_metadata { diff --git a/src/orders/urls.ts b/src/orders/urls.ts index 47be7712ffb..f6c393903d7 100644 --- a/src/orders/urls.ts +++ b/src/orders/urls.ts @@ -105,6 +105,8 @@ export type OrderUrlDialog = | "cancel" | "cancel-fulfillment" | "capture" + | "customer-change" + | "edit-customer-addresses" | "edit-billing-address" | "edit-fulfillment" | "edit-shipping" diff --git a/src/orders/views/OrderDetails/OrderAddressFields.tsx b/src/orders/views/OrderDetails/OrderAddressFields.tsx index 7d823d51dc0..78ce53dcb68 100644 --- a/src/orders/views/OrderDetails/OrderAddressFields.tsx +++ b/src/orders/views/OrderDetails/OrderAddressFields.tsx @@ -57,10 +57,7 @@ const OrderAddressFields = ({ confirmButtonState: isDraft ? orderDraftUpdate.opts.status : orderUpdate.opts.status, - countries: data?.shop?.countries.map(country => ({ - code: country.code, - label: country.country - })), + countries: data?.shop?.countries, errors: isDraft ? orderDraftUpdate.opts.data?.draftOrderUpdate.errors : orderUpdate.opts.data?.orderUpdate.errors, diff --git a/src/orders/views/OrderDetails/OrderDetailsMessages.tsx b/src/orders/views/OrderDetails/OrderDetailsMessages.tsx index 5a62c3c92ad..e0543557500 100644 --- a/src/orders/views/OrderDetails/OrderDetailsMessages.tsx +++ b/src/orders/views/OrderDetails/OrderDetailsMessages.tsx @@ -159,8 +159,8 @@ export const OrderDetailsMessages: React.FC = ({ defaultMessage: "Order successfully updated" }) }); + closeModal(); } - closeModal(); }; const handleShippingMethodUpdate = (data: OrderShippingMethodUpdate) => { const errs = data.orderUpdateShipping?.errors; diff --git a/src/orders/views/OrderDetails/OrderDraftDetails/index.tsx b/src/orders/views/OrderDetails/OrderDraftDetails/index.tsx index ba6ee033b57..72ba1a21ca0 100644 --- a/src/orders/views/OrderDetails/OrderDraftDetails/index.tsx +++ b/src/orders/views/OrderDetails/OrderDraftDetails/index.tsx @@ -1,7 +1,18 @@ import { WindowTitle } from "@saleor/components/WindowTitle"; import { DEFAULT_INITIAL_SEARCH_DATA } from "@saleor/config"; +import { useCustomerAddressesQuery } from "@saleor/customers/queries"; import useNavigator from "@saleor/hooks/useNavigator"; import useUser from "@saleor/hooks/useUser"; +import { CustomerEditData } from "@saleor/orders/components/OrderCustomer"; +import OrderCustomerAddressesEditDialog, { + OrderCustomerAddressesEditDialogOutput +} from "@saleor/orders/components/OrderCustomerAddressesEditDialog"; +import { + CustomerChangeActionEnum, + OrderCustomerChangeData +} from "@saleor/orders/components/OrderCustomerChangeDialog/form"; +import OrderCustomerChangeDialog from "@saleor/orders/components/OrderCustomerChangeDialog/OrderCustomerChangeDialog"; +import { OrderDetails } from "@saleor/orders/types/OrderDetails"; import { OrderDiscountProvider } from "@saleor/products/components/OrderDiscountProviders/OrderDiscountProvider"; import { OrderLineDiscountProvider } from "@saleor/products/components/OrderDiscountProviders/OrderLineDiscountProvider"; import useCustomerSearch from "@saleor/searches/useCustomerSearch"; @@ -16,14 +27,14 @@ import OrderDraftPage from "../../../components/OrderDraftPage"; import OrderProductAddDialog from "../../../components/OrderProductAddDialog"; import OrderShippingMethodEditDialog from "../../../components/OrderShippingMethodEditDialog"; import { useOrderVariantSearch } from "../../../queries"; -import { OrderUrlQueryParams } from "../../../urls"; +import { OrderUrlDialog, OrderUrlQueryParams } from "../../../urls"; import { orderDraftListUrl } from "../../../urls"; interface OrderDraftDetailsProps { id: string; params: OrderUrlQueryParams; loading: any; - data: any; + data: OrderDetails; orderAddNote: any; orderLineUpdate: any; orderLineDelete: any; @@ -32,7 +43,7 @@ interface OrderDraftDetailsProps { orderDraftUpdate: any; orderDraftCancel: any; orderDraftFinalize: any; - openModal: any; + openModal: (action: OrderUrlDialog, newParams?: OrderUrlQueryParams) => void; closeModal: any; } @@ -72,8 +83,70 @@ export const OrderDraftDetails: React.FC = ({ variables: DEFAULT_INITIAL_SEARCH_DATA }); + const { + data: customerAddresses, + loading: customerAddressesLoading + } = useCustomerAddressesQuery({ + variables: { + id: order?.user?.id + }, + skip: params.action !== "edit-customer-addresses" + }); + const intl = useIntl(); + const handleCustomerChange = async ({ + user, + userEmail, + prevUser, + prevUserEmail + }: CustomerEditData) => { + const sameUser = user && user === prevUser; + const sameUserEmail = userEmail && userEmail === prevUserEmail; + if (sameUser || sameUserEmail) { + return; + } + + const result = await orderDraftUpdate.mutate({ + id, + input: { + user, + userEmail + } + }); + + if (result?.data?.draftOrderUpdate?.errors?.length) { + return; + } + + const modalUri = prevUser ? "customer-change" : "edit-customer-addresses"; + openModal(modalUri); + }; + + const handleCustomerChangeAction = (data: OrderCustomerChangeData) => { + if (data.changeActionOption === CustomerChangeActionEnum.CHANGE_ADDRESS) { + openModal("edit-customer-addresses"); + } else { + closeModal(); + } + }; + + const handleCustomerChangeAdresses = async ( + data: OrderCustomerAddressesEditDialogOutput + ) => { + const result = await orderDraftUpdate.mutate({ + id, + input: { + shippingAddress: data.shippingAddress, + billingAddress: data.billingAddress + } + }); + if (!result?.data?.draftOrderUpdate?.errors?.length) { + closeModal(); + } + return result; + }; + return ( <> = ({ fetchUsers={searchUsers} loading={users.loading} usersLoading={users.loading} - onCustomerEdit={data => - orderDraftUpdate.mutate({ - id, - input: data - }) - } + onCustomerEdit={handleCustomerChange} onDraftFinalize={() => orderDraftFinalize.mutate({ id })} onDraftRemove={() => openModal("cancel")} onOrderLineAdd={() => openModal("add-order-line")} onBack={() => navigate(orderDraftListUrl())} order={order} - countries={(data?.shop?.countries || []).map(country => ({ - code: country.code, - label: country.country - }))} onProductClick={id => () => navigate(productUrl(encodeURIComponent(id)))} onBillingAddressEdit={() => openModal("edit-billing-address")} @@ -184,6 +248,23 @@ export const OrderDraftDetails: React.FC = ({ }) } /> + + ); }; diff --git a/src/products/components/ProductExportDialog/messages.ts b/src/products/components/ProductExportDialog/messages.ts index 2e983fa1058..0f4ceba51ba 100644 --- a/src/products/components/ProductExportDialog/messages.ts +++ b/src/products/components/ProductExportDialog/messages.ts @@ -59,11 +59,6 @@ function useProductExportFieldMessages() { defaultMessage: "Export Variant Weight", description: "product field", id: "productExportFieldVariantWeight" - }), - [ProductFieldEnum.VISIBLE]: intl.formatMessage({ - defaultMessage: "Visibility", - description: "product field", - id: "productExportFieldVisibility" }) }; diff --git a/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx b/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx index 7995781bb30..e85e765275e 100644 --- a/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx +++ b/src/shipping/components/ShippingZoneAddWarehouseDialog/ShippingZoneAddWarehouseDialog.tsx @@ -22,6 +22,7 @@ import { buttonMessages } from "@saleor/intl"; import { makeStyles } from "@saleor/theme"; import { DialogProps } from "@saleor/types"; import createSingleAutocompleteSelectHandler from "@saleor/utils/handlers/singleAutocompleteSelectChangeHandler"; +import { mapCountriesToChoices } from "@saleor/utils/maps"; import React from "react"; import { FormattedMessage, useIntl } from "react-intl"; @@ -85,10 +86,7 @@ const ShippingZoneAddWarehouseDialog: React.FC ({ - label: country.country, - value: country.code - })); + const countryChoices = mapCountriesToChoices(countries); return ( `; +exports[`Storyshots Orders / OrderCustomerAddressesEditDialog default 1`] = ` +
+`; + +exports[`Storyshots Orders / OrderCustomerAddressesEditDialog loading 1`] = ` +
+`; + +exports[`Storyshots Orders / OrderCustomerAddressesEditDialog no customer addresses 1`] = ` +
+`; + +exports[`Storyshots Orders / OrderCustomerChangeDialog default 1`] = ` +
+`; + exports[`Storyshots Orders / OrderDraftCancelDialog default 1`] = `
({ - label: c.label, - value: c.code - }))} + countries={mapCountriesToChoices(countries)} countryDisplayValue={customer.defaultBillingAddress.country.country} onChange={undefined} onCountryChange={() => undefined} diff --git a/src/storybook/stories/customers/CustomerAddressDialog.tsx b/src/storybook/stories/customers/CustomerAddressDialog.tsx index 369448178b4..42db605604f 100644 --- a/src/storybook/stories/customers/CustomerAddressDialog.tsx +++ b/src/storybook/stories/customers/CustomerAddressDialog.tsx @@ -12,8 +12,9 @@ const props: CustomerAddressDialogProps = { address: customer.addresses[0], confirmButtonState: "default", countries: countries.map(c => ({ + __typename: "CountryDisplay", code: c.code, - label: c.name + country: c.name })), errors: [], onClose: () => undefined, diff --git a/src/storybook/stories/customers/CustomerCreatePage.tsx b/src/storybook/stories/customers/CustomerCreatePage.tsx index 22dd380c376..9d3f32d9d39 100644 --- a/src/storybook/stories/customers/CustomerCreatePage.tsx +++ b/src/storybook/stories/customers/CustomerCreatePage.tsx @@ -45,7 +45,8 @@ storiesOf("Views / Customers / Create customer", module) ] as Array).map(field => ({ __typename: "AccountError", code: AccountErrorCode.INVALID, - field + field, + addressType: null }))} /> )); diff --git a/src/storybook/stories/customers/CustomerDetailsPage.tsx b/src/storybook/stories/customers/CustomerDetailsPage.tsx index faf7cb10e6e..b0d01c917b6 100644 --- a/src/storybook/stories/customers/CustomerDetailsPage.tsx +++ b/src/storybook/stories/customers/CustomerDetailsPage.tsx @@ -43,7 +43,8 @@ storiesOf("Views / Customers / Customer details", module) >).map(field => ({ __typename: "AccountError", code: AccountErrorCode.INVALID, - field + field, + addressType: null }))} /> )) diff --git a/src/storybook/stories/orders/OrderCancelDialog.tsx b/src/storybook/stories/orders/OrderCancelDialog.tsx index 778b2088416..af413aa38ff 100644 --- a/src/storybook/stories/orders/OrderCancelDialog.tsx +++ b/src/storybook/stories/orders/OrderCancelDialog.tsx @@ -35,7 +35,8 @@ storiesOf("Orders / OrderCancelDialog", module) { __typename: "OrderError", code: OrderErrorCode.CANNOT_CANCEL_ORDER, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderDetailsPage.tsx b/src/storybook/stories/orders/OrderDetailsPage.tsx index 5cff7a2a063..3cf372bb8ea 100644 --- a/src/storybook/stories/orders/OrderDetailsPage.tsx +++ b/src/storybook/stories/orders/OrderDetailsPage.tsx @@ -7,7 +7,7 @@ import React from "react"; import OrderDetailsPage, { OrderDetailsPageProps } from "../../../orders/components/OrderDetailsPage"; -import { countries, order as orderFixture } from "../../../orders/fixtures"; +import { order as orderFixture } from "../../../orders/fixtures"; import { FulfillmentStatus, OrderStatus, @@ -18,7 +18,6 @@ import Decorator from "../../Decorator"; const order = orderFixture(placeholderImage); const props: Omit = { - countries, disabled: false, onBack: () => undefined, onBillingAddressEdit: undefined, diff --git a/src/storybook/stories/orders/OrderDraftCancelDialog.tsx b/src/storybook/stories/orders/OrderDraftCancelDialog.tsx index 05ef02d4d7a..e5eeed60964 100644 --- a/src/storybook/stories/orders/OrderDraftCancelDialog.tsx +++ b/src/storybook/stories/orders/OrderDraftCancelDialog.tsx @@ -26,7 +26,8 @@ storiesOf("Orders / OrderDraftCancelDialog", module) { __typename: "OrderError", code: OrderErrorCode.GRAPHQL_ERROR, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderDraftPage/OrderDraftPage.tsx b/src/storybook/stories/orders/OrderDraftPage/OrderDraftPage.tsx index 2068a66f24f..9611b645f9e 100644 --- a/src/storybook/stories/orders/OrderDraftPage/OrderDraftPage.tsx +++ b/src/storybook/stories/orders/OrderDraftPage/OrderDraftPage.tsx @@ -7,7 +7,7 @@ import React from "react"; import OrderDraftPage, { OrderDraftPageProps } from "../../../../orders/components/OrderDraftPage"; -import { clients, countries, draftOrder } from "../../../../orders/fixtures"; +import { clients, draftOrder } from "../../../../orders/fixtures"; import Decorator from "../../../Decorator"; import { getDiscountsProvidersWrapper } from "./utils"; @@ -15,7 +15,6 @@ const order = draftOrder(placeholderImage); const props: Omit = { ...fetchMoreProps, - countries, disabled: false, fetchUsers: () => undefined, onBack: () => undefined, diff --git a/src/storybook/stories/orders/OrderFulfillmentCancelDialog.tsx b/src/storybook/stories/orders/OrderFulfillmentCancelDialog.tsx index 94d0b76bd5f..2415026cd7b 100644 --- a/src/storybook/stories/orders/OrderFulfillmentCancelDialog.tsx +++ b/src/storybook/stories/orders/OrderFulfillmentCancelDialog.tsx @@ -27,7 +27,8 @@ storiesOf("Orders / OrderFulfillmentCancelDialog", module) { __typename: "OrderError", code: OrderErrorCode.GRAPHQL_ERROR, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderFulfillmentDialog.tsx b/src/storybook/stories/orders/OrderFulfillmentDialog.tsx index 2bb3d4d8237..5b91a2996db 100644 --- a/src/storybook/stories/orders/OrderFulfillmentDialog.tsx +++ b/src/storybook/stories/orders/OrderFulfillmentDialog.tsx @@ -31,12 +31,14 @@ storiesOf("Orders / OrderFulfillmentDialog", module) { __typename: "OrderError", code: OrderErrorCode.FULFILL_ORDER_LINE, - field: null + field: null, + addressType: null }, { __typename: "OrderError", code: OrderErrorCode.INVALID, - field: "trackingNumber" + field: "trackingNumber", + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderFulfillmentTrackingDialog.tsx b/src/storybook/stories/orders/OrderFulfillmentTrackingDialog.tsx index 712e7b4bdea..1c260bde0fc 100644 --- a/src/storybook/stories/orders/OrderFulfillmentTrackingDialog.tsx +++ b/src/storybook/stories/orders/OrderFulfillmentTrackingDialog.tsx @@ -26,12 +26,14 @@ storiesOf("Orders / OrderFulfillmentTrackingDialog", module) { __typename: "OrderError", code: OrderErrorCode.GRAPHQL_ERROR, - field: null + field: null, + addressType: null }, { __typename: "OrderError", code: OrderErrorCode.INVALID, - field: "trackingNumber" + field: "trackingNumber", + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderMarkAsPaidDialog.tsx b/src/storybook/stories/orders/OrderMarkAsPaidDialog.tsx index adc3589eed3..8226d6c6ca3 100644 --- a/src/storybook/stories/orders/OrderMarkAsPaidDialog.tsx +++ b/src/storybook/stories/orders/OrderMarkAsPaidDialog.tsx @@ -27,7 +27,8 @@ storiesOf("Orders / OrderMarkAsPaidDialog", module) { __typename: "OrderError", code: OrderErrorCode.GRAPHQL_ERROR, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderPaymentDialog.tsx b/src/storybook/stories/orders/OrderPaymentDialog.tsx index 5c5cbdfd643..6362fcd38f8 100644 --- a/src/storybook/stories/orders/OrderPaymentDialog.tsx +++ b/src/storybook/stories/orders/OrderPaymentDialog.tsx @@ -26,12 +26,14 @@ storiesOf("Orders / OrderPaymentDialog", module) { __typename: "OrderError", code: OrderErrorCode.CAPTURE_INACTIVE_PAYMENT, - field: null + field: null, + addressType: null }, { __typename: "OrderError", code: OrderErrorCode.INVALID, - field: "payment" + field: "payment", + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderPaymentVoidDialog.tsx b/src/storybook/stories/orders/OrderPaymentVoidDialog.tsx index 82f5f8c5796..259cb7da35f 100644 --- a/src/storybook/stories/orders/OrderPaymentVoidDialog.tsx +++ b/src/storybook/stories/orders/OrderPaymentVoidDialog.tsx @@ -25,7 +25,8 @@ storiesOf("Orders / OrderPaymentVoidDialog", module) { __typename: "OrderError", code: OrderErrorCode.VOID_INACTIVE_PAYMENT, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderProductAddDialog.tsx b/src/storybook/stories/orders/OrderProductAddDialog.tsx index c2459c2beb3..406bd309b3e 100644 --- a/src/storybook/stories/orders/OrderProductAddDialog.tsx +++ b/src/storybook/stories/orders/OrderProductAddDialog.tsx @@ -34,7 +34,8 @@ storiesOf("Orders / OrderProductAddDialog", module) { __typename: "OrderError", code: OrderErrorCode.GRAPHQL_ERROR, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/storybook/stories/orders/OrderShippingMethodEditDialog.tsx b/src/storybook/stories/orders/OrderShippingMethodEditDialog.tsx index 10d323b52c1..b3bcc1b71e0 100644 --- a/src/storybook/stories/orders/OrderShippingMethodEditDialog.tsx +++ b/src/storybook/stories/orders/OrderShippingMethodEditDialog.tsx @@ -29,12 +29,14 @@ storiesOf("Orders / OrderShippingMethodEditDialog", module) { __typename: "OrderError", code: OrderErrorCode.SHIPPING_METHOD_NOT_APPLICABLE, - field: "shippingMethod" + field: "shippingMethod", + addressType: null }, { __typename: "OrderError", code: OrderErrorCode.GRAPHQL_ERROR, - field: null + field: null, + addressType: null } ]} /> diff --git a/src/types/globalTypes.ts b/src/types/globalTypes.ts index 07cbcfb8ed9..325ec55a234 100644 --- a/src/types/globalTypes.ts +++ b/src/types/globalTypes.ts @@ -849,7 +849,6 @@ export enum ProductFieldEnum { VARIANT_MEDIA = "VARIANT_MEDIA", VARIANT_SKU = "VARIANT_SKU", VARIANT_WEIGHT = "VARIANT_WEIGHT", - VISIBLE = "VISIBLE", } export enum ProductMediaType { diff --git a/src/utils/errors/staff.ts b/src/utils/errors/staff.ts index 0c82fde5681..53fa8768cac 100644 --- a/src/utils/errors/staff.ts +++ b/src/utils/errors/staff.ts @@ -10,7 +10,8 @@ function getStaffErrorMessage( return getAccountErrorMessage( err && { ...err, - __typename: "AccountError" + __typename: "AccountError", + addressType: null }, intl );