Client - add Sport administration
This commit is contained in:
@ -4,6 +4,7 @@ import authApi from '@/api/authApi'
|
||||
import { ROOT_STORE, SPORTS_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/types'
|
||||
import { ISportsActions, ISportsState } from '@/store/modules/sports/types'
|
||||
import { ISportPayload } from '@/types/sports'
|
||||
import { handleError } from '@/utils'
|
||||
|
||||
export const actions: ActionTree<ISportsState, IRootState> & ISportsActions = {
|
||||
@ -25,4 +26,20 @@ export const actions: ActionTree<ISportsState, IRootState> & ISportsActions = {
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
[SPORTS_STORE.ACTIONS.UPDATE_SPORTS](
|
||||
context: ActionContext<ISportsState, IRootState>,
|
||||
payload: ISportPayload
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
authApi
|
||||
.patch(`sports/${payload.id}`, { is_active: payload.isActive })
|
||||
.then((res) => {
|
||||
if (res.data.status === 'success') {
|
||||
context.dispatch(SPORTS_STORE.ACTIONS.GET_SPORTS)
|
||||
} else {
|
||||
handleError(context, null)
|
||||
}
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
export enum SportsActions {
|
||||
GET_SPORTS = 'GET_SPORTS',
|
||||
UPDATE_SPORTS = 'UPDATE_SPORTS',
|
||||
}
|
||||
|
||||
export enum SportsGetters {
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
|
||||
import { SPORTS_STORE } from '@/store/constants'
|
||||
import { IRootState } from '@/store/modules/root/types'
|
||||
import { ISport } from '@/types/sports'
|
||||
import { ISport, ISportPayload } from '@/types/sports'
|
||||
|
||||
export interface ISportsState {
|
||||
sports: ISport[]
|
||||
@ -17,6 +17,10 @@ export interface ISportsActions {
|
||||
[SPORTS_STORE.ACTIONS.GET_SPORTS](
|
||||
context: ActionContext<ISportsState, IRootState>
|
||||
): void
|
||||
[SPORTS_STORE.ACTIONS.UPDATE_SPORTS](
|
||||
context: ActionContext<ISportsState, IRootState>,
|
||||
payload: ISportPayload
|
||||
): void
|
||||
}
|
||||
|
||||
export interface ISportsGetters {
|
||||
|
Reference in New Issue
Block a user