Merge pull request #2 from spree/upgrade-checkout

Upgrade checkout
This commit is contained in:
Tomek Niezgoda 2021-09-24 14:33:54 +02:00 committed by GitHub
commit 03295ebb02
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 61 additions and 7 deletions

View File

@ -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

View File

@ -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,

View File

@ -0,0 +1 @@
export default function noopApi(...args: any[]): void {}

View File

@ -0,0 +1 @@
export default function noopApi(...args: any[]): void {}

View 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) => ({}),
}

View File

@ -4,6 +4,7 @@
"wishlist": false,
"cart": true,
"search": true,
"customerAuth": false
"customerAuth": false,
"customCheckout": false
}
}

View 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 () => ({}),
}

View 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 () => ({}),
}

View File

@ -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 }