initial commit. Cloned timetracker repository

This commit is contained in:
Daniel Goc
2026-03-10 09:02:57 +01:00
commit f2952bcef0
189 changed files with 21334 additions and 0 deletions

30
bo/src/router/langs.ts Normal file
View File

@@ -0,0 +1,30 @@
import { useCookie } from "@/composable/useCookie"
import { useFetchJson } from "@/composable/useFetchJson"
import type { Language } from "@/types"
import { reactive, ref } from "vue"
export const langs = reactive([] as Language[])
export const currentLang = ref<Language>()
const deflang = ref<Language>()
const cookie = useCookie()
// Get available language codes for route matching
// export const availableLocales = computed(() => langs.map((l) => l.lang_code))
// Initialize languages from API
export async function initLangs() {
try {
const { items } = await useFetchJson<Language[]>('/api/v1/langs')
langs.push(...items)
let idfromcookie = null
const cc = cookie.getCookie('lang_id')
if (cc) {
idfromcookie = langs.find((x) => x.id == parseInt(cc))
}
deflang.value = items.find((x) => x.is_default == true)
currentLang.value = idfromcookie ?? deflang.value
} catch (error) {
console.error('Failed to fetch languages:', error)
}
}