Client - refresh privacy policy when updated

This commit is contained in:
Sam 2023-03-05 11:08:34 +01:00
parent 04c50ed7c2
commit 5ef3a961e7
6 changed files with 48 additions and 0 deletions

View File

@ -129,6 +129,10 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_USER_PROFILE,
res.data.data
)
if (!res.data.data.accepted_privacy_policy) {
// refresh privacy policy
context.dispatch(ROOT_STORE.ACTIONS.GET_APPLICATION_PRIVACY_POLICY)
}
if (res.data.data.language) {
context.dispatch(
ROOT_STORE.ACTIONS.UPDATE_APPLICATION_LANGUAGE,

View File

@ -51,6 +51,24 @@ export const actions: ActionTree<IRootState, IRootState> & IRootActions = {
})
.catch((error) => handleError(context, error))
},
[ROOT_STORE.ACTIONS.GET_APPLICATION_PRIVACY_POLICY](
context: ActionContext<IRootState, IRootState>
): void {
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
authApi
.get('config')
.then((res) => {
if (res.data.status === 'success') {
context.commit(
ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_PRIVACY_POLICY,
res.data.data
)
} else {
handleError(context, null)
}
})
.catch((error) => handleError(context, error))
},
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_CONFIG](
context: ActionContext<IRootState, IRootState>,
payload: TAppConfigForm

View File

@ -1,5 +1,6 @@
export enum RootActions {
GET_APPLICATION_CONFIG = 'GET_APPLICATION_CONFIG',
GET_APPLICATION_PRIVACY_POLICY = 'GET_APPLICATION_PRIVACY_POLICY',
GET_APPLICATION_STATS = 'GET_APPLICATION_STATS',
UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
UPDATE_APPLICATION_LANGUAGE = 'UPDATE_APPLICATION_LANGUAGE',
@ -19,6 +20,7 @@ export enum RootMutations {
SET_ERROR_MESSAGES = 'SET_ERROR_MESSAGES',
UPDATE_APPLICATION_CONFIG = 'UPDATE_APPLICATION_CONFIG',
UPDATE_APPLICATION_LOADING = 'UPDATE_APPLICATION_LOADING',
UPDATE_APPLICATION_PRIVACY_POLICY = 'UPDATE_APPLICATION_PRIVACY_POLICY',
UPDATE_APPLICATION_STATS = 'UPDATE_APPLICATION_STATS',
UPDATE_LANG = 'UPDATE_LANG',
}

View File

@ -27,6 +27,13 @@ export const mutations: MutationTree<IRootState> & TRootMutations = {
) {
state.appLoading = loading
},
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_PRIVACY_POLICY](
state: IRootState,
appConfig: TAppConfig
) {
state.application.config.privacy_policy = appConfig.privacy_policy
state.application.config.privacy_policy_date = appConfig.privacy_policy_date
},
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_STATS](
state: IRootState,
statistics: IAppStatistics

View File

@ -30,6 +30,9 @@ export interface IRootActions {
[ROOT_STORE.ACTIONS.GET_APPLICATION_STATS](
context: ActionContext<IRootState, IRootState>
): void
[ROOT_STORE.ACTIONS.GET_APPLICATION_PRIVACY_POLICY](
context: ActionContext<IRootState, IRootState>
): void
[ROOT_STORE.ACTIONS.UPDATE_APPLICATION_CONFIG](
context: ActionContext<IRootState, IRootState>,
payload: TAppConfigForm
@ -70,6 +73,10 @@ export type TRootMutations<S = IRootState> = {
state: S,
loading: boolean
): void
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_PRIVACY_POLICY](
state: S,
config: TAppConfig
): void
[ROOT_STORE.MUTATIONS.UPDATE_APPLICATION_STATS](
state: S,
statistics: IAppStatistics

View File

@ -8,5 +8,15 @@
</template>
<script lang="ts" setup>
import { onBeforeMount } from 'vue'
import PrivacyPolicy from '@/components/PrivacyPolicy.vue'
import { ROOT_STORE } from '@/store/constants'
import { useStore } from '@/use/useStore'
const store = useStore()
onBeforeMount(() => {
store.dispatch(ROOT_STORE.ACTIONS.GET_APPLICATION_PRIVACY_POLICY)
})
</script>