diff --git a/src/pages/POS/LoyaltyprogramModal.vue b/src/pages/POS/LoyaltyprogramModal.vue index 21b681ef..51c866f3 100644 --- a/src/pages/POS/LoyaltyprogramModal.vue +++ b/src/pages/POS/LoyaltyprogramModal.vue @@ -143,6 +143,7 @@ export default defineComponent({ this.validationError = false; } catch (error) { this.validationError = true; + showToast({ type: 'error', message: t`${error as string}`, @@ -152,15 +153,23 @@ export default defineComponent({ } }, setLoyaltyPoints() { - if ( - !this.sinvDoc.loyaltyPoints || - this.sinvDoc.loyaltyPoints > this.loyaltyPoints - ) { - return; - } + try { + if (!this.sinvDoc.loyaltyPoints || this.sinvDoc.loyaltyPoints < 0) { + throw new Error(t`Points must be greater than 0`); + } - this.$emit('setLoyaltyPoints', this.sinvDoc.loyaltyPoints); - this.$emit('toggleModal', 'LoyaltyProgram'); + this.$emit('setLoyaltyPoints', this.sinvDoc.loyaltyPoints); + this.$emit('toggleModal', 'LoyaltyProgram'); + + this.validationError = false; + } catch (error) { + this.validationError = true; + + showToast({ + type: 'error', + message: t`${error as string}`, + }); + } }, }, }); diff --git a/src/pages/POS/POS.vue b/src/pages/POS/POS.vue index 765f6700..00fb2b2f 100644 --- a/src/pages/POS/POS.vue +++ b/src/pages/POS/POS.vue @@ -140,10 +140,10 @@ :class="{ 'bg-gray-100': loyaltyPoints, 'bg-gray-600 cursor-not-allowed': - !loyaltyPoints || !sinvDoc.party, + !loyaltyPoints || !sinvDoc.party || !sinvDoc.items?.length, }" @click=" - loyaltyPoints && sinvDoc.party + loyaltyPoints && sinvDoc.party && sinvDoc.items?.length ? toggleModal('LoyaltyProgram', true) : null "