feat: added ts

This commit is contained in:
Arduinum
2026-02-19 16:26:16 +03:00
committed by Arduinum628
parent ec3d712a82
commit d26310ddad
21 changed files with 135 additions and 149 deletions

View File

@@ -0,0 +1,60 @@
import { defineComponent, onMounted, ref } from 'vue'
import { IonIcon } from '@ionic/vue'
import {
timerOutline,
chevronUp,
chevronDown,
playCircleOutline,
pencilOutline,
trashOutline,
} from 'ionicons/icons'
import { getTimers } from '@/db/crud/timerCrud'
import type { TimersRow } from '@/types/timerType'
export default defineComponent({
name: 'TimersList',
components: { IonIcon },
setup() {
const timers = ref<TimersRow[]>([])
const loading = ref<boolean>(true)
const error = ref<string | null>(null)
const expandedId = ref<number | null>(null)
const loadTimers = async (): Promise<void> => {
loading.value = true
error.value = null
try {
const result = await getTimers()
timers.value = result
} catch (e: unknown) {
error.value = e instanceof Error ? e.message : 'Ошибка загрузки таймеров'
} finally {
loading.value = false
}
}
const toggleExpand = (id: number): void => {
expandedId.value = expandedId.value === id ? null : id
}
onMounted(loadTimers)
return {
timers,
loading,
error,
expandedId,
toggleExpand,
timerOutline,
chevronUp,
chevronDown,
playCircleOutline,
pencilOutline,
trashOutline,
}
},
})