Client - a user can request and download data export archive
This commit is contained in:
@ -447,4 +447,40 @@ export const actions: ActionTree<IAuthUserState, IRootState> &
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
[AUTH_USER_STORE.ACTIONS.REQUEST_DATA_EXPORT](
|
||||
context: ActionContext<IAuthUserState, IRootState>
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
authApi
|
||||
.post('auth/profile/export/request')
|
||||
.then((res) => {
|
||||
if (res.data.status === 'success') {
|
||||
context.commit(
|
||||
AUTH_USER_STORE.MUTATIONS.SET_EXPORT_REQUEST,
|
||||
res.data.request
|
||||
)
|
||||
} else {
|
||||
handleError(context, null)
|
||||
}
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
[AUTH_USER_STORE.ACTIONS.GET_REQUEST_DATA_EXPORT](
|
||||
context: ActionContext<IAuthUserState, IRootState>
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
authApi
|
||||
.get('auth/profile/export')
|
||||
.then((res) => {
|
||||
if (res.data.status === 'success') {
|
||||
context.commit(
|
||||
AUTH_USER_STORE.MUTATIONS.SET_EXPORT_REQUEST,
|
||||
res.data.request
|
||||
)
|
||||
} else {
|
||||
handleError(context, null)
|
||||
}
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
}
|
||||
|
@ -5,13 +5,15 @@ export enum AuthUserActions {
|
||||
CONFIRM_EMAIL = 'CONFIRM_EMAIL',
|
||||
DELETE_ACCOUNT = 'DELETE_ACCOUNT',
|
||||
DELETE_PICTURE = 'DELETE_PICTURE',
|
||||
GET_REQUEST_DATA_EXPORT = 'GET_REQUEST_DATA_EXPORT',
|
||||
GET_USER_PROFILE = 'GET_USER_PROFILE',
|
||||
LOGIN_OR_REGISTER = 'LOGIN_OR_REGISTER',
|
||||
LOGOUT = 'LOGOUT',
|
||||
SEND_PASSWORD_RESET_REQUEST = 'SEND_PASSWORD_RESET_REQUEST',
|
||||
REQUEST_DATA_EXPORT = 'REQUEST_DATA_EXPORT',
|
||||
RESEND_ACCOUNT_CONFIRMATION_EMAIL = 'RESEND_ACCOUNT_CONFIRMATION_EMAIL',
|
||||
RESET_USER_PASSWORD = 'RESET_USER_PASSWORD',
|
||||
RESET_USER_SPORT_PREFERENCES = 'RESET_USER_SPORT_PREFERENCES',
|
||||
SEND_PASSWORD_RESET_REQUEST = 'SEND_PASSWORD_RESET_REQUEST',
|
||||
UPDATE_USER_ACCOUNT = 'UPDATE_USER_ACCOUNT',
|
||||
UPDATE_USER_PICTURE = 'UPDATE_USER_PICTURE',
|
||||
UPDATE_USER_PROFILE = 'UPDATE_USER_PROFILE',
|
||||
@ -27,6 +29,7 @@ export enum AuthUserGetters {
|
||||
IS_SUCCESS = 'IS_SUCCESS',
|
||||
IS_REGISTRATION_SUCCESS = 'IS_REGISTRATION_SUCCESS',
|
||||
USER_LOADING = 'USER_LOADING',
|
||||
EXPORT_REQUEST = 'EXPORT_REQUEST',
|
||||
}
|
||||
|
||||
export enum AuthUserMutations {
|
||||
@ -36,4 +39,5 @@ export enum AuthUserMutations {
|
||||
UPDATE_IS_SUCCESS = 'UPDATE_USER_IS_SUCCESS',
|
||||
UPDATE_IS_REGISTRATION_SUCCESS = 'UPDATE_IS_REGISTRATION_SUCCESS',
|
||||
UPDATE_USER_LOADING = 'UPDATE_USER_LOADING',
|
||||
SET_EXPORT_REQUEST = 'SET_EXPORT_REQUEST',
|
||||
}
|
||||
|
@ -15,6 +15,9 @@ export const getters: GetterTree<IAuthUserState, IRootState> &
|
||||
[AUTH_USER_STORE.GETTERS.AUTH_USER_PROFILE]: (state: IAuthUserState) => {
|
||||
return state.authUserProfile
|
||||
},
|
||||
[AUTH_USER_STORE.GETTERS.EXPORT_REQUEST]: (state: IAuthUserState) => {
|
||||
return state.exportRequest
|
||||
},
|
||||
[AUTH_USER_STORE.GETTERS.IS_AUTHENTICATED]: (state: IAuthUserState) => {
|
||||
return state.authToken !== null
|
||||
},
|
||||
|
@ -5,7 +5,7 @@ import {
|
||||
IAuthUserState,
|
||||
TAuthUserMutations,
|
||||
} from '@/store/modules/authUser/types'
|
||||
import { IAuthUserProfile } from '@/types/user'
|
||||
import { IAuthUserProfile, IExportRequest } from '@/types/user'
|
||||
|
||||
export const mutations: MutationTree<IAuthUserState> & TAuthUserMutations = {
|
||||
[AUTH_USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: IAuthUserState) {
|
||||
@ -42,4 +42,10 @@ export const mutations: MutationTree<IAuthUserState> & TAuthUserMutations = {
|
||||
) {
|
||||
state.loading = loading
|
||||
},
|
||||
[AUTH_USER_STORE.MUTATIONS.SET_EXPORT_REQUEST](
|
||||
state: IAuthUserState,
|
||||
exportRequest: IExportRequest
|
||||
) {
|
||||
state.exportRequest = exportRequest
|
||||
},
|
||||
}
|
||||
|
@ -7,4 +7,5 @@ export const authUserState: IAuthUserState = {
|
||||
isSuccess: false,
|
||||
isRegistrationSuccess: false,
|
||||
loading: false,
|
||||
exportRequest: null,
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ import {
|
||||
IUserSportPreferencesPayload,
|
||||
IUserAccountPayload,
|
||||
IUserAccountUpdatePayload,
|
||||
IExportRequest,
|
||||
} from '@/types/user'
|
||||
|
||||
export interface IAuthUserState {
|
||||
@ -27,6 +28,7 @@ export interface IAuthUserState {
|
||||
isRegistrationSuccess: boolean
|
||||
isSuccess: boolean
|
||||
loading: boolean
|
||||
exportRequest: IExportRequest | null
|
||||
}
|
||||
|
||||
export interface IAuthUserActions {
|
||||
@ -115,6 +117,14 @@ export interface IAuthUserActions {
|
||||
context: ActionContext<IAuthUserState, IRootState>,
|
||||
acceptedPolicy: boolean
|
||||
): void
|
||||
|
||||
[AUTH_USER_STORE.ACTIONS.REQUEST_DATA_EXPORT](
|
||||
context: ActionContext<IAuthUserState, IRootState>
|
||||
): void
|
||||
|
||||
[AUTH_USER_STORE.ACTIONS.GET_REQUEST_DATA_EXPORT](
|
||||
context: ActionContext<IAuthUserState, IRootState>
|
||||
): void
|
||||
}
|
||||
|
||||
export interface IAuthUserGetters {
|
||||
@ -124,6 +134,10 @@ export interface IAuthUserGetters {
|
||||
state: IAuthUserState
|
||||
): IAuthUserProfile
|
||||
|
||||
[AUTH_USER_STORE.GETTERS.EXPORT_REQUEST](
|
||||
state: IAuthUserState
|
||||
): IExportRequest | null
|
||||
|
||||
[AUTH_USER_STORE.GETTERS.IS_ADMIN](state: IAuthUserState): boolean
|
||||
|
||||
[AUTH_USER_STORE.GETTERS.IS_AUTHENTICATED](state: IAuthUserState): boolean
|
||||
@ -139,6 +153,10 @@ export interface IAuthUserGetters {
|
||||
|
||||
export type TAuthUserMutations<S = IAuthUserState> = {
|
||||
[AUTH_USER_STORE.MUTATIONS.CLEAR_AUTH_USER_TOKEN](state: S): void
|
||||
[AUTH_USER_STORE.MUTATIONS.SET_EXPORT_REQUEST](
|
||||
state: S,
|
||||
exportRequest: IExportRequest | null
|
||||
): void
|
||||
[AUTH_USER_STORE.MUTATIONS.UPDATE_AUTH_TOKEN](
|
||||
state: S,
|
||||
authToken: string
|
||||
|
Reference in New Issue
Block a user