Merge branch 'US-42-EliminarInquilino' into US-11-ModificarAdministradordeComunidaddeViviendas
This commit is contained in:
commit
1865ce73ae
|
@ -2,7 +2,7 @@ import { Controller, Get, Post, Put, Body, Param, Delete } from '@nestjs/common'
|
|||
import { AppService } from './app.service';
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
constructor(private readonly appService: AppService) { }
|
||||
// #==== API Users
|
||||
@Post('user/createAdminSystem')
|
||||
createAdminSystem(
|
||||
|
@ -15,8 +15,8 @@ export class AppController {
|
|||
@Body('status') status: string,
|
||||
@Body('date_entry') date_entry: Date,
|
||||
) {
|
||||
return this.appService.createAdminSystem(dni, name, last_name, email, phone,
|
||||
user_type, status, date_entry);
|
||||
return this.appService.createAdminSystem(dni, name, last_name, email, phone,
|
||||
user_type, status, date_entry);
|
||||
}
|
||||
|
||||
@Post('user/createGuard')
|
||||
|
@ -33,7 +33,7 @@ export class AppController {
|
|||
@Body('community_id') community_id: string,
|
||||
) {
|
||||
return this.appService.createGuard(dni, name, last_name, email, phone,
|
||||
user_type, status, date_entry,community_id);
|
||||
user_type, status, date_entry, community_id);
|
||||
}
|
||||
|
||||
@Post('user/createAdminCommunity')
|
||||
|
@ -47,10 +47,10 @@ export class AppController {
|
|||
@Body('user_type') user_type: string,
|
||||
@Body('status') status: string,
|
||||
@Body('date_entry') date_entry: Date,
|
||||
@Body('community_id') community_id:string
|
||||
@Body('community_id') community_id: string
|
||||
) {
|
||||
return this.appService.createAdminCommunity(dni, name, last_name, email, phone,
|
||||
user_type, status, date_entry,community_id);
|
||||
user_type, status, date_entry, community_id);
|
||||
}
|
||||
|
||||
@Post('user/createUser')
|
||||
|
@ -82,6 +82,35 @@ export class AppController {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
@Post('user/createTenant')
|
||||
createTenant(
|
||||
@Body('dni') dni: string,
|
||||
@Body('name') name: string,
|
||||
@Body('last_name') last_name: string,
|
||||
@Body('email') email: string,
|
||||
@Body('phone') phone: number,
|
||||
@Body('user_type') user_type: string,
|
||||
@Body('status') status: string,
|
||||
@Body('date_entry') date_entry: Date,
|
||||
@Body('community_id') community_id: string,
|
||||
@Body('number_house') number_house: string,
|
||||
) {
|
||||
return this.appService.createTenant(
|
||||
dni,
|
||||
name,
|
||||
last_name,
|
||||
email,
|
||||
phone,
|
||||
user_type,
|
||||
status,
|
||||
date_entry,
|
||||
community_id,
|
||||
number_house,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@Put('user/updateGuard/:id')
|
||||
updateGuard(
|
||||
@Param('id') id: string,
|
||||
|
@ -174,7 +203,7 @@ export class AppController {
|
|||
allUsersTenants(@Param('community_id') paramCommunity_id: string) {
|
||||
return this.appService.findTenantsCommunity(paramCommunity_id);
|
||||
}
|
||||
|
||||
|
||||
@Get('user/find/:dni')
|
||||
findUser(@Param('dni') paramUserDNI: string) {
|
||||
return this.appService.findUser(paramUserDNI);
|
||||
|
@ -195,9 +224,13 @@ export class AppController {
|
|||
return this.appService.deleteAdminCommunity(id);
|
||||
}
|
||||
|
||||
@Delete('user/deleteTenant/:id')
|
||||
deleteTenant(@Param('id') id: string) {
|
||||
return this.appService.deleteTenant(id);
|
||||
@Put('user/deleteTenant/:id')
|
||||
deleteTenant(
|
||||
@Param('id') id: string,
|
||||
@Body('community_id') community_id: string,
|
||||
@Body('number_house') number_house: string
|
||||
) {
|
||||
return this.appService.deleteTenant(id, community_id, number_house);
|
||||
}
|
||||
|
||||
@Post('user/changeStatus')
|
||||
|
@ -296,8 +329,6 @@ export class AppController {
|
|||
) {
|
||||
return this.appService.saveTenant(community_id, number_house, tenant_id);
|
||||
}
|
||||
|
||||
|
||||
// #==== API Common Areas
|
||||
@Post('commonArea/createCommonArea')
|
||||
createCommonArea(
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { Injectable, Inject } from '@nestjs/common';
|
||||
import { ClientProxy } from '@nestjs/microservices';
|
||||
import { map } from 'rxjs/operators';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
|
@ -55,6 +56,37 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
createTenant(
|
||||
dni: string,
|
||||
name: string,
|
||||
last_name: string,
|
||||
email: string,
|
||||
phone: number,
|
||||
user_type: string,
|
||||
status: string,
|
||||
date_entry: Date,
|
||||
community_id: string,
|
||||
number_house: string,
|
||||
) {
|
||||
const pattern = { cmd: 'createTenant' };
|
||||
const payload = {
|
||||
dni: dni,
|
||||
name: name,
|
||||
last_name: last_name,
|
||||
email: email,
|
||||
phone: phone,
|
||||
password: this.generatePassword(),
|
||||
user_type: user_type,
|
||||
status: status,
|
||||
date_entry: date_entry,
|
||||
community_id: community_id,
|
||||
number_house: number_house,
|
||||
};
|
||||
return this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
updateUser(
|
||||
_id: string,
|
||||
dni: string,
|
||||
|
@ -261,9 +293,9 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
deleteTenant(id: string) {
|
||||
deleteTenant(id: string, community_id: string, number_house: string) {
|
||||
const pattern = { cmd: 'deleteTenant' };
|
||||
const payload = { id: id };
|
||||
const payload = { _id: id, community_id: community_id, number_house: number_house };
|
||||
return this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
|
@ -359,6 +391,31 @@ export class AppService {
|
|||
.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 ===============================
|
||||
//POST parameter from API
|
||||
createCommonArea(
|
||||
|
|
|
@ -53,4 +53,22 @@ export class CommunitiesController {
|
|||
let pstatus = body['status'];
|
||||
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);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'deleteTenant' })
|
||||
deleteTenant(@Payload() body: string) {
|
||||
let id = body['_id'];
|
||||
let tenant_id = body['tenant_id'];
|
||||
let number_house = body['number_house'];
|
||||
return this.communitiesService.deleteTenant(id, number_house, tenant_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import { RpcException, ClientProxy } from '@nestjs/microservices';
|
|||
import { from, lastValueFrom, map, scan, mergeMap } from 'rxjs';
|
||||
import { Admin } from 'src/schemas/admin.entity';
|
||||
import { appendFileSync } from 'fs';
|
||||
import { Tenant, TenantSchema } from 'src/schemas/tenant.schema';
|
||||
|
||||
@Injectable()
|
||||
export class CommunitiesService {
|
||||
|
@ -13,7 +14,7 @@ export class CommunitiesService {
|
|||
@InjectModel(Community.name)
|
||||
private readonly communityModel: Model<CommunityDocument>,
|
||||
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
|
||||
) {}
|
||||
) { }
|
||||
|
||||
async create(community: CommunityDocument): Promise<Community> {
|
||||
return this.communityModel.create(community);
|
||||
|
@ -56,15 +57,15 @@ export class CommunitiesService {
|
|||
}
|
||||
|
||||
async remove(id: string) {
|
||||
return this.communityModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
|
||||
return this.communityModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
||||
new: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async changeStatus(id: string, status: string) {
|
||||
return this.communityModel.findOneAndUpdate({ _id: id }, {status: status}, {
|
||||
return this.communityModel.findOneAndUpdate({ _id: id }, { status: status }, {
|
||||
new: true,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async findCommunityAdmin(community: string, user_type: string) {
|
||||
|
@ -78,4 +79,44 @@ export class CommunitiesService {
|
|||
const finalValue = await lastValueFrom(callback);
|
||||
return finalValue['response'];
|
||||
}
|
||||
|
||||
|
||||
async saveTenant(id: string, number_house: string, ptenant_id: string) {
|
||||
let community = await this.findOne(id);
|
||||
await community.houses.map(house => {
|
||||
if (house.number_house == number_house) {
|
||||
if (house.tenants) {
|
||||
|
||||
house.tenants.tenant_id = ptenant_id
|
||||
} else {
|
||||
let tenant = new Tenant()
|
||||
tenant.tenant_id = ptenant_id;
|
||||
house.tenants = tenant;
|
||||
}
|
||||
house.state = "ocupada"
|
||||
}
|
||||
return house;
|
||||
})
|
||||
|
||||
return await this.communityModel.findOneAndUpdate({ _id: id }, community, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
async deleteTenant(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 = "";
|
||||
house.state = "desocupada"
|
||||
}
|
||||
return house;
|
||||
})
|
||||
|
||||
return await this.communityModel.findOneAndUpdate({ _id: id }, community, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# mail
|
||||
MAIL_HOST=smtp.gmail.com
|
||||
MAIL_USER=mbonilla.guti@gmail.com
|
||||
MAIL_PASSWORD=laofghlofgffmyry
|
||||
MAIL_USER=katoikiap4@gmail.com
|
||||
MAIL_PASSWORD=snxwbncohehilkkz
|
||||
MAIL_FROM=noreply@example.com
|
||||
|
||||
# optional
|
||||
|
|
|
@ -12,7 +12,7 @@ export class EmailController {
|
|||
sendMail(@Payload() toEmail: string) {
|
||||
var response = this.mailService.sendMail({
|
||||
to: toEmail['email'],
|
||||
from: 'mbonilla.guti@gmail.com',
|
||||
from: 'katoikiap4@gmail.com',
|
||||
subject: 'Plain Text Email ✔',
|
||||
text: 'Welcome NestJS Email Sending Tutorial',
|
||||
});
|
||||
|
@ -25,7 +25,7 @@ export class EmailController {
|
|||
const image = "images/email.png";
|
||||
var response = await this.mailService.sendMail({
|
||||
to: user["email"],
|
||||
from: "mbonilla.guti@gmail.com",
|
||||
from: "katoikiap4@gmail.com",
|
||||
subject: 'HTML Dynamic Template',
|
||||
template: 'templateEmail',
|
||||
context: {
|
||||
|
@ -51,7 +51,7 @@ export class EmailController {
|
|||
const logo = "images/Logo Katoikia.png";
|
||||
var response = await this.mailService.sendMail({
|
||||
to: user["email"],
|
||||
from: "mbonilla.guti@gmail.com",
|
||||
from: "katoikiap4@gmail.com",
|
||||
subject: 'Usuario registrado',
|
||||
template: 'emailCreateUserAdminCommunity',
|
||||
context: {
|
||||
|
@ -77,4 +77,39 @@ export class EmailController {
|
|||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@MessagePattern({ cmd: 'emailCreateUserTenant' })
|
||||
async emailCreateUserTenant(@Payload() user: any) {
|
||||
const url = "http://localhost:3000/";
|
||||
const image = "images/email.png";
|
||||
const logo = "images/Logo Katoikia.png";
|
||||
var response = await this.mailService.sendMail({
|
||||
to: user["email"],
|
||||
from: "katoikiap4@gmail.com",
|
||||
subject: 'Usuario registrado',
|
||||
template: 'emailCreateUserTenant',
|
||||
context: {
|
||||
name: user["name"],
|
||||
password: user["password"],
|
||||
date_entry: user["date_entry"],
|
||||
email: user["email"],
|
||||
community_name: user['community_name'],
|
||||
number_house: user['number_house']
|
||||
},
|
||||
attachments: [
|
||||
{
|
||||
filename: 'email.png',
|
||||
path: __dirname + '/mails/images/email.png',
|
||||
cid: 'image_email' //my mistake was putting "cid:logo@cid" here!
|
||||
},
|
||||
{
|
||||
filename: 'Logo_Katoikia.png',
|
||||
path: __dirname + '/mails/images/Logo_Katoikia.png',
|
||||
cid: 'logoKatoikia' //my mistake was putting "cid:logo@cid" here!
|
||||
}
|
||||
]
|
||||
});
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -432,7 +432,7 @@
|
|||
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
|
||||
<h3 class="heading">Información de contacto</h3>
|
||||
<ul>
|
||||
<li><span href="mailto:katoikiaapp@gmail.com" class="text">katoikiaapp@gmail.com</span></li>
|
||||
<li><span href="mailto:katoikiap4@gmail.com" class="text">katoikiap4@gmail.com</span></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -438,8 +438,8 @@
|
|||
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
|
||||
<h3 class="heading">Información de contacto</h3>
|
||||
<ul>
|
||||
<li><span href="mailto:katoikiaapp@gmail.com"
|
||||
class="text">katoikiaapp@gmail.com</span></li>
|
||||
<li><span href="mailto:katoikiap4@gmail.com"
|
||||
class="text">katoikiap4@gmail.com</span></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
|
@ -0,0 +1,459 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml"
|
||||
xmlns:o="urn:schemas-microsoft-com:office:office">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8"> <!-- utf-8 works for most cases -->
|
||||
<meta name="viewport" content="width=device-width"> <!-- Forcing initial-scale shouldn't be necessary -->
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <!-- Use the latest (edge) version of IE rendering engine -->
|
||||
<meta name="x-apple-disable-message-reformatting"> <!-- Disable auto-scale in iOS 10 Mail entirely -->
|
||||
<title></title> <!-- The title tag shows in email notifications, like Android 4.4. -->
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Lato:300,400,700" rel="stylesheet">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.2/css/all.min.css"
|
||||
integrity="sha512-1sCRPdkRXhBV2PBLUdRb4tMg1w2YPf37qatUFeS7zlBy7jJI8Lf4VHwWfZZfpXtYSLy85pkm9GaYVYMfw5BC1A=="
|
||||
crossorigin="anonymous" referrerpolicy="no-referrer" />
|
||||
|
||||
|
||||
<!-- CSS Reset : BEGIN -->
|
||||
<style>
|
||||
html,
|
||||
body {
|
||||
margin: 0 auto !important;
|
||||
padding: 0 !important;
|
||||
height: 100% !important;
|
||||
width: 100% !important;
|
||||
background: #f1f1f1;
|
||||
}
|
||||
|
||||
/* What it does: Stops email clients resizing small text. */
|
||||
* {
|
||||
-ms-text-size-adjust: 100%;
|
||||
-webkit-text-size-adjust: 100%;
|
||||
}
|
||||
|
||||
/* What it does: Centers email on Android 4.4 */
|
||||
div[style*="margin: 16px 0"] {
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
/* What it does: Stops Outlook from adding extra spacing to tables. */
|
||||
table,
|
||||
td {
|
||||
mso-table-lspace: 0pt !important;
|
||||
mso-table-rspace: 0pt !important;
|
||||
}
|
||||
|
||||
/* What it does: Fixes webkit padding issue. */
|
||||
table {
|
||||
border-spacing: 0 !important;
|
||||
border-collapse: collapse !important;
|
||||
table-layout: fixed !important;
|
||||
margin: 0 auto !important;
|
||||
}
|
||||
|
||||
/* What it does: Uses a better rendering method when resizing images in IE. */
|
||||
img {
|
||||
-ms-interpolation-mode: bicubic;
|
||||
}
|
||||
|
||||
/* What it does: Prevents Windows 10 Mail from underlining links despite inline CSS. Styles for underlined links should be inline. */
|
||||
a {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/* What it does: A work-around for email clients meddling in triggered links. */
|
||||
*[x-apple-data-detectors],
|
||||
/* iOS */
|
||||
.unstyle-auto-detected-links *,
|
||||
.aBn {
|
||||
border-bottom: 0 !important;
|
||||
cursor: default !important;
|
||||
color: inherit !important;
|
||||
text-decoration: none !important;
|
||||
font-size: inherit !important;
|
||||
font-family: inherit !important;
|
||||
font-weight: inherit !important;
|
||||
line-height: inherit !important;
|
||||
}
|
||||
|
||||
/* What it does: Prevents Gmail from displaying a download button on large, non-linked images. */
|
||||
.a6S {
|
||||
display: none !important;
|
||||
opacity: 0.01 !important;
|
||||
}
|
||||
|
||||
/* What it does: Prevents Gmail from changing the text color in conversation threads. */
|
||||
.im {
|
||||
color: inherit !important;
|
||||
}
|
||||
|
||||
/* If the above doesn't work, add a .g-img class to any image in question. */
|
||||
img.g-img+div {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
/* What it does: Removes right gutter in Gmail iOS app: https://github.com/TedGoas/Cerberus/issues/89 */
|
||||
/* Create one of these media queries for each additional viewport size you'd like to fix */
|
||||
|
||||
/* iPhone 4, 4S, 5, 5S, 5C, and 5SE */
|
||||
@media only screen and (min-device-width: 320px) and (max-device-width: 374px) {
|
||||
u~div .email-container {
|
||||
min-width: 320px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* iPhone 6, 6S, 7, 8, and X */
|
||||
@media only screen and (min-device-width: 375px) and (max-device-width: 413px) {
|
||||
u~div .email-container {
|
||||
min-width: 375px !important;
|
||||
}
|
||||
}
|
||||
|
||||
/* iPhone 6+, 7+, and 8+ */
|
||||
@media only screen and (min-device-width: 414px) {
|
||||
u~div .email-container {
|
||||
min-width: 414px !important;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- CSS Reset : END -->
|
||||
|
||||
<!-- Progressive Enhancements : BEGIN -->
|
||||
<style>
|
||||
.primary {
|
||||
background: #D7A86E;
|
||||
}
|
||||
|
||||
.bg_white {
|
||||
background: #ffffff;
|
||||
}
|
||||
|
||||
.bg_light {
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.bg_black {
|
||||
background: #000000;
|
||||
}
|
||||
|
||||
.bg_dark {
|
||||
background: rgba(0, 0, 0, .8);
|
||||
}
|
||||
|
||||
.email-section {
|
||||
padding: 2.5em;
|
||||
}
|
||||
|
||||
/*BUTTON*/
|
||||
.btn {
|
||||
padding: 10px 15px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.btn.btn-primary {
|
||||
border-radius: 5px;
|
||||
background: #D7A86E;
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.btn.btn-white {
|
||||
border-radius: 5px;
|
||||
background: #ffffff;
|
||||
color: #000000;
|
||||
}
|
||||
|
||||
.btn.btn-white-outline {
|
||||
border-radius: 5px;
|
||||
background: transparent;
|
||||
border: 1px solid #fff;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.btn.btn-black-outline {
|
||||
border-radius: 0px;
|
||||
background: transparent;
|
||||
border: 2px solid #000;
|
||||
color: #000;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2,
|
||||
h3,
|
||||
h4,
|
||||
h5,
|
||||
h6 {
|
||||
font-family: 'Lato', sans-serif;
|
||||
color: #000000;
|
||||
margin-top: 0;
|
||||
font-weight: 400;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: 'Lato', sans-serif;
|
||||
font-weight: 400;
|
||||
font-size: 15px;
|
||||
line-height: 1.8;
|
||||
color: rgba(0, 0, 0, 0.808);
|
||||
}
|
||||
|
||||
a {
|
||||
color: #D7A86E;
|
||||
}
|
||||
|
||||
table {}
|
||||
|
||||
/*LOGO*/
|
||||
|
||||
.logo h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.logo h1 a {
|
||||
color: #D7A86E;
|
||||
font-size: 24px;
|
||||
font-weight: 700;
|
||||
font-family: 'Lato', sans-serif;
|
||||
}
|
||||
|
||||
/*HERO*/
|
||||
.hero {
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.hero .text {
|
||||
color: rgba(0, 0, 0, 0.884);
|
||||
}
|
||||
|
||||
.hero .text h2 {
|
||||
color: #000;
|
||||
font-size: 40px;
|
||||
margin-bottom: 0;
|
||||
font-weight: 400;
|
||||
line-height: 1.4;
|
||||
}
|
||||
|
||||
.hero .text h3 {
|
||||
font-size: 24px;
|
||||
font-weight: 300;
|
||||
}
|
||||
|
||||
.hero .text h2 span {
|
||||
font-weight: 600;
|
||||
color: #D7A86E;
|
||||
}
|
||||
|
||||
|
||||
/*HEADING SECTION*/
|
||||
.heading-section {}
|
||||
|
||||
.heading-section h2 {
|
||||
color: #000000;
|
||||
font-size: 28px;
|
||||
margin-top: 0;
|
||||
line-height: 1.4;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.heading-section .subheading {
|
||||
margin-bottom: 20px !important;
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
color: rgba(0, 0, 0, .4);
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.heading-section .subheading::after {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: -10px;
|
||||
content: '';
|
||||
width: 100%;
|
||||
height: 2px;
|
||||
background: #D7A86E;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.heading-section-white {
|
||||
color: rgba(255, 255, 255, .8);
|
||||
}
|
||||
|
||||
.heading-section-white h2 {
|
||||
line-height: 1;
|
||||
padding-bottom: 0;
|
||||
}
|
||||
|
||||
.heading-section-white h2 {
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
.heading-section-white .subheading {
|
||||
margin-bottom: 0;
|
||||
display: inline-block;
|
||||
font-size: 13px;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 2px;
|
||||
color: rgba(255, 255, 255, .4);
|
||||
}
|
||||
|
||||
|
||||
ul.social {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
ul.social li {
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
}
|
||||
|
||||
/*FOOTER*/
|
||||
|
||||
.footer {
|
||||
border-top: 1px solid rgba(0, 0, 0, .05);
|
||||
color: rgba(0, 0, 0, .5);
|
||||
}
|
||||
|
||||
.footer .heading {
|
||||
color: #000;
|
||||
font-size: 20px;
|
||||
}
|
||||
|
||||
.footer ul {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.footer ul li {
|
||||
list-style: none;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.footer ul li a {
|
||||
color: rgba(0, 0, 0, 1);
|
||||
}
|
||||
|
||||
|
||||
@media screen and (max-width: 500px) {}
|
||||
</style>
|
||||
|
||||
|
||||
</head>
|
||||
|
||||
<body width="100%" style="margin: 0; padding: 0 !important; mso-line-height-rule: exactly; background-color: #f1f1f1;">
|
||||
<center style="width: 100%; background-color: #f1f1f1;">
|
||||
<div
|
||||
style="display: none; font-size: 1px;max-height: 0px; max-width: 0px; opacity: 0; overflow: hidden; mso-hide: all; font-family: sans-serif;">
|
||||
‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌ ‌
|
||||
</div>
|
||||
<div style="max-width: 600px; margin: 0 auto;" class="email-container">
|
||||
<!-- BEGIN BODY -->
|
||||
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
|
||||
style="margin: auto;">
|
||||
<tr>
|
||||
<td valign="top" class="bg_white" style="padding: 1em 2.5em 0 2.5em;">
|
||||
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
|
||||
<tr>
|
||||
|
||||
<td class="logo" style="text-align: right;">
|
||||
<img src="cid:logoKatoikia" alt="Logo Katoikia"
|
||||
style="width: 60px; max-width: 60px; height: auto; margin: auto; display: block; float: right;">
|
||||
</td>
|
||||
<td class="logo" style="text-align: left;">
|
||||
<h1><a href="#">Katoikia</a></h1>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
</tr><!-- end tr -->
|
||||
<tr>
|
||||
<td valign="middle" class="hero bg_white" style="padding: 3em 0 2em 0;">
|
||||
<img src="cid:image_email" alt="Logo Katoikia"
|
||||
style="width: 150px; max-width: 300px; height: auto; margin: auto; display: block;">
|
||||
</td>
|
||||
</tr><!-- end tr -->
|
||||
<tr>
|
||||
<td valign="middle" class="hero bg_white" style="padding: 2em 0 4em 0;">
|
||||
<table>
|
||||
<tr>
|
||||
<td>
|
||||
<div class="text" style="padding: 0 2.5em; text-align: center;">
|
||||
<h2> Hola , {{ name }} <i class="fa-regular fa-face-smile-wink"
|
||||
style="color:#D7A86E; font-size: 0.8em; margin-left: 20px;"></i></h2>
|
||||
<h3>Ha sido registrado como un Inquilino en Katoikia </h3>
|
||||
<h4><i class="fa-solid fa-calendar-day"
|
||||
style="color:#D7A86E; margin-right: 10px;"></i> Fecha de registro
|
||||
{{date_entry}}</h4>
|
||||
</div>
|
||||
<div class="text" style="padding: 0 4em; text-align: left;">
|
||||
<p>Fue asignado en la comunidad "{{community_name}}" en la vivienda #{{number_house}}</p>
|
||||
|
||||
</div>
|
||||
<div class="text" style="padding: 0 4em; text-align: left;">
|
||||
<h3>Estas son sus credenciales:</h3>
|
||||
<p><i class="fa-regular fa-envelope" style="color:#D7A86E; margin-right: 10px;"></i> Correo electronico: {{email}}</p>
|
||||
<p><i class="fa-solid fa-key" style="color:#D7A86E; margin-right: 10px;"></i> Password: {{password}}</p>
|
||||
|
||||
</div>
|
||||
<div class="text" style="padding: 0 2.5em; text-align: center;">
|
||||
<h3>Ahora puede ingresar con sus credenciales en la app móvil</h3>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr><!-- end tr -->
|
||||
|
||||
<!-- 1 Column Text + Button : END -->
|
||||
</table>
|
||||
<table align="center" role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%"
|
||||
style="margin: auto;">
|
||||
<td valign="middle" class="bg_light footer email-section">
|
||||
<table>
|
||||
<tr>
|
||||
<td valign="top" width="33.333%" style="padding-top: 20px">
|
||||
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="text-align: left; padding-right: 10px">
|
||||
<h3 class="heading">Acerca de</h3>
|
||||
<p>Katoikia es su compañero más cercano para poder estar en contacto con sus vecinos y conocer sobre los mejores anuncios sobre su comunidad.</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td valign="top" width="33.333%" style="padding-top: 20px">
|
||||
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%">
|
||||
<tr>
|
||||
<td style="text-align: left; padding-left: 5px; padding-right: 5px">
|
||||
<h3 class="heading">Información de contacto</h3>
|
||||
<ul>
|
||||
<li><span href="mailto:katoikiap4@gmail.com" class="text">katoikiap4@gmail.com</span></li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- end: tr -->
|
||||
<tr>
|
||||
<td class="bg_light" style="text-align: center">
|
||||
<p><a href="http://localhost:3000" style="color: rgba(0, 0, 0, 0.8)">katoikiaapp.org</a></p>
|
||||
</td>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</center>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -1 +0,0 @@
|
|||
export class CreateNotificationDto {}
|
|
@ -1,6 +0,0 @@
|
|||
import { PartialType } from '@nestjs/mapped-types';
|
||||
import { CreateNotificationDto } from './create-notification.dto';
|
||||
|
||||
export class UpdateNotificationDto extends PartialType(CreateNotificationDto) {
|
||||
id: number;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
import { Controller } from '@nestjs/common';
|
||||
import { MessagePattern, Payload } from '@nestjs/microservices';
|
||||
import { NotificationsService } from './notifications.service';
|
||||
import { CreateNotificationDto } from './dto/create-notification.dto';
|
||||
import { UpdateNotificationDto } from './dto/update-notification.dto';
|
||||
|
||||
@Controller()
|
||||
export class NotificationsController {
|
||||
constructor(private readonly notificationsService: NotificationsService) {}
|
||||
|
||||
@MessagePattern({ cmd: 'createNotification' })
|
||||
create(@Payload() createNotificationDto: CreateNotificationDto) {
|
||||
return this.notificationsService.create(createNotificationDto);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'findAllNotifications' })
|
||||
findAll() {
|
||||
return this.notificationsService.findAll();
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'findOneNotification' })
|
||||
findOne(@Payload() id: number) {
|
||||
return this.notificationsService.findOne(id);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'updateNotification' })
|
||||
update(@Payload() updateNotificationDto: UpdateNotificationDto) {
|
||||
return this.notificationsService.update(
|
||||
updateNotificationDto.id,
|
||||
updateNotificationDto,
|
||||
);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'removeNotification' })
|
||||
remove(@Payload() id: number) {
|
||||
return this.notificationsService.remove(id);
|
||||
}
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { NotificationsService } from './notifications.service';
|
||||
import { NotificationsController } from './notifications.controller';
|
||||
|
||||
@Module({
|
||||
controllers: [NotificationsController],
|
||||
providers: [NotificationsService],
|
||||
})
|
||||
export class NotificationsModule {}
|
|
@ -1,26 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateNotificationDto } from './dto/create-notification.dto';
|
||||
import { UpdateNotificationDto } from './dto/update-notification.dto';
|
||||
|
||||
@Injectable()
|
||||
export class NotificationsService {
|
||||
create(createNotificationDto: CreateNotificationDto) {
|
||||
return 'This action adds a new notification';
|
||||
}
|
||||
|
||||
findAll() {
|
||||
return `This action returns all notifications`;
|
||||
}
|
||||
|
||||
findOne(id: number) {
|
||||
return `This action returns a #${id} notification`;
|
||||
}
|
||||
|
||||
update(id: number, updateNotificationDto: UpdateNotificationDto) {
|
||||
return `This action updates a #${id} notification`;
|
||||
}
|
||||
|
||||
remove(id: number) {
|
||||
return `This action removes a #${id} notification`;
|
||||
}
|
||||
}
|
|
@ -1 +0,0 @@
|
|||
export class Notification {}
|
|
@ -29,6 +29,12 @@ export class UsersController {
|
|||
return this.userService.createAdminCommunity(user);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'createTenant' })
|
||||
createTenant(@Payload() user: UserDocument) {
|
||||
return this.userService.createTenant(user);
|
||||
}
|
||||
|
||||
|
||||
@MessagePattern({ cmd: 'findAllUsers' })
|
||||
findAll() {
|
||||
return this.userService.findAll();
|
||||
|
@ -132,7 +138,10 @@ export class UsersController {
|
|||
|
||||
@MessagePattern({ cmd: 'deleteTenant' })
|
||||
deleteTenant(@Payload() user: any) {
|
||||
return this.userService.deleteTenant(user['id']);
|
||||
let tenant_id = user['_id'];
|
||||
return this.userService.deleteTenant(tenant_id,
|
||||
user['community_id'],
|
||||
user['number_house']);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'changeStatus' })
|
||||
|
|
|
@ -24,6 +24,31 @@ export class UsersService {
|
|||
}
|
||||
|
||||
|
||||
async createTenant(user: UserDocument) {
|
||||
let password = user.password;
|
||||
let passwordEncriptada = Md5.init(user.password);
|
||||
user.password = passwordEncriptada;
|
||||
let userCreated = await this.userModel.create(user);
|
||||
await this.saveTenantNumHouse(user.community_id, user.number_house, userCreated['_id']);
|
||||
|
||||
let community = await this.findCommunity(user.community_id);
|
||||
user.community_id = community['name'];
|
||||
|
||||
const pattern = { cmd: 'emailCreateUserTenant' };
|
||||
const payload = {
|
||||
email: user['email'], password: password, name: user['name'],
|
||||
date_entry: user['date_entry'], community_name: community['name'],
|
||||
number_house: user['number_house']
|
||||
};
|
||||
|
||||
return this.clientNotificationtApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(
|
||||
map((message: string) => ({ message })),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
async createAdminCommunity(user: UserDocument) {
|
||||
let password = user.password;
|
||||
let passwordEncriptada = Md5.init(user.password);
|
||||
|
@ -145,7 +170,6 @@ export class UsersService {
|
|||
return await this.userModel.find({ community_id: pcommunity_id, user_type: 4 })
|
||||
}
|
||||
|
||||
|
||||
async testSendMail(user: UserDocument) {
|
||||
let passwordEncriptada = Md5.init(user.password);
|
||||
user.password = passwordEncriptada;
|
||||
|
@ -171,7 +195,7 @@ export class UsersService {
|
|||
}
|
||||
|
||||
async deleteAdminSystem(id: string) {
|
||||
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
||||
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1'}, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
|
@ -182,10 +206,18 @@ export class UsersService {
|
|||
});
|
||||
}
|
||||
|
||||
async deleteTenant(id: string) {
|
||||
return this.userModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
||||
new: true,
|
||||
});
|
||||
async deleteTenant(tenant_id: string, community_id: string, number_house: string) {
|
||||
|
||||
try{
|
||||
await this.userModel.findOneAndUpdate({ _id: tenant_id }, { status: '-1', number_house:''}, {
|
||||
new: true,
|
||||
});
|
||||
|
||||
return await this.deleteTenantNumHouse(community_id, number_house, tenant_id);
|
||||
} catch(error){
|
||||
console.log(error)
|
||||
return error;
|
||||
}
|
||||
}
|
||||
|
||||
async validateEmail(email: string) {
|
||||
|
@ -231,5 +263,28 @@ export class UsersService {
|
|||
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 }))
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
async deleteTenantNumHouse(community_id: string, number_house: string, tenant_id: string) {
|
||||
const pattern = { cmd: 'deleteTenant' }
|
||||
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(() => {
|
||||
tenantsList()
|
||||
}, [])
|
||||
|
@ -110,9 +120,9 @@ const Inquilinos = () => {
|
|||
_tenant.community_id = cookies.community_id;
|
||||
_tenant.number_house = houseNumber;
|
||||
_tenant.password = _tenant.email;
|
||||
console.log(`Registrando nuevo inquilino: ${_tenant}`)
|
||||
console.log(`Registrando nuevo inquilino: ${_tenant}`)
|
||||
|
||||
fetch(`http://localhost:4000/user/createUser`, {
|
||||
fetch(`http://localhost:4000/user/createTenant`, {
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(_tenant),
|
||||
|
@ -125,7 +135,12 @@ const Inquilinos = () => {
|
|||
console.log(`Hubo un error en el servicio: ${response.status}`)
|
||||
else return response.json()
|
||||
})
|
||||
.then(() => {
|
||||
.then((data) => {
|
||||
if (_tenant.status === '1') {
|
||||
_tenant.status_text = 'Activo'
|
||||
} else if (_tenant.status === '0') {
|
||||
_tenant.status_text = 'Inactivo'
|
||||
}
|
||||
_tenants.push(_tenant)
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
|
@ -133,6 +148,7 @@ const Inquilinos = () => {
|
|||
detail: 'Inquilino creado',
|
||||
life: 3000,
|
||||
})
|
||||
|
||||
setTenants(_tenants)
|
||||
setTenant(emptyTenant)
|
||||
setHouseNumber('')
|
||||
|
@ -168,15 +184,50 @@ const Inquilinos = () => {
|
|||
}
|
||||
|
||||
const deleteTenant = () => {
|
||||
let _tenants = tenants.filter((val) => val._id !== tenant._id)
|
||||
setTenants(_tenants)
|
||||
setDeleteTenantDialog(false)
|
||||
setTenant(emptyTenant)
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Inquilino Eliminado',
|
||||
life: 3000,
|
||||
|
||||
let _tenant = {
|
||||
community_id: tenant.community_id,
|
||||
number_house: tenant.number_house
|
||||
};
|
||||
|
||||
fetch('http://localhost:4000/user/deleteTenant/' + tenant._id, {
|
||||
cache: 'no-cache',
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(_tenant),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(
|
||||
function (response) {
|
||||
if (response.status != 201)
|
||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||
else
|
||||
return response.json();
|
||||
}
|
||||
)
|
||||
.then(
|
||||
function (response) {
|
||||
|
||||
let _tenants = tenants.filter((val) => val._id !== tenant._id)
|
||||
setTenants(_tenants)
|
||||
setDeleteTenantDialog(false)
|
||||
setTenant(emptyTenant)
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Inquilino Eliminado',
|
||||
life: 3000,
|
||||
})
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
err => {
|
||||
console.log('Ocurrió un error con el fetch', err)
|
||||
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Inquilino no se pudo eliminar', life: 3000 });
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
const deleteSelectedTenants = () => {
|
||||
|
|
Loading…
Reference in New Issue