eliminar y eliminar id comunidad de administradores
This commit is contained in:
parent
c5173895fd
commit
49cb71e767
|
@ -323,6 +323,11 @@ export class AppController {
|
||||||
) {
|
) {
|
||||||
return this.appService.saveTenant(community_id, number_house, tenant_id);
|
return this.appService.saveTenant(community_id, number_house, tenant_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Delete('community/deleteCommunity/:id')
|
||||||
|
deleteCommunity(@Param('id') paramCommunityId: string) {
|
||||||
|
return this.appService.deleteCommunity(paramCommunityId);
|
||||||
|
}
|
||||||
// #==== API Common Areas
|
// #==== API Common Areas
|
||||||
@Post('commonArea/createCommonArea')
|
@Post('commonArea/createCommonArea')
|
||||||
createCommonArea(
|
createCommonArea(
|
||||||
|
|
|
@ -407,6 +407,15 @@ export class AppService {
|
||||||
.pipe(map((message: string) => ({ message })));
|
.pipe(map((message: string) => ({ message })));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deleteCommunity(id: string) {
|
||||||
|
const pattern = { cmd: 'removeCommunity' };
|
||||||
|
const payload = { _id: id };
|
||||||
|
return this.clientCommunityApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((message: string) => ({ message })));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ====================== COMMON AREAS ===============================
|
// ====================== COMMON AREAS ===============================
|
||||||
//POST parameter from API
|
//POST parameter from API
|
||||||
createCommonArea(
|
createCommonArea(
|
||||||
|
|
|
@ -57,6 +57,7 @@ export class CommunitiesService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async remove(id: string) {
|
async remove(id: string) {
|
||||||
|
await this.removeIdCommunity(id);
|
||||||
return this.communityModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
return this.communityModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
|
@ -119,4 +120,16 @@ export class CommunitiesService {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeIdCommunity(community: string) {
|
||||||
|
const pattern = { cmd: 'removeIdCommunity' };
|
||||||
|
const payload = { community_id: community};
|
||||||
|
|
||||||
|
let callback = await this.clientUserApp
|
||||||
|
.send<string>(pattern, payload)
|
||||||
|
.pipe(map((response: string) => ({ response })));
|
||||||
|
|
||||||
|
const finalValue = await lastValueFrom(callback);
|
||||||
|
return finalValue['response'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -142,6 +142,13 @@ export class UsersController {
|
||||||
user['number_house']);
|
user['number_house']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@MessagePattern({ cmd: 'removeIdCommunity' })
|
||||||
|
removeIdCommunity(@Payload() user: any) {
|
||||||
|
let community_id = user['community_id'];
|
||||||
|
return this.userService.removeIdCommunity(community_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@MessagePattern({ cmd: 'changeStatus' })
|
@MessagePattern({ cmd: 'changeStatus' })
|
||||||
changeStatus(@Payload() body: string) {
|
changeStatus(@Payload() body: string) {
|
||||||
let pid = body['id'];
|
let pid = body['id'];
|
||||||
|
|
|
@ -295,5 +295,11 @@ export class UsersService {
|
||||||
map((response: string) => ({ response }))
|
map((response: string) => ({ response }))
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async removeIdCommunity(community_id: string){
|
||||||
|
return this.userModel.updateMany({community_id: community_id, user_type:'2' }, {"$set":{"community_id": ''}});
|
||||||
|
/*await this.userModel.updateMany({community_id: community_id, user_type:'3' }, {"$set":{"community_id": ''}, {"status": '-1'}});
|
||||||
|
return this.userModel.updateMany({community_id: community_id, user_type:'4' }, {"$set":{"community_id": ''}, {"status": '-1'}});*/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -315,10 +315,8 @@ const Communities = () => {
|
||||||
setDeleteCommunitiesDialog(true);
|
setDeleteCommunitiesDialog(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const infoCommunity = async (community) => {
|
const infoCommunity = async (community) => {
|
||||||
await tenantsList(community._id);
|
await tenantsList(community._id);
|
||||||
|
|
||||||
setCommunity({ ...community });
|
setCommunity({ ...community });
|
||||||
setCommunityDialog(true);
|
setCommunityDialog(true);
|
||||||
};
|
};
|
||||||
|
@ -383,9 +381,8 @@ const Communities = () => {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const deleteCommunity = () => {
|
const deleteCommunity = () => {
|
||||||
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
|
fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -416,7 +413,6 @@ const Communities = () => {
|
||||||
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 });
|
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
*/
|
|
||||||
let _communities = communitiesList.filter((val) => val._id !== community._id);
|
let _communities = communitiesList.filter((val) => val._id !== community._id);
|
||||||
_communities = _communities.filter(
|
_communities = _communities.filter(
|
||||||
(val) => val.status != -1,
|
(val) => val.status != -1,
|
||||||
|
|
Loading…
Reference in New Issue