import odooApi from '~/libs/odooApi'; export const getUserCart = async (userId: number) => { return await odooApi('GET', `/api/v1/user/${userId}/cart`); }; interface UpsertUserCartProps { userId: number; type: 'product' | 'promotion'; id: number; qty: number; selected: boolean; source?: 'buy' | 'add_to_cart'; qtyAppend?: boolean; } export const upsertUserCart = async ({ userId, type, id, qty, selected, source = 'add_to_cart', qtyAppend = false, }: UpsertUserCartProps) => { return await odooApi('POST', `/api/v1/user/${userId}/cart/create-or-update`, { product_id: type === 'product' ? id : null, qty, selected, program_line_id: type === 'promotion' ? id : null, source, qty_append: qtyAppend, }); }; export const deleteUserCart = async (userId: number, ids: number[]) => { return await odooApi( 'DELETE', `/api/v1/user/${userId}/cart?ids=${ids.join(',')}` ); };