Client - refacto

This commit is contained in:
Sam 2021-10-31 17:03:24 +01:00
parent feb4f0f7c3
commit 332983d9ea
4 changed files with 7 additions and 4 deletions

View File

@ -46,7 +46,7 @@ export const actions: ActionTree<IUsersState, IRootState> & IUsersActions = {
.then((res) => { .then((res) => {
if (res.data.status === 'success') { if (res.data.status === 'success') {
context.commit( context.commit(
USERS_STORE.MUTATIONS.UPDATE_USER, USERS_STORE.MUTATIONS.UPDATE_USER_IN_USERS,
res.data.data.users[0] res.data.data.users[0]
) )
} else { } else {

View File

@ -10,7 +10,7 @@ export enum UsersGetters {
} }
export enum UsersMutations { export enum UsersMutations {
UPDATE_USER = 'UPDATE_USER', UPDATE_USER_IN_USERS = 'UPDATE_USER_IN_USERS',
UPDATE_USERS = 'UPDATE_USERS', UPDATE_USERS = 'UPDATE_USERS',
UPDATE_USERS_LOADING = 'UPDATE_USERS_LOADING', UPDATE_USERS_LOADING = 'UPDATE_USERS_LOADING',
UPDATE_USERS_PAGINATION = 'UPDATE_USERS_PAGINATION', UPDATE_USERS_PAGINATION = 'UPDATE_USERS_PAGINATION',

View File

@ -6,7 +6,7 @@ import { IPagination } from '@/types/api'
import { IUserProfile } from '@/types/user' import { IUserProfile } from '@/types/user'
export const mutations: MutationTree<IUsersState> & TUsersMutations = { export const mutations: MutationTree<IUsersState> & TUsersMutations = {
[USERS_STORE.MUTATIONS.UPDATE_USER]( [USERS_STORE.MUTATIONS.UPDATE_USER_IN_USERS](
state: IUsersState, state: IUsersState,
updatedUser: IUserProfile updatedUser: IUserProfile
) { ) {

View File

@ -34,7 +34,10 @@ export interface IUsersGetters {
} }
export type TUsersMutations<S = IUsersState> = { export type TUsersMutations<S = IUsersState> = {
[USERS_STORE.MUTATIONS.UPDATE_USER](state: S, updatedUser: IUserProfile): void [USERS_STORE.MUTATIONS.UPDATE_USER_IN_USERS](
state: S,
updatedUser: IUserProfile
): void
[USERS_STORE.MUTATIONS.UPDATE_USERS](state: S, users: IUserProfile[]): void [USERS_STORE.MUTATIONS.UPDATE_USERS](state: S, users: IUserProfile[]): void
[USERS_STORE.MUTATIONS.UPDATE_USERS_LOADING](state: S, loading: boolean): void [USERS_STORE.MUTATIONS.UPDATE_USERS_LOADING](state: S, loading: boolean): void
[USERS_STORE.MUTATIONS.UPDATE_USERS_PAGINATION]( [USERS_STORE.MUTATIONS.UPDATE_USERS_PAGINATION](