mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
@@ -1,9 +1,9 @@
|
||||
import type { CheckoutEndpoint } from '.'
|
||||
|
||||
const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
||||
req: request,
|
||||
const getCheckout: CheckoutEndpoint['handlers']['getCheckout'] = async ({
|
||||
req: _request,
|
||||
res: response,
|
||||
config,
|
||||
config: _config,
|
||||
}) => {
|
||||
try {
|
||||
const html = `
|
||||
@@ -41,4 +41,4 @@ const checkout: CheckoutEndpoint['handlers']['checkout'] = async ({
|
||||
}
|
||||
}
|
||||
|
||||
export default checkout
|
||||
export default getCheckout
|
@@ -2,7 +2,7 @@ import { createEndpoint } from '@commerce/api'
|
||||
import type { GetAPISchema, CommerceAPI } from '@commerce/api'
|
||||
import checkoutEndpoint from '@commerce/api/endpoints/checkout'
|
||||
import type { CheckoutSchema } from '@commerce/types/checkout'
|
||||
import checkout from './checkout'
|
||||
import getCheckout from './get-checkout'
|
||||
import type { SpreeApiProvider } from '../..'
|
||||
|
||||
export type CheckoutAPI = GetAPISchema<
|
||||
@@ -12,7 +12,10 @@ export type CheckoutAPI = GetAPISchema<
|
||||
|
||||
export type CheckoutEndpoint = CheckoutAPI['endpoint']
|
||||
|
||||
export const handlers: CheckoutEndpoint['handlers'] = { checkout }
|
||||
export const handlers: CheckoutEndpoint['handlers'] = {
|
||||
getCheckout,
|
||||
submitCheckout: () => {},
|
||||
}
|
||||
|
||||
const checkoutApi = createEndpoint<CheckoutAPI>({
|
||||
handler: checkoutEndpoint,
|
||||
|
1
framework/spree/api/endpoints/customer/address.ts
Normal file
1
framework/spree/api/endpoints/customer/address.ts
Normal file
@@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
1
framework/spree/api/endpoints/customer/card.ts
Normal file
1
framework/spree/api/endpoints/customer/card.ts
Normal file
@@ -0,0 +1 @@
|
||||
export default function noopApi(...args: any[]): void {}
|
14
framework/spree/checkout/use-checkout.tsx
Normal file
14
framework/spree/checkout/use-checkout.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { SWRHook } from '@commerce/utils/types'
|
||||
import useCheckout, { UseCheckout } from '@commerce/checkout/use-checkout'
|
||||
|
||||
export default useCheckout as UseCheckout<typeof handler>
|
||||
|
||||
export const handler: SWRHook<any> = {
|
||||
fetchOptions: {
|
||||
query: '',
|
||||
},
|
||||
async fetcher({ input, options, fetch }) {},
|
||||
useHook:
|
||||
({ useData }) =>
|
||||
async (input) => ({}),
|
||||
}
|
@@ -4,6 +4,7 @@
|
||||
"wishlist": false,
|
||||
"cart": true,
|
||||
"search": true,
|
||||
"customerAuth": false
|
||||
"customerAuth": false,
|
||||
"customCheckout": false
|
||||
}
|
||||
}
|
||||
|
16
framework/spree/customer/address/use-add-item.tsx
Normal file
16
framework/spree/customer/address/use-add-item.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import useAddItem from '@commerce/customer/address/use-add-item'
|
||||
import type { UseAddItem } from '@commerce/customer/address/use-add-item'
|
||||
import type { MutationHook } from '@commerce/utils/types'
|
||||
|
||||
export default useAddItem as UseAddItem<typeof handler>
|
||||
|
||||
export const handler: MutationHook<any> = {
|
||||
fetchOptions: {
|
||||
query: '',
|
||||
},
|
||||
async fetcher({ input, options, fetch }) {},
|
||||
useHook:
|
||||
({ fetch }) =>
|
||||
() =>
|
||||
async () => ({}),
|
||||
}
|
16
framework/spree/customer/card/use-add-item.tsx
Normal file
16
framework/spree/customer/card/use-add-item.tsx
Normal file
@@ -0,0 +1,16 @@
|
||||
import useAddItem from '@commerce/customer/address/use-add-item'
|
||||
import type { UseAddItem } from '@commerce/customer/address/use-add-item'
|
||||
import type { MutationHook } from '@commerce/utils/types'
|
||||
|
||||
export default useAddItem as UseAddItem<typeof handler>
|
||||
|
||||
export const handler: MutationHook<any> = {
|
||||
fetchOptions: {
|
||||
query: '',
|
||||
},
|
||||
async fetcher({ input, options, fetch }) {},
|
||||
useHook:
|
||||
({ fetch }) =>
|
||||
() =>
|
||||
async () => ({}),
|
||||
}
|
@@ -8,6 +8,7 @@ import { handler as useSearch } from './product/use-search'
|
||||
import { handler as useLogin } from './auth/use-login'
|
||||
import { handler as useLogout } from './auth/use-logout'
|
||||
import { handler as useSignup } from './auth/use-signup'
|
||||
import { handler as useCheckout } from './checkout/use-checkout'
|
||||
import { requireConfigValue } from './isomorphic-config'
|
||||
|
||||
const spreeProvider = {
|
||||
@@ -18,6 +19,7 @@ const spreeProvider = {
|
||||
customer: { useCustomer },
|
||||
products: { useSearch },
|
||||
auth: { useLogin, useLogout, useSignup },
|
||||
checkout: { useCheckout },
|
||||
}
|
||||
|
||||
export { spreeProvider }
|
||||
|
Reference in New Issue
Block a user