refactor logic for MAX-btn and added validation for check integer-type

This commit is contained in:
Kostya
2024-01-25 20:47:21 +03:00
parent fe52c01dae
commit e3612f5f01

View File

@@ -151,7 +151,7 @@ import SwiperCore from 'swiper/core';
import {Navigation } from "swiper/modules"; import {Navigation } from "swiper/modules";
import { useVuelidate } from '@vuelidate/core' import { useVuelidate } from '@vuelidate/core'
import { maxValue, minValue, required, numeric } from "@vuelidate/validators"; import { maxValue, minValue, required, numeric, integer } from "@vuelidate/validators";
SwiperCore.use([Navigation]); SwiperCore.use([Navigation]);
@@ -187,8 +187,8 @@ export default {
}, },
validations() { validations() {
return { return {
amountCrystals: { required, numeric, minValue: minValue(1), maxValue: maxValue(24) }, amountCrystals: { required, numeric, minValue: minValue(1), maxValue: maxValue(24), integer },
amountDeposit: { required, numeric, minValue: minValue(1), maxValue: maxValue(this.balance) } amountDeposit: { required, numeric, minValue: minValue(1), maxValue: maxValue(this.balance), integer }
} }
}, },
watch: { watch: {
@@ -406,15 +406,13 @@ export default {
} }
return word return word
}, },
clickedBtnChoice(index, content) { async clickedBtnChoice(index, content) {
this.clickedBtn = index this.clickedBtn = index
if (content === 'max') { if (content === 'max') {
setTimeout( async () => {
await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken')) await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken'))
.then((response) => { .then((response) => {
this.amountDeposit = response.currentMoney this.amountDeposit = parseInt(response.currentMoney)
}) })
}, 1000)
} }
else { else {
this.amountDeposit = content this.amountDeposit = content