This commit is contained in:
Greg Hoskin 2021-06-11 09:37:45 -07:00
parent 2d3055ea96
commit 9402062a5a
2 changed files with 0 additions and 61 deletions

View File

@ -1,28 +0,0 @@
import { CollectionEdge } from '../../schema'
import { getConfig, SwellConfig } from '..'
const getAllCollections = async (options?: {
variables?: any
config: SwellConfig
preview?: boolean
}) => {
let { config, variables = { limit: 25 } } = options ?? {}
config = getConfig(config)
const response = await config.fetch('categories', 'list', { variables })
const edges = response.results ?? []
const categories = edges.map(
({ node: { id: entityId, title: name, handle } }: CollectionEdge) => ({
entityId,
name,
path: `/${handle}`,
})
)
return {
categories,
}
}
export default getAllCollections

View File

@ -1,33 +0,0 @@
import { HookFetcherFn } from '@commerce/utils/types'
import { Cart } from '@commerce/types'
// import { checkoutCreate, checkoutToCart } from '.'
import { FetchCartInput } from '@commerce/cart/use-cart'
import { data } from 'autoprefixer'
import { normalizeCart } from '../../utils'
const fetcher: HookFetcherFn<Cart | null, FetchCartInput> = async ({
options,
// input: { cartId: checkoutId },
fetch,
}) => {
let checkout
// if (checkoutId) {
const data = await fetch({
query: 'cart',
method: 'get',
// variables: { category: categoryId },
})
// checkout = data.node
// }
// if (checkout?.completedAt || !checkoutId) {
// checkout = await checkoutCreate(fetch)
// }
// TODO: Fix this type
// return checkoutToCart({ checkout } as any)
return normalizeCart(data)
}
export default fetcher