fix(coupons): remove duplicate business cols from coupons in PromoterDashboard and CouponsView
This commit is contained in:
@ -34,7 +34,7 @@ export const couponsService = {
|
||||
/** Create a new coupon */
|
||||
async createCoupon(coupon: Omit<Coupon, 'id' | 'created_at' | 'updated_at'>): Promise<Coupon> {
|
||||
// Prevent sending nested business properties over insert
|
||||
const { business, ...payload } = coupon as any
|
||||
const { business, business_name, business_address, business_phone, created_at, updated_at, id, ...payload } = coupon as any
|
||||
const { data, error } = await supabase.from('coupons').insert([payload]).select().single()
|
||||
if (error) throw new Error(error.message)
|
||||
return data as Coupon
|
||||
@ -42,7 +42,7 @@ export const couponsService = {
|
||||
|
||||
/** Update an existing coupon */
|
||||
async updateCoupon(id: string, coupon: Partial<Coupon>): Promise<Coupon> {
|
||||
const { business, ...payload } = coupon as any
|
||||
const { business, business_name, business_address, business_phone, created_at, updated_at, id: _id, ...payload } = coupon as any
|
||||
const { data, error } = await supabase.from('coupons').update(payload).eq('id', id).select().single()
|
||||
if (error) throw new Error(error.message)
|
||||
return data as Coupon
|
||||
|
||||
Reference in New Issue
Block a user