mirror of
https://github.com/vercel/commerce.git
synced 2025-03-27 15:55:54 +00:00
* Add ordercloud provider * Fix provider errors * Make submit checkout optional * Make submit checkout optional * Remove nullables when creating endpoint type * Update readme * Log checkout error * Log error * Save token to cookie * Update fetch rest * Use token at checkout Co-authored-by: Luis Alvarez <luis@vercel.com>
29 lines
683 B
TypeScript
29 lines
683 B
TypeScript
import type { CartSchema } from '../../../types/cart'
|
|
import type { OrdercloudAPI } from '../..'
|
|
|
|
import { GetAPISchema, createEndpoint } from '@commerce/api'
|
|
import cartEndpoint from '@commerce/api/endpoints/cart'
|
|
|
|
import getCart from './get-cart'
|
|
import addItem from './add-item'
|
|
import updateItem from './update-item'
|
|
import removeItem from './remove-item'
|
|
|
|
export type CartAPI = GetAPISchema<OrdercloudAPI, CartSchema>
|
|
|
|
export type CartEndpoint = CartAPI['endpoint']
|
|
|
|
export const handlers: CartEndpoint['handlers'] = {
|
|
getCart,
|
|
addItem,
|
|
updateItem,
|
|
removeItem,
|
|
}
|
|
|
|
const cartApi = createEndpoint<CartAPI>({
|
|
handler: cartEndpoint,
|
|
handlers,
|
|
})
|
|
|
|
export default cartApi
|