agregar numero de vivienda a inquilino
This commit is contained in:
parent
6d6fafd177
commit
ff5c6e55ff
|
@ -215,6 +215,14 @@ 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);
|
||||||
|
}
|
||||||
|
|
||||||
// #==== 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 {
|
||||||
|
@ -283,6 +284,24 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// ====================== COMMON AREAS ===============================
|
// ====================== COMMON AREAS ===============================
|
||||||
//POST parameter from API
|
//POST parameter from API
|
||||||
createCommonArea(
|
createCommonArea(
|
||||||
|
|
|
@ -154,7 +154,6 @@ export class UsersService {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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;
|
||||||
|
@ -228,5 +227,22 @@ export class UsersService {
|
||||||
new: true,
|
new: true,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,8 @@ const Inquilinos = () => {
|
||||||
const [submitted, setSubmitted] = useState(false)
|
const [submitted, setSubmitted] = useState(false)
|
||||||
const toast = useRef(null)
|
const toast = useRef(null)
|
||||||
const dt = useRef(null)
|
const dt = useRef(null)
|
||||||
|
const [housesList, setHousesList] = useState([])
|
||||||
|
const [houseId, setHouseId] = useState(null)
|
||||||
const [cookies, setCookie] = useCookies()
|
const [cookies, setCookie] = useCookies()
|
||||||
const [changeStatusTenantDialog, setChangeStatusTenantDialog] =
|
const [changeStatusTenantDialog, setChangeStatusTenantDialog] =
|
||||||
useState(false)
|
useState(false)
|
||||||
|
@ -85,10 +86,27 @@ const Inquilinos = () => {
|
||||||
setCommunitiesList(await list)
|
setCommunitiesList(await list)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function getHouses() {
|
||||||
|
let response = await fetch(
|
||||||
|
`http://localhost:4000/community/findHousesCommunity/${cookies.community_id}`,
|
||||||
|
{ method: 'GET' },
|
||||||
|
)
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(res => console.log())
|
||||||
|
let resList = await response.json()
|
||||||
|
let list = await resList.message
|
||||||
|
setHousesList(await list)
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
tenantsList()
|
tenantsList()
|
||||||
}, [tenantsList])
|
}, [tenantsList])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getHouses()
|
||||||
|
}, [])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCommunites()
|
getCommunites()
|
||||||
}, [])
|
}, [])
|
||||||
|
@ -98,6 +116,13 @@ const Inquilinos = () => {
|
||||||
value: item._id,
|
value: item._id,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
const hList = housesList.map((item) => ({
|
||||||
|
label: item.number_house,
|
||||||
|
value: item._id,
|
||||||
|
}))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function registrarInquilino() {
|
function registrarInquilino() {
|
||||||
let newTenant = {
|
let newTenant = {
|
||||||
_id: null,
|
_id: null,
|
||||||
|
@ -613,9 +638,9 @@ const Inquilinos = () => {
|
||||||
<Dropdown
|
<Dropdown
|
||||||
required
|
required
|
||||||
id='numero_vivienda'
|
id='numero_vivienda'
|
||||||
value={communityId}
|
value={houseId}
|
||||||
options={cList}
|
options={hList}
|
||||||
onChange={(e) => setCommunityId(e.value)}
|
onChange={(e) => setHouseId(e.value)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<Button label='Registrar' onClick={registrarInquilino} />
|
<Button label='Registrar' onClick={registrarInquilino} />
|
||||||
|
|
Loading…
Reference in New Issue