fix(coupons): remove duplicate business cols from coupons in PromoterDashboard and CouponsView

This commit is contained in:
2026-02-26 15:36:32 -05:00
parent 23f8438456
commit 10cb37c866
6 changed files with 15 additions and 28 deletions

View File

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