mirror of
https://github.com/vercel/commerce.git
synced 2025-07-30 13:41:22 +00:00
.vscode
assets
components
config
framework
bigcommerce
commerce
saleor
shopify
swell
api
auth
cart
utils
checkout-create.ts
checkout-to-cart.ts
fetcher.ts
index.ts
index.ts
use-add-item.tsx
use-cart.tsx
use-remove-item.tsx
use-update-item.tsx
common
customer
product
utils
wishlist
.env.template
commerce.config.json
const.ts
fetcher.ts
index.tsx
next.config.js
provider.ts
schema.d.ts
schema.graphql
swell-js.d.ts
types.ts
vendure
lib
pages
public
.editorconfig
.env.template
.gitignore
.prettierignore
.prettierrc
README.md
codegen.bigcommerce.json
codegen.json
commerce.config.json
global.d.ts
license.md
next-env.d.ts
next.config.js
package.json
postcss.config.js
tailwind.config.js
tsconfig.json
yarn.lock
34 lines
838 B
TypeScript
34 lines
838 B
TypeScript
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
|