mirror of
https://github.com/vercel/commerce.git
synced 2025-07-06 21:11:20 +00:00
Remove unused function
Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
parent
8d19c79054
commit
0e160cc695
1
packages/opencommerce/src/api/endpoints/customer/card.ts
Normal file
1
packages/opencommerce/src/api/endpoints/customer/card.ts
Normal file
@ -0,0 +1 @@
|
|||||||
|
export default function noopApi(...args: any[]): void {}
|
@ -1,43 +0,0 @@
|
|||||||
import type { CustomerCardEndpoint } from '.'
|
|
||||||
import createPaymentIntent from '../../../mutations/create-payment-intent'
|
|
||||||
|
|
||||||
const addItem: CustomerCardEndpoint['handlers']['addItem'] = async ({
|
|
||||||
res,
|
|
||||||
body: { item, cartId },
|
|
||||||
config,
|
|
||||||
req: { cookies },
|
|
||||||
}) => {
|
|
||||||
// Return an error if no item is present
|
|
||||||
if (!item) {
|
|
||||||
return res.status(400).json({
|
|
||||||
data: null,
|
|
||||||
errors: [{ message: 'Missing item' }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
// Return an error if no cart is present
|
|
||||||
if (!cartId) {
|
|
||||||
return res.status(400).json({
|
|
||||||
data: null,
|
|
||||||
errors: [{ message: 'Cookie not found' }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const {
|
|
||||||
data: { createStripePaymentIntent },
|
|
||||||
} = await config.fetch(createPaymentIntent, {
|
|
||||||
variables: {
|
|
||||||
input: {
|
|
||||||
cartId,
|
|
||||||
shopId: config.shopId,
|
|
||||||
cartToken: cookies[config.anonymousCartTokenCookie],
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return res.status(200).json({
|
|
||||||
data: createStripePaymentIntent.paymentIntentClientSecret,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export default addItem
|
|
@ -1,9 +0,0 @@
|
|||||||
import type { CustomerCardEndpoint } from '.'
|
|
||||||
|
|
||||||
const getCards: CustomerCardEndpoint['handlers']['getCards'] = async ({
|
|
||||||
res,
|
|
||||||
}) => {
|
|
||||||
return res.status(200).json({ data: null, errors: [] })
|
|
||||||
}
|
|
||||||
|
|
||||||
export default getCards
|
|
@ -1,26 +0,0 @@
|
|||||||
import { GetAPISchema, createEndpoint } from '@vercel/commerce/api'
|
|
||||||
import customerCardEndpoint from '@vercel/commerce/api/endpoints/customer/card'
|
|
||||||
import { CustomerCardSchema } from '../../../../types/customer/card'
|
|
||||||
import { OpenCommerceAPI } from '../../..'
|
|
||||||
|
|
||||||
import getCards from './get-cards'
|
|
||||||
import addItem from './add-item'
|
|
||||||
// import updateItem from './update-item'
|
|
||||||
// import removeItem from './remove-item'
|
|
||||||
|
|
||||||
export type CustomerCardAPI = GetAPISchema<OpenCommerceAPI, CustomerCardSchema>
|
|
||||||
export type CustomerCardEndpoint = CustomerCardAPI['endpoint']
|
|
||||||
|
|
||||||
export const handlers: CustomerCardEndpoint['handlers'] = {
|
|
||||||
getCards,
|
|
||||||
addItem,
|
|
||||||
updateItem: () => {},
|
|
||||||
removeItem: () => {},
|
|
||||||
}
|
|
||||||
|
|
||||||
const customerCardApi = createEndpoint<CustomerCardAPI>({
|
|
||||||
handler: customerCardEndpoint,
|
|
||||||
handlers,
|
|
||||||
})
|
|
||||||
|
|
||||||
export default customerCardApi
|
|
Loading…
x
Reference in New Issue
Block a user