mirror of
https://github.com/vercel/commerce.git
synced 2025-06-20 06:01:21 +00:00
cleanup
This commit is contained in:
parent
2d3055ea96
commit
9402062a5a
@ -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
|
|
@ -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
|
|
Loading…
x
Reference in New Issue
Block a user