diff --git a/schema.graphql b/schema.graphql index 89b27f930..4d12f342c 100644 --- a/schema.graphql +++ b/schema.graphql @@ -92,6 +92,12 @@ type AccountUpdate { user: User } +type AccountUpdateMeta { + errors: [Error!] + accountErrors: [AccountError!] + user: User +} + type Address implements Node { id: ID! firstName: String! @@ -132,7 +138,7 @@ input AddressInput { city: String cityArea: String postalCode: String - country: String + country: CountryCode countryArea: String phone: String } @@ -1553,6 +1559,8 @@ type Fulfillment implements Node { status: FulfillmentStatus! trackingNumber: String! shippingDate: DateTime! + privateMeta: [MetaStore]! + meta: [MetaStore]! lines: [FulfillmentLine] statusDisplay: String } @@ -1568,6 +1576,16 @@ input FulfillmentCancelInput { restock: Boolean } +type FulfillmentClearMeta { + errors: [Error!] + fulfillment: Fulfillment +} + +type FulfillmentClearPrivateMeta { + errors: [Error!] + fulfillment: Fulfillment +} + type FulfillmentCreate { errors: [Error!] fulfillment: Fulfillment @@ -1597,6 +1615,16 @@ enum FulfillmentStatus { CANCELED } +type FulfillmentUpdateMeta { + errors: [Error!] + fulfillment: Fulfillment +} + +type FulfillmentUpdatePrivateMeta { + errors: [Error!] + fulfillment: Fulfillment +} + type FulfillmentUpdateTracking { errors: [Error!] fulfillment: Fulfillment @@ -2112,14 +2140,18 @@ type Mutation { orderCancel(id: ID!, restock: Boolean!): OrderCancel orderCapture(amount: Decimal!, id: ID!): OrderCapture orderClearPrivateMeta(id: ID!, input: MetaPath!): OrderClearPrivateMeta - orderClearMeta(id: ID!, input: MetaPath!): OrderClearMeta + orderClearMeta(input: MetaPath!, token: UUID!): OrderClearMeta orderFulfillmentCancel(id: ID!, input: FulfillmentCancelInput!): FulfillmentCancel orderFulfillmentCreate(input: FulfillmentCreateInput!, order: ID): FulfillmentCreate orderFulfillmentUpdateTracking(id: ID!, input: FulfillmentUpdateTrackingInput!): FulfillmentUpdateTracking + orderFulfillmentClearMeta(id: ID!, input: MetaPath!): FulfillmentClearMeta + orderFulfillmentClearPrivateMeta(id: ID!, input: MetaPath!): FulfillmentClearPrivateMeta + orderFulfillmentUpdateMeta(id: ID!, input: MetaInput!): FulfillmentUpdateMeta + orderFulfillmentUpdatePrivateMeta(id: ID!, input: MetaInput!): FulfillmentUpdatePrivateMeta orderMarkAsPaid(id: ID!): OrderMarkAsPaid orderRefund(amount: Decimal!, id: ID!): OrderRefund orderUpdate(id: ID!, input: OrderUpdateInput!): OrderUpdate - orderUpdateMeta(id: ID!, input: MetaInput!): OrderUpdateMeta + orderUpdateMeta(input: MetaInput!, token: UUID!): OrderUpdateMeta orderUpdatePrivateMeta(id: ID!, input: MetaInput!): OrderUpdatePrivateMeta orderUpdateShipping(order: ID!, input: OrderUpdateShippingInput): OrderUpdateShipping orderVoid(id: ID!): OrderVoid @@ -2179,8 +2211,6 @@ type Mutation { requestPasswordReset(email: String!, redirectUrl: String!): RequestPasswordReset setPassword(token: String!, email: String!, password: String!): SetPassword passwordChange(newPassword: String!, oldPassword: String!): PasswordChange - userUpdateMetadata(id: ID!, input: MetaInput!): UserUpdateMeta - userClearMetadata(id: ID!, input: MetaPath!): UserClearMeta accountAddressCreate(input: AddressInput!, type: AddressTypeEnum): AccountAddressCreate accountAddressUpdate(id: ID!, input: AddressInput!): AccountAddressUpdate accountAddressDelete(id: ID!): AccountAddressDelete @@ -2189,6 +2219,7 @@ type Mutation { accountUpdate(input: AccountInput!): AccountUpdate accountRequestDeletion(redirectUrl: String!): AccountRequestDeletion accountDelete(token: String!): AccountDelete + accountUpdateMeta(input: MetaInput!): AccountUpdateMeta customerPasswordReset(input: CustomerPasswordResetInput!): CustomerPasswordReset customerAddressCreate(input: AddressInput!, type: AddressTypeEnum): CustomerAddressCreate customerSetDefaultAddress(id: ID!, type: AddressTypeEnum!): CustomerSetDefaultAddress @@ -2209,6 +2240,8 @@ type Mutation { userAvatarUpdate(image: Upload!): UserAvatarUpdate userAvatarDelete: UserAvatarDelete userBulkSetActive(ids: [ID]!, isActive: Boolean!): UserBulkSetActive + userUpdateMetadata(id: ID!, input: MetaInput!): UserUpdateMeta + userClearMetadata(id: ID!, input: MetaPath!): UserClearMeta userUpdatePrivateMetadata(id: ID!, input: MetaInput!): UserUpdatePrivateMeta userClearPrivateMetadata(id: ID!, input: MetaPath!): UserClearPrivateMeta serviceAccountCreate(input: ServiceAccountInput!): ServiceAccountCreate @@ -3327,6 +3360,8 @@ type ProductVariantUpdatePrivateMeta { type Query { webhook(id: ID!): Webhook webhooks(filter: WebhookFilterInput, before: String, after: String, first: Int, last: Int): WebhookCountableConnection + webhookEvents: [WebhookEvent] + webhookSamplePayload(eventType: WebhookEventTypeEnum!): JSONString translations(kind: TranslatableKinds!, before: String, after: String, first: Int, last: Int): TranslatableItemConnection shop: Shop shippingZone(id: ID!): ShippingZone @@ -3744,6 +3779,8 @@ type Shop { currencies: [String]! defaultCurrency: String! defaultCountry: CountryDisplay + defaultMailSenderName: String + defaultMailSenderAddress: String description: String domain: Domain! homepageCollection: Collection @@ -3763,6 +3800,7 @@ type Shop { defaultDigitalMaxDownloads: Int defaultDigitalUrlValidDays: Int companyAddress: Address + customerSetPasswordUrl: String } type ShopAddressUpdate { @@ -3810,6 +3848,9 @@ input ShopSettingsInput { automaticFulfillmentDigitalProducts: Boolean defaultDigitalMaxDownloads: Int defaultDigitalUrlValidDays: Int + defaultMailSenderName: String + defaultMailSenderAddress: String + customerSetPasswordUrl: String } type ShopSettingsTranslate { @@ -4317,6 +4358,7 @@ enum WebhookErrorCode { type WebhookEvent { eventType: WebhookEventTypeEnum + name: String } enum WebhookEventTypeEnum { diff --git a/src/customers/views/CustomerAddresses.tsx b/src/customers/views/CustomerAddresses.tsx index da7c30019..d8b483c92 100644 --- a/src/customers/views/CustomerAddresses.tsx +++ b/src/customers/views/CustomerAddresses.tsx @@ -8,7 +8,7 @@ import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; import useShop from "@saleor/hooks/useShop"; import { commonMessages } from "@saleor/intl"; -import { getMutationState, maybe } from "../../misc"; +import { getMutationState, maybe, transformFormToAddress } from "../../misc"; import CustomerAddressDialog from "../components/CustomerAddressDialog"; import CustomerAddressListPage from "../components/CustomerAddressListPage"; import { @@ -176,7 +176,7 @@ const CustomerAddresses: React.FC = ({ createCustomerAddress({ variables: { id, - input + input: transformFormToAddress(input) } }) } @@ -202,7 +202,7 @@ const CustomerAddresses: React.FC = ({ updateCustomerAddress({ variables: { id: params.id, - input + input: transformFormToAddress(input) } }) } diff --git a/src/customers/views/CustomerCreate.tsx b/src/customers/views/CustomerCreate.tsx index 679864da5..7713ad076 100644 --- a/src/customers/views/CustomerCreate.tsx +++ b/src/customers/views/CustomerCreate.tsx @@ -4,7 +4,7 @@ import { useIntl } from "react-intl"; import { WindowTitle } from "@saleor/components/WindowTitle"; import useNavigator from "@saleor/hooks/useNavigator"; import useNotifier from "@saleor/hooks/useNotifier"; -import { maybe } from "../../misc"; +import { maybe, transformFormToAddress } from "../../misc"; import CustomerCreatePage from "../components/CustomerCreatePage"; import { TypedCreateCustomerMutation } from "../mutations"; import { TypedCustomerCreateDataQuery } from "../queries"; @@ -73,8 +73,8 @@ export const CustomerCreate: React.StatelessComponent<{}> = () => { createCustomer({ variables: { input: { - defaultBillingAddress: address, - defaultShippingAddress: address, + defaultBillingAddress: transformFormToAddress(address), + defaultShippingAddress: transformFormToAddress(address), email: formData.email, firstName: formData.customerFirstName, lastName: formData.customerLastName, diff --git a/src/misc.ts b/src/misc.ts index 883496397..ff80d36a2 100644 --- a/src/misc.ts +++ b/src/misc.ts @@ -5,10 +5,12 @@ import urlJoin from "url-join"; import { ConfirmButtonTransitionState } from "./components/ConfirmButton/ConfirmButton"; import { APP_MOUNT_URI } from "./config"; -import { AddressType } from "./customers/types"; +import { AddressType, AddressTypeInput } from "./customers/types"; import { PartialMutationProviderOutput, UserError } from "./types"; import { + AddressInput, AuthorizationKeyType, + CountryCode, OrderStatus, PaymentChargeStatusEnum } from "./types/globalTypes"; @@ -336,3 +338,12 @@ export function parseBoolean(a: string): boolean { export function capitalize(s: string) { return s.charAt(0).toLocaleUpperCase() + s.slice(1); } + +export function transformFormToAddress( + address: AddressTypeInput +): AddressInput { + return { + ...address, + country: findInEnum(address.country, CountryCode) + }; +} diff --git a/src/orders/views/OrderDetails/index.tsx b/src/orders/views/OrderDetails/index.tsx index 4ff24ae2b..a33c405d4 100644 --- a/src/orders/views/OrderDetails/index.tsx +++ b/src/orders/views/OrderDetails/index.tsx @@ -5,7 +5,12 @@ import useNavigator from "@saleor/hooks/useNavigator"; import { DEFAULT_INITIAL_SEARCH_DATA } from "../../../config"; import SearchCustomers from "../../../containers/SearchCustomers"; import { customerUrl } from "../../../customers/urls"; -import { getMutationState, maybe, transformAddressToForm } from "../../../misc"; +import { + getMutationState, + maybe, + transformAddressToForm, + transformFormToAddress +} from "../../../misc"; import { productUrl } from "../../../products/urls"; import { OrderStatus } from "../../../types/globalTypes"; import OrderAddressEditDialog from "../../components/OrderAddressEditDialog"; @@ -592,7 +597,9 @@ export const OrderDetails: React.StatelessComponent = ({ orderUpdate.mutate({ id, input: { - shippingAddress + shippingAddress: transformFormToAddress( + shippingAddress + ) } }) } @@ -625,7 +632,9 @@ export const OrderDetails: React.StatelessComponent = ({ orderUpdate.mutate({ id, input: { - billingAddress + billingAddress: transformFormToAddress( + billingAddress + ) } }) } diff --git a/src/siteSettings/views/index.tsx b/src/siteSettings/views/index.tsx index 77758cb18..776c1d5ea 100644 --- a/src/siteSettings/views/index.tsx +++ b/src/siteSettings/views/index.tsx @@ -7,8 +7,8 @@ import { commonMessages, sectionNames } from "@saleor/intl"; import { useIntl } from "react-intl"; import { configurationMenuUrl } from "../../configuration"; -import { getMutationState, maybe } from "../../misc"; -import { AuthorizationKeyType } from "../../types/globalTypes"; +import { findInEnum, getMutationState, maybe } from "../../misc"; +import { AuthorizationKeyType, CountryCode } from "../../types/globalTypes"; import SiteSettingsKeyDialog, { SiteSettingsKeyDialogForm } from "../components/SiteSettingsKeyDialog"; @@ -130,7 +130,7 @@ export const SiteSettings: React.StatelessComponent = ({ addressInput: { city: data.city, companyName: data.companyName, - country: data.country, + country: findInEnum(data.country, CountryCode), countryArea: data.countryArea, phone: data.phone, postalCode: data.postalCode, diff --git a/src/types/globalTypes.ts b/src/types/globalTypes.ts index 029e1ff9d..bf3380c70 100644 --- a/src/types/globalTypes.ts +++ b/src/types/globalTypes.ts @@ -43,6 +43,259 @@ export enum ConfigurationTypeFieldEnum { STRING = "STRING", } +export enum CountryCode { + AD = "AD", + AE = "AE", + AF = "AF", + AG = "AG", + AI = "AI", + AL = "AL", + AM = "AM", + AO = "AO", + AQ = "AQ", + AR = "AR", + AS = "AS", + AT = "AT", + AU = "AU", + AW = "AW", + AX = "AX", + AZ = "AZ", + BA = "BA", + BB = "BB", + BD = "BD", + BE = "BE", + BF = "BF", + BG = "BG", + BH = "BH", + BI = "BI", + BJ = "BJ", + BL = "BL", + BM = "BM", + BN = "BN", + BO = "BO", + BQ = "BQ", + BR = "BR", + BS = "BS", + BT = "BT", + BV = "BV", + BW = "BW", + BY = "BY", + BZ = "BZ", + CA = "CA", + CC = "CC", + CD = "CD", + CF = "CF", + CG = "CG", + CH = "CH", + CI = "CI", + CK = "CK", + CL = "CL", + CM = "CM", + CN = "CN", + CO = "CO", + CR = "CR", + CU = "CU", + CV = "CV", + CW = "CW", + CX = "CX", + CY = "CY", + CZ = "CZ", + DE = "DE", + DJ = "DJ", + DK = "DK", + DM = "DM", + DO = "DO", + DZ = "DZ", + EC = "EC", + EE = "EE", + EG = "EG", + EH = "EH", + ER = "ER", + ES = "ES", + ET = "ET", + EU = "EU", + FI = "FI", + FJ = "FJ", + FK = "FK", + FM = "FM", + FO = "FO", + FR = "FR", + GA = "GA", + GB = "GB", + GD = "GD", + GE = "GE", + GF = "GF", + GG = "GG", + GH = "GH", + GI = "GI", + GL = "GL", + GM = "GM", + GN = "GN", + GP = "GP", + GQ = "GQ", + GR = "GR", + GS = "GS", + GT = "GT", + GU = "GU", + GW = "GW", + GY = "GY", + HK = "HK", + HM = "HM", + HN = "HN", + HR = "HR", + HT = "HT", + HU = "HU", + ID = "ID", + IE = "IE", + IL = "IL", + IM = "IM", + IN = "IN", + IO = "IO", + IQ = "IQ", + IR = "IR", + IS = "IS", + IT = "IT", + JE = "JE", + JM = "JM", + JO = "JO", + JP = "JP", + KE = "KE", + KG = "KG", + KH = "KH", + KI = "KI", + KM = "KM", + KN = "KN", + KP = "KP", + KR = "KR", + KW = "KW", + KY = "KY", + KZ = "KZ", + LA = "LA", + LB = "LB", + LC = "LC", + LI = "LI", + LK = "LK", + LR = "LR", + LS = "LS", + LT = "LT", + LU = "LU", + LV = "LV", + LY = "LY", + MA = "MA", + MC = "MC", + MD = "MD", + ME = "ME", + MF = "MF", + MG = "MG", + MH = "MH", + MK = "MK", + ML = "ML", + MM = "MM", + MN = "MN", + MO = "MO", + MP = "MP", + MQ = "MQ", + MR = "MR", + MS = "MS", + MT = "MT", + MU = "MU", + MV = "MV", + MW = "MW", + MX = "MX", + MY = "MY", + MZ = "MZ", + NA = "NA", + NC = "NC", + NE = "NE", + NF = "NF", + NG = "NG", + NI = "NI", + NL = "NL", + NO = "NO", + NP = "NP", + NR = "NR", + NU = "NU", + NZ = "NZ", + OM = "OM", + PA = "PA", + PE = "PE", + PF = "PF", + PG = "PG", + PH = "PH", + PK = "PK", + PL = "PL", + PM = "PM", + PN = "PN", + PR = "PR", + PS = "PS", + PT = "PT", + PW = "PW", + PY = "PY", + QA = "QA", + RE = "RE", + RO = "RO", + RS = "RS", + RU = "RU", + RW = "RW", + SA = "SA", + SB = "SB", + SC = "SC", + SD = "SD", + SE = "SE", + SG = "SG", + SH = "SH", + SI = "SI", + SJ = "SJ", + SK = "SK", + SL = "SL", + SM = "SM", + SN = "SN", + SO = "SO", + SR = "SR", + SS = "SS", + ST = "ST", + SV = "SV", + SX = "SX", + SY = "SY", + SZ = "SZ", + TC = "TC", + TD = "TD", + TF = "TF", + TG = "TG", + TH = "TH", + TJ = "TJ", + TK = "TK", + TL = "TL", + TM = "TM", + TN = "TN", + TO = "TO", + TR = "TR", + TT = "TT", + TV = "TV", + TW = "TW", + TZ = "TZ", + UA = "UA", + UG = "UG", + UM = "UM", + US = "US", + UY = "UY", + UZ = "UZ", + VA = "VA", + VC = "VC", + VE = "VE", + VG = "VG", + VI = "VI", + VN = "VN", + VU = "VU", + WF = "WF", + WS = "WS", + YE = "YE", + YT = "YT", + ZA = "ZA", + ZM = "ZM", + ZW = "ZW", +} + export enum DiscountStatusEnum { ACTIVE = "ACTIVE", EXPIRED = "EXPIRED", @@ -299,6 +552,7 @@ export enum WebhookEventTypeEnum { CUSTOMER_CREATED = "CUSTOMER_CREATED", ORDER_CANCELLED = "ORDER_CANCELLED", ORDER_CREATED = "ORDER_CREATED", + ORDER_FULFILLED = "ORDER_FULFILLED", ORDER_FULLY_PAID = "ORDER_FULLY_PAID", ORDER_UPDATED = "ORDER_UPDATED", PRODUCT_CREATED = "PRODUCT_CREATED", @@ -320,7 +574,7 @@ export interface AddressInput { city?: string | null; cityArea?: string | null; postalCode?: string | null; - country?: string | null; + country?: CountryCode | null; countryArea?: string | null; phone?: string | null; } @@ -748,6 +1002,9 @@ export interface ShopSettingsInput { automaticFulfillmentDigitalProducts?: boolean | null; defaultDigitalMaxDownloads?: number | null; defaultDigitalUrlValidDays?: number | null; + defaultMailSenderName?: string | null; + defaultMailSenderAddress?: string | null; + customerSetPasswordUrl?: string | null; } export interface SiteDomainInput {