Client - minor refacto
This commit is contained in:
parent
0cc33faf97
commit
045559cfd8
@ -79,7 +79,6 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ComputedRef, computed, ref, capitalize } from 'vue'
|
import { ComputedRef, computed, ref, capitalize } from 'vue'
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
|
|
||||||
import UserPicture from '@/components/User/UserPicture.vue'
|
import UserPicture from '@/components/User/UserPicture.vue'
|
||||||
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
import { AUTH_USER_STORE, ROOT_STORE } from '@/store/constants'
|
||||||
@ -90,7 +89,6 @@
|
|||||||
|
|
||||||
const emit = defineEmits(['menuInteraction'])
|
const emit = defineEmits(['menuInteraction'])
|
||||||
|
|
||||||
const { locale } = useI18n()
|
|
||||||
const store = useStore()
|
const store = useStore()
|
||||||
|
|
||||||
const authUser: ComputedRef<IAuthUserProfile> = computed(
|
const authUser: ComputedRef<IAuthUserProfile> = computed(
|
||||||
@ -113,9 +111,10 @@
|
|||||||
emit('menuInteraction', false)
|
emit('menuInteraction', false)
|
||||||
}
|
}
|
||||||
function updateLanguage(option: IDropdownOption) {
|
function updateLanguage(option: IDropdownOption) {
|
||||||
locale.value = option.value.toString()
|
store.dispatch(
|
||||||
document.querySelector('html')?.setAttribute('lang', locale.value)
|
ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE,
|
||||||
store.commit(ROOT_STORE.MUTATIONS.UPDATE_LANG, option.value)
|
option.value.toString()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
function logout() {
|
function logout() {
|
||||||
store.dispatch(AUTH_USER_STORE.ACTIONS.LOGOUT)
|
store.dispatch(AUTH_USER_STORE.ACTIONS.LOGOUT)
|
||||||
|
@ -2,7 +2,6 @@ import { ActionContext, ActionTree } from 'vuex'
|
|||||||
|
|
||||||
import authApi from '@/api/authApi'
|
import authApi from '@/api/authApi'
|
||||||
import api from '@/api/defaultApi'
|
import api from '@/api/defaultApi'
|
||||||
import createI18n from '@/i18n'
|
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import {
|
import {
|
||||||
AUTH_USER_STORE,
|
AUTH_USER_STORE,
|
||||||
@ -32,8 +31,6 @@ import {
|
|||||||
} from '@/types/user'
|
} from '@/types/user'
|
||||||
import { handleError } from '@/utils'
|
import { handleError } from '@/utils'
|
||||||
|
|
||||||
const { locale } = createI18n.global
|
|
||||||
|
|
||||||
const removeAuthUserData = (
|
const removeAuthUserData = (
|
||||||
context: ActionContext<IAuthUserState, IRootState>
|
context: ActionContext<IAuthUserState, IRootState>
|
||||||
) => {
|
) => {
|
||||||
@ -126,11 +123,10 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
|||||||
res.data.data
|
res.data.data
|
||||||
)
|
)
|
||||||
if (res.data.data.language) {
|
if (res.data.data.language) {
|
||||||
context.commit(
|
context.dispatch(
|
||||||
ROOT_STORE.MUTATIONS.UPDATE_LANG,
|
ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE,
|
||||||
res.data.data.language
|
res.data.data.language
|
||||||
)
|
)
|
||||||
locale.value = res.data.data.language
|
|
||||||
}
|
}
|
||||||
context.dispatch(SPORTS_STORE.ACTIONS.GET_SPORTS)
|
context.dispatch(SPORTS_STORE.ACTIONS.GET_SPORTS)
|
||||||
} else {
|
} else {
|
||||||
@ -251,12 +247,12 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
|||||||
AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE,
|
AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE,
|
||||||
res.data.data
|
res.data.data
|
||||||
)
|
)
|
||||||
context.commit(
|
context
|
||||||
ROOT_STORE.MUTATIONS.UPDATE_LANG,
|
.dispatch(
|
||||||
res.data.data.language
|
ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE,
|
||||||
)
|
res.data.data.language
|
||||||
locale.value = res.data.data.language
|
)
|
||||||
router.push('/profile/preferences')
|
.then(() => router.push('/profile/preferences'))
|
||||||
} else {
|
} else {
|
||||||
handleError(context, null)
|
handleError(context, null)
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,15 @@
|
|||||||
import { ActionContext, ActionTree } from 'vuex'
|
import { ActionContext, ActionTree } from 'vuex'
|
||||||
|
|
||||||
import authApi from '@/api/authApi'
|
import authApi from '@/api/authApi'
|
||||||
|
import createI18n from '@/i18n'
|
||||||
import router from '@/router'
|
import router from '@/router'
|
||||||
import { ROOT_STORE } from '@/store/constants'
|
import { ROOT_STORE } from '@/store/constants'
|
||||||
import { IRootActions, IRootState } from '@/store/modules/root/types'
|
import { IRootActions, IRootState } from '@/store/modules/root/types'
|
||||||
import { TAppConfigForm } from '@/types/application'
|
import { TAppConfigForm } from '@/types/application'
|
||||||
import { handleError } from '@/utils'
|
import { handleError } from '@/utils'
|
||||||
|
|
||||||
|
const { locale } = createI18n.global
|
||||||
|
|
||||||
export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
||||||
[ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
|
[ROOT_STORE.ACTIONS.GET_APPLICATION_CONFIG](
|
||||||
context: ActionContext<IRootState, IRootState>
|
context: ActionContext<IRootState, IRootState>
|
||||||
@ -68,4 +71,12 @@ export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
|
|||||||
})
|
})
|
||||||
.catch((error) => handleError(context, error))
|
.catch((error) => handleError(context, error))
|
||||||
},
|
},
|
||||||
|
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE](
|
||||||
|
context: ActionContext<IRootState, IRootState>,
|
||||||
|
language: string
|
||||||
|
): void {
|
||||||
|
document.querySelector('html')?.setAttribute('lang', language)
|
||||||
|
context.commit(ROOT_STORE.MUTATIONS.UPDATE_LANG, language)
|
||||||
|
locale.value = language
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ export enum RootActions {
|
|||||||
GET_APPLICATION_CONFIG = 'GET_APPLICATION_CONFIG',
|
GET_APPLICATION_CONFIG = 'GET_APPLICATION_CONFIG',
|
||||||
GET_APPLICATION_STATS = 'GET_APPLICATION_STATS',
|
GET_APPLICATION_STATS = 'GET_APPLICATION_STATS',
|
||||||
UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
|
UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
|
||||||
|
UPDATE_APPLICATION_LANGUAGE = 'UPDATE_APPLICATION_LANGUAGE',
|
||||||
}
|
}
|
||||||
|
|
||||||
export enum RootGetters {
|
export enum RootGetters {
|
||||||
|
@ -34,6 +34,10 @@ export interface IRootActions {
|
|||||||
context: ActionContext<IRootState, IRootState>,
|
context: ActionContext<IRootState, IRootState>,
|
||||||
payload: TAppConfigForm
|
payload: TAppConfigForm
|
||||||
): void
|
): void
|
||||||
|
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE](
|
||||||
|
context: ActionContext<IRootState, IRootState>,
|
||||||
|
langauge: string
|
||||||
|
): void
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface IRootGetters {
|
export interface IRootGetters {
|
||||||
|
Loading…
Reference in New Issue
Block a user