Client - add selects to sort users in administration

This commit is contained in:
Sam
2021-10-31 13:27:16 +01:00
parent 80afbe5968
commit 4a5f175053
9 changed files with 189 additions and 26 deletions

View File

@ -4,14 +4,14 @@ import authApi from '@/api/authApi'
import { ROOT_STORE, USERS_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/types'
import { IUsersActions, IUsersState } from '@/store/modules/users/types'
import { IPaginationPayload } from '@/types/api'
import { TPaginationPayload } from '@/types/api'
import { IAdminUserPayload } from '@/types/user'
import { handleError } from '@/utils'
export const actions: ActionTree<IUsersState, IRootState> & IUsersActions = {
[USERS_STORE.ACTIONS.GET_USERS](
context: ActionContext<IUsersState, IRootState>,
payload: IPaginationPayload
payload: TPaginationPayload
): void {
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
context.commit(USERS_STORE.MUTATIONS.UPDATE_USERS_LOADING, true)
@ -40,7 +40,6 @@ export const actions: ActionTree<IUsersState, IRootState> & IUsersActions = {
context: ActionContext<IUsersState, IRootState>,
payload: IAdminUserPayload
): void {
console.log('payload', payload)
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
authApi
.patch(`users/${payload.username}`, { admin: payload.admin })

View File

@ -7,7 +7,7 @@ import {
import { USERS_STORE } from '@/store/constants'
import { IRootState } from '@/store/modules/root/types'
import { IPagination, IPaginationPayload } from '@/types/api'
import { IPagination, TPaginationPayload } from '@/types/api'
import { IAdminUserPayload, IUserProfile } from '@/types/user'
export interface IUsersState {
@ -19,7 +19,7 @@ export interface IUsersState {
export interface IUsersActions {
[USERS_STORE.ACTIONS.GET_USERS](
context: ActionContext<IUsersState, IRootState>,
payload: IPaginationPayload
payload: TPaginationPayload
): void
[USERS_STORE.ACTIONS.UPDATE_USER](
context: ActionContext<IUsersState, IRootState>,