4
0
forked from crowetic/commerce

Removed @framework imports within framework providers

This commit is contained in:
Luis Alvarez 2021-02-25 16:54:18 -05:00
parent 121ec4b61f
commit 46ae76c67f
21 changed files with 40 additions and 47 deletions

View File

@ -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 */ `

View File

@ -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']

View File

@ -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)

View File

@ -1,4 +1,4 @@
import { ProductEdge } from '@framework/schema'
import { ProductEdge } from '../../schema'
import { ShopifyConfig } from '..'
const fetchAllProducts = async ({

View File

@ -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,

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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>>

View File

@ -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) => {

View File

@ -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

View File

@ -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'

View File

@ -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({

View File

@ -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'

View File

@ -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 = {

View File

@ -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,
}
},

View File

@ -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 = {

View File

@ -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,

View File

@ -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 = {

View File

@ -7,7 +7,7 @@ import {
ProductVariantConnection,
ProductOption,
MoneyV2,
} from '@framework/schema'
} from '../schema'
import type { Cart, LineItem } from '../types'