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