diff --git a/.env.template b/.env.template index 9d8a57355..b68daaffe 100644 --- a/.env.template +++ b/.env.template @@ -11,5 +11,5 @@ BIGCOMMERCE_CHANNEL_ID= NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN= NEXT_PUBLIC_SHOPIFY_STOREFRONT_ACCESS_TOKEN= -SWELL_STORE_ID= -SWELL_PUBLIC_KEY= \ No newline at end of file +NEXT_PUBLIC_SWELL_STORE_ID= +NEXT_PUBLIC_SWELL_PUBLIC_KEY= diff --git a/framework/swell/api/utils/fetch-swell-api.ts b/framework/swell/api/utils/fetch-swell-api.ts index e070483ae..d70b71954 100644 --- a/framework/swell/api/utils/fetch-swell-api.ts +++ b/framework/swell/api/utils/fetch-swell-api.ts @@ -1,4 +1,4 @@ -import { swellConfig } from '../../index' +import { swellConfig } from '../..' const fetchSwellApi = async ( query: string, diff --git a/framework/swell/cart/use-add-item.tsx b/framework/swell/cart/use-add-item.tsx index a86d2ab28..990514d42 100644 --- a/framework/swell/cart/use-add-item.tsx +++ b/framework/swell/cart/use-add-item.tsx @@ -5,7 +5,6 @@ import useCart from './use-cart' import { Cart, CartItemBody } from '../types' import { checkoutToCart } from './utils' import { getCheckoutId } from '../utils' -import { Mutation, MutationCheckoutLineItemsAddArgs } from '../schema' import { useCallback } from 'react' export default useAddItem as UseAddItem @@ -38,7 +37,7 @@ export const handler: MutationHook = { variables.variant_id = item.variantId } - const response = await fetch({ + const response = await fetch({ ...options, variables, }) diff --git a/framework/swell/cart/use-remove-item.tsx b/framework/swell/cart/use-remove-item.tsx index 13d137da4..8dc1ea713 100644 --- a/framework/swell/cart/use-remove-item.tsx +++ b/framework/swell/cart/use-remove-item.tsx @@ -13,10 +13,8 @@ import useRemoveItem, { } from '@commerce/cart/use-remove-item' import useCart from './use-cart' -import { checkoutLineItemRemoveMutation, getCheckoutId } from '../utils' import { checkoutToCart } from './utils' import { Cart, LineItem } from '../types' -import { Mutation, MutationCheckoutLineItemsRemoveArgs } from '../schema' import { RemoveCartItemBody } from '@commerce/types' export type RemoveItemFn = T extends LineItem @@ -39,12 +37,10 @@ export const handler = { options, fetch, }: HookFetcherContext) { - const response = await fetch( - { - ...options, - variables: [itemId], - } - ) + const response = await fetch({ + ...options, + variables: [itemId], + }) return checkoutToCart(response) }, useHook: ({ @@ -52,9 +48,9 @@ export const handler = { }: MutationHookContext) => < T extends LineItem | undefined = undefined >( - item + ctx: { item?: T } = {} ) => { - // const { item } = ctx + const { item } = ctx const { mutate } = useCart() const removeItem: RemoveItemFn = async (input) => { const itemId = input?.id ?? item?.id diff --git a/framework/swell/cart/use-update-item.tsx b/framework/swell/cart/use-update-item.tsx index 38ad65bf1..b74b65dc9 100644 --- a/framework/swell/cart/use-update-item.tsx +++ b/framework/swell/cart/use-update-item.tsx @@ -14,7 +14,6 @@ import useCart from './use-cart' import { handler as removeItemHandler } from './use-remove-item' import type { Cart, LineItem, UpdateCartItemBody } from '../types' import { checkoutToCart } from './utils' -import { Mutation, MutationCheckoutLineItemsUpdateArgs } from '../schema' export type UpdateItemInput = T extends LineItem ? Partial> @@ -46,12 +45,10 @@ export const handler = { message: 'The item quantity has to be a valid integer', }) } - const response = await fetch( - { - ...options, - variables: [item.itemId, { quantity: item.quantity }], - } - ) + const response = await fetch({ + ...options, + variables: [item.itemId, { quantity: item.quantity }], + }) return checkoutToCart(response) }, diff --git a/framework/swell/common/get-all-pages.ts b/framework/swell/common/get-all-pages.ts index 489af339c..99e07f6e6 100644 --- a/framework/swell/common/get-all-pages.ts +++ b/framework/swell/common/get-all-pages.ts @@ -25,7 +25,7 @@ const getAllPages = async (options?: { config = getConfig(config) const { locale, fetchSwell } = config const { results } = await fetchSwell('content', 'list', ['pages']) - const pages = results.map(({ slug, ...rest }) => ({ + const pages = results.map(({ slug, ...rest }: { slug: string }) => ({ url: `/${locale}/${slug}`, ...rest, }))