From a06fd092585b7049833571765d44fb2a934a83f1 Mon Sep 17 00:00:00 2001 From: cond0r Date: Sat, 29 May 2021 10:17:53 +0300 Subject: [PATCH] Fixes --- components/product/Swatch/Swatch.module.css | 10 ++-------- components/product/Swatch/Swatch.tsx | 14 ++++++-------- .../api/endpoints/catalog/products/get-products.ts | 4 ++-- framework/commerce/types/product.ts | 6 +++--- framework/commerce/types/wishlist.ts | 2 +- .../shopify/api/endpoints/checkout/checkout.ts | 4 ++-- framework/shopify/api/operations/get-all-pages.ts | 4 ++-- .../shopify/api/operations/get-all-products.ts | 2 +- framework/shopify/api/operations/get-page.ts | 2 +- framework/shopify/api/operations/get-site-info.ts | 2 +- framework/shopify/auth/use-login.tsx | 12 ++++++------ framework/shopify/auth/use-signup.tsx | 2 +- framework/shopify/utils/get-brands.ts | 2 +- pages/search.tsx | 3 ++- 14 files changed, 31 insertions(+), 38 deletions(-) diff --git a/components/product/Swatch/Swatch.module.css b/components/product/Swatch/Swatch.module.css index 68d7c6aa6..051435afd 100644 --- a/components/product/Swatch/Swatch.module.css +++ b/components/product/Swatch/Swatch.module.css @@ -1,10 +1,8 @@ .root { composes: root from 'components/ui/Button/Button.module.css'; - @apply h-12 p-0 bg-primary text-primary rounded-full mr-3 inline-flex + @apply h-12 w-12 bg-primary text-primary rounded-full mr-3 inline-flex items-center justify-center cursor-pointer transition duration-150 ease-in-out - shadow-none border-gray-200 border box-border; - - min-width: 3em; + p-0 shadow-none border-gray-200 border box-border; & > span { @apply absolute; @@ -15,10 +13,6 @@ } } -.size { - @apply px-3 leading-none; -} - .color { @apply text-black transition duration-150 ease-in-out; diff --git a/components/product/Swatch/Swatch.tsx b/components/product/Swatch/Swatch.tsx index b6de8fad3..663d01dfa 100644 --- a/components/product/Swatch/Swatch.tsx +++ b/components/product/Swatch/Swatch.tsx @@ -21,14 +21,14 @@ const Swatch: FC & Props> = ({ active, ...props }) => { + variant = variant?.toLowerCase() label = label?.toLowerCase() - const isColor = color !== '' const rootClassName = cn( s.root, { [s.active]: active, - [s.size]: !isColor, + [s.size]: variant === 'size', [s.color]: color, [s.dark]: color ? isDark(color) : false, }, @@ -38,20 +38,18 @@ const Swatch: FC & Props> = ({ return ( ) } -export default Swatch +export default Swatch \ No newline at end of file diff --git a/framework/bigcommerce/api/endpoints/catalog/products/get-products.ts b/framework/bigcommerce/api/endpoints/catalog/products/get-products.ts index 707f43811..6dde39e28 100644 --- a/framework/bigcommerce/api/endpoints/catalog/products/get-products.ts +++ b/framework/bigcommerce/api/endpoints/catalog/products/get-products.ts @@ -25,10 +25,10 @@ const getProducts: ProductsEndpoint['handlers']['getProducts'] = async ({ if (search) url.searchParams.set('keyword', search) if (categoryId && Number.isInteger(Number(categoryId))) - url.searchParams.set('categories:in', categoryId) + url.searchParams.set('categories:in', String(categoryId)) if (brandId && Number.isInteger(Number(brandId))) - url.searchParams.set('brand_id', brandId) + url.searchParams.set('brand_id', String(brandId)) if (sort) { const [_sort, direction] = sort.split('-') diff --git a/framework/commerce/types/product.ts b/framework/commerce/types/product.ts index 4db8269e3..a12e332b4 100644 --- a/framework/commerce/types/product.ts +++ b/framework/commerce/types/product.ts @@ -14,7 +14,7 @@ export type ProductPrice = { } export type ProductOption = { - __typename: 'MultipleChoiceOption' + __typename?: 'MultipleChoiceOption' id: string displayName: string values: ProductOptionValues[] @@ -47,8 +47,8 @@ export type Product = { export type SearchProductsBody = { search?: string - categoryId?: string - brandId?: string + categoryId?: string | number + brandId?: string | number sort?: string locale?: string } diff --git a/framework/commerce/types/wishlist.ts b/framework/commerce/types/wishlist.ts index e71cdc7e4..b3759849c 100644 --- a/framework/commerce/types/wishlist.ts +++ b/framework/commerce/types/wishlist.ts @@ -2,7 +2,7 @@ export type Wishlist = any export type WishlistItemBody = { - variantId: string + variantId: string | number productId: string } diff --git a/framework/shopify/api/endpoints/checkout/checkout.ts b/framework/shopify/api/endpoints/checkout/checkout.ts index 747a53b51..0c340a129 100644 --- a/framework/shopify/api/endpoints/checkout/checkout.ts +++ b/framework/shopify/api/endpoints/checkout/checkout.ts @@ -2,8 +2,8 @@ import { SHOPIFY_CHECKOUT_ID_COOKIE, SHOPIFY_CHECKOUT_URL_COOKIE, SHOPIFY_CUSTOMER_TOKEN_COOKIE, -} from '@framework/const' -import associateCustomerWithCheckoutMutation from '@framework/utils/mutations/associate-customer-with-checkout' +} from '../../../const' +import associateCustomerWithCheckoutMutation from '../../../utils/mutations/associate-customer-with-checkout' import type { CheckoutEndpoint } from '.' const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({ diff --git a/framework/shopify/api/operations/get-all-pages.ts b/framework/shopify/api/operations/get-all-pages.ts index 3dd4cf6fe..ab0af9ff7 100644 --- a/framework/shopify/api/operations/get-all-pages.ts +++ b/framework/shopify/api/operations/get-all-pages.ts @@ -6,8 +6,8 @@ import { GetAllPagesQuery, GetAllPagesQueryVariables, PageEdge, -} from '@framework/schema' -import { normalizePages } from '@framework/utils' +} from '../../schema' +import { normalizePages } from '../../utils' import type { ShopifyConfig, Provider } from '..' import type { GetAllPagesOperation, Page } from '../../types/page' import getAllPagesQuery from '../../utils/queries/get-all-pages-query' diff --git a/framework/shopify/api/operations/get-all-products.ts b/framework/shopify/api/operations/get-all-products.ts index 6b8bd1f5e..08d781d5c 100644 --- a/framework/shopify/api/operations/get-all-products.ts +++ b/framework/shopify/api/operations/get-all-products.ts @@ -10,7 +10,7 @@ import { } from '../../schema' import type { ShopifyConfig, Provider } from '..' import getAllProductsQuery from '../../utils/queries/get-all-products-query' -import { normalizeProduct } from '@framework/utils' +import { normalizeProduct } from '../../utils' export default function getAllProductsOperation({ commerce, diff --git a/framework/shopify/api/operations/get-page.ts b/framework/shopify/api/operations/get-page.ts index cf71bc635..67e135ebe 100644 --- a/framework/shopify/api/operations/get-page.ts +++ b/framework/shopify/api/operations/get-page.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } from '@commerce/api/operations' -import { normalizePage } from '@framework/utils' +import { normalizePage } from '../../utils' import type { ShopifyConfig, Provider } from '..' import { GetPageQuery, diff --git a/framework/shopify/api/operations/get-site-info.ts b/framework/shopify/api/operations/get-site-info.ts index 071d68aff..27b63b0f9 100644 --- a/framework/shopify/api/operations/get-site-info.ts +++ b/framework/shopify/api/operations/get-site-info.ts @@ -2,7 +2,7 @@ import type { OperationContext, OperationOptions, } from '@commerce/api/operations' -import { GetSiteInfoQuery, GetSiteInfoQueryVariables } from '@framework/schema' +import { GetSiteInfoQueryVariables } from '../../schema' import type { ShopifyConfig, Provider } from '..' import { GetSiteInfoOperation } from '../../types/site' diff --git a/framework/shopify/auth/use-login.tsx b/framework/shopify/auth/use-login.tsx index e90dbf730..d4369b7c2 100644 --- a/framework/shopify/auth/use-login.tsx +++ b/framework/shopify/auth/use-login.tsx @@ -5,18 +5,18 @@ import useLogin, { UseLogin } from '@commerce/auth/use-login' import type { LoginHook } from '../types/login' import useCustomer from '../customer/use-customer' -import createCustomerAccessTokenMutation from '../utils/mutations/customer-access-token-create' -import { setCustomerToken, throwUserErrors } from '@framework/utils' import { - Mutation, - MutationCustomerAccessTokenCreateArgs, -} from '@framework/schema' + setCustomerToken, + throwUserErrors, + customerAccessTokenCreateMutation, +} from '../utils' +import { Mutation, MutationCustomerAccessTokenCreateArgs } from '../schema' export default useLogin as UseLogin export const handler: MutationHook = { fetchOptions: { - query: createCustomerAccessTokenMutation, + query: customerAccessTokenCreateMutation, }, async fetcher({ input: { email, password }, options, fetch }) { if (!(email && password)) { diff --git a/framework/shopify/auth/use-signup.tsx b/framework/shopify/auth/use-signup.tsx index abcc36a9c..29557e960 100644 --- a/framework/shopify/auth/use-signup.tsx +++ b/framework/shopify/auth/use-signup.tsx @@ -10,7 +10,7 @@ import { handleAutomaticLogin, throwUserErrors, customerCreateMutation, -} from '@framework/utils' +} from '../utils' export default useSignup as UseSignup diff --git a/framework/shopify/utils/get-brands.ts b/framework/shopify/utils/get-brands.ts index afd015dbe..3065e4ae8 100644 --- a/framework/shopify/utils/get-brands.ts +++ b/framework/shopify/utils/get-brands.ts @@ -1,7 +1,7 @@ import { GetAllProductVendorsQuery, GetAllProductVendorsQueryVariables, -} from '@framework/schema' +} from '../schema' import { ShopifyConfig } from '../api' import getAllProductVendors from './queries/get-all-product-vendors-query' diff --git a/pages/search.tsx b/pages/search.tsx index 57b8de80f..958db5526 100644 --- a/pages/search.tsx +++ b/pages/search.tsx @@ -34,8 +34,9 @@ const SORT = Object.entries({ export async function getStaticProps({ preview, locale, + locales, }: GetStaticPropsContext) { - const config = { locale } + const config = { locale, locales } const { pages } = await commerce.getAllPages({ config, preview }) const { categories, brands } = await commerce.getSiteInfo({ config, preview }) return {