Refactor decimalCount method and add it on a file to be used in many components
This commit is contained in:
parent
4999f3d145
commit
be90ff746b
@ -8,6 +8,7 @@ import { connectProvider } from "@/blockchain/provider";
|
||||
import { verifyNetworkLiquidity } from "@/utils/networkLiquidity";
|
||||
import { NetworkEnum } from "@/model/NetworkEnum";
|
||||
import type { ValidDeposit } from "@/model/ValidDeposit";
|
||||
import { decimalCount } from "@/utils/decimalCount";
|
||||
|
||||
// Store reference
|
||||
const etherStore = useEtherStore();
|
||||
@ -62,16 +63,6 @@ const handleInputEvent = (event: any): void => {
|
||||
verifyLiquidity();
|
||||
};
|
||||
|
||||
// Enable button methods
|
||||
// Check if has more than 2 decimal places
|
||||
const decimalCount = (num: number): number => {
|
||||
const numStr = String(num);
|
||||
if (numStr.includes(".")) {
|
||||
return numStr.split(".")[1].length;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
|
||||
// Verify if there is a valid deposit to buy
|
||||
const verifyLiquidity = (): void => {
|
||||
enableConfirmButton.value = false;
|
||||
|
@ -2,6 +2,7 @@
|
||||
import { ref } from "vue";
|
||||
import CustomButton from "../../components/CustomButton.vue";
|
||||
import { debounce } from "@/utils/debounce";
|
||||
import { decimalCount } from "@/utils/decimalCount";
|
||||
|
||||
// Reactive state
|
||||
const tokenValue = ref<number>(0);
|
||||
@ -25,16 +26,6 @@ const handleInputEvent = (event: any): void => {
|
||||
}
|
||||
validDecimals.value = true;
|
||||
};
|
||||
|
||||
// Enable button methods
|
||||
// Check if has more than 2 decimal places
|
||||
const decimalCount = (num: number): number => {
|
||||
const numStr = String(num);
|
||||
if (numStr.includes(".")) {
|
||||
return numStr.split(".")[1].length;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -2,6 +2,7 @@
|
||||
import { ref } from "vue";
|
||||
import CustomButton from "../CustomButton.vue";
|
||||
import { debounce } from "@/utils/debounce";
|
||||
import { decimalCount } from "@/utils/decimalCount";
|
||||
|
||||
// Reactive state
|
||||
const offer = ref<string | number>("");
|
||||
@ -27,16 +28,6 @@ const handleInputEvent = (event: any): void => {
|
||||
}
|
||||
validDecimals.value = true;
|
||||
};
|
||||
|
||||
// Enable button methods
|
||||
// Check if has more than 2 decimal places
|
||||
const decimalCount = (num: Number): number => {
|
||||
const numStr = String(num);
|
||||
if (numStr.includes(".")) {
|
||||
return numStr.split(".")[1].length;
|
||||
}
|
||||
return 0;
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
7
src/utils/decimalCount.ts
Normal file
7
src/utils/decimalCount.ts
Normal file
@ -0,0 +1,7 @@
|
||||
export const decimalCount = (num: number): number => {
|
||||
const numStr = String(num);
|
||||
if (numStr.includes(".")) {
|
||||
return numStr.split(".")[1].length;
|
||||
}
|
||||
return 0;
|
||||
};
|
Loading…
x
Reference in New Issue
Block a user