Refactor decimalCount method and add it on a file to be used in many components

This commit is contained in:
RcleydsonR
2023-01-18 23:38:00 -03:00
parent 4999f3d145
commit be90ff746b
4 changed files with 10 additions and 30 deletions

View File

@@ -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>