forked from crowetic/commerce
Remove unrequired actions
This commit is contained in:
parent
200f148488
commit
970d35dc08
@ -1,25 +0,0 @@
|
|||||||
import type { WishlistHandlers } from '..'
|
|
||||||
|
|
||||||
// Return current wishlist info
|
|
||||||
const addWishlist: WishlistHandlers['addWishlist'] = async ({
|
|
||||||
res,
|
|
||||||
body: { wishlist },
|
|
||||||
config,
|
|
||||||
}) => {
|
|
||||||
if (!wishlist) {
|
|
||||||
return res.status(400).json({
|
|
||||||
data: null,
|
|
||||||
errors: [{ message: 'Missing wishlist data' }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const options = {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify(wishlist),
|
|
||||||
}
|
|
||||||
const { data } = await config.storeApiFetch(`/v3/wishlists/`, options)
|
|
||||||
|
|
||||||
res.status(200).json({ data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export default addWishlist
|
|
@ -1,23 +0,0 @@
|
|||||||
import type { Wishlist, WishlistHandlers } from '..'
|
|
||||||
|
|
||||||
// Return all wishlists
|
|
||||||
const getAllWishlists: WishlistHandlers['getAllWishlists'] = async ({
|
|
||||||
res,
|
|
||||||
body: { customerId },
|
|
||||||
config,
|
|
||||||
}) => {
|
|
||||||
let result: { data?: Wishlist[] } = {}
|
|
||||||
|
|
||||||
try {
|
|
||||||
result = await config.storeApiFetch(
|
|
||||||
`/v3/wishlists/customer_id=${customerId}`
|
|
||||||
)
|
|
||||||
} catch (error) {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
|
|
||||||
const data = (result.data ?? []) as any
|
|
||||||
res.status(200).json({ data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export default getAllWishlists
|
|
@ -1,25 +0,0 @@
|
|||||||
import type { WishlistHandlers } from '..'
|
|
||||||
|
|
||||||
// Return current wishlist info
|
|
||||||
const removeWishlist: WishlistHandlers['removeWishlist'] = async ({
|
|
||||||
res,
|
|
||||||
body: { wishlistId },
|
|
||||||
config,
|
|
||||||
}) => {
|
|
||||||
if (!wishlistId) {
|
|
||||||
return res.status(400).json({
|
|
||||||
data: null,
|
|
||||||
errors: [{ message: 'Invalid request' }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const result = await config.storeApiFetch<{ data: any } | null>(
|
|
||||||
`/v3/wishlists/${wishlistId}/`,
|
|
||||||
{ method: 'DELETE' }
|
|
||||||
)
|
|
||||||
const data = result?.data ?? null
|
|
||||||
|
|
||||||
res.status(200).json({ data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export default removeWishlist
|
|
@ -1,27 +0,0 @@
|
|||||||
import type { WishlistHandlers } from '..'
|
|
||||||
|
|
||||||
// Update wish info
|
|
||||||
const updateWishlist: WishlistHandlers['updateWishlist'] = async ({
|
|
||||||
res,
|
|
||||||
body: { wishlistId, wishlist },
|
|
||||||
config,
|
|
||||||
}) => {
|
|
||||||
if (!wishlistId || !wishlist) {
|
|
||||||
return res.status(400).json({
|
|
||||||
data: null,
|
|
||||||
errors: [{ message: 'Invalid request' }],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
const { data } = await config.storeApiFetch(
|
|
||||||
`/v3/wishlists/${wishlistId}/`,
|
|
||||||
{
|
|
||||||
method: 'PUT',
|
|
||||||
body: JSON.stringify(wishlist),
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
res.status(200).json({ data })
|
|
||||||
}
|
|
||||||
|
|
||||||
export default updateWishlist
|
|
Loading…
x
Reference in New Issue
Block a user