Skip to content

Open source personal finance application

chore(generateId): refactor

Ilya Komichevd62ef6ca0936
diff --git a/components/categories/Form.vue b/components/categories/Form.vue
index 8bf75c5b..6c72fedc 100644
--- a/components/categories/Form.vue
+++ b/components/categories/Form.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import generateId from '~/utils/id'
+import { generateId } from '~/utils/generateId'
import icons from '~/assets/js/icons'
import type { CategoryForm, CategoryID, CategoryItem } from '~/components/categories/types'
import { allColors } from '~/assets/js/colors'
diff --git a/components/trnForm/Index.vue b/components/trnForm/Index.vue
index 41d06f3f..cd186d06 100644
--- a/components/trnForm/Index.vue
+++ b/components/trnForm/Index.vue
@@ -3,7 +3,7 @@ import Vue from 'vue'
import dayjs from 'dayjs'
import SwiperCore, { Pagination } from 'swiper'
import 'swiper/swiper-bundle.css'
-import generateId from '~/utils/id'
+import { generateId } from '~/utils/generateId'
import useCalculator from '~/components/trnForm/calculator/useCalculator'
import useTrnFormValidate from '~/components/trnForm/useTrnFormValidate'
diff --git a/components/wallets/Form.vue b/components/wallets/Form.vue
index 6087617d..4e6d825c 100644
--- a/components/wallets/Form.vue
+++ b/components/wallets/Form.vue
@@ -1,5 +1,5 @@
<script setup lang="ts">
-import generateId from '~/utils/id'
+import { generateId } from '~/utils/generateId'
import type { WalletForm, WalletID } from '~/components/wallets/types'
import { allColors } from '~/assets/js/colors'
import { getPreparedFormData } from '~/components/wallets/getForm'
diff --git a/services/rates/api.ts b/services/rates/api.ts
index ddac4f07..4c046143 100644
--- a/services/rates/api.ts
+++ b/services/rates/api.ts
@@ -1,8 +1,6 @@
import axios from 'axios'
-type Props = Record<string, string>
-
-export const getRatesOfUSD = async (apiKey: string): Promise<Props | false> => {
+export const getRatesOfUSD = async (apiKey: string): Promise<Record<string, string> | false> => {
const serviceUrl = `https://openexchangerates.org/api/latest.json?app_id=${apiKey}`
const { data } = await axios.get(serviceUrl)
diff --git a/utils/generateId.ts b/utils/generateId.ts
new file mode 100644
index 00000000..6a13c095
--- /dev/null
+++ b/utils/generateId.ts
@@ -0,0 +1,3 @@
+export function generateId() {
+ return Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
+}
diff --git a/utils/id.js b/utils/id.js
deleted file mode 100644
index 0edbea61..00000000
--- a/utils/id.js
+++ /dev/null
@@ -1,6 +0,0 @@
-import dayjs from 'dayjs'
-
-export default function (date) {
- const string = Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15)
- return `${dayjs(date).format('YYMMDD')}_${string.slice(0, 6)}`
-}