From e3612f5f01181b370ec873925788dd081ffc7c9f Mon Sep 17 00:00:00 2001 From: Kostya Date: Thu, 25 Jan 2024 20:47:21 +0300 Subject: [PATCH] refactor logic for MAX-btn and added validation for check integer-type --- .../src/pages/games-pages/SapergamePage.vue | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/luckydiamond/src/pages/games-pages/SapergamePage.vue b/luckydiamond/src/pages/games-pages/SapergamePage.vue index a429077..3cba20c 100644 --- a/luckydiamond/src/pages/games-pages/SapergamePage.vue +++ b/luckydiamond/src/pages/games-pages/SapergamePage.vue @@ -151,7 +151,7 @@ import SwiperCore from 'swiper/core'; import {Navigation } from "swiper/modules"; 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]); @@ -187,8 +187,8 @@ export default { }, validations() { return { - amountCrystals: { required, numeric, minValue: minValue(1), maxValue: maxValue(24) }, - amountDeposit: { required, numeric, minValue: minValue(1), maxValue: maxValue(this.balance) } + amountCrystals: { required, numeric, minValue: minValue(1), maxValue: maxValue(24), integer }, + amountDeposit: { required, numeric, minValue: minValue(1), maxValue: maxValue(this.balance), integer } } }, watch: { @@ -406,15 +406,13 @@ export default { } return word }, - clickedBtnChoice(index, content) { + async clickedBtnChoice(index, content) { this.clickedBtn = index if (content === 'max') { - setTimeout( async () => { - await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken')) - .then((response) => { - this.amountDeposit = response.currentMoney - }) - }, 1000) + await GetCurrentMoney(GetCookie('AUTHTOKEN'), GetCookie('SearchToken')) + .then((response) => { + this.amountDeposit = parseInt(response.currentMoney) + }) } else { this.amountDeposit = content