Initial commit: G3FO recurring investment schedule frontend
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
import { useRoute, useRouter } from 'vue-router'
|
||||
import type { AppPreferences } from '@/config/urlPreferences'
|
||||
import type { AppLocale } from '@/i18n/locale'
|
||||
import { useAppStore } from '@/stores/app'
|
||||
import type { AppTheme } from '@/theme/types'
|
||||
|
||||
export function useUrlPreferences() {
|
||||
const route = useRoute()
|
||||
const router = useRouter()
|
||||
const appStore = useAppStore()
|
||||
|
||||
function replacePreferences(partial: Partial<AppPreferences>) {
|
||||
const query = appStore.buildQueryForPreferences(partial, route.query)
|
||||
router.replace({ path: route.path, hash: route.hash, query })
|
||||
}
|
||||
|
||||
function setLocale(next: AppLocale) {
|
||||
replacePreferences({ locale: next })
|
||||
}
|
||||
|
||||
function setTheme(next: AppTheme) {
|
||||
replacePreferences({ theme: next })
|
||||
}
|
||||
|
||||
return { setLocale, setTheme }
|
||||
}
|
||||
Reference in New Issue
Block a user