forked from crowetic/commerce
Removed @framework imports within framework providers
This commit is contained in:
parent
121ec4b61f
commit
46ae76c67f
@ -2,7 +2,7 @@ import type { GetProductQuery, GetProductQueryVariables } from '../schema'
|
||||
import setProductLocaleMeta from '../api/utils/set-product-locale-meta'
|
||||
import { productInfoFragment } from '../api/fragments/product'
|
||||
import { BigcommerceConfig, getConfig } from '../api'
|
||||
import { normalizeProduct } from '@framework/lib/normalize'
|
||||
import { normalizeProduct } from '../lib/normalize'
|
||||
import type { Product } from '@commerce/types'
|
||||
|
||||
export const getProductQuery = /* GraphQL */ `
|
||||
|
@ -7,10 +7,10 @@ import {
|
||||
SHOPIFY_CHECKOUT_ID_COOKIE,
|
||||
SHOPIFY_CHECKOUT_URL_COOKIE,
|
||||
SHOPIFY_CUSTOMER_TOKEN_COOKIE,
|
||||
} from '@framework/const'
|
||||
} from '../../const'
|
||||
|
||||
import { getConfig } from '..'
|
||||
import associateCustomerWithCheckoutMutation from '@framework/utils/mutations/associate-customer-with-checkout'
|
||||
import associateCustomerWithCheckoutMutation from '../../utils/mutations/associate-customer-with-checkout'
|
||||
|
||||
const METHODS = ['GET']
|
||||
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
API_TOKEN,
|
||||
SHOPIFY_CHECKOUT_ID_COOKIE,
|
||||
SHOPIFY_CUSTOMER_TOKEN_COOKIE,
|
||||
} from '@framework/const'
|
||||
} from '../const'
|
||||
|
||||
if (!API_URL) {
|
||||
console.log(process.env)
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ProductEdge } from '@framework/schema'
|
||||
import { ProductEdge } from '../../schema'
|
||||
import { ShopifyConfig } from '..'
|
||||
|
||||
const fetchAllProducts = async ({
|
||||
|
@ -2,7 +2,7 @@ import type { GraphQLFetcher } from '@commerce/api'
|
||||
import fetch from './fetch'
|
||||
|
||||
import { API_URL, API_TOKEN } from '../../const'
|
||||
import { getError } from '@framework/utils/handle-fetch-response'
|
||||
import { getError } from '../../utils/handle-fetch-response'
|
||||
|
||||
const fetchGraphqlApi: GraphQLFetcher = async (
|
||||
query: string,
|
||||
|
@ -8,9 +8,9 @@ import {
|
||||
CustomerUserError,
|
||||
Mutation,
|
||||
MutationCheckoutCreateArgs,
|
||||
} from '@framework/schema'
|
||||
} from '../schema'
|
||||
import useLogin, { UseLogin } from '@commerce/auth/use-login'
|
||||
import { setCustomerToken } from '@framework/utils'
|
||||
import { setCustomerToken } from '../utils'
|
||||
|
||||
export default useLogin as UseLogin<typeof handler>
|
||||
|
||||
|
@ -2,11 +2,8 @@ import { useCallback } from 'react'
|
||||
import type { MutationHook } from '@commerce/utils/types'
|
||||
import useLogout, { UseLogout } from '@commerce/auth/use-logout'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
import customerAccessTokenDeleteMutation from '@framework/utils/mutations/customer-access-token-delete'
|
||||
import {
|
||||
getCustomerToken,
|
||||
setCustomerToken,
|
||||
} from '@framework/utils/customer-token'
|
||||
import customerAccessTokenDeleteMutation from '../utils/mutations/customer-access-token-delete'
|
||||
import { getCustomerToken, setCustomerToken } from '../utils/customer-token'
|
||||
|
||||
export default useLogout as UseLogout<typeof handler>
|
||||
|
||||
|
@ -3,13 +3,13 @@ import type { MutationHook } from '@commerce/utils/types'
|
||||
import { CommerceError } from '@commerce/utils/errors'
|
||||
import useSignup, { UseSignup } from '@commerce/auth/use-signup'
|
||||
import useCustomer from '../customer/use-customer'
|
||||
import { CustomerCreateInput } from '@framework/schema'
|
||||
import { CustomerCreateInput } from '../schema'
|
||||
|
||||
import {
|
||||
customerCreateMutation,
|
||||
customerAccessTokenCreateMutation,
|
||||
} from '@framework/utils/mutations'
|
||||
import handleLogin from '@framework/utils/handle-login'
|
||||
} from '../utils/mutations'
|
||||
import handleLogin from '../utils/handle-login'
|
||||
|
||||
export default useSignup as UseSignup<typeof handler>
|
||||
|
||||
|
@ -13,13 +13,10 @@ import useRemoveItem, {
|
||||
} from '@commerce/cart/use-remove-item'
|
||||
|
||||
import useCart from './use-cart'
|
||||
import { checkoutLineItemRemoveMutation, getCheckoutId } from '@framework/utils'
|
||||
import { checkoutLineItemRemoveMutation, getCheckoutId } from '../utils'
|
||||
import { checkoutToCart } from './utils'
|
||||
import { Cart, LineItem } from '@framework/types'
|
||||
import {
|
||||
Mutation,
|
||||
MutationCheckoutLineItemsRemoveArgs,
|
||||
} from '@framework/schema'
|
||||
import { Cart, LineItem } from '../types'
|
||||
import { Mutation, MutationCheckoutLineItemsRemoveArgs } from '../schema'
|
||||
import { RemoveCartItemBody } from '@commerce/types'
|
||||
|
||||
export type RemoveItemFn<T = any> = T extends LineItem
|
||||
|
@ -15,10 +15,7 @@ import { handler as removeItemHandler } from './use-remove-item'
|
||||
import type { Cart, LineItem, UpdateCartItemBody } from '../types'
|
||||
import { checkoutToCart } from './utils'
|
||||
import { getCheckoutId, checkoutLineItemUpdateMutation } from '../utils'
|
||||
import {
|
||||
Mutation,
|
||||
MutationCheckoutLineItemsUpdateArgs,
|
||||
} from '@framework/schema'
|
||||
import { Mutation, MutationCheckoutLineItemsUpdateArgs } from '../schema'
|
||||
|
||||
export type UpdateItemInput<T = any> = T extends LineItem
|
||||
? Partial<UpdateItemInputBase<LineItem>>
|
||||
|
@ -1,9 +1,9 @@
|
||||
import {
|
||||
SHOPIFY_CHECKOUT_ID_COOKIE,
|
||||
SHOPIFY_CHECKOUT_URL_COOKIE,
|
||||
} from '@framework/const'
|
||||
} from '../../const'
|
||||
|
||||
import checkoutCreateMutation from '@framework/utils/mutations/checkout-create'
|
||||
import checkoutCreateMutation from '../../utils/mutations/checkout-create'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
export const checkoutCreate = async (fetch: any) => {
|
||||
|
@ -6,8 +6,8 @@ import {
|
||||
CheckoutLineItemsRemovePayload,
|
||||
CheckoutLineItemsUpdatePayload,
|
||||
Maybe,
|
||||
} from '@framework/schema'
|
||||
import { normalizeCart } from '@framework/utils'
|
||||
} from '../../schema'
|
||||
import { normalizeCart } from '../../utils'
|
||||
|
||||
export type CheckoutPayload =
|
||||
| CheckoutLineItemsAddPayload
|
||||
|
@ -1,5 +1,5 @@
|
||||
import getCategories, { Category } from '@framework/utils/get-categories'
|
||||
import getVendors, { Brands } from '@framework/utils/get-vendors'
|
||||
import getCategories, { Category } from '../utils/get-categories'
|
||||
import getVendors, { Brands } from '../utils/get-vendors'
|
||||
|
||||
import { getConfig, ShopifyConfig } from '../api'
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { getConfig, ShopifyConfig } from '@framework/api'
|
||||
import getCustomerIdQuery from '@framework/utils/queries/get-customer-id-query'
|
||||
import { getConfig, ShopifyConfig } from '../api'
|
||||
import getCustomerIdQuery from '../utils/queries/get-customer-id-query'
|
||||
import Cookies from 'js-cookie'
|
||||
|
||||
async function getCustomerId({
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CollectionEdge } from '@framework/schema'
|
||||
import { CollectionEdge } from '../schema'
|
||||
import { getConfig, ShopifyConfig } from '../api'
|
||||
import getAllCollectionsQuery from '../utils/queries/get-all-collections-query'
|
||||
|
||||
|
@ -2,7 +2,7 @@ import { GraphQLFetcherResult } from '@commerce/api'
|
||||
import { getConfig, ShopifyConfig } from '../api'
|
||||
import { ProductEdge } from '../schema'
|
||||
import { getAllProductsQuery } from '../utils/queries'
|
||||
import { normalizeProduct } from '@framework/utils/normalize'
|
||||
import { normalizeProduct } from '../utils/normalize'
|
||||
import { Product } from '@commerce/types'
|
||||
|
||||
type Variables = {
|
||||
|
@ -1,17 +1,16 @@
|
||||
import { SWRHook } from '@commerce/utils/types'
|
||||
import useSearch, { UseSearch } from '@commerce/product/use-search'
|
||||
|
||||
import { ProductEdge } from '@framework/schema'
|
||||
import { ProductEdge } from '../schema'
|
||||
import {
|
||||
getAllProductsQuery,
|
||||
getSearchVariables,
|
||||
normalizeProduct,
|
||||
} from '@framework/utils'
|
||||
import type { ShopifyProvider } from '..'
|
||||
} from '../utils'
|
||||
|
||||
import { Product } from '@commerce/types'
|
||||
|
||||
export default useSearch as UseSearch<ShopifyProvider>
|
||||
export default useSearch as UseSearch<typeof handler>
|
||||
|
||||
export type SearchProductsInput = {
|
||||
search?: string
|
||||
@ -40,7 +39,10 @@ export const handler: SWRHook<
|
||||
})
|
||||
const edges = resp.products?.edges
|
||||
return {
|
||||
products: edges?.map(({ node: p }: ProductEdge) => normalizeProduct(p)),
|
||||
products: edges?.map(({ node: p }: ProductEdge) =>
|
||||
// TODO: Fix this product type
|
||||
normalizeProduct(p as any)
|
||||
),
|
||||
found: !!edges?.length,
|
||||
}
|
||||
},
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ShopifyConfig } from '@framework/api'
|
||||
import { CollectionEdge } from '@framework/schema'
|
||||
import { ShopifyConfig } from '../api'
|
||||
import { CollectionEdge } from '../schema'
|
||||
import getSiteCollectionsQuery from './queries/get-all-collections-query'
|
||||
|
||||
export type Category = {
|
||||
|
@ -1,5 +1,5 @@
|
||||
import getSortVariables from './get-sort-variables'
|
||||
import type { SearchProductsInput } from '@framework/product/use-search'
|
||||
import type { SearchProductsInput } from '../product/use-search'
|
||||
|
||||
export const getSearchVariables = ({
|
||||
categoryId,
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { ShopifyConfig } from '@framework/api'
|
||||
import fetchAllProducts from '@framework/api/utils/fetch-all-products'
|
||||
import { ShopifyConfig } from '../api'
|
||||
import fetchAllProducts from '../api/utils/fetch-all-products'
|
||||
import getAllProductVendors from './queries/get-all-product-vendors-query'
|
||||
|
||||
export type BrandNode = {
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
ProductVariantConnection,
|
||||
ProductOption,
|
||||
MoneyV2,
|
||||
} from '@framework/schema'
|
||||
} from '../schema'
|
||||
|
||||
import type { Cart, LineItem } from '../types'
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user