Merge branch 'agregaNumeroViviendaRegistroInquilino' into US-42-EliminarInquilino
This commit is contained in:
		
						commit
						b6b21a19c7
					
				| 
						 | 
					@ -261,7 +261,21 @@ export class AppController {
 | 
				
			||||||
    return this.appService.changeStatusCommunity(pId, pStatus);
 | 
					    return this.appService.changeStatusCommunity(pId, pStatus);
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Get('community/findHousesCommunity/:id')
 | 
				
			||||||
 | 
					  findHousesCommunity(
 | 
				
			||||||
 | 
					    @Param('id') community_id: string,
 | 
				
			||||||
 | 
					  ) {
 | 
				
			||||||
 | 
					    return this.appService.findHousesCommunity(community_id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  @Post('community/saveTenant')
 | 
				
			||||||
 | 
					  saveTenant(
 | 
				
			||||||
 | 
					    @Body('community_id') community_id: string,
 | 
				
			||||||
 | 
					    @Body('number_house') number_house: string,
 | 
				
			||||||
 | 
					    @Body('tenant_id') tenant_id: string,
 | 
				
			||||||
 | 
					  ) {
 | 
				
			||||||
 | 
					    return this.appService.saveTenant(community_id, number_house, tenant_id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  // #==== API Common Areas
 | 
					  // #==== API Common Areas
 | 
				
			||||||
  @Post('commonArea/createCommonArea')
 | 
					  @Post('commonArea/createCommonArea')
 | 
				
			||||||
  createCommonArea(
 | 
					  createCommonArea(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,7 @@
 | 
				
			||||||
import { Injectable, Inject } from '@nestjs/common';
 | 
					import { Injectable, Inject } from '@nestjs/common';
 | 
				
			||||||
import { ClientProxy } from '@nestjs/microservices';
 | 
					import { ClientProxy } from '@nestjs/microservices';
 | 
				
			||||||
import { map } from 'rxjs/operators';
 | 
					import { map } from 'rxjs/operators';
 | 
				
			||||||
 | 
					import { lastValueFrom } from 'rxjs';
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@Injectable()
 | 
					@Injectable()
 | 
				
			||||||
export class AppService {
 | 
					export class AppService {
 | 
				
			||||||
| 
						 | 
					@ -337,6 +338,31 @@ export class AppService {
 | 
				
			||||||
      .pipe(map((message: string) => ({ message })));
 | 
					      .pipe(map((message: string) => ({ message })));
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async findHousesCommunity(community_id: string) {
 | 
				
			||||||
 | 
					    const pattern = { cmd: 'findOneCommunity' }
 | 
				
			||||||
 | 
					    const payload = { _id: community_id }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let callback = await this.clientCommunityApp
 | 
				
			||||||
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((response: string) => ({ response }))
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					    const finalValue = await lastValueFrom(callback);
 | 
				
			||||||
 | 
					    const response = finalValue['response'];
 | 
				
			||||||
 | 
					    const houses = response['houses'];
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    return houses;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  saveTenant(id: string, number_house: string, tenant_id: string) {
 | 
				
			||||||
 | 
					    const pattern = { cmd: 'saveTenant' };
 | 
				
			||||||
 | 
					    const payload = { _id: id, number_house: number_house, tenant_id: tenant_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(
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -53,4 +53,13 @@ export class CommunitiesController {
 | 
				
			||||||
     let pstatus = body['status'];
 | 
					     let pstatus = body['status'];
 | 
				
			||||||
     return this.communitiesService.changeStatus(pid,pstatus);
 | 
					     return this.communitiesService.changeStatus(pid,pstatus);
 | 
				
			||||||
   }
 | 
					   }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   @MessagePattern({ cmd: 'saveTenant' })
 | 
				
			||||||
 | 
					   saveTenant(@Payload() body: string) {
 | 
				
			||||||
 | 
					    let id = body['_id'];
 | 
				
			||||||
 | 
					    let tenant_id = body['tenant_id'];
 | 
				
			||||||
 | 
					    let number_house = body['number_house'];
 | 
				
			||||||
 | 
					    return this.communitiesService.saveTenant(id, number_house, tenant_id);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,4 +78,23 @@ export class CommunitiesService {
 | 
				
			||||||
    const finalValue = await lastValueFrom(callback);
 | 
					    const finalValue = await lastValueFrom(callback);
 | 
				
			||||||
    return finalValue['response'];
 | 
					    return finalValue['response'];
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async saveTenant(id: string, number_house: string, tenant_id: string) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    let community = await this.findOne(id);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    await community.houses.map(house => {
 | 
				
			||||||
 | 
					      if(house.number_house == number_house){
 | 
				
			||||||
 | 
					        house.tenants.tenant_id = tenant_id
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					      return house;
 | 
				
			||||||
 | 
					    })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    console.log(community.houses)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					   return await this.communityModel.findOneAndUpdate({ _id: id }, community, {
 | 
				
			||||||
 | 
					      new: true,
 | 
				
			||||||
 | 
					    });
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -145,7 +145,6 @@ export class UsersService {
 | 
				
			||||||
    return await this.userModel.find({ community_id: pcommunity_id, user_type: 4 })
 | 
					    return await this.userModel.find({ community_id: pcommunity_id, user_type: 4 })
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
  async testSendMail(user: UserDocument) {
 | 
					  async testSendMail(user: UserDocument) {
 | 
				
			||||||
    let passwordEncriptada = Md5.init(user.password);
 | 
					    let passwordEncriptada = Md5.init(user.password);
 | 
				
			||||||
    user.password = passwordEncriptada;
 | 
					    user.password = passwordEncriptada;
 | 
				
			||||||
| 
						 | 
					@ -231,5 +230,17 @@ export class UsersService {
 | 
				
			||||||
      new: true,
 | 
					      new: true,
 | 
				
			||||||
    });
 | 
					    });
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async saveTenantNumHouse(community_id: string, number_house:string, tenant_id: string) {
 | 
				
			||||||
 | 
					    const pattern = { cmd: 'saveTenant' }
 | 
				
			||||||
 | 
					    const payload = { _id: community_id, number_house: number_house,  tenant_id: tenant_id }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    return await this.clientCommunityApp
 | 
				
			||||||
 | 
					      .send<string>(pattern, payload)
 | 
				
			||||||
 | 
					      .pipe(
 | 
				
			||||||
 | 
					        map((response: string) => ({ response }))
 | 
				
			||||||
 | 
					      )
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -93,6 +93,16 @@ const Inquilinos = () => {
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  async function getHouses() {
 | 
				
			||||||
 | 
					    let response = await fetch(
 | 
				
			||||||
 | 
					      `http://localhost:4000/community/findHousesCommunity/${cookies.community_id}`,
 | 
				
			||||||
 | 
					      { method: 'GET' },
 | 
				
			||||||
 | 
					    )
 | 
				
			||||||
 | 
					    let resList = await response.json()
 | 
				
			||||||
 | 
					    setHousesList(await resList)
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  useEffect(() => {
 | 
					  useEffect(() => {
 | 
				
			||||||
    tenantsList()
 | 
					    tenantsList()
 | 
				
			||||||
  }, [])
 | 
					  }, [])
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue