mirror of
https://github.com/frappe/books.git
synced 2025-01-03 15:17:30 +00:00
feat: add validations for redeeming loyalty points
This commit is contained in:
parent
57d3208437
commit
53cf61d4fe
@ -143,6 +143,7 @@ export default defineComponent({
|
|||||||
this.validationError = false;
|
this.validationError = false;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
this.validationError = true;
|
this.validationError = true;
|
||||||
|
|
||||||
showToast({
|
showToast({
|
||||||
type: 'error',
|
type: 'error',
|
||||||
message: t`${error as string}`,
|
message: t`${error as string}`,
|
||||||
@ -152,15 +153,23 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
setLoyaltyPoints() {
|
setLoyaltyPoints() {
|
||||||
if (
|
try {
|
||||||
!this.sinvDoc.loyaltyPoints ||
|
if (!this.sinvDoc.loyaltyPoints || this.sinvDoc.loyaltyPoints < 0) {
|
||||||
this.sinvDoc.loyaltyPoints > this.loyaltyPoints
|
throw new Error(t`Points must be greater than 0`);
|
||||||
) {
|
}
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.$emit('setLoyaltyPoints', this.sinvDoc.loyaltyPoints);
|
this.$emit('setLoyaltyPoints', this.sinvDoc.loyaltyPoints);
|
||||||
this.$emit('toggleModal', 'LoyaltyProgram');
|
this.$emit('toggleModal', 'LoyaltyProgram');
|
||||||
|
|
||||||
|
this.validationError = false;
|
||||||
|
} catch (error) {
|
||||||
|
this.validationError = true;
|
||||||
|
|
||||||
|
showToast({
|
||||||
|
type: 'error',
|
||||||
|
message: t`${error as string}`,
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -140,10 +140,10 @@
|
|||||||
:class="{
|
:class="{
|
||||||
'bg-gray-100': loyaltyPoints,
|
'bg-gray-100': loyaltyPoints,
|
||||||
'bg-gray-600 cursor-not-allowed':
|
'bg-gray-600 cursor-not-allowed':
|
||||||
!loyaltyPoints || !sinvDoc.party,
|
!loyaltyPoints || !sinvDoc.party || !sinvDoc.items?.length,
|
||||||
}"
|
}"
|
||||||
@click="
|
@click="
|
||||||
loyaltyPoints && sinvDoc.party
|
loyaltyPoints && sinvDoc.party && sinvDoc.items?.length
|
||||||
? toggleModal('LoyaltyProgram', true)
|
? toggleModal('LoyaltyProgram', true)
|
||||||
: null
|
: null
|
||||||
"
|
"
|
||||||
|
Loading…
Reference in New Issue
Block a user