feat: separated coupon and voucher errors

This commit is contained in:
2025-12-02 18:26:59 +03:00
parent fdcfce0a79
commit dd12cb8c34
2 changed files with 20 additions and 2 deletions

View File

@@ -16,6 +16,8 @@ export const useCartStore = defineStore('cart', {
success: '', success: '',
coupon: '', coupon: '',
voucher: '', voucher: '',
error_coupon: '',
error_voucher: '',
}), }),
getters: { getters: {
@@ -128,10 +130,11 @@ export const useCartStore = defineStore('cart', {
try { try {
this.isLoading = true; this.isLoading = true;
this.error_warning = ''; this.error_warning = '';
this.error_coupon = '';
const response = await setCoupon(this.coupon); const response = await setCoupon(this.coupon);
if (response.error) { if (response.error) {
this.error_warning = response.error; this.error_coupon = response.error;
} else { } else {
await this.getProducts(); await this.getProducts();
} }
@@ -147,10 +150,11 @@ export const useCartStore = defineStore('cart', {
try { try {
this.isLoading = true; this.isLoading = true;
this.error_warning = ''; this.error_warning = '';
this.error_voucher = '';
const response = await setVoucher(this.voucher); const response = await setVoucher(this.voucher);
if (response.error) { if (response.error) {
this.error_warning = response.error; this.error_voucher = response.error;
} else { } else {
await this.getProducts(); await this.getProducts();
} }

View File

@@ -14,6 +14,20 @@
<span>{{ cart.error_warning }}</span> <span>{{ cart.error_warning }}</span>
</div> </div>
<div v-if="cart.error_coupon" role="alert" class="alert alert-error">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 shrink-0 stroke-current" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span>{{ cart.error_coupon }}</span>
</div>
<div v-if="cart.error_voucher" role="alert" class="alert alert-error">
<svg xmlns="http://www.w3.org/2000/svg" class="h-6 w-6 shrink-0 stroke-current" fill="none" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 14l2-2m0 0l2-2m-2 2l-2-2m2 2l2 2m7-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span>{{ cart.error_voucher }}</span>
</div>
<div v-if="cart.items.length > 0" class="pb-10"> <div v-if="cart.items.length > 0" class="pb-10">
<div <div
v-for="(item, index) in cart.items" v-for="(item, index) in cart.items"