This commit is contained in:
parent
5b5d8835af
commit
0175d9065d
|
@ -155,6 +155,12 @@ export class AppController {
|
||||||
return this.appService.deleteAdminSystem(id);
|
return this.appService.deleteAdminSystem(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Delete('user/deleteAdminCommunity/:id')
|
||||||
|
deleteAdminCommunity(@Param('id') id: string) {
|
||||||
|
return this.appService.deleteAdminCommunity(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Post('user/changeStatus')
|
@Post('user/changeStatus')
|
||||||
changeStatusUser(
|
changeStatusUser(
|
||||||
@Body('id') pId: string,
|
@Body('id') pId: string,
|
||||||
|
|
|
@ -193,6 +193,14 @@ export class AppService {
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteAdminCommunity(id: string) {
|
||||||
|
const pattern = { cmd: 'deleteAdminCommunity' };
|
||||||
|
const payload = { id: id };
|
||||||
|
return this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((message: string) => ({ message })));
|
||||||
|
}
|
||||||
|
|
||||||
inicioSesion(pEmail: string, pPassword: string) {
|
inicioSesion(pEmail: string, pPassword: string) {
|
||||||
const pattern = { cmd: 'loginUser' };
|
const pattern = { cmd: 'loginUser' };
|
||||||
const payload = { email: pEmail, password: pPassword };
|
const payload = { email: pEmail, password: pPassword };
|
||||||
|
|
|
@ -112,12 +112,17 @@ export class UsersController {
|
||||||
|
|
||||||
@MessagePattern({ cmd: 'deleteAdminSystem' })
|
@MessagePattern({ cmd: 'deleteAdminSystem' })
|
||||||
deleteAdminSystem(@Payload() user: any) {
|
deleteAdminSystem(@Payload() user: any) {
|
||||||
console.log('entró');
|
|
||||||
|
|
||||||
return this.userService.deleteAdminSystem(user['id']);
|
return this.userService.deleteAdminSystem(user['id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'deleteAdminCommunity' })
|
||||||
|
deleteAdminCommunity(@Payload() user: any) {
|
||||||
|
return this.userService.deleteAdminCommunity(user['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@MessagePattern({ cmd: 'changeStatus' })
|
@MessagePattern({ cmd: 'changeStatus' })
|
||||||
changeStatus(@Payload() body: string) {
|
changeStatus(@Payload() body: string) {
|
||||||
let pid = body['id'];
|
let pid = body['id'];
|
||||||
|
|
|
@ -185,6 +185,13 @@ export class UsersService {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
deleteAdminCommunity(id: string) {
|
||||||
|
return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
|
||||||
|
new: true,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async validateEmail(email: string) {
|
async validateEmail(email: string) {
|
||||||
let repo1 = this.userModel;
|
let repo1 = this.userModel;
|
||||||
return new Promise<User>((resolve, reject) => {
|
return new Promise<User>((resolve, reject) => {
|
||||||
|
|
|
@ -117,64 +117,56 @@ const AdministradoresComunidad = () => {
|
||||||
|
|
||||||
|
|
||||||
const deleteAdminCommunity = () => {
|
const deleteAdminCommunity = () => {
|
||||||
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
|
fetch('http://localhost:4000/user/deleteAdminCommunity/' + adminCommunity._id, {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.then(
|
.then(
|
||||||
function (response) {
|
function (response) {
|
||||||
if (response.status != 201)
|
if (response.status != 201)
|
||||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||||
else
|
else
|
||||||
return response.json();
|
return response.json();
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(
|
.then(
|
||||||
function (response) {
|
function (response) {
|
||||||
|
|
||||||
|
let _administrators = listaAdmins.filter(
|
||||||
|
(val) => val._id !== adminCommunity._id,
|
||||||
|
);
|
||||||
|
setListaAdmins(_administrators);
|
||||||
|
setDeleteAdminCommunityDialog(false);
|
||||||
|
setAdminCommunity(emptyAdminCommunity);
|
||||||
|
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador Comunidad Eliminada', life: 3000 });
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch(
|
||||||
|
err => {
|
||||||
|
console.log('Ocurrió un error con el fetch', err)
|
||||||
|
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador Comunidad no se pudo eliminar', life: 3000 });
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
let _community = communities.filter(val => val._id !== community._id);
|
|
||||||
setCommunities(_community);
|
|
||||||
setDeleteCommunityDialog(false);
|
|
||||||
setCommunity(emptyCommunity);
|
|
||||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 });
|
|
||||||
}
|
|
||||||
)
|
|
||||||
.catch(
|
|
||||||
err => {
|
|
||||||
console.log('Ocurrió un error con el fetch', err)
|
|
||||||
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 });
|
|
||||||
}
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
let _administrators = listaAdmins.filter(
|
|
||||||
(val) => val._id !== adminCommunity._id,
|
|
||||||
);
|
|
||||||
setListaAdmins(_administrators);
|
|
||||||
setDeleteAdminCommunityDialog(false);
|
|
||||||
setAdminCommunity(emptyAdminCommunity);
|
|
||||||
toast.current.show({
|
|
||||||
severity: 'success',
|
|
||||||
summary: 'Administrador de Comunidad Eliminada',
|
|
||||||
life: 3000,
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteSelectedAdminsCommunity = () => {
|
const deleteSelectedAdminsCommunity = () => {
|
||||||
let _admins = listaAdmins.filter(
|
let _admins = listaAdmins.filter(
|
||||||
(val) => !selectedAdminsCommunities.includes(val),
|
(val) => !selectedAdminsCommunities.includes(val),
|
||||||
);
|
);
|
||||||
/* selectedCommunities.map((item) => {
|
selectedAdminsCommunities.map((item) => {
|
||||||
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, {
|
fetch('http://localhost:4000/user/deleteAdminCommunity/' + item._id, {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})*/
|
})
|
||||||
setListaAdmins(_admins);
|
setListaAdmins(_admins);
|
||||||
setDeleteAdminsCommunitiesDialog(false);
|
setDeleteAdminsCommunitiesDialog(false);
|
||||||
setSelectedAdminsCommunities(null);
|
setSelectedAdminsCommunities(null);
|
||||||
|
|
Loading…
Reference in New Issue