From cd8158d99e1273c5dcf893019a1382147bfec639 Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Mon, 13 Jan 2020 17:41:06 +0100 Subject: [PATCH 1/6] Update GraphQL queries --- apollo.config.js | 8 +++-- src/@sdk/fragments/products.ts | 2 +- .../fragments/types/ProductVariantFields.ts | 6 ++-- src/@sdk/mutations/types/AccountUpdate.ts | 26 +------------- src/@sdk/mutations/types/CreateCheckout.ts | 18 +--------- src/@sdk/mutations/types/CreateUserAddress.ts | 26 +------------- src/@sdk/mutations/types/DeleteUserAddress.ts | 24 ------------- .../types/SetCustomerDefaultAddress.ts | 26 +------------- .../types/UpdateCheckoutBillingAddress.ts | 18 +--------- .../mutations/types/UpdateCheckoutLine.ts | 2 +- .../types/UpdateCheckoutShippingAddress.ts | 34 +------------------ src/@sdk/mutations/types/UpdateUserAddress.ts | 26 +------------- src/@sdk/queries/attributes.ts | 2 +- src/@sdk/queries/products.ts | 6 ++-- src/@sdk/queries/types/CheckoutDetails.ts | 16 --------- src/@sdk/queries/types/ProductDetails.ts | 18 +++------- src/@sdk/queries/types/ProductList.ts | 6 ++-- src/@sdk/queries/types/UserCheckoutDetails.ts | 16 --------- src/@sdk/queries/types/UserDetails.ts | 24 ------------- src/checkout/views/Payment/queries.ts | 24 +++++++------ .../OverlayManager/Search/queries.ts | 2 +- src/views/Category/queries.ts | 8 ++--- src/views/Category/types/Category.ts | 4 +-- src/views/Collection/queries.ts | 8 ++--- src/views/Collection/types/Collection.ts | 4 +-- src/views/Product/View.tsx | 4 +-- src/views/Product/queries.ts | 6 ++-- src/views/Product/types/ProductDetails.ts | 18 +++------- .../Product/types/ProductVariantFields.ts | 6 ++-- src/views/Product/types/VariantList.ts | 6 ++-- src/views/Search/queries.ts | 7 ++-- src/views/Search/types/SearchProducts.ts | 4 +-- 32 files changed, 75 insertions(+), 330 deletions(-) diff --git a/apollo.config.js b/apollo.config.js index ec93a63878..b18c0395f9 100644 --- a/apollo.config.js +++ b/apollo.config.js @@ -2,7 +2,9 @@ module.exports = { client: { service: { name: "saleor", - url: "http://localhost:8000/graphql/" - } - } + url: "http://localhost:8000/graphql/", + includes: ["./**/*.js", "./**/*.ts"], + excludes: ["**/__tests__/**/*"], + }, + }, }; diff --git a/src/@sdk/fragments/products.ts b/src/@sdk/fragments/products.ts index eaebfa83c0..94d96544dd 100644 --- a/src/@sdk/fragments/products.ts +++ b/src/@sdk/fragments/products.ts @@ -50,7 +50,7 @@ export const productVariantFragment = gql` id name } - value { + values { id name value: name diff --git a/src/@sdk/fragments/types/ProductVariantFields.ts b/src/@sdk/fragments/types/ProductVariantFields.ts index cd36721903..6fdacb8ddb 100644 --- a/src/@sdk/fragments/types/ProductVariantFields.ts +++ b/src/@sdk/fragments/types/ProductVariantFields.ts @@ -122,7 +122,7 @@ export interface ProductVariantFields_attributes_attribute { name: string | null; } -export interface ProductVariantFields_attributes_value { +export interface ProductVariantFields_attributes_values { __typename: "AttributeValue"; /** * The ID of the object. @@ -145,9 +145,9 @@ export interface ProductVariantFields_attributes { */ attribute: ProductVariantFields_attributes_attribute; /** - * The value or the first value of an attribute. + * Values of an attribute. */ - value: ProductVariantFields_attributes_value | null; + values: (ProductVariantFields_attributes_values | null)[]; } export interface ProductVariantFields { diff --git a/src/@sdk/mutations/types/AccountUpdate.ts b/src/@sdk/mutations/types/AccountUpdate.ts index 52c773a519..7d94595cfb 100644 --- a/src/@sdk/mutations/types/AccountUpdate.ts +++ b/src/@sdk/mutations/types/AccountUpdate.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AccountInput } from "./../../types/globalTypes"; +import { AccountInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: AccountUpdate @@ -52,14 +52,6 @@ export interface AccountUpdate_accountUpdate_user_defaultShippingAddress { country: AccountUpdate_accountUpdate_user_defaultShippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface AccountUpdate_accountUpdate_user_defaultBillingAddress_country { @@ -93,14 +85,6 @@ export interface AccountUpdate_accountUpdate_user_defaultBillingAddress { country: AccountUpdate_accountUpdate_user_defaultBillingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface AccountUpdate_accountUpdate_user_addresses_country { @@ -134,14 +118,6 @@ export interface AccountUpdate_accountUpdate_user_addresses { country: AccountUpdate_accountUpdate_user_addresses_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface AccountUpdate_accountUpdate_user { diff --git a/src/@sdk/mutations/types/CreateCheckout.ts b/src/@sdk/mutations/types/CreateCheckout.ts index d74f885523..53bec4a34b 100644 --- a/src/@sdk/mutations/types/CreateCheckout.ts +++ b/src/@sdk/mutations/types/CreateCheckout.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { CheckoutCreateInput } from "./../../types/globalTypes"; +import { CheckoutCreateInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateCheckout @@ -169,14 +169,6 @@ export interface CreateCheckout_checkoutCreate_checkout_billingAddress { country: CreateCheckout_checkoutCreate_checkout_billingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CreateCheckout_checkoutCreate_checkout_shippingAddress_country { @@ -210,14 +202,6 @@ export interface CreateCheckout_checkoutCreate_checkout_shippingAddress { country: CreateCheckout_checkoutCreate_checkout_shippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CreateCheckout_checkoutCreate_checkout_availableShippingMethods_price { diff --git a/src/@sdk/mutations/types/CreateUserAddress.ts b/src/@sdk/mutations/types/CreateUserAddress.ts index 4ed01407b2..26b0de51f4 100644 --- a/src/@sdk/mutations/types/CreateUserAddress.ts +++ b/src/@sdk/mutations/types/CreateUserAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../types/globalTypes"; +import { AddressInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateUserAddress @@ -52,14 +52,6 @@ export interface CreateUserAddress_accountAddressCreate_user_defaultShippingAddr country: CreateUserAddress_accountAddressCreate_user_defaultShippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CreateUserAddress_accountAddressCreate_user_defaultBillingAddress_country { @@ -93,14 +85,6 @@ export interface CreateUserAddress_accountAddressCreate_user_defaultBillingAddre country: CreateUserAddress_accountAddressCreate_user_defaultBillingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CreateUserAddress_accountAddressCreate_user_addresses_country { @@ -134,14 +118,6 @@ export interface CreateUserAddress_accountAddressCreate_user_addresses { country: CreateUserAddress_accountAddressCreate_user_addresses_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CreateUserAddress_accountAddressCreate_user { diff --git a/src/@sdk/mutations/types/DeleteUserAddress.ts b/src/@sdk/mutations/types/DeleteUserAddress.ts index 76f08957ab..46dffe8376 100644 --- a/src/@sdk/mutations/types/DeleteUserAddress.ts +++ b/src/@sdk/mutations/types/DeleteUserAddress.ts @@ -50,14 +50,6 @@ export interface DeleteUserAddress_accountAddressDelete_user_defaultShippingAddr country: DeleteUserAddress_accountAddressDelete_user_defaultShippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface DeleteUserAddress_accountAddressDelete_user_defaultBillingAddress_country { @@ -91,14 +83,6 @@ export interface DeleteUserAddress_accountAddressDelete_user_defaultBillingAddre country: DeleteUserAddress_accountAddressDelete_user_defaultBillingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface DeleteUserAddress_accountAddressDelete_user_addresses_country { @@ -132,14 +116,6 @@ export interface DeleteUserAddress_accountAddressDelete_user_addresses { country: DeleteUserAddress_accountAddressDelete_user_addresses_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface DeleteUserAddress_accountAddressDelete_user { diff --git a/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts b/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts index 2923bb4869..ca01eafc4b 100644 --- a/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts +++ b/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressTypeEnum } from "./../../types/globalTypes"; +import { AddressTypeEnum } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: SetCustomerDefaultAddress @@ -52,14 +52,6 @@ export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_default country: SetCustomerDefaultAddress_accountSetDefaultAddress_user_defaultShippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_defaultBillingAddress_country { @@ -93,14 +85,6 @@ export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_default country: SetCustomerDefaultAddress_accountSetDefaultAddress_user_defaultBillingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_addresses_country { @@ -134,14 +118,6 @@ export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_address country: SetCustomerDefaultAddress_accountSetDefaultAddress_user_addresses_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user { diff --git a/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts b/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts index 078637906a..a489a63eaf 100644 --- a/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts +++ b/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../types/globalTypes"; +import { AddressInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCheckoutBillingAddress @@ -169,14 +169,6 @@ export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_check country: UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_billingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_shippingAddress_country { @@ -210,14 +202,6 @@ export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_check country: UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_shippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_availableShippingMethods_price { diff --git a/src/@sdk/mutations/types/UpdateCheckoutLine.ts b/src/@sdk/mutations/types/UpdateCheckoutLine.ts index 69e83f5530..3df1a86bf2 100644 --- a/src/@sdk/mutations/types/UpdateCheckoutLine.ts +++ b/src/@sdk/mutations/types/UpdateCheckoutLine.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { CheckoutLineInput } from "./../../types/globalTypes"; +import { CheckoutLineInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCheckoutLine diff --git a/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts b/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts index 59daf72680..842d4c6e32 100644 --- a/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts +++ b/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../types/globalTypes"; +import { AddressInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCheckoutShippingAddress @@ -169,14 +169,6 @@ export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_che country: UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_billingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_shippingAddress_country { @@ -210,14 +202,6 @@ export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_che country: UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_shippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_availableShippingMethods_price { @@ -734,14 +718,6 @@ export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_bill country: UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_billingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_shippingAddress_country { @@ -775,14 +751,6 @@ export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_ship country: UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_shippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_availableShippingMethods_price { diff --git a/src/@sdk/mutations/types/UpdateUserAddress.ts b/src/@sdk/mutations/types/UpdateUserAddress.ts index 8c4b7ae772..e16bedad1f 100644 --- a/src/@sdk/mutations/types/UpdateUserAddress.ts +++ b/src/@sdk/mutations/types/UpdateUserAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../types/globalTypes"; +import { AddressInput } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateUserAddress @@ -52,14 +52,6 @@ export interface UpdateUserAddress_accountAddressUpdate_user_defaultShippingAddr country: UpdateUserAddress_accountAddressUpdate_user_defaultShippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateUserAddress_accountAddressUpdate_user_defaultBillingAddress_country { @@ -93,14 +85,6 @@ export interface UpdateUserAddress_accountAddressUpdate_user_defaultBillingAddre country: UpdateUserAddress_accountAddressUpdate_user_defaultBillingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateUserAddress_accountAddressUpdate_user_addresses_country { @@ -134,14 +118,6 @@ export interface UpdateUserAddress_accountAddressUpdate_user_addresses { country: UpdateUserAddress_accountAddressUpdate_user_addresses_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UpdateUserAddress_accountAddressUpdate_user { diff --git a/src/@sdk/queries/attributes.ts b/src/@sdk/queries/attributes.ts index 2e8a90ef65..6d8441c9b0 100644 --- a/src/@sdk/queries/attributes.ts +++ b/src/@sdk/queries/attributes.ts @@ -2,7 +2,7 @@ import gql from "graphql-tag"; export const attributes = gql` query Attributes($id: ID!) { - attributes(inCategory: $id, first: 100) { + attributes(filter: { inCategory: $id }, first: 100) { edges { node { id diff --git a/src/@sdk/queries/products.ts b/src/@sdk/queries/products.ts index 2085a57271..194fea819a 100644 --- a/src/@sdk/queries/products.ts +++ b/src/@sdk/queries/products.ts @@ -55,7 +55,7 @@ export const productListDetails = gql` edges { node { ...BasicProductFields - price { + basePrice { amount currency localized @@ -128,9 +128,7 @@ export const productDetails = gql` } seoDescription seoTitle - availability { - available - } + isAvailable } } `; diff --git a/src/@sdk/queries/types/CheckoutDetails.ts b/src/@sdk/queries/types/CheckoutDetails.ts index 90c31b518f..ffda17c76c 100644 --- a/src/@sdk/queries/types/CheckoutDetails.ts +++ b/src/@sdk/queries/types/CheckoutDetails.ts @@ -154,14 +154,6 @@ export interface CheckoutDetails_checkout_billingAddress { country: CheckoutDetails_checkout_billingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CheckoutDetails_checkout_shippingAddress_country { @@ -195,14 +187,6 @@ export interface CheckoutDetails_checkout_shippingAddress { country: CheckoutDetails_checkout_shippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface CheckoutDetails_checkout_availableShippingMethods_price { diff --git a/src/@sdk/queries/types/ProductDetails.ts b/src/@sdk/queries/types/ProductDetails.ts index fed0bd9409..520729d4c2 100644 --- a/src/@sdk/queries/types/ProductDetails.ts +++ b/src/@sdk/queries/types/ProductDetails.ts @@ -715,7 +715,7 @@ export interface ProductDetails_product_variants_attributes_attribute { name: string | null; } -export interface ProductDetails_product_variants_attributes_value { +export interface ProductDetails_product_variants_attributes_values { __typename: "AttributeValue"; /** * The ID of the object. @@ -738,9 +738,9 @@ export interface ProductDetails_product_variants_attributes { */ attribute: ProductDetails_product_variants_attributes_attribute; /** - * The value or the first value of an attribute. + * Values of an attribute. */ - value: ProductDetails_product_variants_attributes_value | null; + values: (ProductDetails_product_variants_attributes_values | null)[]; } export interface ProductDetails_product_variants { @@ -769,14 +769,6 @@ export interface ProductDetails_product_variants { attributes: ProductDetails_product_variants_attributes[]; } -export interface ProductDetails_product_availability { - __typename: "ProductPricingInfo"; - /** - * Whether it is in stock and visible or not. - */ - available: boolean | null; -} - export interface ProductDetails_product { __typename: "Product"; /** @@ -817,9 +809,9 @@ export interface ProductDetails_product { seoDescription: string | null; seoTitle: string | null; /** - * Informs about product's availability in the storefront, current price and discounts. + * Whether the product is in stock and visible or not. */ - availability: ProductDetails_product_availability | null; + isAvailable: boolean | null; } export interface ProductDetails { diff --git a/src/@sdk/queries/types/ProductList.ts b/src/@sdk/queries/types/ProductList.ts index 4bd82de949..a5a81368a4 100644 --- a/src/@sdk/queries/types/ProductList.ts +++ b/src/@sdk/queries/types/ProductList.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AttributeInput, ProductOrder } from "./../../types/globalTypes"; +import { AttributeInput, ProductOrder } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL query operation: ProductList @@ -28,7 +28,7 @@ export interface ProductList_products_edges_node_thumbnail2x { url: string; } -export interface ProductList_products_edges_node_price { +export interface ProductList_products_edges_node_basePrice { __typename: "Money"; /** * Amount of money. @@ -103,7 +103,7 @@ export interface ProductList_products_edges_node { /** * The product's default base price. */ - price: ProductList_products_edges_node_price | null; + basePrice: ProductList_products_edges_node_basePrice | null; /** * Lists the storefront product's pricing, the current price and discounts, only meant for displaying. */ diff --git a/src/@sdk/queries/types/UserCheckoutDetails.ts b/src/@sdk/queries/types/UserCheckoutDetails.ts index abfed62303..361068fea9 100644 --- a/src/@sdk/queries/types/UserCheckoutDetails.ts +++ b/src/@sdk/queries/types/UserCheckoutDetails.ts @@ -154,14 +154,6 @@ export interface UserCheckoutDetails_me_checkout_billingAddress { country: UserCheckoutDetails_me_checkout_billingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UserCheckoutDetails_me_checkout_shippingAddress_country { @@ -195,14 +187,6 @@ export interface UserCheckoutDetails_me_checkout_shippingAddress { country: UserCheckoutDetails_me_checkout_shippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UserCheckoutDetails_me_checkout_availableShippingMethods_price { diff --git a/src/@sdk/queries/types/UserDetails.ts b/src/@sdk/queries/types/UserDetails.ts index b550bf7456..47ec52737c 100644 --- a/src/@sdk/queries/types/UserDetails.ts +++ b/src/@sdk/queries/types/UserDetails.ts @@ -37,14 +37,6 @@ export interface UserDetails_me_defaultShippingAddress { country: UserDetails_me_defaultShippingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UserDetails_me_defaultBillingAddress_country { @@ -78,14 +70,6 @@ export interface UserDetails_me_defaultBillingAddress { country: UserDetails_me_defaultBillingAddress_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UserDetails_me_addresses_country { @@ -119,14 +103,6 @@ export interface UserDetails_me_addresses { country: UserDetails_me_addresses_country; countryArea: string; phone: string | null; - /** - * Address is user's default billing address. - */ - isDefaultBillingAddress: boolean | null; - /** - * Address is user's default shipping address. - */ - isDefaultShippingAddress: boolean | null; } export interface UserDetails_me { diff --git a/src/checkout/views/Payment/queries.ts b/src/checkout/views/Payment/queries.ts index e7fc4ccd1d..0d13d00644 100644 --- a/src/checkout/views/Payment/queries.ts +++ b/src/checkout/views/Payment/queries.ts @@ -5,14 +5,18 @@ import { TypedQuery } from "../../../core/queries"; import { createPayment, createPaymentVariables } from "./types/createPayment"; import { getPaymentToken, - getPaymentTokenVariables + getPaymentTokenVariables, } from "./types/getPaymentToken"; -const getPaymentTokenQuery = gql` - query getPaymentToken($gateway: String!) { - paymentClientToken(gateway: $gateway) - } -`; +/* + TODO: getPaymentTokenQuery is deprecated, fix it. +*/ + +// const getPaymentTokenQuery = gql` +// query getPaymentToken($gateway: String!) { +// paymentClientToken(gateway: $gateway) +// } +// `; const paymentMethodCreateMutation = gql` mutation createPayment($input: PaymentInput!, $checkoutId: ID!) { @@ -25,10 +29,10 @@ const paymentMethodCreateMutation = gql` } `; -export const TypedGetPaymentTokenQuery = TypedQuery< - getPaymentToken, - getPaymentTokenVariables ->(getPaymentTokenQuery); +// export const TypedGetPaymentTokenQuery = TypedQuery< +// getPaymentToken, +// getPaymentTokenVariables +// >(getPaymentTokenQuery); export const TypedPaymentMethodCreateMutation = TypedMutation< createPayment, diff --git a/src/components/OverlayManager/Search/queries.ts b/src/components/OverlayManager/Search/queries.ts index 65fe596676..5200a60d83 100644 --- a/src/components/OverlayManager/Search/queries.ts +++ b/src/components/OverlayManager/Search/queries.ts @@ -5,7 +5,7 @@ import { SearchResults, SearchResultsVariables } from "./types/SearchResults"; const searchResultsQuery = gql` query SearchResults($query: String!) { - products(query: $query, first: 20) { + products(filter: { search: $query }, first: 20) { edges { node { id diff --git a/src/views/Category/queries.ts b/src/views/Category/queries.ts index 0c6de05588..1aa9d197e8 100644 --- a/src/views/Category/queries.ts +++ b/src/views/Category/queries.ts @@ -3,7 +3,7 @@ import gql from "graphql-tag"; import { TypedQuery } from "../../core/queries"; import { basicProductFragment, - productPricingFragment + productPricingFragment, } from "../Product/queries"; import { Category, CategoryVariables } from "./types/Category"; @@ -12,7 +12,7 @@ export const categoryProductsQuery = gql` ${productPricingFragment} query Category( $id: ID! - $attributes: [AttributeScalar] + $attributes: [AttributeInput] $after: String $pageSize: Int $sortBy: ProductOrder @@ -21,10 +21,10 @@ export const categoryProductsQuery = gql` ) { products( after: $after - attributes: $attributes first: $pageSize sortBy: $sortBy filter: { + attributes: $attributes categories: [$id] minimalPrice: { gte: $priceGte, lte: $priceLte } } @@ -64,7 +64,7 @@ export const categoryProductsQuery = gql` } } } - attributes(inCategory: $id, first: 100) { + attributes(filter: { inCategory: $id }, first: 100) { edges { node { id diff --git a/src/views/Category/types/Category.ts b/src/views/Category/types/Category.ts index 0c740c77ae..08b868a453 100644 --- a/src/views/Category/types/Category.ts +++ b/src/views/Category/types/Category.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { ProductOrder } from "./../../../../types/globalTypes"; +import { AttributeInput, ProductOrder } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL query operation: Category @@ -428,7 +428,7 @@ export interface Category { export interface CategoryVariables { id: string; - attributes?: (any | null)[] | null; + attributes?: (AttributeInput | null)[] | null; after?: string | null; pageSize?: number | null; sortBy?: ProductOrder | null; diff --git a/src/views/Collection/queries.ts b/src/views/Collection/queries.ts index f2ef81ef12..07a77c79d1 100644 --- a/src/views/Collection/queries.ts +++ b/src/views/Collection/queries.ts @@ -3,7 +3,7 @@ import gql from "graphql-tag"; import { TypedQuery } from "../../core/queries"; import { basicProductFragment, - productPricingFragment + productPricingFragment, } from "../Product/queries"; import { Collection, CollectionVariables } from "./types/Collection"; @@ -12,7 +12,7 @@ export const collectionProductsQuery = gql` ${productPricingFragment} query Collection( $id: ID! - $attributes: [AttributeScalar] + $attributes: [AttributeInput] $after: String $pageSize: Int $sortBy: ProductOrder @@ -31,10 +31,10 @@ export const collectionProductsQuery = gql` } products( after: $after - attributes: $attributes first: $pageSize sortBy: $sortBy filter: { + attributes: $attributes collections: [$id] minimalPrice: { gte: $priceGte, lte: $priceLte } } @@ -57,7 +57,7 @@ export const collectionProductsQuery = gql` startCursor } } - attributes(inCollection: $id, first: 100) { + attributes(filter: { inCollection: $id }, first: 100) { edges { node { id diff --git a/src/views/Collection/types/Collection.ts b/src/views/Collection/types/Collection.ts index a100216f66..075ea2842f 100644 --- a/src/views/Collection/types/Collection.ts +++ b/src/views/Collection/types/Collection.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { ProductOrder } from "./../../../../types/globalTypes"; +import { AttributeInput, ProductOrder } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL query operation: Collection @@ -403,7 +403,7 @@ export interface Collection { export interface CollectionVariables { id: string; - attributes?: (any | null)[] | null; + attributes?: (AttributeInput | null)[] | null; after?: string | null; pageSize?: number | null; sortBy?: ProductOrder | null; diff --git a/src/views/Product/View.tsx b/src/views/Product/View.tsx index ab0a577c81..cabc9ab281 100644 --- a/src/views/Product/View.tsx +++ b/src/views/Product/View.tsx @@ -29,8 +29,8 @@ const extractMeta = (product: ProductDetails_product) => ({ property: "product:price:currency", }, { - content: product.availability.available ? "in stock" : "out off stock", - property: "product:availability", + content: product.isAvailable ? "in stock" : "out off stock", + property: "product:isAvailable", }, { content: product.category.name, diff --git a/src/views/Product/queries.ts b/src/views/Product/queries.ts index 62e9265db3..20e42649b4 100644 --- a/src/views/Product/queries.ts +++ b/src/views/Product/queries.ts @@ -96,7 +96,7 @@ export const productVariantFragment = gql` id name } - value { + values { id name value: name @@ -148,9 +148,7 @@ export const productDetailsQuery = gql` } seoDescription seoTitle - availability { - available - } + isAvailable } } `; diff --git a/src/views/Product/types/ProductDetails.ts b/src/views/Product/types/ProductDetails.ts index fed0bd9409..520729d4c2 100644 --- a/src/views/Product/types/ProductDetails.ts +++ b/src/views/Product/types/ProductDetails.ts @@ -715,7 +715,7 @@ export interface ProductDetails_product_variants_attributes_attribute { name: string | null; } -export interface ProductDetails_product_variants_attributes_value { +export interface ProductDetails_product_variants_attributes_values { __typename: "AttributeValue"; /** * The ID of the object. @@ -738,9 +738,9 @@ export interface ProductDetails_product_variants_attributes { */ attribute: ProductDetails_product_variants_attributes_attribute; /** - * The value or the first value of an attribute. + * Values of an attribute. */ - value: ProductDetails_product_variants_attributes_value | null; + values: (ProductDetails_product_variants_attributes_values | null)[]; } export interface ProductDetails_product_variants { @@ -769,14 +769,6 @@ export interface ProductDetails_product_variants { attributes: ProductDetails_product_variants_attributes[]; } -export interface ProductDetails_product_availability { - __typename: "ProductPricingInfo"; - /** - * Whether it is in stock and visible or not. - */ - available: boolean | null; -} - export interface ProductDetails_product { __typename: "Product"; /** @@ -817,9 +809,9 @@ export interface ProductDetails_product { seoDescription: string | null; seoTitle: string | null; /** - * Informs about product's availability in the storefront, current price and discounts. + * Whether the product is in stock and visible or not. */ - availability: ProductDetails_product_availability | null; + isAvailable: boolean | null; } export interface ProductDetails { diff --git a/src/views/Product/types/ProductVariantFields.ts b/src/views/Product/types/ProductVariantFields.ts index cd36721903..6fdacb8ddb 100644 --- a/src/views/Product/types/ProductVariantFields.ts +++ b/src/views/Product/types/ProductVariantFields.ts @@ -122,7 +122,7 @@ export interface ProductVariantFields_attributes_attribute { name: string | null; } -export interface ProductVariantFields_attributes_value { +export interface ProductVariantFields_attributes_values { __typename: "AttributeValue"; /** * The ID of the object. @@ -145,9 +145,9 @@ export interface ProductVariantFields_attributes { */ attribute: ProductVariantFields_attributes_attribute; /** - * The value or the first value of an attribute. + * Values of an attribute. */ - value: ProductVariantFields_attributes_value | null; + values: (ProductVariantFields_attributes_values | null)[]; } export interface ProductVariantFields { diff --git a/src/views/Product/types/VariantList.ts b/src/views/Product/types/VariantList.ts index b1f5cc5899..249cc8ba37 100644 --- a/src/views/Product/types/VariantList.ts +++ b/src/views/Product/types/VariantList.ts @@ -122,7 +122,7 @@ export interface VariantList_productVariants_edges_node_attributes_attribute { name: string | null; } -export interface VariantList_productVariants_edges_node_attributes_value { +export interface VariantList_productVariants_edges_node_attributes_values { __typename: "AttributeValue"; /** * The ID of the object. @@ -145,9 +145,9 @@ export interface VariantList_productVariants_edges_node_attributes { */ attribute: VariantList_productVariants_edges_node_attributes_attribute; /** - * The value or the first value of an attribute. + * Values of an attribute. */ - value: VariantList_productVariants_edges_node_attributes_value | null; + values: (VariantList_productVariants_edges_node_attributes_values | null)[]; } export interface VariantList_productVariants_edges_node_product_thumbnail { diff --git a/src/views/Search/queries.ts b/src/views/Search/queries.ts index e2d6d6604a..64d9f7e9cb 100644 --- a/src/views/Search/queries.ts +++ b/src/views/Search/queries.ts @@ -4,21 +4,20 @@ import { TypedQuery } from "../../core/queries"; import { productPricingFragment } from "../Product/queries"; import { SearchProducts, - SearchProductsVariables + SearchProductsVariables, } from "./types/SearchProducts"; export const searchProductsQuery = gql` ${productPricingFragment} query SearchProducts( $query: String! - $attributes: [AttributeScalar] + $attributes: [AttributeInput] $pageSize: Int $sortBy: ProductOrder $after: String ) { products( - query: $query - attributes: $attributes + filter: { search: $query, attributes: $attributes } first: $pageSize sortBy: $sortBy after: $after diff --git a/src/views/Search/types/SearchProducts.ts b/src/views/Search/types/SearchProducts.ts index 0f8335a241..1a4e89379c 100644 --- a/src/views/Search/types/SearchProducts.ts +++ b/src/views/Search/types/SearchProducts.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { ProductOrder } from "./../../../../types/globalTypes"; +import { AttributeInput, ProductOrder } from "./../../../../types/globalTypes"; // ==================================================== // GraphQL query operation: SearchProducts @@ -370,7 +370,7 @@ export interface SearchProducts { export interface SearchProductsVariables { query: string; - attributes?: (any | null)[] | null; + attributes?: (AttributeInput | null)[] | null; pageSize?: number | null; sortBy?: ProductOrder | null; after?: string | null; From 745d0b9a1112af54af9dfac74c5b3ef7aa9ccebf Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Tue, 14 Jan 2020 11:07:45 +0100 Subject: [PATCH 2/6] Use product pricing field instead of basePrice --- src/@sdk/mutations/types/AccountUpdate.ts | 26 ++- src/@sdk/mutations/types/CreateCheckout.ts | 18 +- src/@sdk/mutations/types/CreateUserAddress.ts | 26 ++- src/@sdk/mutations/types/DeleteUserAddress.ts | 24 +++ .../types/SetCustomerDefaultAddress.ts | 26 ++- .../types/UpdateCheckoutBillingAddress.ts | 18 +- .../mutations/types/UpdateCheckoutLine.ts | 2 +- .../types/UpdateCheckoutShippingAddress.ts | 34 +++- src/@sdk/mutations/types/UpdateUserAddress.ts | 26 ++- src/@sdk/queries/products.ts | 21 +-- src/@sdk/queries/types/CheckoutDetails.ts | 16 ++ src/@sdk/queries/types/ProductDetails.ts | 20 -- src/@sdk/queries/types/ProductList.ts | 176 +++++++++++++++++- src/@sdk/queries/types/UserCheckoutDetails.ts | 16 ++ src/@sdk/queries/types/UserDetails.ts | 24 +++ src/components/ProductDescription/index.tsx | 24 ++- src/views/Product/Page.tsx | 2 +- src/views/Product/queries.ts | 5 - src/views/Product/types/ProductDetails.ts | 20 -- 19 files changed, 440 insertions(+), 84 deletions(-) diff --git a/src/@sdk/mutations/types/AccountUpdate.ts b/src/@sdk/mutations/types/AccountUpdate.ts index 7d94595cfb..52c773a519 100644 --- a/src/@sdk/mutations/types/AccountUpdate.ts +++ b/src/@sdk/mutations/types/AccountUpdate.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AccountInput } from "./../../../../types/globalTypes"; +import { AccountInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: AccountUpdate @@ -52,6 +52,14 @@ export interface AccountUpdate_accountUpdate_user_defaultShippingAddress { country: AccountUpdate_accountUpdate_user_defaultShippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface AccountUpdate_accountUpdate_user_defaultBillingAddress_country { @@ -85,6 +93,14 @@ export interface AccountUpdate_accountUpdate_user_defaultBillingAddress { country: AccountUpdate_accountUpdate_user_defaultBillingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface AccountUpdate_accountUpdate_user_addresses_country { @@ -118,6 +134,14 @@ export interface AccountUpdate_accountUpdate_user_addresses { country: AccountUpdate_accountUpdate_user_addresses_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface AccountUpdate_accountUpdate_user { diff --git a/src/@sdk/mutations/types/CreateCheckout.ts b/src/@sdk/mutations/types/CreateCheckout.ts index 53bec4a34b..d74f885523 100644 --- a/src/@sdk/mutations/types/CreateCheckout.ts +++ b/src/@sdk/mutations/types/CreateCheckout.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { CheckoutCreateInput } from "./../../../../types/globalTypes"; +import { CheckoutCreateInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateCheckout @@ -169,6 +169,14 @@ export interface CreateCheckout_checkoutCreate_checkout_billingAddress { country: CreateCheckout_checkoutCreate_checkout_billingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CreateCheckout_checkoutCreate_checkout_shippingAddress_country { @@ -202,6 +210,14 @@ export interface CreateCheckout_checkoutCreate_checkout_shippingAddress { country: CreateCheckout_checkoutCreate_checkout_shippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CreateCheckout_checkoutCreate_checkout_availableShippingMethods_price { diff --git a/src/@sdk/mutations/types/CreateUserAddress.ts b/src/@sdk/mutations/types/CreateUserAddress.ts index 26b0de51f4..4ed01407b2 100644 --- a/src/@sdk/mutations/types/CreateUserAddress.ts +++ b/src/@sdk/mutations/types/CreateUserAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../../../types/globalTypes"; +import { AddressInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: CreateUserAddress @@ -52,6 +52,14 @@ export interface CreateUserAddress_accountAddressCreate_user_defaultShippingAddr country: CreateUserAddress_accountAddressCreate_user_defaultShippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CreateUserAddress_accountAddressCreate_user_defaultBillingAddress_country { @@ -85,6 +93,14 @@ export interface CreateUserAddress_accountAddressCreate_user_defaultBillingAddre country: CreateUserAddress_accountAddressCreate_user_defaultBillingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CreateUserAddress_accountAddressCreate_user_addresses_country { @@ -118,6 +134,14 @@ export interface CreateUserAddress_accountAddressCreate_user_addresses { country: CreateUserAddress_accountAddressCreate_user_addresses_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CreateUserAddress_accountAddressCreate_user { diff --git a/src/@sdk/mutations/types/DeleteUserAddress.ts b/src/@sdk/mutations/types/DeleteUserAddress.ts index 46dffe8376..76f08957ab 100644 --- a/src/@sdk/mutations/types/DeleteUserAddress.ts +++ b/src/@sdk/mutations/types/DeleteUserAddress.ts @@ -50,6 +50,14 @@ export interface DeleteUserAddress_accountAddressDelete_user_defaultShippingAddr country: DeleteUserAddress_accountAddressDelete_user_defaultShippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface DeleteUserAddress_accountAddressDelete_user_defaultBillingAddress_country { @@ -83,6 +91,14 @@ export interface DeleteUserAddress_accountAddressDelete_user_defaultBillingAddre country: DeleteUserAddress_accountAddressDelete_user_defaultBillingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface DeleteUserAddress_accountAddressDelete_user_addresses_country { @@ -116,6 +132,14 @@ export interface DeleteUserAddress_accountAddressDelete_user_addresses { country: DeleteUserAddress_accountAddressDelete_user_addresses_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface DeleteUserAddress_accountAddressDelete_user { diff --git a/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts b/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts index ca01eafc4b..2923bb4869 100644 --- a/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts +++ b/src/@sdk/mutations/types/SetCustomerDefaultAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressTypeEnum } from "./../../../../types/globalTypes"; +import { AddressTypeEnum } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: SetCustomerDefaultAddress @@ -52,6 +52,14 @@ export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_default country: SetCustomerDefaultAddress_accountSetDefaultAddress_user_defaultShippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_defaultBillingAddress_country { @@ -85,6 +93,14 @@ export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_default country: SetCustomerDefaultAddress_accountSetDefaultAddress_user_defaultBillingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_addresses_country { @@ -118,6 +134,14 @@ export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user_address country: SetCustomerDefaultAddress_accountSetDefaultAddress_user_addresses_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface SetCustomerDefaultAddress_accountSetDefaultAddress_user { diff --git a/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts b/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts index a489a63eaf..078637906a 100644 --- a/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts +++ b/src/@sdk/mutations/types/UpdateCheckoutBillingAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../../../types/globalTypes"; +import { AddressInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCheckoutBillingAddress @@ -169,6 +169,14 @@ export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_check country: UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_billingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_shippingAddress_country { @@ -202,6 +210,14 @@ export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_check country: UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_shippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutBillingAddress_checkoutBillingAddressUpdate_checkout_availableShippingMethods_price { diff --git a/src/@sdk/mutations/types/UpdateCheckoutLine.ts b/src/@sdk/mutations/types/UpdateCheckoutLine.ts index 3df1a86bf2..69e83f5530 100644 --- a/src/@sdk/mutations/types/UpdateCheckoutLine.ts +++ b/src/@sdk/mutations/types/UpdateCheckoutLine.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { CheckoutLineInput } from "./../../../../types/globalTypes"; +import { CheckoutLineInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCheckoutLine diff --git a/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts b/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts index 842d4c6e32..59daf72680 100644 --- a/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts +++ b/src/@sdk/mutations/types/UpdateCheckoutShippingAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../../../types/globalTypes"; +import { AddressInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateCheckoutShippingAddress @@ -169,6 +169,14 @@ export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_che country: UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_billingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_shippingAddress_country { @@ -202,6 +210,14 @@ export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_che country: UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_shippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutShippingAddressUpdate_checkout_availableShippingMethods_price { @@ -718,6 +734,14 @@ export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_bill country: UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_billingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_shippingAddress_country { @@ -751,6 +775,14 @@ export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_ship country: UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_shippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateCheckoutShippingAddress_checkoutEmailUpdate_checkout_availableShippingMethods_price { diff --git a/src/@sdk/mutations/types/UpdateUserAddress.ts b/src/@sdk/mutations/types/UpdateUserAddress.ts index e16bedad1f..8c4b7ae772 100644 --- a/src/@sdk/mutations/types/UpdateUserAddress.ts +++ b/src/@sdk/mutations/types/UpdateUserAddress.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AddressInput } from "./../../../../types/globalTypes"; +import { AddressInput } from "./../../types/globalTypes"; // ==================================================== // GraphQL mutation operation: UpdateUserAddress @@ -52,6 +52,14 @@ export interface UpdateUserAddress_accountAddressUpdate_user_defaultShippingAddr country: UpdateUserAddress_accountAddressUpdate_user_defaultShippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateUserAddress_accountAddressUpdate_user_defaultBillingAddress_country { @@ -85,6 +93,14 @@ export interface UpdateUserAddress_accountAddressUpdate_user_defaultBillingAddre country: UpdateUserAddress_accountAddressUpdate_user_defaultBillingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateUserAddress_accountAddressUpdate_user_addresses_country { @@ -118,6 +134,14 @@ export interface UpdateUserAddress_accountAddressUpdate_user_addresses { country: UpdateUserAddress_accountAddressUpdate_user_addresses_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UpdateUserAddress_accountAddressUpdate_user { diff --git a/src/@sdk/queries/products.ts b/src/@sdk/queries/products.ts index 194fea819a..bfc9f4d321 100644 --- a/src/@sdk/queries/products.ts +++ b/src/@sdk/queries/products.ts @@ -32,6 +32,7 @@ export const productPricingFragment = gql` export const productListDetails = gql` ${basicProductFragment} + ${productPricingFragment} query ProductList( $id: ID! $attributes: [AttributeInput] @@ -55,20 +56,7 @@ export const productListDetails = gql` edges { node { ...BasicProductFields - basePrice { - amount - currency - localized - } - pricing { - priceRange { - start { - gross { - localized - } - } - } - } + ...ProductPricingField category { id name @@ -115,11 +103,6 @@ export const productDetails = gql` id url } - basePrice { - amount - currency - localized - } attributes { ...SelectedAttributeFields } diff --git a/src/@sdk/queries/types/CheckoutDetails.ts b/src/@sdk/queries/types/CheckoutDetails.ts index ffda17c76c..90c31b518f 100644 --- a/src/@sdk/queries/types/CheckoutDetails.ts +++ b/src/@sdk/queries/types/CheckoutDetails.ts @@ -154,6 +154,14 @@ export interface CheckoutDetails_checkout_billingAddress { country: CheckoutDetails_checkout_billingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CheckoutDetails_checkout_shippingAddress_country { @@ -187,6 +195,14 @@ export interface CheckoutDetails_checkout_shippingAddress { country: CheckoutDetails_checkout_shippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface CheckoutDetails_checkout_availableShippingMethods_price { diff --git a/src/@sdk/queries/types/ProductDetails.ts b/src/@sdk/queries/types/ProductDetails.ts index 520729d4c2..6d2acc563b 100644 --- a/src/@sdk/queries/types/ProductDetails.ts +++ b/src/@sdk/queries/types/ProductDetails.ts @@ -547,22 +547,6 @@ export interface ProductDetails_product_images { url: string; } -export interface ProductDetails_product_basePrice { - __typename: "Money"; - /** - * Amount of money. - */ - amount: number; - /** - * Currency code. - */ - currency: string; - /** - * Money formatted according to the current locale. - */ - localized: string; -} - export interface ProductDetails_product_attributes_attribute { __typename: "Attribute"; /** @@ -794,10 +778,6 @@ export interface ProductDetails_product { * List of images for the product. */ images: (ProductDetails_product_images | null)[] | null; - /** - * The product's default base price. - */ - basePrice: ProductDetails_product_basePrice | null; /** * List of attributes assigned to this product. */ diff --git a/src/@sdk/queries/types/ProductList.ts b/src/@sdk/queries/types/ProductList.ts index a5a81368a4..94a3181fa7 100644 --- a/src/@sdk/queries/types/ProductList.ts +++ b/src/@sdk/queries/types/ProductList.ts @@ -2,7 +2,7 @@ /* eslint-disable */ // This file was automatically generated and should not be edited. -import { AttributeInput, ProductOrder } from "./../../../../types/globalTypes"; +import { AttributeInput, ProductOrder } from "./../../types/globalTypes"; // ==================================================== // GraphQL query operation: ProductList @@ -28,7 +28,7 @@ export interface ProductList_products_edges_node_thumbnail2x { url: string; } -export interface ProductList_products_edges_node_basePrice { +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_start_gross { __typename: "Money"; /** * Amount of money. @@ -44,8 +44,116 @@ export interface ProductList_products_edges_node_basePrice { localized: string; } +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_start_net { + __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; + /** + * Money formatted according to the current locale. + */ + localized: string; +} + +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_start { + __typename: "TaxedMoney"; + /** + * Amount of money including taxes. + */ + gross: ProductList_products_edges_node_pricing_priceRangeUndiscounted_start_gross; + /** + * Amount of money without taxes. + */ + net: ProductList_products_edges_node_pricing_priceRangeUndiscounted_start_net; +} + +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop_gross { + __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; + /** + * Money formatted according to the current locale. + */ + localized: string; +} + +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop_net { + __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; + /** + * Money formatted according to the current locale. + */ + localized: string; +} + +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop { + __typename: "TaxedMoney"; + /** + * Amount of money including taxes. + */ + gross: ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop_gross; + /** + * Amount of money without taxes. + */ + net: ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop_net; +} + +export interface ProductList_products_edges_node_pricing_priceRangeUndiscounted { + __typename: "TaxedMoneyRange"; + /** + * Lower bound of a price range. + */ + start: ProductList_products_edges_node_pricing_priceRangeUndiscounted_start | null; + /** + * Upper bound of a price range. + */ + stop: ProductList_products_edges_node_pricing_priceRangeUndiscounted_stop | null; +} + export interface ProductList_products_edges_node_pricing_priceRange_start_gross { __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; + /** + * Money formatted according to the current locale. + */ + localized: string; +} + +export interface ProductList_products_edges_node_pricing_priceRange_start_net { + __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; /** * Money formatted according to the current locale. */ @@ -58,6 +166,54 @@ export interface ProductList_products_edges_node_pricing_priceRange_start { * Amount of money including taxes. */ gross: ProductList_products_edges_node_pricing_priceRange_start_gross; + /** + * Amount of money without taxes. + */ + net: ProductList_products_edges_node_pricing_priceRange_start_net; +} + +export interface ProductList_products_edges_node_pricing_priceRange_stop_gross { + __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; + /** + * Money formatted according to the current locale. + */ + localized: string; +} + +export interface ProductList_products_edges_node_pricing_priceRange_stop_net { + __typename: "Money"; + /** + * Amount of money. + */ + amount: number; + /** + * Currency code. + */ + currency: string; + /** + * Money formatted according to the current locale. + */ + localized: string; +} + +export interface ProductList_products_edges_node_pricing_priceRange_stop { + __typename: "TaxedMoney"; + /** + * Amount of money including taxes. + */ + gross: ProductList_products_edges_node_pricing_priceRange_stop_gross; + /** + * Amount of money without taxes. + */ + net: ProductList_products_edges_node_pricing_priceRange_stop_net; } export interface ProductList_products_edges_node_pricing_priceRange { @@ -66,10 +222,22 @@ export interface ProductList_products_edges_node_pricing_priceRange { * Lower bound of a price range. */ start: ProductList_products_edges_node_pricing_priceRange_start | null; + /** + * Upper bound of a price range. + */ + stop: ProductList_products_edges_node_pricing_priceRange_stop | null; } export interface ProductList_products_edges_node_pricing { __typename: "ProductPricingInfo"; + /** + * Whether it is in sale or not. + */ + onSale: boolean | null; + /** + * The undiscounted price range of the product variants. + */ + priceRangeUndiscounted: ProductList_products_edges_node_pricing_priceRangeUndiscounted | null; /** * The discounted price range of the product variants. */ @@ -100,10 +268,6 @@ export interface ProductList_products_edges_node { * The main thumbnail for a product. */ thumbnail2x: ProductList_products_edges_node_thumbnail2x | null; - /** - * The product's default base price. - */ - basePrice: ProductList_products_edges_node_basePrice | null; /** * Lists the storefront product's pricing, the current price and discounts, only meant for displaying. */ diff --git a/src/@sdk/queries/types/UserCheckoutDetails.ts b/src/@sdk/queries/types/UserCheckoutDetails.ts index 361068fea9..abfed62303 100644 --- a/src/@sdk/queries/types/UserCheckoutDetails.ts +++ b/src/@sdk/queries/types/UserCheckoutDetails.ts @@ -154,6 +154,14 @@ export interface UserCheckoutDetails_me_checkout_billingAddress { country: UserCheckoutDetails_me_checkout_billingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UserCheckoutDetails_me_checkout_shippingAddress_country { @@ -187,6 +195,14 @@ export interface UserCheckoutDetails_me_checkout_shippingAddress { country: UserCheckoutDetails_me_checkout_shippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UserCheckoutDetails_me_checkout_availableShippingMethods_price { diff --git a/src/@sdk/queries/types/UserDetails.ts b/src/@sdk/queries/types/UserDetails.ts index 47ec52737c..b550bf7456 100644 --- a/src/@sdk/queries/types/UserDetails.ts +++ b/src/@sdk/queries/types/UserDetails.ts @@ -37,6 +37,14 @@ export interface UserDetails_me_defaultShippingAddress { country: UserDetails_me_defaultShippingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UserDetails_me_defaultBillingAddress_country { @@ -70,6 +78,14 @@ export interface UserDetails_me_defaultBillingAddress { country: UserDetails_me_defaultBillingAddress_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UserDetails_me_addresses_country { @@ -103,6 +119,14 @@ export interface UserDetails_me_addresses { country: UserDetails_me_addresses_country; countryArea: string; phone: string | null; + /** + * Address is user's default billing address. + */ + isDefaultBillingAddress: boolean | null; + /** + * Address is user's default shipping address. + */ + isDefaultShippingAddress: boolean | null; } export interface UserDetails_me { diff --git a/src/components/ProductDescription/index.tsx b/src/components/ProductDescription/index.tsx index aa3bb7de5d..64d2ab2de2 100644 --- a/src/components/ProductDescription/index.tsx +++ b/src/components/ProductDescription/index.tsx @@ -6,7 +6,7 @@ import { TextField } from "@components/molecules"; import { ProductVariantPicker } from "@components/organisms"; import { ProductDetails_product_attributes, - ProductDetails_product_basePrice, + ProductDetails_product_pricing, ProductDetails_product_variants, ProductDetails_product_variants_pricing, } from "@sdk/queries/types/ProductDetails"; @@ -19,7 +19,7 @@ interface ProductDescriptionProps { productVariants: ProductDetails_product_variants[]; selectedAttributes: ProductDetails_product_attributes[]; name: string; - basePrice: ProductDetails_product_basePrice; + pricing: ProductDetails_product_pricing; children: React.ReactNode; addToCart(varinatId: string, quantity?: number): void; } @@ -89,7 +89,7 @@ class ProductDescription extends React.Component< }; getProductPrice = () => { - const { basePrice } = this.props; + const { pricing } = this.props; const { variantPricing, eachVariantPricingRange } = this.state; if (variantPricing) { @@ -106,8 +106,22 @@ class ProductDescription extends React.Component< )} - ${this.getLocalPriceFormat(max, currency)}`; } } else { - const { amount, currency } = basePrice; - return this.getLocalPriceFormat(amount, currency); + const { + start: { + gross: { amount: min, currency }, + }, + stop: { + gross: { amount: max }, + }, + } = pricing.priceRange; + if (min === max) { + return this.getLocalPriceFormat(min, currency); + } else { + return `${this.getLocalPriceFormat( + min, + currency + )} - ${this.getLocalPriceFormat(max, currency)}`; + } } }; diff --git a/src/views/Product/Page.tsx b/src/views/Product/Page.tsx index b3b059614e..8d53aaa958 100644 --- a/src/views/Product/Page.tsx +++ b/src/views/Product/Page.tsx @@ -82,7 +82,7 @@ class Page extends React.PureComponent<{ product: ProductDetails_product }> { name={product.name} productVariants={product.variants} selectedAttributes={product.attributes} - basePrice={product.basePrice} + pricing={product.pricing} addToCart={cart.add} > diff --git a/src/views/Product/queries.ts b/src/views/Product/queries.ts index 20e42649b4..393f14299c 100644 --- a/src/views/Product/queries.ts +++ b/src/views/Product/queries.ts @@ -135,11 +135,6 @@ export const productDetailsQuery = gql` id url } - basePrice { - amount - currency - localized - } attributes { ...SelectedAttributeFields } diff --git a/src/views/Product/types/ProductDetails.ts b/src/views/Product/types/ProductDetails.ts index 520729d4c2..6d2acc563b 100644 --- a/src/views/Product/types/ProductDetails.ts +++ b/src/views/Product/types/ProductDetails.ts @@ -547,22 +547,6 @@ export interface ProductDetails_product_images { url: string; } -export interface ProductDetails_product_basePrice { - __typename: "Money"; - /** - * Amount of money. - */ - amount: number; - /** - * Currency code. - */ - currency: string; - /** - * Money formatted according to the current locale. - */ - localized: string; -} - export interface ProductDetails_product_attributes_attribute { __typename: "Attribute"; /** @@ -794,10 +778,6 @@ export interface ProductDetails_product { * List of images for the product. */ images: (ProductDetails_product_images | null)[] | null; - /** - * The product's default base price. - */ - basePrice: ProductDetails_product_basePrice | null; /** * List of attributes assigned to this product. */ From 1ccb49d20fe4effdf6cd996561ea247cfc875d22 Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Tue, 14 Jan 2020 11:32:50 +0100 Subject: [PATCH 3/6] Remove deprecated get payment token query --- src/checkout/views/Payment/queries.ts | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/src/checkout/views/Payment/queries.ts b/src/checkout/views/Payment/queries.ts index 0d13d00644..b192b870db 100644 --- a/src/checkout/views/Payment/queries.ts +++ b/src/checkout/views/Payment/queries.ts @@ -1,22 +1,7 @@ import gql from "graphql-tag"; import { TypedMutation } from "../../../core/mutations"; -import { TypedQuery } from "../../../core/queries"; import { createPayment, createPaymentVariables } from "./types/createPayment"; -import { - getPaymentToken, - getPaymentTokenVariables, -} from "./types/getPaymentToken"; - -/* - TODO: getPaymentTokenQuery is deprecated, fix it. -*/ - -// const getPaymentTokenQuery = gql` -// query getPaymentToken($gateway: String!) { -// paymentClientToken(gateway: $gateway) -// } -// `; const paymentMethodCreateMutation = gql` mutation createPayment($input: PaymentInput!, $checkoutId: ID!) { @@ -29,11 +14,6 @@ const paymentMethodCreateMutation = gql` } `; -// export const TypedGetPaymentTokenQuery = TypedQuery< -// getPaymentToken, -// getPaymentTokenVariables -// >(getPaymentTokenQuery); - export const TypedPaymentMethodCreateMutation = TypedMutation< createPayment, createPaymentVariables From d21dba24953ce3ceb28635e6fbd2ce0570657c2a Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Tue, 14 Jan 2020 11:57:26 +0100 Subject: [PATCH 4/6] Use product variant attribute first value as variant picker attribute value --- .../ProductVariantPicker.tsx | 4 +- .../ProductVariantPicker/fixtures.ts | 126 ++++++++++-------- .../hooks/useProductVariantsAttributes.tsx | 6 +- ...lectableProductVariantsAttributeValues.tsx | 2 +- src/@next/types/IProductVariantsAttributes.ts | 6 +- 5 files changed, 81 insertions(+), 63 deletions(-) diff --git a/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx b/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx index 67046e96a0..0752209c36 100755 --- a/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx +++ b/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx @@ -28,9 +28,9 @@ export const ProductVariantPicker: React.FC = ({ const productVariantAttributeId = productVariantAttribute.attribute.id; if ( - productVariantAttribute.value && + productVariantAttribute.values[0] && productVariantsAttributesSelectedValues[productVariantAttributeId] && - productVariantAttribute.value.id === + productVariantAttribute.values[0].id === productVariantsAttributesSelectedValues[productVariantAttributeId]! .id ) { diff --git a/src/@next/components/organisms/ProductVariantPicker/fixtures.ts b/src/@next/components/organisms/ProductVariantPicker/fixtures.ts index 26168899c0..8ad430eae2 100644 --- a/src/@next/components/organisms/ProductVariantPicker/fixtures.ts +++ b/src/@next/components/organisms/ProductVariantPicker/fixtures.ts @@ -49,12 +49,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Material", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6ODI=", - name: "cotton", - value: "cotton", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6ODI=", + name: "cotton", + value: "cotton", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, { @@ -63,12 +65,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Color", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6ODM=", - name: "yellow", - value: "yellow", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6ODM=", + name: "yellow", + value: "yellow", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, { @@ -77,12 +81,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Size", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6NDc=", - name: "1l", - value: "1l", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6NDc=", + name: "1l", + value: "1l", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, ], @@ -135,12 +141,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Material", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6ODY=", - name: "wool", - value: "wool", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6ODY=", + name: "wool", + value: "wool", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, { @@ -149,12 +157,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Color", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6ODQ=", - name: "red", - value: "red", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6ODQ=", + name: "red", + value: "red", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, { @@ -163,12 +173,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Size", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6NDg=", - name: "2l", - value: "2l", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6NDg=", + name: "2l", + value: "2l", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, ], @@ -221,12 +233,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Material", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6ODY=", - name: "wool", - value: "wool", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6ODY=", + name: "wool", + value: "wool", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, { @@ -235,12 +249,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Color", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6ODU=", - name: "turquoise", - value: "turquoise", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6ODU=", + name: "turquoise", + value: "turquoise", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, { @@ -249,12 +265,14 @@ export const productVariants: ProductDetails_product_variants[] = [ name: "Size", __typename: "Attribute", }, - value: { - id: "QXR0cmlidXRlVmFsdWU6NDY=", - name: "500ml", - value: "500ml", - __typename: "AttributeValue", - }, + values: [ + { + id: "QXR0cmlidXRlVmFsdWU6NDY=", + name: "500ml", + value: "500ml", + __typename: "AttributeValue", + }, + ], __typename: "SelectedAttribute", }, ], diff --git a/src/@next/hooks/useProductVariantsAttributes.tsx b/src/@next/hooks/useProductVariantsAttributes.tsx index 75672d7ccc..3cd80bdc2b 100644 --- a/src/@next/hooks/useProductVariantsAttributes.tsx +++ b/src/@next/hooks/useProductVariantsAttributes.tsx @@ -24,17 +24,17 @@ export const useProductVariantsAttributes = ( if (variantsAttributeExists) { const variantsAttributeValueExists = variantsAttributes[ productVariantAttributeId - ].values.includes(productVariantAttribute.value!); + ].values.includes(productVariantAttribute.values[0]!); if (!variantsAttributeValueExists) { variantsAttributes[productVariantAttributeId].values.push( - productVariantAttribute.value! + productVariantAttribute.values[0]! ); } } else { variantsAttributes[productVariantAttributeId] = { attribute: productVariantAttribute.attribute, - values: [productVariantAttribute.value!], + values: [productVariantAttribute.values[0]!], }; } }); diff --git a/src/@next/hooks/useSelectableProductVariantsAttributeValues.tsx b/src/@next/hooks/useSelectableProductVariantsAttributeValues.tsx index 825bfcfc81..de29f7aed8 100644 --- a/src/@next/hooks/useSelectableProductVariantsAttributeValues.tsx +++ b/src/@next/hooks/useSelectableProductVariantsAttributeValues.tsx @@ -38,7 +38,7 @@ export const useSelectableProductVariantsAttributeValues = ( return ( productVariantAttribute.attribute.id === selectedValueAttributeId && - productVariantAttribute.value === + productVariantAttribute.values[0] === productVariantsAttributesSelectedValues[ selectedValueAttributeId ] diff --git a/src/@next/types/IProductVariantsAttributes.ts b/src/@next/types/IProductVariantsAttributes.ts index 91822478dd..61ffad008e 100644 --- a/src/@next/types/IProductVariantsAttributes.ts +++ b/src/@next/types/IProductVariantsAttributes.ts @@ -1,12 +1,12 @@ import { ISelectOption } from "@types"; import { ProductDetails_product_variants_attributes_attribute, - ProductDetails_product_variants_attributes_value, + ProductDetails_product_variants_attributes_values, } from "../../@sdk/queries/types/ProductDetails"; export interface IProductVariantsAttribute { attribute: ProductDetails_product_variants_attributes_attribute; - values: ProductDetails_product_variants_attributes_value[]; + values: ProductDetails_product_variants_attributes_values[]; } export interface IProductVariantsAttributes { @@ -14,7 +14,7 @@ export interface IProductVariantsAttributes { } export interface IProductVariantsAttributesSelectedValues { - [key: string]: ProductDetails_product_variants_attributes_value | null; + [key: string]: ProductDetails_product_variants_attributes_values | null; } export interface IProductVariantsAttributesOptionValue extends ISelectOption { From 49afa86e8d188af35d1fdef3bb2c6d78d3443d69 Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Tue, 14 Jan 2020 12:45:53 +0100 Subject: [PATCH 5/6] Fix Typescript check in product variant picker --- .../organisms/ProductVariantPicker/ProductVariantPicker.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx b/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx index 0752209c36..857f17c7d1 100755 --- a/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx +++ b/src/@next/components/organisms/ProductVariantPicker/ProductVariantPicker.tsx @@ -30,7 +30,7 @@ export const ProductVariantPicker: React.FC = ({ if ( productVariantAttribute.values[0] && productVariantsAttributesSelectedValues[productVariantAttributeId] && - productVariantAttribute.values[0].id === + productVariantAttribute.values[0]!.id === productVariantsAttributesSelectedValues[productVariantAttributeId]! .id ) { From 9c43ae093cdabe2817cda4763026cd5d97bad34c Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Tue, 14 Jan 2020 13:09:06 +0100 Subject: [PATCH 6/6] Run jest tests serially to prevent no memory availability errors --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 44c478d540..26be2f189a 100644 --- a/package.json +++ b/package.json @@ -153,7 +153,7 @@ "node": ">=10.0.0 <11" }, "scripts": { - "test": "jest --config .jest/config.json", + "test": "jest --runInBand --config .jest/config.json", "start": "cross-env NODE_ENV=develop webpack-dev-server --history-api-fallback --watch --port 3000 --mode development --hotOnly", "start:worker": "npm run start -- --service-worker", "build": "webpack -p",