Update all for Postgres and new techniques

This commit is contained in:
Sebastián Ramírez
2019-02-23 18:44:29 +04:00
parent 1b4d244033
commit 6fdba19639
72 changed files with 793 additions and 1316 deletions

View File

@@ -3,7 +3,6 @@ import { ActionContext } from 'vuex';
import {
commitSetUsers,
commitSetUser,
commitSetRoles,
} from './accessors/commit';
import { IUserProfileCreate, IUserProfileUpdate } from '@/interfaces';
import { State } from '../state';
@@ -23,12 +22,12 @@ export const actions = {
await dispatchCheckApiError(context, error);
}
},
async actionUpdateUser(context: MainContext, payload: { name: string, user: IUserProfileUpdate }) {
async actionUpdateUser(context: MainContext, payload: { id: number, user: IUserProfileUpdate }) {
try {
const loadingNotification = { content: 'saving', showProgress: true };
commitAddNotification(context, loadingNotification);
const response = (await Promise.all([
api.updateUser(context.rootState.main.token, payload.name, payload.user),
api.updateUser(context.rootState.main.token, payload.id, payload.user),
await new Promise((resolve, reject) => setTimeout(() => resolve(), 500)),
]))[0];
commitSetUser(context, response.data);
@@ -53,12 +52,4 @@ export const actions = {
await dispatchCheckApiError(context, error);
}
},
async actionGetRoles(context: MainContext) {
try {
const response = await api.getRoles(context.rootState.main.token);
commitSetRoles(context, response.data.roles);
} catch (error) {
await dispatchCheckApiError(context, error);
}
},
};