fix: add refresh after crd operation in membership

This commit is contained in:
caturbgs 2021-12-22 23:37:06 +07:00
parent 9be9287fb2
commit 38c4aca9be

View File

@ -48,7 +48,11 @@ export class Membership {
async create(data) {
try {
return await http.post('/users').send(data)
const response = await http.post('/users').send(data);
this.ctx.authentication.userData.role === "Admin"
? await this.ctx.membership.getData()
: await this.ctx.membership.getDataBySuperior();
return response;
} catch (e) {
console.error(e);
}
@ -57,8 +61,10 @@ export class Membership {
async update(id, data) {
try {
const response = await http.put('/users/' + id).send(data);
console.log(response, 'Data user')
console.log(JSON.stringify(response.body.data), 'Data')
this.ctx.authentication.userData.role === "Admin"
? await this.ctx.membership.getData()
: await this.ctx.membership.getDataBySuperior();
return response;
} catch (e) {
console.error(e);
}
@ -66,11 +72,14 @@ export class Membership {
async delete(id) {
try {
return await http.del('/users/' + id);
const response = await http.del('/users/' + id);
this.ctx.authentication.userData.role === "Admin"
? await this.ctx.membership.getData()
: await this.ctx.membership.getDataBySuperior();
return response;
} catch (e) {
console.error(e);
}
}
async changeStatus(id, status) {