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

@ -36,9 +36,6 @@ const currentCoupon = ref<Partial<Coupon>>({
title: '',
business_id: null,
description: '',
business_name: '',
business_address: '',
business_phone: '',
image_url: '',
social_media: '',
terms: '',
@ -83,7 +80,7 @@ function checkHash() {
const filteredCoupons = computed(() => {
return coupons.value.filter(c => {
const matchesSearch = c.title.toLowerCase().includes(searchQuery.value.toLowerCase()) ||
(c.business_name?.toLowerCase().includes(searchQuery.value.toLowerCase()))
(c.business?.name?.toLowerCase().includes(searchQuery.value.toLowerCase()))
const matchesCategory = categoryFilter.value === 'Todas' || c.category === categoryFilter.value
return matchesSearch && matchesCategory
})
@ -247,9 +244,6 @@ function openCreateModal() {
title: '',
business_id: null,
description: '',
business_name: '',
business_address: '',
business_phone: '',
image_url: '',
social_media: '',
terms: '',
@ -266,9 +260,6 @@ function openCreateModal() {
function handleBusinessChange() {
const selectedBiz = businesses.value.find(b => b.id === currentCoupon.value.business_id)
if (selectedBiz) {
currentCoupon.value.business_name = selectedBiz.name
currentCoupon.value.business_address = selectedBiz.address
currentCoupon.value.business_phone = selectedBiz.phone
currentCoupon.value.image_url = selectedBiz.image_url
currentCoupon.value.social_media = selectedBiz.social_media
currentCoupon.value.category = selectedBiz.category
@ -297,8 +288,7 @@ async function saveCoupon() {
if (!isEditing.value) delete data.id
const fieldsToClean = [
'description', 'business_name', 'business_address',
'business_phone', 'image_url', 'social_media', 'terms',
'description', 'image_url', 'social_media', 'terms',
'discount_percentage', 'discount_amount', 'valid_from', 'valid_until'
]
@ -459,7 +449,7 @@ async function toggleCouponStatus(coupon: Coupon) {
<strong>{{ coupon.title }}</strong>
<div class="business-tag">
<span class="material-icons">store</span>
{{ coupon.business_name || 'Comercio Local' }}
{{ coupon.business?.name || 'Comercio Local' }}
</div>
</div>
</div>
@ -638,7 +628,7 @@ async function toggleCouponStatus(coupon: Coupon) {
<div class="form-row">
<div class="form-group">
<label>Nombre del Local</label>
<input v-model="currentCoupon.business_name" type="text">
<input :value="businesses.find(b => b.id === currentCoupon.business_id)?.name || ''" type="text" readonly disabled class="readonly-input">
</div>
<div class="form-group">
<label>Categoría</label>