testing editar guarda perifl
This commit is contained in:
commit
8d8540e3f6
|
@ -1,4 +1,5 @@
|
|||
import { Controller, Get, Post, Put, Body, Param, Delete } from '@nestjs/common';
|
||||
import { Console } from 'console';
|
||||
import { AppService } from './app.service';
|
||||
@Controller()
|
||||
export class AppController {
|
||||
|
@ -233,6 +234,36 @@ export class AppController {
|
|||
return this.appService.deleteTenant(id, community_id, number_house);
|
||||
}
|
||||
|
||||
@Put('user/resetUserPassword/:id')
|
||||
resetUserPassword(@Param('id') id: string,
|
||||
@Body('dni') dni: string,
|
||||
@Body('name') name: string,
|
||||
@Body('last_name') last_name: string,
|
||||
@Body('email') email: string,
|
||||
@Body('phone') phone: number,
|
||||
@Body('password') password: string,
|
||||
@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.updateUser(
|
||||
id,
|
||||
dni,
|
||||
name,
|
||||
last_name,
|
||||
email,
|
||||
phone,
|
||||
password,
|
||||
user_type,
|
||||
status,
|
||||
date_entry,
|
||||
community_id,
|
||||
number_house,
|
||||
);
|
||||
}
|
||||
|
||||
@Post('user/changeStatus')
|
||||
changeStatusUser(
|
||||
@Body('id') pId: string,
|
||||
|
@ -275,6 +306,30 @@ export class AppController {
|
|||
return this.appService.updateAdminSystem(_id, dni, name, last_name, email, phone);
|
||||
}
|
||||
|
||||
@Put('user/updateTenant/:id')
|
||||
updateTenant(
|
||||
@Param('id') id: string,
|
||||
@Body('dni') dni: string,
|
||||
@Body('name') name: string,
|
||||
@Body('last_name') last_name: string,
|
||||
@Body('email') email: string,
|
||||
@Body('phone') phone: number,
|
||||
@Body('community_id') community_id: string,
|
||||
@Body('number_house') number_house: string,
|
||||
) {
|
||||
|
||||
return this.appService.updateTenant(
|
||||
id,
|
||||
dni,
|
||||
name,
|
||||
last_name,
|
||||
email,
|
||||
phone,
|
||||
community_id,
|
||||
number_house,
|
||||
);
|
||||
}
|
||||
|
||||
// #==== API Communities
|
||||
@Post('community/createCommunity')
|
||||
createCommunity(
|
||||
|
@ -339,10 +394,16 @@ export class AppController {
|
|||
saveTenant(
|
||||
@Body('community_id') community_id: string,
|
||||
@Body('number_house') number_house: string,
|
||||
@Body('tenant_id') tenant_id: string,
|
||||
@Body('_id') tenant_id: string,
|
||||
) {
|
||||
console.log(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
|
||||
@Post('commonArea/createCommonArea')
|
||||
createCommonArea(
|
||||
|
@ -390,6 +451,23 @@ export class AppController {
|
|||
return this.appService.changeStatusCommonArea(pId, pStatus);
|
||||
}
|
||||
|
||||
@Post('commonArea/updateCommonArea')
|
||||
updateCommonArea(
|
||||
@Body('_id') id: string,
|
||||
@Body('name') name: string,
|
||||
@Body('hourMin') hourMin: string,
|
||||
@Body('hourMax') hourMax: string,
|
||||
@Body('bookable') bookable: number,
|
||||
@Body('community_id') community_id: string,
|
||||
) {
|
||||
return this.appService.updateCommonArea(
|
||||
id,
|
||||
name,
|
||||
hourMin,
|
||||
hourMax,
|
||||
bookable,
|
||||
community_id,);
|
||||
}
|
||||
// #==== API GUEST
|
||||
//#API userService - create user
|
||||
@Post('guest/createGuest')
|
||||
|
@ -445,61 +523,30 @@ export class AppController {
|
|||
return this.appService.updateGuest(_id);
|
||||
}
|
||||
|
||||
// #==== API Payment
|
||||
|
||||
@Post('payment/createPayment')
|
||||
createPayment(
|
||||
@Body('date_payment') date_payment: Date,
|
||||
@Body('mount') mount: number,
|
||||
@Body('description') description: string,
|
||||
@Body('period') period: string,
|
||||
@Body('status') status: string,
|
||||
@Body('user_id') user_id: string,
|
||||
@Body('communty_id') communty_id: string,
|
||||
) {
|
||||
return this.appService.createPayment(
|
||||
date_payment,
|
||||
mount,
|
||||
description,
|
||||
period,
|
||||
status,
|
||||
user_id,
|
||||
communty_id,
|
||||
);
|
||||
}
|
||||
|
||||
@Get('payment/allPayments')
|
||||
allPayments() {
|
||||
return this.appService.allPayments();
|
||||
}
|
||||
|
||||
@Get('payment/find/:dni')
|
||||
findPayment(@Param('dni') paramPaymentDNI: string) {
|
||||
return this.appService.findPayment(paramPaymentDNI);
|
||||
}
|
||||
|
||||
// #==== API Reservation
|
||||
|
||||
@Post('reservation/createReservation')
|
||||
createReservation(
|
||||
@Body('start_time') start_time: string,
|
||||
@Body('finish_time') finish_time: string,
|
||||
@Body('date') date: string,
|
||||
@Body('time') time: string,
|
||||
@Body('status') status: string,
|
||||
@Body('date_entry') date_entry: Date,
|
||||
@Body('user_id') user_id: string,
|
||||
@Body('common_area_id') common_area_id: string,
|
||||
@Body('common_area_name') common_area_name: string,
|
||||
@Body('communty_id') communty_id: string,
|
||||
@Body('community_id') community_id: string,
|
||||
) {
|
||||
return this.appService.createReservation(
|
||||
start_time,
|
||||
finish_time,
|
||||
date,
|
||||
time,
|
||||
status,
|
||||
date_entry,
|
||||
user_id,
|
||||
common_area_id,
|
||||
common_area_name,
|
||||
communty_id,
|
||||
community_id,
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -513,6 +560,18 @@ export class AppController {
|
|||
return this.appService.findReservation(paramReservation);
|
||||
}
|
||||
|
||||
@Get('reservation/findReservations/:id')
|
||||
findReservations(@Param('id') community_id: string) {
|
||||
return this.appService.findReservations(community_id);
|
||||
}
|
||||
|
||||
|
||||
@Delete('reservation/deleteReservation/:id')
|
||||
deleteReservation(@Param('id') id: string) {
|
||||
return this.appService.deleteReservation(id);
|
||||
}
|
||||
|
||||
|
||||
// #==== API Post
|
||||
|
||||
@Post('post/createPost')
|
||||
|
@ -525,6 +584,16 @@ export class AppController {
|
|||
return this.appService.createPost(post, date_entry, user_id, community_id);
|
||||
}
|
||||
|
||||
@Put('post/updatePost/:id')
|
||||
updatePost(
|
||||
@Param('id') id: string,
|
||||
@Body('post') post: string,
|
||||
@Body('user_id') user_id: string,
|
||||
@Body('community_id') community_id: string,
|
||||
) {
|
||||
return this.appService.updatePost(id, post, user_id, community_id);
|
||||
}
|
||||
|
||||
@Get('post/allPosts')
|
||||
allPosts() {
|
||||
return this.appService.allPosts();
|
||||
|
|
|
@ -175,6 +175,36 @@ export class AppService {
|
|||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
|
||||
async updateTenant(
|
||||
_id: string,
|
||||
dni: string,
|
||||
name: string,
|
||||
last_name: string,
|
||||
email: string,
|
||||
phone: number,
|
||||
community_id: string,
|
||||
number_house: string,
|
||||
) {
|
||||
await this.saveTenant(community_id, number_house, _id);
|
||||
|
||||
const pattern = { cmd: 'updateTenant' };
|
||||
const payload = {
|
||||
id: _id,
|
||||
dni: dni,
|
||||
name: name,
|
||||
last_name: last_name,
|
||||
email: email,
|
||||
phone: phone,
|
||||
community_id: community_id,
|
||||
number_house: number_house,
|
||||
};
|
||||
return this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
//POST parameter from API
|
||||
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number
|
||||
, user_type: string, status: string, date_entry: Date) {
|
||||
|
@ -225,6 +255,22 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
resetUserPassword(id: string, dni: string, name: string, last_name: string, email: string, phone: number
|
||||
, user_type: string, status: string, date_entry: Date, community_id: string) {
|
||||
const pattern = { cmd: 'resetUserPassword' };
|
||||
|
||||
const payload = {
|
||||
id: id, 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
|
||||
|
||||
};
|
||||
return this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(
|
||||
map((message: string) => ({ message })),
|
||||
);
|
||||
}
|
||||
|
||||
allUsersAdminSistema() {
|
||||
const pattern = { cmd: 'findAdminSistema' };
|
||||
const payload = {};
|
||||
|
@ -430,6 +476,15 @@ export class AppService {
|
|||
.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 ===============================
|
||||
//POST parameter from API
|
||||
createCommonArea(
|
||||
|
@ -498,7 +553,27 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
|
||||
updateCommonArea(
|
||||
id: string,
|
||||
name: string,
|
||||
hourMin: string,
|
||||
hourMax: string,
|
||||
bookable: number,
|
||||
community_id: string,
|
||||
) {
|
||||
const pattern = { cmd: 'updateCommonArea' };
|
||||
const payload = {
|
||||
id: id,
|
||||
name: name,
|
||||
hourMin: hourMin,
|
||||
hourMax: hourMax,
|
||||
bookable: bookable,
|
||||
community_id: community_id,
|
||||
};
|
||||
return this.clientCommonAreaApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
// ====================== GUESTS ===============================
|
||||
|
||||
//POST parameter from API
|
||||
|
@ -518,6 +593,7 @@ export class AppService {
|
|||
const payload = {
|
||||
name: name, last_name: last_name, dni: dni, number_plate: number_plate, phone: phone,
|
||||
status: status,tenant_id:tenant_id, community_id:community_id,date_entry: date_entry,type_guest:type_guest
|
||||
|
||||
};
|
||||
return this.clientGuestApp
|
||||
.send<string>(pattern, payload)
|
||||
|
@ -567,56 +643,17 @@ export class AppService {
|
|||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })))
|
||||
}
|
||||
// ====================== PAYMENTS ===============================
|
||||
|
||||
//POST parameter from API
|
||||
createPayment(
|
||||
date_payment: Date,
|
||||
mount: number,
|
||||
description: string,
|
||||
period: string,
|
||||
status: string,
|
||||
user_id: string,
|
||||
communty_id: string,
|
||||
) {
|
||||
const pattern = { cmd: 'createPayment' };
|
||||
const payload = {
|
||||
date_payment: date_payment, mount: mount, description: description,
|
||||
period: period, status: status, user_id: user_id, communty_id: communty_id
|
||||
};
|
||||
return this.clientPaymentApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
allPayments() {
|
||||
const pattern = { cmd: 'findAllPayments' };
|
||||
const payload = {};
|
||||
return this.clientPaymentApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
//GET parameter from API
|
||||
findPayment(paramPaymentId: string) {
|
||||
const pattern = { cmd: 'findOnePayment' };
|
||||
const payload = { id: paramPaymentId };
|
||||
return this.clientPaymentApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
// ====================== RESERVATIONS ===============================
|
||||
|
||||
//POST parameter from API
|
||||
createReservation(start_time: string, finish_time: string, status: string,
|
||||
createReservation(date: string, time: string, status: string,
|
||||
date_entry: Date, user_id: string, common_area_id: string,
|
||||
common_area_name: string, communty_id: string) {
|
||||
common_area_name: string, community_id: string) {
|
||||
const pattern = { cmd: 'createReservation' };
|
||||
const payload = {
|
||||
start_time: start_time, finish_time: finish_time, status: status,
|
||||
date: date, time: time, status: status,
|
||||
date_entry: date_entry, user_id: user_id, common_area_id: common_area_id,
|
||||
common_area_name: common_area_name, communty_id: communty_id
|
||||
common_area_name: common_area_name, community_id: community_id
|
||||
};
|
||||
return this.clientReservationApp
|
||||
.send<string>(pattern, payload)
|
||||
|
@ -640,6 +677,23 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
findReservations(community_id: string) {
|
||||
const pattern = { cmd: 'findReservationsByCommunity' };
|
||||
const payload = { community_id: community_id };
|
||||
return this.clientReservationApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
//DELETE parameter from API
|
||||
deleteReservation(paramReservationId: string) {
|
||||
const pattern = { cmd: 'removeReservation' };
|
||||
const payload = { id: paramReservationId };
|
||||
return this.clientReservationApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
// ====================== POSTS ===============================
|
||||
|
||||
//POST parameter from API
|
||||
|
@ -655,6 +709,16 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
updatePost(id: string, post: string, user_id: string, community_id: string) {
|
||||
const pattern = { cmd: 'updatePost' };
|
||||
const payload = {
|
||||
post: post, id: id, user_id: user_id, community_id: community_id
|
||||
};
|
||||
return this.clientPostApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
allPosts() {
|
||||
const pattern = { cmd: 'findAllPosts' };
|
||||
const payload = {};
|
||||
|
@ -786,4 +850,19 @@ export class AppService {
|
|||
|
||||
return pass;
|
||||
}
|
||||
|
||||
|
||||
|
||||
async saveTenantNumHouse(community_id: string, number_house: string, tenant_id: string) {
|
||||
|
||||
const pattern = { cmd: 'saveTenantNumHouse' }
|
||||
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 }))
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@ const { Navigator, Screen } = createMaterialTopTabNavigator();
|
|||
|
||||
export default function Profile({ navigation }) {
|
||||
|
||||
const baseURL = `${API.BASE_URL}/user/updateUser/`
|
||||
const baseURL = `${API.BASE_URL}/user/updateGuarda/`
|
||||
const [index, setIndex] = useState(0);
|
||||
const layout = useWindowDimensions();
|
||||
const userData = useContext(UserContext)
|
||||
|
@ -203,12 +203,7 @@ export default function Profile({ navigation }) {
|
|||
"last_name": apellido,
|
||||
"email": email,
|
||||
"phone": userData.user.phone,
|
||||
"password": userData.user.password,
|
||||
"user_type": userData.user.user_type,
|
||||
"status": userData.user.status,
|
||||
"date_entry": userData.user.date_entry,
|
||||
"community_id": userData.user.community_id,
|
||||
"number_house": '20'
|
||||
"community_id": userData.user.community_id
|
||||
}
|
||||
|
||||
console.log(data);
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
module.exports = {
|
||||
parser: '@typescript-eslint/parser',
|
||||
parserOptions: {
|
||||
project: 'tsconfig.json',
|
||||
tsconfigRootDir : __dirname,
|
||||
sourceType: 'module',
|
||||
},
|
||||
plugins: ['@typescript-eslint/eslint-plugin'],
|
||||
extends: [
|
||||
'plugin:@typescript-eslint/recommended',
|
||||
'plugin:prettier/recommended',
|
||||
],
|
||||
root: true,
|
||||
env: {
|
||||
node: true,
|
||||
jest: true,
|
||||
},
|
||||
ignorePatterns: ['.eslintrc.js'],
|
||||
rules: {
|
||||
'@typescript-eslint/interface-name-prefix': 'off',
|
||||
'@typescript-eslint/explicit-function-return-type': 'off',
|
||||
'@typescript-eslint/explicit-module-boundary-types': 'off',
|
||||
'@typescript-eslint/no-explicit-any': 'off',
|
||||
},
|
||||
};
|
|
@ -1,35 +0,0 @@
|
|||
# compiled output
|
||||
/dist
|
||||
/node_modules
|
||||
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
pnpm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# OS
|
||||
.DS_Store
|
||||
|
||||
# Tests
|
||||
/coverage
|
||||
/.nyc_output
|
||||
|
||||
# IDEs and editors
|
||||
/.idea
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# IDE - VSCode
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"singleQuote": true,
|
||||
"trailingComma": "all"
|
||||
}
|
|
@ -1,73 +0,0 @@
|
|||
<p align="center">
|
||||
<a href="http://nestjs.com/" target="blank"><img src="https://nestjs.com/img/logo-small.svg" width="200" alt="Nest Logo" /></a>
|
||||
</p>
|
||||
|
||||
[circleci-image]: https://img.shields.io/circleci/build/github/nestjs/nest/master?token=abc123def456
|
||||
[circleci-url]: https://circleci.com/gh/nestjs/nest
|
||||
|
||||
<p align="center">A progressive <a href="http://nodejs.org" target="_blank">Node.js</a> framework for building efficient and scalable server-side applications.</p>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/v/@nestjs/core.svg" alt="NPM Version" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/l/@nestjs/core.svg" alt="Package License" /></a>
|
||||
<a href="https://www.npmjs.com/~nestjscore" target="_blank"><img src="https://img.shields.io/npm/dm/@nestjs/common.svg" alt="NPM Downloads" /></a>
|
||||
<a href="https://circleci.com/gh/nestjs/nest" target="_blank"><img src="https://img.shields.io/circleci/build/github/nestjs/nest/master" alt="CircleCI" /></a>
|
||||
<a href="https://coveralls.io/github/nestjs/nest?branch=master" target="_blank"><img src="https://coveralls.io/repos/github/nestjs/nest/badge.svg?branch=master#9" alt="Coverage" /></a>
|
||||
<a href="https://discord.gg/G7Qnnhy" target="_blank"><img src="https://img.shields.io/badge/discord-online-brightgreen.svg" alt="Discord"/></a>
|
||||
<a href="https://opencollective.com/nest#backer" target="_blank"><img src="https://opencollective.com/nest/backers/badge.svg" alt="Backers on Open Collective" /></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://opencollective.com/nest/sponsors/badge.svg" alt="Sponsors on Open Collective" /></a>
|
||||
<a href="https://paypal.me/kamilmysliwiec" target="_blank"><img src="https://img.shields.io/badge/Donate-PayPal-ff3f59.svg"/></a>
|
||||
<a href="https://opencollective.com/nest#sponsor" target="_blank"><img src="https://img.shields.io/badge/Support%20us-Open%20Collective-41B883.svg" alt="Support us"></a>
|
||||
<a href="https://twitter.com/nestframework" target="_blank"><img src="https://img.shields.io/twitter/follow/nestframework.svg?style=social&label=Follow"></a>
|
||||
</p>
|
||||
<!--[![Backers on Open Collective](https://opencollective.com/nest/backers/badge.svg)](https://opencollective.com/nest#backer)
|
||||
[![Sponsors on Open Collective](https://opencollective.com/nest/sponsors/badge.svg)](https://opencollective.com/nest#sponsor)-->
|
||||
|
||||
## Description
|
||||
|
||||
[Nest](https://github.com/nestjs/nest) framework TypeScript starter repository.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
## Running the app
|
||||
|
||||
```bash
|
||||
# development
|
||||
$ npm run start
|
||||
|
||||
# watch mode
|
||||
$ npm run start:dev
|
||||
|
||||
# production mode
|
||||
$ npm run start:prod
|
||||
```
|
||||
|
||||
## Test
|
||||
|
||||
```bash
|
||||
# unit tests
|
||||
$ npm run test
|
||||
|
||||
# e2e tests
|
||||
$ npm run test:e2e
|
||||
|
||||
# test coverage
|
||||
$ npm run test:cov
|
||||
```
|
||||
|
||||
## Support
|
||||
|
||||
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please [read more here](https://docs.nestjs.com/support).
|
||||
|
||||
## Stay in touch
|
||||
|
||||
- Author - [Kamil Myśliwiec](https://kamilmysliwiec.com)
|
||||
- Website - [https://nestjs.com](https://nestjs.com/)
|
||||
- Twitter - [@nestframework](https://twitter.com/nestframework)
|
||||
|
||||
## License
|
||||
|
||||
Nest is [MIT licensed](LICENSE).
|
|
@ -1,5 +0,0 @@
|
|||
{
|
||||
"$schema": "https://json.schemastore.org/nest-cli",
|
||||
"collection": "@nestjs/schematics",
|
||||
"sourceRoot": "src"
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,77 +0,0 @@
|
|||
{
|
||||
"name": "service-a",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist",
|
||||
"build": "nest build",
|
||||
"format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
||||
"start": "nest start",
|
||||
"start:dev": "nest start --watch",
|
||||
"start:debug": "nest start --debug --watch",
|
||||
"start:prod": "node dist/main",
|
||||
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
|
||||
"test:e2e": "jest --config ./test/jest-e2e.json"
|
||||
},
|
||||
"dependencies": {
|
||||
"@nestjs/common": "^8.0.0",
|
||||
"@nestjs/core": "^8.0.0",
|
||||
"@nestjs/mapped-types": "*",
|
||||
"@nestjs/microservices": "^8.4.7",
|
||||
"@nestjs/mongoose": "^9.1.1",
|
||||
"@nestjs/platform-express": "^8.0.0",
|
||||
"@nestjs/swagger": "^5.2.1",
|
||||
"mongoose": "^6.4.1",
|
||||
"reflect-metadata": "^0.1.13",
|
||||
"rimraf": "^3.0.2",
|
||||
"rxjs": "^7.2.0",
|
||||
"swagger-ui-express": "^4.4.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@nestjs/cli": "^8.0.0",
|
||||
"@nestjs/schematics": "^8.0.0",
|
||||
"@nestjs/testing": "^8.0.0",
|
||||
"@types/express": "^4.17.13",
|
||||
"@types/jest": "27.5.0",
|
||||
"@types/node": "^16.0.0",
|
||||
"@types/supertest": "^2.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
||||
"@typescript-eslint/parser": "^5.0.0",
|
||||
"eslint": "^8.0.1",
|
||||
"eslint-config-prettier": "^8.3.0",
|
||||
"eslint-plugin-prettier": "^4.0.0",
|
||||
"jest": "28.0.3",
|
||||
"prettier": "^2.3.2",
|
||||
"source-map-support": "^0.5.20",
|
||||
"supertest": "^6.1.3",
|
||||
"ts-jest": "28.0.1",
|
||||
"ts-loader": "^9.2.3",
|
||||
"ts-node": "^10.0.0",
|
||||
"tsconfig-paths": "4.0.0",
|
||||
"typescript": "^4.3.5"
|
||||
},
|
||||
"jest": {
|
||||
"moduleFileExtensions": [
|
||||
"js",
|
||||
"json",
|
||||
"ts"
|
||||
],
|
||||
"rootDir": "src",
|
||||
"testRegex": ".*\\.spec\\.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
},
|
||||
"collectCoverageFrom": [
|
||||
"**/*.(t|j)s"
|
||||
],
|
||||
"coverageDirectory": "../coverage",
|
||||
"testEnvironment": "node"
|
||||
}
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
describe('AppController', () => {
|
||||
let appController: AppController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const app: TestingModule = await Test.createTestingModule({
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
}).compile();
|
||||
|
||||
appController = app.get<AppController>(AppController);
|
||||
});
|
||||
|
||||
describe('root', () => {
|
||||
it('should return "Hello World!"', () => {
|
||||
expect(appController.getHello()).toBe('Hello World!');
|
||||
});
|
||||
});
|
||||
});
|
|
@ -1,12 +0,0 @@
|
|||
import { Controller, Get } from '@nestjs/common';
|
||||
import { AppService } from './app.service';
|
||||
|
||||
@Controller()
|
||||
export class AppController {
|
||||
constructor(private readonly appService: AppService) {}
|
||||
|
||||
@Get()
|
||||
getHello(): string {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { AppController } from './app.controller';
|
||||
import { AppService } from './app.service';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
import { BooksModule } from './books/books.module';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MongooseModule.forRoot(
|
||||
`mongodb+srv://proyecto_4:proyecto_4@proyecto4.yv4fb.mongodb.net/servicio_books?retryWrites=true&w=majority`,
|
||||
),
|
||||
BooksModule,
|
||||
],
|
||||
controllers: [AppController],
|
||||
providers: [AppService],
|
||||
})
|
||||
export class AppModule {}
|
|
@ -1,8 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
|
||||
@Injectable()
|
||||
export class AppService {
|
||||
getHello(): string {
|
||||
return 'Hello World!';
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { BooksController } from './books.controller';
|
||||
import { BooksService } from './books.service';
|
||||
|
||||
describe('BooksController', () => {
|
||||
let controller: BooksController;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
controllers: [BooksController],
|
||||
providers: [BooksService],
|
||||
}).compile();
|
||||
|
||||
controller = module.get<BooksController>(BooksController);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(controller).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -1,47 +0,0 @@
|
|||
import { Req } from '@nestjs/common';
|
||||
import {
|
||||
Controller,
|
||||
Get,
|
||||
Post,
|
||||
Body,
|
||||
Patch,
|
||||
Param,
|
||||
Delete,
|
||||
} from '@nestjs/common';
|
||||
import { ApiTags } from '@nestjs/swagger';
|
||||
import { Request } from 'express';
|
||||
import { BooksService } from './books.service';
|
||||
import { CreateBookDto } from './dto/create-book.dto';
|
||||
import { UpdateBookDto } from './dto/update-book.dto';
|
||||
import { BookDocument } from './schemas/book.schema';
|
||||
|
||||
@Controller('books')
|
||||
@ApiTags('book')
|
||||
export class BooksController {
|
||||
constructor(private readonly booksService: BooksService) {}
|
||||
|
||||
@Post()
|
||||
create(@Body() book: BookDocument) {
|
||||
return this.booksService.create(book);
|
||||
}
|
||||
|
||||
@Get()
|
||||
findAll(@Req() request: Request) {
|
||||
return this.booksService.findAll(request);
|
||||
}
|
||||
|
||||
@Get(':id')
|
||||
findOne(@Param('id') id: string) {
|
||||
return this.booksService.findOne(id);
|
||||
}
|
||||
|
||||
@Patch(':id')
|
||||
update(@Param('id') id: string, @Body() book: BookDocument) {
|
||||
return this.booksService.update(id, book);
|
||||
}
|
||||
|
||||
@Delete(':id')
|
||||
remove(@Param('id') id: string) {
|
||||
return this.booksService.remove(id);
|
||||
}
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
import { Module } from '@nestjs/common';
|
||||
import { BooksService } from './books.service';
|
||||
import { BooksController } from './books.controller';
|
||||
import { MongooseModule } from '@nestjs/mongoose';
|
||||
import { Book, BookSchema } from './schemas/book.schema';
|
||||
|
||||
@Module({
|
||||
imports: [
|
||||
MongooseModule.forFeature([{ name: Book.name, schema: BookSchema }]),
|
||||
],
|
||||
controllers: [BooksController],
|
||||
providers: [BooksService],
|
||||
})
|
||||
export class BooksModule {}
|
|
@ -1,18 +0,0 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { BooksService } from './books.service';
|
||||
|
||||
describe('BooksService', () => {
|
||||
let service: BooksService;
|
||||
|
||||
beforeEach(async () => {
|
||||
const module: TestingModule = await Test.createTestingModule({
|
||||
providers: [BooksService],
|
||||
}).compile();
|
||||
|
||||
service = module.get<BooksService>(BooksService);
|
||||
});
|
||||
|
||||
it('should be defined', () => {
|
||||
expect(service).toBeDefined();
|
||||
});
|
||||
});
|
|
@ -1,39 +0,0 @@
|
|||
import { Injectable } from '@nestjs/common';
|
||||
import { CreateBookDto } from './dto/create-book.dto';
|
||||
import { UpdateBookDto } from './dto/update-book.dto';
|
||||
import { InjectModel } from '@nestjs/mongoose';
|
||||
import { Book, BookDocument } from './schemas/book.schema';
|
||||
import { Model } from 'mongoose';
|
||||
import { Request } from 'express';
|
||||
|
||||
@Injectable()
|
||||
export class BooksService {
|
||||
constructor(
|
||||
@InjectModel(Book.name) private readonly bookModel: Model<BookDocument>,
|
||||
) {}
|
||||
|
||||
async create(book: BookDocument): Promise<Book> {
|
||||
return this.bookModel.create(book);
|
||||
}
|
||||
|
||||
async findAll(request: Request): Promise<Book[]> {
|
||||
return this.bookModel
|
||||
.find(request.query)
|
||||
.setOptions({ sanitizeFilter: true })
|
||||
.exec();
|
||||
}
|
||||
|
||||
async findOne(id: string): Promise<Book> {
|
||||
return this.bookModel.findOne({ _id: id }).exec();
|
||||
}
|
||||
|
||||
async update(id: string, book: BookDocument) {
|
||||
return this.bookModel.findOneAndUpdate({ _id: id }, book, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
|
||||
async remove(id: string) {
|
||||
return this.bookModel.findByIdAndRemove({ _id: id }).exec();
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
import { ApiProperty } from '@nestjs/swagger';
|
||||
|
||||
export class CreateBookDto {
|
||||
@ApiProperty({
|
||||
example: 'Nest.js: A Progressive Node.js Framework (English Edition)',
|
||||
})
|
||||
readonly title: string;
|
||||
|
||||
@ApiProperty({ example: 'Web Development' })
|
||||
readonly genre: string;
|
||||
|
||||
@ApiProperty({
|
||||
example:
|
||||
'JavaScript frameworks go in and out of style very quickly as web technologies change and grow. Nest.js is a good starting point for many developers that are looking to use a modern web framework because it uses a language that is very similar to that of the most used language on the web to this day, JavaScript...',
|
||||
})
|
||||
readonly description: string;
|
||||
|
||||
@ApiProperty({ example: 'Jay Bell' })
|
||||
readonly author: string;
|
||||
|
||||
@ApiProperty({ example: 350 })
|
||||
readonly pages: number;
|
||||
|
||||
@ApiProperty({
|
||||
example: 'https://m.media-amazon.com/images/I/41fveBeDWmL._SY346_.jpg',
|
||||
})
|
||||
readonly image_url: string;
|
||||
|
||||
@ApiProperty({ example: ['NestJS', 'REST API'] })
|
||||
readonly keywords: string[];
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
import { PartialType } from '@nestjs/swagger';
|
||||
import { CreateBookDto } from './create-book.dto';
|
||||
|
||||
export class UpdateBookDto extends PartialType(CreateBookDto) {}
|
|
@ -1,27 +0,0 @@
|
|||
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||
import { Document } from 'mongoose';
|
||||
|
||||
export type BookDocument = Book & Document;
|
||||
|
||||
@Schema()
|
||||
export class Book {
|
||||
@Prop()
|
||||
genre: string;
|
||||
|
||||
@Prop()
|
||||
description: string;
|
||||
|
||||
@Prop()
|
||||
author: string;
|
||||
|
||||
@Prop()
|
||||
pages: number;
|
||||
|
||||
@Prop()
|
||||
image_url: string;
|
||||
|
||||
@Prop([String])
|
||||
keywords: string[];
|
||||
}
|
||||
|
||||
export const BookSchema = SchemaFactory.createForClass(Book);
|
|
@ -1,21 +0,0 @@
|
|||
import { NestFactory } from '@nestjs/core';
|
||||
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
|
||||
// Configurar títulos de documentación
|
||||
const options = new DocumentBuilder()
|
||||
.setTitle('MongoDB Book REST API')
|
||||
.setDescription('API REST para libros con MongoDB')
|
||||
.setVersion('1.0')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, options);
|
||||
|
||||
// La ruta en que se sirve la documentación
|
||||
SwaggerModule.setup('docs', app, document);
|
||||
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
|
@ -1,24 +0,0 @@
|
|||
import { Test, TestingModule } from '@nestjs/testing';
|
||||
import { INestApplication } from '@nestjs/common';
|
||||
import * as request from 'supertest';
|
||||
import { AppModule } from './../src/app.module';
|
||||
|
||||
describe('AppController (e2e)', () => {
|
||||
let app: INestApplication;
|
||||
|
||||
beforeEach(async () => {
|
||||
const moduleFixture: TestingModule = await Test.createTestingModule({
|
||||
imports: [AppModule],
|
||||
}).compile();
|
||||
|
||||
app = moduleFixture.createNestApplication();
|
||||
await app.init();
|
||||
});
|
||||
|
||||
it('/ (GET)', () => {
|
||||
return request(app.getHttpServer())
|
||||
.get('/')
|
||||
.expect(200)
|
||||
.expect('Hello World!');
|
||||
});
|
||||
});
|
|
@ -1,9 +0,0 @@
|
|||
{
|
||||
"moduleFileExtensions": ["js", "json", "ts"],
|
||||
"rootDir": ".",
|
||||
"testEnvironment": "node",
|
||||
"testRegex": ".e2e-spec.ts$",
|
||||
"transform": {
|
||||
"^.+\\.(t|j)s$": "ts-jest"
|
||||
}
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"exclude": ["node_modules", "test", "dist", "**/*spec.ts"]
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"declaration": true,
|
||||
"removeComments": true,
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"allowSyntheticDefaultImports": true,
|
||||
"target": "es2017",
|
||||
"sourceMap": true,
|
||||
"outDir": "./dist",
|
||||
"baseUrl": "./",
|
||||
"incremental": true,
|
||||
"skipLibCheck": true,
|
||||
"strictNullChecks": false,
|
||||
"noImplicitAny": false,
|
||||
"strictBindCallApply": false,
|
||||
"forceConsistentCasingInFileNames": false,
|
||||
"noFallthroughCasesInSwitch": false
|
||||
}
|
||||
}
|
|
@ -47,4 +47,10 @@ export class CommonAreasController {
|
|||
let pstatus = body['status'];
|
||||
return this.commonAreasService.changeStatus(pid, pstatus);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'removeIdCommunity' })
|
||||
removeIdCommunity(@Payload() area: any) {
|
||||
let community_id = area['community_id'];
|
||||
return this.commonAreasService.removeIdCommunity(community_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ export class CommonAreasService {
|
|||
}
|
||||
|
||||
update(id: string, commonArea: CommonAreaDocument) {
|
||||
console.log(commonArea);
|
||||
return this.commonAreaModel.findOneAndUpdate({ _id: id }, commonArea, {
|
||||
new: true,
|
||||
});
|
||||
|
@ -47,4 +48,8 @@ export class CommonAreasService {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
async removeIdCommunity(community_id: string){
|
||||
await this.commonAreaModel.updateMany({community_id: community_id}, {"$set":{"status": '-1'}});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,6 @@ export class CommunitiesController {
|
|||
|
||||
@MessagePattern({ cmd: 'saveTenant' })
|
||||
saveTenant(@Payload() body: string) {
|
||||
|
||||
let id = body['_id'];
|
||||
let tenant_id = body['tenant_id'];
|
||||
let number_house = body['number_house'];
|
||||
|
|
|
@ -18,6 +18,26 @@ import { Community, CommunitySchema } from '../schemas/community.schema';
|
|||
},
|
||||
},
|
||||
]),
|
||||
ClientsModule.register([
|
||||
{
|
||||
name: 'SERVICIO_AREAS_COMUNES',
|
||||
transport: Transport.TCP,
|
||||
options: {
|
||||
host: '127.0.0.1',
|
||||
port: 3003,
|
||||
},
|
||||
},
|
||||
]),
|
||||
ClientsModule.register([
|
||||
{
|
||||
name: 'SERVICIO_RESERVACIONES',
|
||||
transport: Transport.TCP,
|
||||
options: {
|
||||
host: '127.0.0.1',
|
||||
port: 3006,
|
||||
},
|
||||
},
|
||||
]),
|
||||
MongooseModule.forFeature([
|
||||
{ name: Community.name, schema: CommunitySchema },
|
||||
]),
|
||||
|
|
|
@ -14,6 +14,8 @@ export class CommunitiesService {
|
|||
@InjectModel(Community.name)
|
||||
private readonly communityModel: Model<CommunityDocument>,
|
||||
@Inject('SERVICIO_USUARIOS') private readonly clientUserApp: ClientProxy,
|
||||
@Inject('SERVICIO_AREAS_COMUNES') private readonly clientAreaApp: ClientProxy,
|
||||
@Inject('SERVICIO_RESERVACIONES') private readonly clientReservationApp: ClientProxy,
|
||||
) { }
|
||||
|
||||
async create(community: CommunityDocument): Promise<Community> {
|
||||
|
@ -57,6 +59,7 @@ export class CommunitiesService {
|
|||
}
|
||||
|
||||
async remove(id: string) {
|
||||
await this.removeIdCommunity(id);
|
||||
return this.communityModel.findOneAndUpdate({ _id: id }, { status: '-1' }, {
|
||||
new: true,
|
||||
});
|
||||
|
@ -80,13 +83,11 @@ export class CommunitiesService {
|
|||
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()
|
||||
|
@ -97,26 +98,47 @@ export class CommunitiesService {
|
|||
}
|
||||
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) {
|
||||
if(house.tenants)
|
||||
house.tenants.tenant_id = "";
|
||||
house.state = "desocupada"
|
||||
}
|
||||
return house;
|
||||
})
|
||||
|
||||
return await this.communityModel.findOneAndUpdate({ _id: id }, community, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
|
||||
async removeIdCommunity(community: string) {
|
||||
const pattern = { cmd: 'removeIdCommunity' };
|
||||
const payload = { community_id: community };
|
||||
|
||||
await this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((response: string) => ({ response })));
|
||||
|
||||
const pattern2 = { cmd: 'removeIdCommunity' };
|
||||
const payload2 = { community_id: community };
|
||||
|
||||
await this.clientAreaApp
|
||||
.send<string>(pattern2, payload2)
|
||||
.pipe(map((response: string) => ({ response })));
|
||||
|
||||
const pattern3 = { cmd: 'removeIdCommunity' };
|
||||
const payload3 = { community_id: community };
|
||||
|
||||
await this.clientReservationApp
|
||||
.send<string>(pattern3, payload3)
|
||||
.pipe(map((response: string) => ({ response })));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -112,4 +112,37 @@ export class EmailController {
|
|||
});
|
||||
return response;
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'emailResetUserPassword' })
|
||||
async emailResetUserPassword(@Payload() user: any) {
|
||||
const url = "http://localhost:3000/";
|
||||
const image = "images/email.png";
|
||||
const logo = "images/Logo Katoikia.png";
|
||||
let response = await this.mailService.sendMail({
|
||||
to: user["email"],
|
||||
from: "katoikiap4@gmail.com",
|
||||
subject: 'Restablecer contraseña',
|
||||
template: 'emailResetUserPassword',
|
||||
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'
|
||||
},
|
||||
{
|
||||
filename: 'Logo_Katoikia.png',
|
||||
path: __dirname + '/mails/images/Logo_Katoikia.png',
|
||||
cid: 'logoKatoikia'
|
||||
}],
|
||||
});
|
||||
return response;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,451 @@
|
|||
<!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 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>
|
|
@ -28,6 +28,12 @@ export class ReservationsController {
|
|||
return this.reservationsService.findOne(_id);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'findReservationsByCommunity' })
|
||||
findReservationsByCommunity(@Payload() body: string) {
|
||||
let community_id = body['community_id'];
|
||||
return this.reservationsService.findReservationsByCommunity(community_id);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'updateReservation' })
|
||||
update(@Payload() reservation: ReservationDocument) {
|
||||
return this.reservationsService.update(reservation.id, reservation);
|
||||
|
@ -38,4 +44,10 @@ export class ReservationsController {
|
|||
let _id = id['id'];
|
||||
return this.reservationsService.remove(_id);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'removeIdCommunity' })
|
||||
removeIdCommunity(@Payload() reservation: any) {
|
||||
let community_id = reservation['community_id'];
|
||||
return this.reservationsService.removeIdCommunity(community_id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,6 @@ export class ReservationsService {
|
|||
) {}
|
||||
|
||||
create(reservation: ReservationDocument) {
|
||||
console.log(reservation);
|
||||
|
||||
return this.reservationModel.create(reservation);
|
||||
}
|
||||
|
||||
|
@ -45,4 +43,13 @@ export class ReservationsService {
|
|||
new: true,
|
||||
});
|
||||
}
|
||||
|
||||
async removeIdCommunity(community_id: string){
|
||||
await this.reservationModel.updateMany({community_id: community_id}, {"$set":{"status": '-1'}});
|
||||
}
|
||||
|
||||
|
||||
async findReservationsByCommunity(community_id: string){
|
||||
return this.reservationModel.find({ community_id: community_id }).exec();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ export type ReservationDocument = Reservation & Document;
|
|||
@Schema({ collection: 'reservations' })
|
||||
export class Reservation {
|
||||
@Prop()
|
||||
start_time: string;
|
||||
date: Date;
|
||||
|
||||
@Prop()
|
||||
finish_time: string;
|
||||
time: string;
|
||||
|
||||
@Prop()
|
||||
status: string;
|
||||
|
@ -23,12 +23,12 @@ export class Reservation {
|
|||
@Prop()
|
||||
common_area_name: string;
|
||||
|
||||
@Prop()
|
||||
user_id: string;
|
||||
|
||||
@Prop()
|
||||
community_id: string;
|
||||
|
||||
@Prop()
|
||||
user_id: string;
|
||||
}
|
||||
|
||||
export const ReservationSchema = SchemaFactory.createForClass(Reservation);
|
||||
|
|
|
@ -77,7 +77,7 @@ export class UsersController {
|
|||
|
||||
@MessagePattern({ cmd: 'updateGuard' })
|
||||
updateGuard(@Payload() guard: UserDocument) {
|
||||
return this.userService.update(guard.id, guard);
|
||||
return this.userService.update(guard._id, guard);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'updateAdminCommunity' })
|
||||
|
@ -85,6 +85,11 @@ export class UsersController {
|
|||
return this.userService.update(user._id, user);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'updateTenant' })
|
||||
updateTenant(@Payload() tenant: UserDocument) {
|
||||
return this.userService.updateTenant(tenant.id, tenant);
|
||||
}
|
||||
|
||||
@MessagePattern({ cmd: 'removeUser' })
|
||||
remove(@Payload() id: string) {
|
||||
let dni = id['dni'];
|
||||
|
@ -147,6 +152,13 @@ export class UsersController {
|
|||
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' })
|
||||
changeStatus(@Payload() body: string) {
|
||||
let pid = body['id'];
|
||||
|
|
|
@ -29,7 +29,7 @@ export class UsersService {
|
|||
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']);
|
||||
await this.saveTenant(user.community_id, user.number_house, userCreated['_id']);
|
||||
|
||||
let community = await this.findCommunity(user.community_id);
|
||||
user.community_id = community['name'];
|
||||
|
@ -72,11 +72,30 @@ export class UsersService {
|
|||
);
|
||||
}
|
||||
|
||||
async resetUserPassword(user: UserDocument) {
|
||||
const password = user.password;
|
||||
const passwordEncriptada = Md5.init(password);
|
||||
user.password = passwordEncriptada;
|
||||
this.userModel.findOneAndUpdate({ _id: user._id }, { password: passwordEncriptada }, {
|
||||
new: true,
|
||||
});
|
||||
const pattern = { cmd: 'emailResetUserPassword' };
|
||||
const payload = {
|
||||
email: user['email'], password: user['password'],
|
||||
date_entry: user['date_entry'], community_name: user['community_id']
|
||||
};
|
||||
return this.clientNotificationtApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(
|
||||
map((message: string) => ({ message }))
|
||||
);
|
||||
}
|
||||
|
||||
async findCommunity(community_id: string) {
|
||||
const pattern = { cmd: 'findOneCommunity' }
|
||||
const payload = { _id: community_id }
|
||||
|
||||
let callback = await this.clientCommunityApp
|
||||
let callback = this.clientCommunityApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(
|
||||
map((response: string) => ({ response }))
|
||||
|
@ -98,6 +117,9 @@ export class UsersService {
|
|||
}
|
||||
|
||||
async update(id: string, user: UserDocument) {
|
||||
console.log(id)
|
||||
console.log(user)
|
||||
|
||||
return this.userModel.findOneAndUpdate({ _id: id }, user, {
|
||||
new: true,
|
||||
});
|
||||
|
@ -112,6 +134,18 @@ export class UsersService {
|
|||
});
|
||||
}
|
||||
|
||||
async updateTenant(id: string, user: UserDocument) {
|
||||
await this.saveTenant(user.community_id, user.number_house, user.id);
|
||||
|
||||
return await this.userModel.findOneAndUpdate({ _id: id }, {
|
||||
name: user['name'], last_name: user['last_name'],
|
||||
dni: user['dni'], email: user['email'], phone: user['phone'],
|
||||
number_house: user['number_house']
|
||||
}, {
|
||||
new: true,
|
||||
});
|
||||
}
|
||||
|
||||
/* async remove(id: string) {
|
||||
return this.userModel.findByIdAndRemove({ _id: id }).exec();
|
||||
}*/
|
||||
|
@ -274,7 +308,7 @@ export class UsersService {
|
|||
}
|
||||
|
||||
|
||||
async saveTenantNumHouse(community_id: string, number_house: string, tenant_id: string) {
|
||||
async saveTenant(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 }
|
||||
|
||||
|
@ -295,5 +329,11 @@ export class UsersService {
|
|||
map((response: string) => ({ response }))
|
||||
)
|
||||
}
|
||||
|
||||
async removeIdCommunity(community_id: string){
|
||||
await 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' } });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7164,3 +7164,7 @@
|
|||
flex-direction: column;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.layout-config-button{
|
||||
display: none!important;
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<html lang="es">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Katoikia</title>
|
||||
|
|
|
@ -34,6 +34,7 @@ import GuardasSeguridad from './components/GuardasSeguridad';
|
|||
import Communities from './components/ComunidadViviendas';
|
||||
import Inquilinos from './components/Inquilinos';
|
||||
import RegistroComunicado from './components/RegistroComunicado';
|
||||
import InvitadosComunidad from './components/InvitadosComunidad';
|
||||
import "../node_modules/bootstrap/dist/css/bootstrap.min.css";
|
||||
|
||||
import Crud from './pages/Crud';
|
||||
|
@ -56,6 +57,8 @@ import AreasComunes from './components/AreasComunes';
|
|||
import { useCookies } from "react-cookie";
|
||||
import LogInUser from './components/LogInUser';
|
||||
import Page404 from './components/Page404'
|
||||
import Reservaciones from './components/Reservaciones';
|
||||
import PerfilAdminComunidad from './components/PerfilAdminComunidad';
|
||||
|
||||
|
||||
const App = () => {
|
||||
|
@ -201,9 +204,9 @@ const App = () => {
|
|||
icon: PrimeIcons.BUILDING,
|
||||
to: '/areasComunes',
|
||||
},
|
||||
|
||||
{ label: 'Comunicados', icon: PrimeIcons.COMMENTS, to: '/registroComunicado' },
|
||||
|
||||
{ label: 'Invitados', icon: PrimeIcons.USERS, to: '/invitadosComunidad' },
|
||||
{ label: 'Reservaciones', icon: PrimeIcons.CALENDAR, to: '/reservaciones'},
|
||||
]
|
||||
},
|
||||
]
|
||||
|
@ -467,7 +470,10 @@ const App = () => {
|
|||
<Route path="/guardasSeguridad" component={GuardasSeguridad} />
|
||||
<Route path="/inquilinos" component={Inquilinos} />
|
||||
<Route path="/areasComunes" component={AreasComunes} />
|
||||
<Route path="/reservaciones" component={Reservaciones} />
|
||||
<Route path="/registroComunicado" component={RegistroComunicado} />
|
||||
<Route path="/invitadosComunidad" component={InvitadosComunidad} />
|
||||
<Route path="/pefilAdminComunidad" component={PerfilAdminComunidad} />
|
||||
</>
|
||||
)
|
||||
} else {
|
||||
|
|
|
@ -13,8 +13,8 @@ export const AppFooter = (props) => {
|
|||
height="20"
|
||||
className="mr-2"
|
||||
/>
|
||||
by
|
||||
<span className="font-medium ml-2">PrimeReact</span>
|
||||
por
|
||||
<span className="font-medium ml-2">Deimos</span>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -88,10 +88,11 @@ export const AppTopbar = (props) => {
|
|||
</button>
|
||||
</li> */}
|
||||
<li className='mx-2' hidden={!logged}>
|
||||
<button className="p-link layout-topbar-button" >
|
||||
<a href="/pefilAdminComunidad"> <button className="p-link layout-topbar-button" >
|
||||
<i className="pi pi-user" />
|
||||
<span>Perfil</span>
|
||||
</button>
|
||||
|
||||
</button></a>
|
||||
</li>
|
||||
<li className='mx-2' hidden={!logged}>
|
||||
<button className="p-link layout-topbar-button" onClick={cerrarSesion} >
|
||||
|
|
|
@ -67,6 +67,7 @@ const AdministradoresComunidad = () => {
|
|||
item.status_text = 'Eliminado';
|
||||
}
|
||||
//item.full_name returns the repositorie name
|
||||
if (item.community_id || item.community_id != '') {
|
||||
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
|
||||
.then((response2) => response2.json())
|
||||
.then(data => data.message)
|
||||
|
@ -74,6 +75,10 @@ const AdministradoresComunidad = () => {
|
|||
item.community_name = data['name']
|
||||
return item
|
||||
})
|
||||
} else {
|
||||
item.community_name = "Sin Comunidad Asignada";
|
||||
return item;
|
||||
}
|
||||
}));
|
||||
})
|
||||
.then(data => {
|
||||
|
@ -87,9 +92,6 @@ const AdministradoresComunidad = () => {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async function getCommunites() {
|
||||
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
|
@ -314,7 +316,6 @@ const AdministradoresComunidad = () => {
|
|||
detail: 'Administrador de comunidad actualizado',
|
||||
life: 3000,
|
||||
})
|
||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador de Comunidad de vivienda Actualizada', life: 3000 });
|
||||
|
||||
listaAdmin();
|
||||
setCommunityId('');
|
||||
|
|
|
@ -107,6 +107,7 @@ const AdministradoresSistema = () => {
|
|||
|
||||
} else {
|
||||
if (_admin._id) {
|
||||
|
||||
fetch('http://localhost:4000/user/updateAdminSystem/', {
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
|
|
|
@ -8,7 +8,7 @@ import { Toast } from 'primereact/toast';
|
|||
import { Dialog } from 'primereact/dialog';
|
||||
import { Toolbar } from 'primereact/toolbar';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faClock, faHome, faHomeAlt, faUserAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faAt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
|
@ -41,11 +41,10 @@ const AreasComunes = () => {
|
|||
const [submitted, setSubmitted] = useState(false);
|
||||
const toast = useRef(null);
|
||||
const dt = useRef(null);
|
||||
|
||||
const [cookies, setCookie] = useCookies();
|
||||
const [changeStatusAreaDialog, setChangeStatusAreaDialog] = useState(false);
|
||||
|
||||
|
||||
const [areaDialog, setAreaDialog] = useState(false);
|
||||
const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar")
|
||||
|
||||
async function getCommonAreas() {
|
||||
await fetch(`http://localhost:4000/commonArea/findByCommunity/${cookies.community_id}`, { method: 'GET' })
|
||||
|
@ -57,7 +56,7 @@ const AreasComunes = () => {
|
|||
if (item.bookable == '1') {
|
||||
item.bookable_text = 'Necesaria';
|
||||
} else {
|
||||
item.bookable_text = 'No es necesarioa';
|
||||
item.bookable_text = 'No es necesaria';
|
||||
}
|
||||
|
||||
if (item.status == '1') {
|
||||
|
@ -69,7 +68,6 @@ const AreasComunes = () => {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
data = data.filter(
|
||||
(val) => val.status != -1,
|
||||
)
|
||||
|
@ -81,17 +79,27 @@ const AreasComunes = () => {
|
|||
getCommonAreas();
|
||||
}, []);
|
||||
|
||||
const findIndexById = (id) => {
|
||||
let index = -1;
|
||||
for (let i = 0; i < commonAreaList.length; i++) {
|
||||
if (commonAreaList[i]._id === id) {
|
||||
index = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
const saveCommonArea = () => {
|
||||
let _common_areas = [...commonAreaList];
|
||||
let _common_area = { ...commonArea };
|
||||
_common_area.community_id = cookies.community_id;
|
||||
if (
|
||||
commonArea.name &&
|
||||
commonArea.hourMin < commonArea.hourMax
|
||||
) {
|
||||
let _common_areas = [...commonAreaList];
|
||||
let _common_area = { ...commonArea };
|
||||
_common_area.community_id = cookies.community_id;
|
||||
|
||||
// console.log(houses)
|
||||
fetch('http://localhost:4000/commonArea/createCommonArea', {
|
||||
if (commonArea._id) {
|
||||
fetch('http://localhost:4000/commonArea/updateCommonArea', {
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(_common_area),
|
||||
|
@ -108,6 +116,8 @@ const AreasComunes = () => {
|
|||
return data.message;
|
||||
})
|
||||
.then((data) => {
|
||||
const index = findIndexById(commonArea._id);
|
||||
|
||||
if (data) {
|
||||
if (data.bookable == '1') {
|
||||
data.bookable_text = 'Necesaria';
|
||||
|
@ -123,15 +133,16 @@ const AreasComunes = () => {
|
|||
data.status_text = 'Eliminado';
|
||||
}
|
||||
}
|
||||
_common_areas.push(data);
|
||||
_common_areas[index] = _common_area;
|
||||
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Registro exitoso',
|
||||
detail: 'Área Común Creada',
|
||||
summary: 'Actualización exitosa',
|
||||
detail: 'Área Común Actualizada',
|
||||
life: 3000,
|
||||
});
|
||||
setCommonAreaList(_common_areas);
|
||||
setAreaDialog(false);
|
||||
setCommonArea(emptyCommonArea);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
@ -144,12 +155,71 @@ const AreasComunes = () => {
|
|||
});
|
||||
|
||||
});
|
||||
} else {
|
||||
// console.log(houses)
|
||||
fetch('http://localhost:4000/commonArea/createCommonArea', {
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(_common_area),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.status != 201 && response.status != 200)
|
||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||
else return response.json();
|
||||
})
|
||||
.then(function (data) {
|
||||
return data.message;
|
||||
})
|
||||
.then((data) => {
|
||||
|
||||
if (data) {
|
||||
if (data.bookable == '1') {
|
||||
data.bookable_text = 'Necesaria';
|
||||
} else {
|
||||
data.bookable_text = 'No es necesaria';
|
||||
}
|
||||
|
||||
if (data.status == '1') {
|
||||
data.status_text = 'Activo';
|
||||
} else if (data.status == '0') {
|
||||
data.status_text = 'Inactivo';
|
||||
} else {
|
||||
data.status_text = 'Eliminado';
|
||||
}
|
||||
}
|
||||
_common_areas.push(_common_area);
|
||||
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Registro exitoso',
|
||||
detail: 'Área Común Registrado',
|
||||
life: 3000,
|
||||
});
|
||||
setCommonAreaList(_common_areas);
|
||||
setAreaDialog(false);
|
||||
|
||||
setCommonArea(emptyCommonArea);
|
||||
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Ocurrió un error con el fetch', err);
|
||||
toast.current.show({
|
||||
severity: 'danger',
|
||||
summary: 'Error',
|
||||
detail: 'No se pudo registrar el área común',
|
||||
life: 3000
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
} else {
|
||||
setSubmitted(true);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const deleteCommonArea = () => {
|
||||
fetch('http://localhost:4000/commonArea/deleteCommonArea/' + commonArea._id, {
|
||||
cache: 'no-cache',
|
||||
|
@ -283,8 +353,6 @@ const AreasComunes = () => {
|
|||
setDeleteCommonAreasDialog(true);
|
||||
};
|
||||
|
||||
|
||||
|
||||
const hideChangeStatusAreaDialog = () => {
|
||||
setChangeStatusAreaDialog(false);
|
||||
};
|
||||
|
@ -294,6 +362,27 @@ const AreasComunes = () => {
|
|||
setChangeStatusAreaDialog(true);
|
||||
};
|
||||
|
||||
const hideAreaDialog = () => {
|
||||
setSubmitted(false);
|
||||
setAreaDialog(false);
|
||||
setCommonArea(emptyCommonArea);
|
||||
setSaveButtonTitle('Registrar');
|
||||
|
||||
};
|
||||
|
||||
const openNewArea = () => {
|
||||
setCommonArea(emptyCommonArea);
|
||||
setAreaDialog(true);
|
||||
setSubmitted(false);
|
||||
};
|
||||
|
||||
const editArea = (area) => {
|
||||
setCommonArea({ ...area });
|
||||
setAreaDialog(true);
|
||||
setSaveButtonTitle('Actualizar');
|
||||
|
||||
};
|
||||
|
||||
const actionsCommonArea = (rowData) => {
|
||||
let icono = '';
|
||||
let text = '';
|
||||
|
@ -307,15 +396,21 @@ const AreasComunes = () => {
|
|||
|
||||
return (
|
||||
<div className="actions">
|
||||
<Button
|
||||
icon="pi pi-pencil"
|
||||
className="p-button-rounded p-button-success my-2 mx-2"
|
||||
onClick={() => editArea(rowData)}
|
||||
title="Editar Área Común"
|
||||
/>
|
||||
<Button
|
||||
icon={`${icono}`}
|
||||
className="p-button-rounded p-button-warning mt-2 mx-2"
|
||||
className="p-button-rounded p-button-warning my-2 mx-2"
|
||||
onClick={() => confirmChangeStatusArea(rowData)}
|
||||
title={`${text}`}
|
||||
/>
|
||||
<Button
|
||||
icon="pi pi-trash"
|
||||
className="p-button-rounded p-button-danger mt-2"
|
||||
className="p-button-rounded p-button-danger my-2 mx-2"
|
||||
onClick={() => confirmDeleteCommonArea(rowData)}
|
||||
/>
|
||||
</div>
|
||||
|
@ -335,6 +430,32 @@ const AreasComunes = () => {
|
|||
setCommonArea(_commonArea);
|
||||
};
|
||||
|
||||
const onTimeChange = (e, name) => {
|
||||
e.target.value.split(':')[1] = "00";
|
||||
const val = (e.target && e.target.value.split(':')[0]) || '';
|
||||
let _area = { ...commonArea };
|
||||
document.getElementById(`${name}`).value = val + ":00";
|
||||
_area[`${name}`] = val + ":00";
|
||||
setCommonArea(_area);
|
||||
};
|
||||
|
||||
const areaDialogFooter = (
|
||||
<>
|
||||
<Button
|
||||
label={`${saveButtonTitle}`}
|
||||
icon="pi pi-check"
|
||||
className="p-button-primary"
|
||||
onClick={saveCommonArea}
|
||||
/>
|
||||
<Button
|
||||
label="Cerrar"
|
||||
icon="pi pi-times"
|
||||
className="p-button-text"
|
||||
onClick={hideAreaDialog}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
const deleteCommonAreaDialogFooter = (
|
||||
<>
|
||||
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteCommonAreaDialog} />
|
||||
|
@ -370,7 +491,18 @@ const AreasComunes = () => {
|
|||
return (
|
||||
<React.Fragment>
|
||||
<div className="my-2">
|
||||
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedCommonAreas || !selectedCommonAreas.length} />
|
||||
<Button
|
||||
label="Agregar Área Común"
|
||||
icon="pi pi-plus"
|
||||
className="p-button-primary mr-2"
|
||||
onClick={openNewArea}
|
||||
/>
|
||||
<Button label="Eliminar"
|
||||
icon="pi pi-trash"
|
||||
className="p-button-danger"
|
||||
onClick={confirmDeleteSelected}
|
||||
disabled={!selectedCommonAreas || !selectedCommonAreas.length}
|
||||
/>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
)
|
||||
|
@ -401,7 +533,7 @@ const AreasComunes = () => {
|
|||
const headerName = (
|
||||
<>
|
||||
<p>{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> {' '}
|
||||
<FontAwesomeIcon icon={faHomeAlt} style={{ color: "#C08135" }} /> {' '}
|
||||
Nombre
|
||||
</p>
|
||||
</>
|
||||
|
@ -411,7 +543,7 @@ const AreasComunes = () => {
|
|||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#D7A86E" }} />{' '}
|
||||
<FontAwesomeIcon icon={faClock} style={{ color: "#D7A86E" }} />{' '}
|
||||
Hora de apertura
|
||||
</p>
|
||||
</>
|
||||
|
@ -420,7 +552,7 @@ const AreasComunes = () => {
|
|||
const headerHourMax = (
|
||||
<>
|
||||
<p> {' '}
|
||||
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: "#C08135" }} />{' '}
|
||||
<FontAwesomeIcon icon={faClock} style={{ color: "#C08135" }} />{' '}
|
||||
Hora de cierre
|
||||
</p>
|
||||
</>
|
||||
|
@ -488,26 +620,154 @@ const AreasComunes = () => {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="grid">
|
||||
<div className="col-12">
|
||||
<Toast ref={toast} />
|
||||
<div className="card">
|
||||
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
|
||||
<DataTable ref={dt} value={commonAreaList} dataKey="_id" paginator rows={5} selection={selectedCommonAreas} onSelectionChange={(e) => setSelectedCommonAreas(e.value)}
|
||||
scrollable scrollHeight="400px" scrollDirection="both" header={header}
|
||||
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
|
||||
<DataTable ref={dt} value={commonAreaList} dataKey="_id" paginator rows={10} selection={selectedCommonAreas} onSelectionChange={(e) => setSelectedCommonAreas(e.value)}
|
||||
scrollable scrollHeight="700px" scrollDirection="both" header={header}
|
||||
rowsPerPageOptions={[10, 20, 30]} className="datatable-responsive mt-3"
|
||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} áreas comunes"
|
||||
globalFilter={globalFilter} emptyMessage="No hay áreas comunes registrados.">
|
||||
<Column selectionMode="multiple" headerStyle={{ width: '3rem' }}></Column>
|
||||
<Column field="name" sortable header={headerName} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="hourMin" header={headerHourMin} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }} alignFrozen="left"></Column>
|
||||
<Column field="hourMax" header={headerHourMax} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> </Column>
|
||||
<Column field="hourMin" sortable header={headerHourMin} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }} alignFrozen="left"></Column>
|
||||
<Column field="hourMax" sortable header={headerHourMax} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> </Column>
|
||||
<Column field="bookable" sortable header={headerBookable} body={bookableBodyTemplate} style={{ flexGrow: 1, flexBasis: '200px', minWidth: '200px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="status" sortable header={headerStatus} body={statusBodyTemplate} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsCommonArea}></Column>
|
||||
<Column style={{ flexGrow: 1, flexBasis: '80px', minWidth: '80px' }} body={actionsCommonArea}></Column>
|
||||
</DataTable>
|
||||
<Dialog
|
||||
visible={areaDialog}
|
||||
style={{ width: '650px' }}
|
||||
header="Agregar Área Común"
|
||||
modal
|
||||
className="p-fluid"
|
||||
footer={areaDialogFooter}
|
||||
onHide={hideAreaDialog}
|
||||
>
|
||||
{commonArea && (
|
||||
<div className="p-fluid formgrid grid">
|
||||
<div className="field col-12 md:col-12">
|
||||
<label htmlFor="name">Nombre</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<InputText id="name"
|
||||
type="text"
|
||||
onChange={(e) => onInputChange(e, 'name')}
|
||||
value={commonArea.name}
|
||||
required
|
||||
autoFocus
|
||||
className={classNames({
|
||||
'p-invalid': submitted && commonArea.name === '',
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && commonArea.name === '' && (
|
||||
<small className="p-invalid">Nombre es requirido.</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="hourMin">Hora apertura</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-clock"></i>
|
||||
</span>
|
||||
<InputText id="hourMin"
|
||||
type="time"
|
||||
min="00:00" max="23:59"
|
||||
step="3600"
|
||||
onChange={(e) => onTimeChange(e, 'hourMin')}
|
||||
value={commonArea.hourMin}
|
||||
required
|
||||
autoFocus
|
||||
className={classNames({
|
||||
'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin),
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && (
|
||||
<small className="p-invalid">La hora de apertura debe ser menor que la hora de cierre.</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="hourMax">Hora de cierre</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-clock"></i>
|
||||
</span>
|
||||
<InputText id="hourMax"
|
||||
type="time"
|
||||
min="00:00"
|
||||
max="23:59"
|
||||
step="3600"
|
||||
onChange={(e) => onTimeChange(e, 'hourMax')}
|
||||
value={commonArea.hourMax}
|
||||
required
|
||||
autoFocus
|
||||
className={classNames({
|
||||
'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin),
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && (
|
||||
<small className="p-invalid">La hora de cierre debe ser mayor que la hora de apertura</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-12">
|
||||
<label htmlFor="bookable">¿Necesita Reservación?</label>
|
||||
<div className="formgrid grid align-items-end" style={{ marginTop: '12px', width: '300px' }}>
|
||||
<div className="field-radiobutton col-6">
|
||||
|
||||
<RadioButton
|
||||
inputId="bookable1"
|
||||
name="bookable"
|
||||
value="1"
|
||||
onChange={onBookableChange}
|
||||
checked={commonArea.bookable === 1}
|
||||
/>
|
||||
<label htmlFor="bookable1">
|
||||
<span className="p-icon-input-khaki">
|
||||
<i className="pi pi-check status status-1"></i> Sí
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div className="field-radiobutton col-6">
|
||||
<RadioButton
|
||||
inputId="bookable2"
|
||||
name="bookable"
|
||||
value="0"
|
||||
onChange={onBookableChange}
|
||||
checked={commonArea.bookable === 0}
|
||||
/>
|
||||
<label htmlFor="bookable2">
|
||||
<span className="p-icon-input-khaki">
|
||||
<i className="pi pi-times status status-0"></i> No
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
)}
|
||||
</Dialog>
|
||||
<Dialog visible={deleteCommonAreaDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteCommonAreaDialogFooter} onHide={hideDeleteCommonAreaDialog}>
|
||||
<div className="flex align-items-center justify-content-center">
|
||||
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||
|
@ -542,123 +802,6 @@ const AreasComunes = () => {
|
|||
</Dialog>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div className="card">
|
||||
<h5>Registro de área común</h5>
|
||||
<div className="p-fluid formgrid grid">
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="name">Nombre</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<InputText id="name"
|
||||
type="text"
|
||||
onChange={(e) => onInputChange(e, 'name')}
|
||||
value={commonArea.name}
|
||||
required
|
||||
autoFocus
|
||||
className={classNames({
|
||||
'p-invalid': submitted && commonArea.name === '',
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && commonArea.name === '' && (
|
||||
<small className="p-invalid">Nombre es requirido.</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="hourMin">Hora apertura</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<InputText id="hourMin"
|
||||
type="time"
|
||||
min="00:00" max="23:59"
|
||||
step="3600000"
|
||||
onChange={(e) => onInputChange(e, 'hourMin')}
|
||||
value={commonArea.hourMin}
|
||||
required
|
||||
autoFocus
|
||||
className={classNames({
|
||||
'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin),
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && (
|
||||
<small className="p-invalid">La hora de apertura debe ser menor que la hora de cierre.</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="hourMax">Hora de cierre</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<InputText id="hourMax"
|
||||
type="time"
|
||||
min="00:00" max="23:59"
|
||||
step="3600000"
|
||||
onChange={(e) => onInputChange(e, 'hourMax')}
|
||||
value={commonArea.hourMax}
|
||||
required
|
||||
autoFocus
|
||||
className={classNames({
|
||||
'p-invalid': submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin),
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && compareTimesMinRequired(commonArea.hourMax, commonArea.hourMin) && (
|
||||
<small className="p-invalid">La hora de cierre debe ser mayor que la hora de apertura</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="bookable">¿Necesita Reservación?</label>
|
||||
<div className="formgrid grid align-items-end" style={{ marginTop: '12px', width: '300px' }}>
|
||||
<div className="field-radiobutton col-6">
|
||||
|
||||
<RadioButton
|
||||
inputId="bookable1"
|
||||
name="bookable"
|
||||
value="1"
|
||||
onChange={onBookableChange}
|
||||
checked={commonArea.bookable === '1'}
|
||||
/>
|
||||
<label htmlFor="bookable1">
|
||||
<span className="p-icon-input-khaki">
|
||||
<i className="pi pi-check status status-1"></i> Sí
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div className="field-radiobutton col-6">
|
||||
<RadioButton
|
||||
inputId="bookable2"
|
||||
name="bookable"
|
||||
value="0"
|
||||
onChange={onBookableChange}
|
||||
checked={commonArea.bookable === '0'}
|
||||
/>
|
||||
<label htmlFor="bookable2">
|
||||
<span className="p-icon-input-khaki">
|
||||
<i className="pi pi-times status status-0"></i> No
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button label="Registrar" onClick={saveCommonArea}></Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
);
|
||||
|
|
|
@ -315,10 +315,8 @@ const Communities = () => {
|
|||
setDeleteCommunitiesDialog(true);
|
||||
};
|
||||
|
||||
|
||||
const infoCommunity = async (community) => {
|
||||
await tenantsList(community._id);
|
||||
|
||||
setCommunity({ ...community });
|
||||
setCommunityDialog(true);
|
||||
};
|
||||
|
@ -383,9 +381,8 @@ const Communities = () => {
|
|||
);
|
||||
}
|
||||
|
||||
|
||||
const deleteCommunity = () => {
|
||||
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
|
||||
fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
|
||||
cache: 'no-cache',
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
|
@ -403,8 +400,8 @@ const Communities = () => {
|
|||
.then(
|
||||
function (response) {
|
||||
|
||||
let _community = communities.filter(val => val._id !== community._id);
|
||||
setCommunities(_community);
|
||||
let _community = communitiesList.filter(val => val._id !== community._id);
|
||||
setCommunitiesList(_community);
|
||||
setDeleteCommunityDialog(false);
|
||||
setCommunity(emptyCommunity);
|
||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 });
|
||||
|
@ -416,7 +413,6 @@ const Communities = () => {
|
|||
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);
|
||||
_communities = _communities.filter(
|
||||
(val) => val.status != -1,
|
||||
|
|
|
@ -72,6 +72,9 @@ const Inquilinos = () => {
|
|||
item.number_house = 'Sin vivienda asignada'
|
||||
}
|
||||
})
|
||||
data = data.filter(
|
||||
(val) => val.status != -1,
|
||||
);
|
||||
setTenants(data)
|
||||
})
|
||||
}
|
||||
|
@ -156,9 +159,9 @@ const Inquilinos = () => {
|
|||
.catch((error) => console.log(`Ocurrió un error: ${error}`))
|
||||
} else setSubmitted(true)
|
||||
} else {
|
||||
let _tenant = { ..._tenant, number_house: houseNumber };
|
||||
let _tenant = { ...tenant, number_house: houseNumber };
|
||||
console.log(`Actualizando inquilino: ${_tenant}`)
|
||||
fetch(`http://localhost:4000/user/updateUser/${tenant._id}`, {
|
||||
fetch(`http://localhost:4000/user/updateTenant/${tenant._id}`, {
|
||||
cache: 'no-cache',
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(_tenant),
|
||||
|
@ -170,6 +173,17 @@ const Inquilinos = () => {
|
|||
console.log(`Hubo un error en el servicio: ${response.status}`)
|
||||
else return response.json()
|
||||
}).then(() => {
|
||||
|
||||
fetch('http://localhost:4000/community/saveTenant',
|
||||
{
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(_tenant),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
});
|
||||
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Éxito',
|
||||
|
|
|
@ -0,0 +1,219 @@
|
|||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { Button } from 'primereact/button';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { Toolbar } from 'primereact/toolbar';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faUserAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faAt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
|
||||
import { useCookies } from 'react-cookie';
|
||||
import classNames from 'classnames';
|
||||
|
||||
const InvitadosComunidad = () => {
|
||||
const [cookies] = useCookies();
|
||||
const [globalFilter, setGlobalFilter] = useState(null);
|
||||
const [invitados, setInvitados] = useState([]);
|
||||
const [selectedInvitados, setSelectedInvitados] = useState([]);
|
||||
const tableRef = useRef(null);
|
||||
const toastRef = useRef(null);
|
||||
|
||||
const getInvitados = async () => {
|
||||
await fetch(`http://localhost:4000/guest/allGuests`, {
|
||||
method: 'GET',
|
||||
})
|
||||
.then((response) => response.json())
|
||||
.then((data) => data.message)
|
||||
.then((data) => {
|
||||
data = data.filter(
|
||||
(invitado) => invitado.community === cookies.community_id,
|
||||
);
|
||||
setInvitados(data);
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getInvitados();
|
||||
}, [getInvitados, invitados]);
|
||||
|
||||
const leftToolbarTemplate = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="my-2">
|
||||
<p>Boton Eliminar aqui</p>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const rightToolbarTemplate = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Button
|
||||
label="Exportar"
|
||||
icon="pi pi-upload"
|
||||
className="p-button-help"
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const headerName = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} /> Nombre
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerTenant = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} /> Inquilino
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerLastName = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#D7A86E' }} />{' '}
|
||||
Apellido(s)
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerPlate = (
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: '#C08135' }} />{' '}
|
||||
Placa
|
||||
</p>
|
||||
);
|
||||
|
||||
const headerDNI = (
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: '#C08135' }} />{' '}
|
||||
Identificación
|
||||
</p>
|
||||
);
|
||||
|
||||
const headerEmail = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faAt} style={{ color: '#D7A86E' }} /> Correo
|
||||
Electrónico
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerPhone = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faPhoneAlt} style={{ color: '#C08135' }} />{' '}
|
||||
Teléfono
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerTemplate = (
|
||||
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||
<h5 className="m-0">Invitados</h5>
|
||||
<span className="block mt-2 md:mt-0 p-input-icon-left">
|
||||
<i className="pi pi-search" />
|
||||
<InputText
|
||||
type="search"
|
||||
onInput={(e) => setGlobalFilter(e.target.value)}
|
||||
placeholder="Buscar..."
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div className="grid">
|
||||
<div className="col-12">
|
||||
<Toast ref={toastRef} />
|
||||
<div className="card">
|
||||
<Toolbar
|
||||
className="mb-4"
|
||||
left={leftToolbarTemplate}
|
||||
right={rightToolbarTemplate}
|
||||
/>
|
||||
<DataTable
|
||||
ref={tableRef}
|
||||
value={invitados}
|
||||
dataKey="_id"
|
||||
paginator
|
||||
rows={10}
|
||||
selection={selectedInvitados}
|
||||
onSelectionChange={(e) => setSelectedInvitados(e.value)}
|
||||
scrollable
|
||||
scrollHeight="500px"
|
||||
scrollWidth="100%"
|
||||
scrollDirection="both"
|
||||
header={headerTemplate}
|
||||
rowsPerPageOptions={[10, 20, 30]}
|
||||
className="datatable-responsive mt-3"
|
||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||
currentPageReportTemplate="{currentPage} de {totalPages}"
|
||||
globalFilter={globalFilter}
|
||||
emptyMessageTemplate="No se encontraron invitados"
|
||||
>
|
||||
<Column field="name" header="Nombre" sortable header={headerName} />
|
||||
<Column
|
||||
field="last_name"
|
||||
header="Apellido"
|
||||
sortable
|
||||
header={headerLastName}
|
||||
/>
|
||||
<Column field="dni" header="DNI" sortable header={headerDNI} />
|
||||
<Column
|
||||
field="number_plate"
|
||||
header="Placa"
|
||||
sortable
|
||||
header={headerPlate}
|
||||
/>
|
||||
<Column
|
||||
field="telefono"
|
||||
header="Teléfono"
|
||||
sortable
|
||||
header={headerPhone}
|
||||
/>
|
||||
<Column
|
||||
field="email"
|
||||
header="Email"
|
||||
sortable
|
||||
header={headerEmail}
|
||||
/>
|
||||
<Column
|
||||
field="date_entry"
|
||||
header="Fecha de registro"
|
||||
sortable
|
||||
header={headerName}
|
||||
/>
|
||||
<Column
|
||||
field="tenant_name"
|
||||
header="Inquilino"
|
||||
sortable
|
||||
header={headerTenant}
|
||||
/>
|
||||
</DataTable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default React.memo(InvitadosComunidad);
|
|
@ -0,0 +1,361 @@
|
|||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { useCookies } from "react-cookie";
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faMapLocationDot } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faHashtag } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
const PerfilAdminComunidad = () => {
|
||||
|
||||
let emptyAdminCommunity = {
|
||||
_id: null,
|
||||
dni: '',
|
||||
name: '',
|
||||
last_name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
confirmPassword: '',
|
||||
community_id: '',
|
||||
community_name: '',
|
||||
user_type: '2',
|
||||
date_entry: new Date(),
|
||||
status: '1',
|
||||
status_text: '',
|
||||
};
|
||||
|
||||
let emptyCommunity = {
|
||||
_id: null,
|
||||
name: '',
|
||||
province: '',
|
||||
canton: '',
|
||||
district: '',
|
||||
phone: '',
|
||||
num_houses: 0,
|
||||
status: '1',
|
||||
status_text: '',
|
||||
date_entry: new Date(),
|
||||
houses: [],
|
||||
};
|
||||
|
||||
const [admin, setAdmin] = useState(emptyAdminCommunity);
|
||||
const [community, setCommunity] = useState(emptyCommunity);
|
||||
const [cookies, setCookie] = useCookies();
|
||||
const [globalFilter, setGlobalFilter] = useState(null);
|
||||
//para el perfil de la comunidad
|
||||
const [tenants, setTenants] = useState([]);
|
||||
const [commonAreaList, setCommonAreaList] = useState([]);
|
||||
const [provincesList, setProvincesList] = useState([]);
|
||||
const [cantonsList, setCantonsList] = useState([]);
|
||||
const [districtsList, setDistrictsList] = useState([]);
|
||||
|
||||
async function getProvinces() {
|
||||
const response = await fetch('assets/demo/data/provincias.json', {
|
||||
method: 'GET',
|
||||
});
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
|
||||
async function getCantons() {
|
||||
const response = await fetch('assets/demo/data/cantones.json', {
|
||||
method: 'GET',
|
||||
});
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
|
||||
async function getDistricts() {
|
||||
const response = await fetch('assets/demo/data/distritos.json', {
|
||||
method: 'GET',
|
||||
});
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
async function getAdmin() {
|
||||
await fetch('http://localhost:4000/user/findUserById/' + cookies.id, { method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
.then(data => {
|
||||
let item = data.message;
|
||||
setAdmin(item);
|
||||
if (item.community_id || item.community_id != '') {
|
||||
getCommunity()
|
||||
} else {
|
||||
item.community_name = "Sin Comunidad Asignada";
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getAdmin();
|
||||
}, [])
|
||||
|
||||
async function getCommunity() {
|
||||
let pList = await getProvinces();
|
||||
let cList = await getCantons();
|
||||
let dList = await getDistricts();
|
||||
await fetch(`http://localhost:4000/community/findCommunityName/${cookies.community_id}`, { method: 'GET' })
|
||||
.then((response2) => response2.json())
|
||||
.then(data => data.message)
|
||||
.then(data => {
|
||||
data.province = pList.find((p) => p.code === data.province).name;
|
||||
data.canton = cList.find((p) => p.code === data.canton).name;
|
||||
data.district = dList.find((p) => p.code === data.district).name;
|
||||
setCommunity(data)
|
||||
})
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getCommunity();
|
||||
}, [])
|
||||
|
||||
async function tenantsList(id) {
|
||||
await fetch(`http://localhost:4000/user/findTenants/${id}`, { method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
.then(data => data.message)
|
||||
.then(data => {
|
||||
data = data.filter(
|
||||
(val) => val.status != -1,
|
||||
)
|
||||
setTenants(data)
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
tenantsList(cookies.community_id);
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
function findNameTenant(tenant_id) {
|
||||
let name = '';
|
||||
if (tenant_id == '') {
|
||||
name = 'Sin inquilino';
|
||||
} else {
|
||||
let tenant = tenants.find(t => t._id == tenant_id)
|
||||
name = tenant['name'] + ' ' + tenant['last_name'];
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
const headerNumberHouses = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faHashtag} style={{ color: '#D7A86E' }} />{' '}
|
||||
Código de vivienda
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerTenant = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} />{' '}
|
||||
Inquilino
|
||||
</p>
|
||||
|
||||
</>
|
||||
);
|
||||
|
||||
const tenantsBodyTemplate = (rowData) => {
|
||||
let tenants = rowData.tenants;
|
||||
let name = 'Sin inquilino';
|
||||
if (rowData.tenants) {
|
||||
name = findNameTenant(tenants.tenant_id);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
{name}
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="grid justify-content-center">
|
||||
|
||||
<div className="col-6" >
|
||||
<div className="card">
|
||||
<div className='container text-center'>
|
||||
<div className='row my-4'>
|
||||
<div className=" col-12 md:col-12">
|
||||
<h3>Información Básica</h3>
|
||||
</div>
|
||||
<div className=" col-6 md:col-6">
|
||||
<i className="pi pi-home icon-khaki"></i>
|
||||
<p><strong>Nombre Completo</strong></p>
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup justify-content-evenly">
|
||||
<p>{admin.name + ' ' + admin.last_name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className=" col-6 md:col-6">
|
||||
<i className="pi pi-id-card icon-khaki"></i>
|
||||
<p><strong>Identificación</strong></p>
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup justify-content-evenly">
|
||||
<p>{admin.dni}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className='row my-4'>
|
||||
<div className=" col-12 md:col-12">
|
||||
<h3>Contacto</h3>
|
||||
</div>
|
||||
<div className=" col-6 md:col-6">
|
||||
<i className="pi pi-at icon-khaki"></i>
|
||||
<p><strong>Correo Electrónico</strong></p>
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup justify-content-evenly">
|
||||
<p>{admin.email}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className=" col-6 md:col-6">
|
||||
<i className="pi pi-phone icon-khaki"></i>
|
||||
<p><strong>Número de teléfono</strong></p>
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup justify-content-evenly">
|
||||
<p>{admin.phone}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div className='col-6'>
|
||||
{community && (
|
||||
<div className="card">
|
||||
<div className='container text-center'>
|
||||
<div className='row my-4'>
|
||||
<div className=" col-12 md:col-12">
|
||||
<h3>Comunidad Asignada</h3>
|
||||
</div>
|
||||
<div className=" col-4 md:col-4">
|
||||
<i className="pi pi-home icon-khaki"></i>
|
||||
<p><strong>Nombre</strong></p>
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup align-items-center justify-content-evenly">
|
||||
<p>{community.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-4 md:col-4">
|
||||
<i className="pi pi-phone icon-khaki"></i>
|
||||
<p><strong>Teléfono Administrativo</strong></p>
|
||||
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup align-items-center justify-content-evenly">
|
||||
<p>{community.phone}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div className=" col-4 col-md-4 md:col-4">
|
||||
<i className="pi pi-map-marker icon-khaki"></i>
|
||||
|
||||
<p><strong>Ubicación</strong></p>
|
||||
<div className="p-0 col-10 md:col-10">
|
||||
<div className="p-inputgroup align-items-center justify-content-evenly">
|
||||
<p>{community.province}, {community.canton}, {community.district}</p>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className='row my-5'>
|
||||
<div className=" col-12 md:col-12">
|
||||
<h3>Viviendas de la Comunidad</h3>
|
||||
</div>
|
||||
<div className=" col-12 md:col-12">
|
||||
<i className="pi pi-hashtag icon-khaki"></i>
|
||||
|
||||
<p><strong>Cantidad de Viviendas</strong></p>
|
||||
<div className="p-0 col-2 md:col-2" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup justify-content-evenly">
|
||||
<p>{community.num_houses}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
<div className='grid justify-content-center'>
|
||||
|
||||
<div className='col-6'>
|
||||
{community && (
|
||||
<div className="card">
|
||||
<div className='container text-center'>
|
||||
|
||||
<div className='row my-5'>
|
||||
<div className=" col-12 md:col-12">
|
||||
|
||||
|
||||
<h3> Viviendas</h3>
|
||||
<div className="p-0 col-12 md:col-12" style={{ margin: '0 auto' }}>
|
||||
<div className="p-inputgroup justify-content-evenly">
|
||||
<DataTable
|
||||
value={community.houses}
|
||||
paginator
|
||||
rows={5}
|
||||
scrollable
|
||||
scrollHeight="200px"
|
||||
scrollDirection="both"
|
||||
rowsPerPageOptions={[5, 10, 25]}
|
||||
className="datatable-responsive mt-3"
|
||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} viviendas"
|
||||
globalFilter={globalFilter}
|
||||
>
|
||||
<Column
|
||||
field="number_house"
|
||||
header={headerNumberHouses}
|
||||
style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px' }}
|
||||
></Column>
|
||||
<Column
|
||||
field="tenants"
|
||||
header={headerTenant}
|
||||
body={tenantsBodyTemplate}
|
||||
style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px' }}
|
||||
></Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(PerfilAdminComunidad)
|
|
@ -16,7 +16,7 @@ import classNames from 'classnames';
|
|||
|
||||
const RegistroComunicado = () => {
|
||||
|
||||
let emptyComunicado = {
|
||||
const emptyComunicado = {
|
||||
_id: null,
|
||||
post: '',
|
||||
user_id: '',
|
||||
|
@ -29,6 +29,7 @@ const RegistroComunicado = () => {
|
|||
|
||||
const [comunicado, setComunicado] = useState(emptyComunicado);
|
||||
const [comunicados, setComunicados] = useState([]);
|
||||
const [saveButtonLabel, setSaveButtonLabel] = useState('Registrar');
|
||||
const [comunicadoId, setComunicadoId] = useState(null);
|
||||
const [showDeleteDialog, setShowDeleteDialog] = useState(false);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
|
@ -48,8 +49,9 @@ const RegistroComunicado = () => {
|
|||
}
|
||||
|
||||
const saveComunicado = () => {
|
||||
if (comunicado._id === null) {
|
||||
var data = {
|
||||
post: document.getElementById('txt_comunicado').value,
|
||||
post: comunicado.post,
|
||||
user_id: cookies.id,
|
||||
community_id: cookies.community_id
|
||||
};
|
||||
|
@ -67,12 +69,40 @@ const RegistroComunicado = () => {
|
|||
else
|
||||
return response.json();
|
||||
}).then((_response) => {
|
||||
setComunicado(emptyComunicado);
|
||||
listaComunis();
|
||||
}).catch(
|
||||
err => console.log('Ocurrió un error con el fetch', err)
|
||||
);
|
||||
} else {
|
||||
const data = {
|
||||
_id: comunicado._id,
|
||||
post: comunicado.post,
|
||||
user_id: comunicado.user_id,
|
||||
community_id: comunicado.community_id
|
||||
};
|
||||
|
||||
fetch(`http://localhost:4000/post/updatePost/${comunicado._id}`, {
|
||||
cache: 'no-cache',
|
||||
method: 'PUT',
|
||||
body: JSON.stringify(data),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
}).then((response) => {
|
||||
if (response.status != 200)
|
||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||
else
|
||||
return response.json();
|
||||
}).then((_response) => {
|
||||
setComunicado(emptyComunicado);
|
||||
setSaveButtonLabel('Registrar');
|
||||
listaComunis();
|
||||
}).catch(
|
||||
err => console.log('Ocurrió un error con el fetch', err)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
const header = (
|
||||
<React.Fragment>
|
||||
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||
|
@ -111,9 +141,27 @@ const RegistroComunicado = () => {
|
|||
)
|
||||
}
|
||||
|
||||
const edit = (rowData) => {
|
||||
setComunicado(rowData);
|
||||
setComunicadoId(rowData._id);
|
||||
setSaveButtonLabel('Actualizar');
|
||||
}
|
||||
|
||||
const cancelEdit = () => {
|
||||
setComunicado(emptyComunicado);
|
||||
setSaveButtonLabel('Registrar');
|
||||
setComunicadoId(null);
|
||||
}
|
||||
|
||||
const actions = (rowData) => {
|
||||
return (
|
||||
<div className="actions">
|
||||
<Button
|
||||
icon="pi pi-pencil"
|
||||
className="p-button-rounded p-button-success mt-2 mx-2"
|
||||
onClick={() => edit(rowData)}
|
||||
title="Editar"
|
||||
/>
|
||||
<Button
|
||||
icon='pi pi-trash'
|
||||
className='p-button-rounded p-button-danger mt-2 mx-2'
|
||||
|
@ -167,7 +215,7 @@ const RegistroComunicado = () => {
|
|||
>
|
||||
<div className="flex align-items-center justify-content-center">
|
||||
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||
{comunicado && <span>¿Estás seguro que desea eliminar el aviso "<b>{comunicado.post}</b>"?</span>}
|
||||
{comunicado && <span>¿Está seguro que desea eliminar el aviso "<b>{comunicado.post}</b>"?</span>}
|
||||
</div>
|
||||
</Dialog>
|
||||
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
|
||||
|
@ -200,11 +248,35 @@ const RegistroComunicado = () => {
|
|||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-pencil"></i>
|
||||
</span>
|
||||
<InputTextarea id="txt_comunicado" rows="4" />
|
||||
<InputTextarea
|
||||
value={comunicado.post}
|
||||
placeholder="Ingrese el contenido del comunicado"
|
||||
onChange={(e) => setComunicado({ ...comunicado, post: e.target.value })}
|
||||
id="txt_comunicado"
|
||||
type="text"
|
||||
autoResize
|
||||
rows={5}
|
||||
cols={50}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<Button label="Registrar" onClick={saveComunicado} />
|
||||
<div style={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
gap: "10px",
|
||||
width: "100%"
|
||||
}}>
|
||||
<Button
|
||||
label={`${saveButtonLabel}`}
|
||||
onClick={saveComunicado}
|
||||
/>
|
||||
{saveButtonLabel === 'Actualizar' && (
|
||||
<Button
|
||||
label="Cancelar"
|
||||
onClick={cancelEdit}
|
||||
className="p-button-danger" />)}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -0,0 +1,860 @@
|
|||
import React, { useEffect, useState, useRef } from 'react';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import { Button } from 'primereact/button';
|
||||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import classNames from 'classnames';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { Toolbar } from 'primereact/toolbar';
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
||||
import { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faClockFour } from '@fortawesome/free-solid-svg-icons';
|
||||
import { useCookies } from 'react-cookie';
|
||||
|
||||
const Reservations = () => {
|
||||
let emptyReservation = {
|
||||
_id: null,
|
||||
date: '',
|
||||
time: '',
|
||||
user_id: '',
|
||||
user_name: '',
|
||||
common_area_id: '',
|
||||
common_area_name: '',
|
||||
community_id: '',
|
||||
status: '1',
|
||||
status_text: '',
|
||||
date_entry: new Date(),
|
||||
};
|
||||
|
||||
|
||||
const [reservations, setReservations] = useState([]);
|
||||
const [reservation, setReservation] = useState(emptyReservation);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
const [selectedReservations, setSelectedReservations] = useState(null);
|
||||
const [globalFilter, setGlobalFilter] = useState(null);
|
||||
const [deleteReservationDialog, setDeleteReservationDialog] = useState(false);
|
||||
const [deleteReservationsDialog, setDeleteReservationsDialog] = useState(false);
|
||||
const toast = useRef(null);
|
||||
const dt = useRef(null);
|
||||
const [cookies, setCookies] = useCookies()
|
||||
const [areas, setAreas] = useState([]);
|
||||
const [area, setArea] = useState();
|
||||
const [areaId, setAreaId] = useState();
|
||||
const [tenants, setTenants] = useState([]);
|
||||
const [tenantId, setTenantId] = useState();
|
||||
const [saveButtonTitle, setSaveButtonTitle] = useState("Registrar")
|
||||
const [reservationDialog, setReservationDialog] = useState(false);
|
||||
const [dateMax, setDateMax] = useState();
|
||||
|
||||
|
||||
async function tenantsList(id) {
|
||||
await fetch(`http://localhost:4000/user/findTenants/${id}`,
|
||||
{ method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
.then(data => data.message)
|
||||
.then(data => {
|
||||
data = data.filter(
|
||||
(val) => val.status != -1,
|
||||
)
|
||||
data = data.map(item => {
|
||||
item.password = '';
|
||||
return item;
|
||||
})
|
||||
setTenants(data)
|
||||
});
|
||||
}
|
||||
|
||||
async function areasList(id) {
|
||||
await fetch(`http://localhost:4000/commonArea/findByCommunity/${id}`,
|
||||
{ method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
.then(data => data.message)
|
||||
.then(data => {
|
||||
data = data.filter(
|
||||
(val) => val.status != -1
|
||||
)
|
||||
data = data.filter(
|
||||
(val) => val.bookable == 1,
|
||||
)
|
||||
setAreas(data)
|
||||
});
|
||||
}
|
||||
|
||||
async function reservationList(id) {
|
||||
await fetch(`http://localhost:4000/reservation/findReservations/${id}`,
|
||||
{ method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
.then(data => data.message)
|
||||
.then(data => {
|
||||
data = data.filter(
|
||||
(val) => val.status != -1,
|
||||
)
|
||||
data.map((item) => {
|
||||
|
||||
item.date = formatDateString(item.date)
|
||||
|
||||
if (item.status == '1') {
|
||||
item.status_text = 'Activo';
|
||||
} else if (item.status == '0') {
|
||||
item.status_text = 'Inactivo';
|
||||
}
|
||||
})
|
||||
|
||||
setReservations(data)
|
||||
});
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
tenantsList(cookies.community_id);
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
areasList(cookies.community_id);
|
||||
}, [])
|
||||
|
||||
|
||||
reservations.map((item) => {
|
||||
let tenant = tenants.find(item2 => item2._id == item.user_id);
|
||||
if (tenant) {
|
||||
item.user_name = tenant.name + ' ' + tenant.last_name;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
reservationList(cookies.community_id);
|
||||
}, [])
|
||||
|
||||
const saveReservation = () => {
|
||||
|
||||
let _reservations = [...reservations];
|
||||
let _reservation = { ...reservation };
|
||||
|
||||
if (_reservation.date && _reservation.time && tenantId && areaId
|
||||
&& !validationTime()
|
||||
&& !validationIsSameUser() && !validationIsReservation()) {
|
||||
_reservation.common_area_name = areas.find(item => item._id == areaId).name;
|
||||
let tenant = tenants.find(item => item._id == tenantId);
|
||||
_reservation.user_name = tenant.name + ' ' + tenant.last_name;
|
||||
_reservation.user_id = tenantId;
|
||||
_reservation.common_area_id = areaId;
|
||||
_reservation.community_id = cookies.community_id;
|
||||
|
||||
|
||||
if (_reservation.status == '1') {
|
||||
_reservation.status_text = 'Activo';
|
||||
} else if (_reservation.status == '0') {
|
||||
_reservation.status_text = 'Inactivo';
|
||||
}
|
||||
fetch('http://localhost:4000/reservation/createReservation/', {
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(_reservation),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then((response) => {
|
||||
if (response.status !== 200 && response.status !== 201)
|
||||
console.log(`Hubo un error en el servicio: ${response.status}`)
|
||||
else return response.json()
|
||||
}).then((response) => {
|
||||
let _r = response.message;
|
||||
_r.date = formatDateString(_r.date)
|
||||
_reservations.push(_r);
|
||||
setReservations(_reservations)
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Éxito',
|
||||
detail: 'Reservación realizada',
|
||||
life: 3000,
|
||||
});
|
||||
|
||||
setReservationDialog(false)
|
||||
setAreaId('')
|
||||
setTenantId('')
|
||||
})
|
||||
|
||||
} else {
|
||||
setSubmitted(true);
|
||||
}
|
||||
}
|
||||
|
||||
const actionsReservation = (rowData) => {
|
||||
return (
|
||||
<div className="actions">
|
||||
<Button
|
||||
icon="pi pi-trash"
|
||||
className="p-button-rounded p-button-danger mt-2 mx-2"
|
||||
onClick={() => confirmDeleteReservation(rowData)}
|
||||
title="Eliminar Reserva"
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const confirmDeleteReservation = (reservation) => {
|
||||
setReservation(reservation);
|
||||
setDeleteReservationDialog(true);
|
||||
};
|
||||
|
||||
const confirmDeleteSelected = () => {
|
||||
setDeleteReservationsDialog(true);
|
||||
};
|
||||
|
||||
const cancelEdit = () => {
|
||||
setReservation(emptyReservation);
|
||||
setSaveButtonTitle('Registrar');
|
||||
setAreaId('');
|
||||
setTenantId('');
|
||||
}
|
||||
|
||||
const hideNewReservationDialog = () => {
|
||||
setSubmitted(false);
|
||||
setReservationDialog(false);
|
||||
setReservation(emptyReservation);
|
||||
setAreaId('');
|
||||
setTenantId('');
|
||||
};
|
||||
|
||||
const openNewReservation = () => {
|
||||
setReservation(emptyReservation);
|
||||
setReservationDialog(true);
|
||||
setSubmitted(false);
|
||||
};
|
||||
|
||||
|
||||
|
||||
const hideDeleteReservationDialog = () => {
|
||||
setDeleteReservationDialog(false);
|
||||
};
|
||||
|
||||
const hideDeleteReservationsDialog = () => {
|
||||
setDeleteReservationsDialog(false);
|
||||
};
|
||||
|
||||
|
||||
const deleteReservation = () => {
|
||||
|
||||
|
||||
fetch('http://localhost:4000/reservation/deleteReservation/' + reservation._id, {
|
||||
cache: 'no-cache',
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
})
|
||||
.then(function (response) {
|
||||
if (response.status != 201 || response.status != 200)
|
||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||
else return response.json();
|
||||
})
|
||||
.then(function (response) {
|
||||
let _reservation = reservations.filter(
|
||||
(val) => (val._id !== reservation._id),
|
||||
);
|
||||
|
||||
setReservations(_reservation);
|
||||
setDeleteReservationDialog(false);
|
||||
setReservation(emptyReservation);
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Éxito',
|
||||
detail: 'Reservación Eliminada',
|
||||
life: 3000,
|
||||
});
|
||||
})
|
||||
.catch((err) => {
|
||||
console.log('Ocurrió un error con el fetch', err);
|
||||
toast.current.show({
|
||||
severity: 'danger',
|
||||
summary: 'Error',
|
||||
detail: 'Reservación no se pudo Eliminar',
|
||||
life: 3000,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
const deleteSelectedReservations = () => {
|
||||
let _reservations = reservations.filter(
|
||||
(val) => (!selectedReservations.includes(val)),
|
||||
);
|
||||
selectedReservations.map((item) => {
|
||||
fetch('http://localhost:4000/reservation/deleteReservation/' + item._id, {
|
||||
cache: 'no-cache',
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
});
|
||||
_reservations = _reservations.filter(
|
||||
(val) => val.status != -1,
|
||||
)
|
||||
setReservations(_reservations);
|
||||
setDeleteReservationsDialog(false);
|
||||
setSelectedReservations(null);
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Éxito',
|
||||
detail: 'Reservaciones Eliminadas',
|
||||
life: 3000,
|
||||
});
|
||||
};
|
||||
|
||||
const leftToolbarTemplate = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<div className="my-2">
|
||||
<Button
|
||||
label="Nueva Reservación"
|
||||
icon="pi pi-plus"
|
||||
className="p-button-success mr-2"
|
||||
onClick={openNewReservation}
|
||||
/>
|
||||
<Button
|
||||
label="Eliminar"
|
||||
icon="pi pi-trash"
|
||||
className="p-button-danger"
|
||||
onClick={confirmDeleteSelected}
|
||||
disabled={!selectedReservations || !selectedReservations.length}
|
||||
/>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const rightToolbarTemplate = () => {
|
||||
return (
|
||||
<React.Fragment>
|
||||
<Button
|
||||
label="Exportar"
|
||||
icon="pi pi-upload"
|
||||
className="p-button-help"
|
||||
/>
|
||||
</React.Fragment>
|
||||
);
|
||||
};
|
||||
|
||||
const reservationDialogFooter = (
|
||||
<>
|
||||
<Button
|
||||
label="Cerrar"
|
||||
icon="pi pi-times"
|
||||
className="p-button-text"
|
||||
onClick={hideNewReservationDialog}
|
||||
/>
|
||||
|
||||
</>
|
||||
);
|
||||
|
||||
const deleteReservationDialogFooter = (
|
||||
<>
|
||||
<Button
|
||||
label="No"
|
||||
icon="pi pi-times"
|
||||
className="p-button-text"
|
||||
onClick={hideDeleteReservationDialog}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
icon="pi pi-check"
|
||||
className="p-button-text"
|
||||
onClick={deleteReservation}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
const deleteReservationsDialogFooter = (
|
||||
<>
|
||||
<Button
|
||||
label="No"
|
||||
icon="pi pi-times"
|
||||
className="p-button-text"
|
||||
onClick={hideDeleteReservationsDialog}
|
||||
/>
|
||||
<Button
|
||||
label="Yes"
|
||||
icon="pi pi-check"
|
||||
className="p-button-text"
|
||||
onClick={deleteSelectedReservations}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
const header = (
|
||||
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||
<h5 className="m-0">
|
||||
Reservaciones <i className="fal fa-user"></i>
|
||||
</h5>
|
||||
<span className="block mt-2 md:mt-0 p-input-icon-left">
|
||||
<i className="pi pi-search" />
|
||||
<InputText
|
||||
type="search"
|
||||
onInput={(e) => setGlobalFilter(e.target.value)}
|
||||
placeholder="Buscar..."
|
||||
/>
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
const headerDate = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faClockFour} style={{ color: '#C08135' }} />
|
||||
Fecha de Reserva
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerTime = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faClockFour} style={{ color: '#D7A86E' }} />{' '}
|
||||
Hora de Reserva
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerUser = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} />{' '}
|
||||
Inquilino
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
|
||||
const headerArea = (
|
||||
<>
|
||||
<p>
|
||||
{' '}
|
||||
<FontAwesomeIcon icon={faHome} style={{ color: '#D7A86E' }} />{' '}
|
||||
Área Reservada
|
||||
</p>
|
||||
</>
|
||||
);
|
||||
|
||||
const headerStatus = (
|
||||
<>
|
||||
<p> {' '}
|
||||
<FontAwesomeIcon icon={faCircleQuestion} style={{ color: "#C08135" }} />{' '}
|
||||
Estado
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
|
||||
const statusBodyTemplate = (rowData) => {
|
||||
return (
|
||||
<>
|
||||
<span
|
||||
className={`status status-${rowData.status}`}
|
||||
>
|
||||
{rowData.status_text}
|
||||
</span>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const onInputChange = (e, name) => {
|
||||
const val = (e.target && e.target.value) || '';
|
||||
let _reservation = { ...reservation };
|
||||
_reservation[`${name}`] = val;
|
||||
|
||||
setReservation(_reservation);
|
||||
};
|
||||
|
||||
const onTimeChange = (e) => {
|
||||
e.target.value.split(':')[1] = "00";
|
||||
const val = (e.target && e.target.value.split(':')[0]) || '';
|
||||
let _reservation = { ...reservation };
|
||||
document.getElementById('time').value = val + ":00";
|
||||
_reservation['time'] = val + ":00";
|
||||
setReservation(_reservation);
|
||||
|
||||
};
|
||||
|
||||
const handleAreas = (e) => {
|
||||
const getAreaId = e.target.value;
|
||||
setAreaId(getAreaId);
|
||||
let area = areas.find(item => item._id == getAreaId);
|
||||
setArea(area)
|
||||
}
|
||||
|
||||
const handleTenants = (e) => {
|
||||
const getTenantId = e.target.value;
|
||||
setTenantId(getTenantId);
|
||||
}
|
||||
|
||||
const aList = areas.map((item) => ({
|
||||
label: item.name,
|
||||
value: item._id,
|
||||
}));
|
||||
|
||||
const tList = tenants.map((item) => ({
|
||||
label: item.name,
|
||||
value: item._id,
|
||||
}));
|
||||
|
||||
function validationTime() {
|
||||
let value = true;
|
||||
const [hourR, minuteR] = reservation.time.split(':');
|
||||
if (hourR != "") {
|
||||
const [hourMin, minuteMin] = area.hourMin.split(':');
|
||||
const [hourMax, minuteMax] = area.hourMax.split(':');
|
||||
if ((parseInt(hourR) >= parseInt(hourMin)) && (parseInt(hourR) <= parseInt(hourMax))) {
|
||||
value = false;
|
||||
}
|
||||
} else {
|
||||
value = false;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
function formatDateString(dateString) {
|
||||
let date = new Date(dateString).toLocaleDateString("es-CL");
|
||||
return date;
|
||||
}
|
||||
|
||||
function validationIsReservation() {
|
||||
if (reservation.date && reservation.time && areaId) {
|
||||
let date1 = new Date(reservation.date).toJSON().split('T')[0];
|
||||
let date2 = date1.split('-')[2] + '-' + date1.split('-')[1] + '-' + date1.split('-')[0];
|
||||
|
||||
let booked = reservations.filter(item => item.common_area_id == areaId
|
||||
&& item.date == date2
|
||||
&& item.time == reservation.time);
|
||||
|
||||
if (booked.length > 0) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function validationIsSameUser() {
|
||||
if (reservation.date && tenantId && areaId) {
|
||||
let date1 = new Date(reservation.date).toJSON().split('T')[0];
|
||||
let date2 = date1.split('-')[2] + '-' + date1.split('-')[1] + '-' + date1.split('-')[0];
|
||||
|
||||
let booked = reservations.filter(item => item.common_area_id == areaId
|
||||
&& item.date == date2
|
||||
&& item.user_id == tenantId);
|
||||
if (booked.length >= 2) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const getDateMax = () => {
|
||||
let today = new Date();
|
||||
today.setDate(today.getDate() + 7)
|
||||
return today.toJSON().split('T')[0];
|
||||
}
|
||||
|
||||
const getDateMin = () => {
|
||||
let today = new Date();
|
||||
today.setDate(today.getDate() - 1)
|
||||
return today.toJSON().split('T')[0];
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid">
|
||||
<div className="col-12">
|
||||
<Toast ref={toast} />
|
||||
<div className="card">
|
||||
<Toolbar
|
||||
className="mb-4"
|
||||
left={leftToolbarTemplate}
|
||||
right={rightToolbarTemplate}
|
||||
></Toolbar>
|
||||
<DataTable
|
||||
ref={dt}
|
||||
value={reservations}
|
||||
dataKey="_id"
|
||||
paginator
|
||||
rows={5}
|
||||
selection={selectedReservations}
|
||||
onSelectionChange={(e) => setSelectedReservations(e.value)}
|
||||
scrollable
|
||||
scrollHeight="400px"
|
||||
scrollDirection="both"
|
||||
header={header}
|
||||
rowsPerPageOptions={[5, 10, 25]}
|
||||
className="datatable-responsive mt-3"
|
||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} reservaciones de la comunidad"
|
||||
globalFilter={globalFilter}
|
||||
emptyMessage="No hay reservas registradas."
|
||||
>
|
||||
<Column
|
||||
selectionMode="multiple"
|
||||
headerStyle={{ width: '3rem' }}
|
||||
></Column>
|
||||
<Column
|
||||
field="date"
|
||||
sortable
|
||||
header={headerDate}
|
||||
style={{
|
||||
flexGrow: 1,
|
||||
flexBasis: '160px',
|
||||
minWidth: '160px',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
></Column>
|
||||
<Column
|
||||
field="time"
|
||||
sortable
|
||||
header={headerTime}
|
||||
style={{
|
||||
flexGrow: 1,
|
||||
flexBasis: '160px',
|
||||
minWidth: '160px',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
alignFrozen="left"
|
||||
></Column>
|
||||
<Column
|
||||
field="user_name"
|
||||
header={headerUser}
|
||||
style={{
|
||||
flexGrow: 1,
|
||||
flexBasis: '160px',
|
||||
minWidth: '160px',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
></Column>
|
||||
<Column
|
||||
field="common_area_name"
|
||||
header={headerArea}
|
||||
style={{
|
||||
flexGrow: 1,
|
||||
flexBasis: '160px',
|
||||
minWidth: '160px',
|
||||
wordBreak: 'break-word',
|
||||
}}
|
||||
></Column>
|
||||
<Column
|
||||
field="status"
|
||||
sortable
|
||||
header={headerStatus}
|
||||
body={statusBodyTemplate}
|
||||
style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
|
||||
</Column>
|
||||
<Column
|
||||
|
||||
style={{ flexGrow: 1, flexBasis: '80px', minWidth: '80px' }}
|
||||
body={actionsReservation}
|
||||
></Column>
|
||||
</DataTable>
|
||||
<Dialog
|
||||
visible={reservationDialog}
|
||||
style={{ width: '650px' }}
|
||||
header="Reservar Área para Inquilino"
|
||||
modal
|
||||
className="p-fluid"
|
||||
footer={reservationDialogFooter}
|
||||
onHide={hideNewReservationDialog}
|
||||
>
|
||||
{reservation && (
|
||||
<div className="p-fluid formgrid grid">
|
||||
<div className="field col-12 md:col-12">
|
||||
<label htmlFor="common_area_id">Área Común: </label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<Dropdown
|
||||
placeholder="--Seleccione el Area Común a Reservar--"
|
||||
id="common_area_id"
|
||||
value={areaId}
|
||||
options={aList}
|
||||
onChange={handleAreas}
|
||||
required autoFocus
|
||||
className={
|
||||
classNames({ 'p-invalid': submitted && !areaId })}
|
||||
/>
|
||||
</div>
|
||||
{submitted
|
||||
&& !areaId
|
||||
&& <small className="p-invalid">Área Común es requerida.</small>}
|
||||
</div>
|
||||
</div>
|
||||
{area &&
|
||||
<>
|
||||
<div className="field col-6 md:col-6">
|
||||
<label htmlFor="name">Fecha</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<InputText
|
||||
id="date"
|
||||
onChange={(e) => onInputChange(e, 'date')}
|
||||
required
|
||||
autoFocus
|
||||
min={getDateMin()}
|
||||
max={getDateMax()}
|
||||
type="date"
|
||||
lang='es-CL'
|
||||
value={reservation.date}
|
||||
className={classNames({
|
||||
'p-invalid': submitted && (reservation.date === ''
|
||||
|| validationIsReservation()),
|
||||
})}
|
||||
/>
|
||||
|
||||
</div>
|
||||
{submitted && reservation.date === '' && (
|
||||
<small className="p-invalid">Fecha es requirida.</small>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="field col-6 md:col-6">
|
||||
<label htmlFor="name">Hora de Reservación</label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<InputText
|
||||
id="time"
|
||||
value={reservation.time}
|
||||
onChange={(e) => onTimeChange(e)}
|
||||
required
|
||||
autoFocus
|
||||
type="time"
|
||||
step='3600'
|
||||
className={classNames({
|
||||
'p-invalid': submitted && (reservation.time === ''
|
||||
|| validationTime() || validationIsReservation()),
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted && reservation.time === '' && (
|
||||
<small className="p-invalid">Hora es requirido.</small>
|
||||
)}
|
||||
{submitted && validationTime() && (
|
||||
<small className="p-invalid">La hora de inicio debe ser mayor de {area.hourMin} y menor de {area.hourMax} .</small>
|
||||
)}
|
||||
{submitted && validationIsReservation() && (
|
||||
<small className="p-invalid">Ya hay una reservación en la fecha y hora ingresada.</small>
|
||||
)}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
}
|
||||
<div className="field col-12 md:col-12">
|
||||
<label htmlFor="user_id">Inquilino: </label>
|
||||
<div className="p-0 col-12 md:col-12">
|
||||
<div className="p-inputgroup">
|
||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||
<i className="pi pi-home"></i>
|
||||
</span>
|
||||
<Dropdown
|
||||
placeholder="--Seleccione el Inquilino a Reservar--"
|
||||
id="user_id"
|
||||
value={tenantId}
|
||||
options={tList}
|
||||
onChange={handleTenants}
|
||||
required autoFocus
|
||||
className={
|
||||
classNames({
|
||||
'p-invalid': submitted && (!tenantId
|
||||
|| validationIsSameUser())
|
||||
})}
|
||||
/>
|
||||
</div>
|
||||
{submitted
|
||||
&& !tenantId
|
||||
&& <small className="p-invalid">Inquilino es requerido.</small>}
|
||||
{submitted && validationIsSameUser() && (
|
||||
<small className="p-invalid">El inquilino no puede reservar más de dos veces el mismo día.</small>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div style={{
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
gap: "10px",
|
||||
width: "100%"
|
||||
}}>
|
||||
<Button
|
||||
label={`${saveButtonTitle}`}
|
||||
onClick={saveReservation}
|
||||
/>
|
||||
{saveButtonTitle === 'Actualizar' && (
|
||||
<Button
|
||||
label="Cancelar"
|
||||
onClick={cancelEdit}
|
||||
className="p-button-danger" />)}
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Dialog>
|
||||
<Dialog
|
||||
visible={deleteReservationDialog}
|
||||
style={{ width: '450px' }}
|
||||
header="Confirmar"
|
||||
modal
|
||||
footer={deleteReservationDialogFooter}
|
||||
onHide={hideDeleteReservationDialog}
|
||||
>
|
||||
<div className="flex align-items-center justify-content-center">
|
||||
<i
|
||||
className="pi pi-exclamation-triangle mr-3"
|
||||
style={{ fontSize: '2rem' }}
|
||||
/>
|
||||
{reservation && (
|
||||
<span>
|
||||
¿Estás seguro que desea eliminar la reservación de <b>{reservation.user_name}</b>?
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Dialog>
|
||||
<Dialog
|
||||
visible={deleteReservationsDialog}
|
||||
style={{ width: '450px' }}
|
||||
header="Confirmar"
|
||||
modal
|
||||
footer={deleteReservationsDialogFooter}
|
||||
onHide={hideDeleteReservationsDialog}
|
||||
>
|
||||
<div className="flex align-items-center justify-content-center">
|
||||
<i
|
||||
className="pi pi-exclamation-triangle mr-3"
|
||||
style={{ fontSize: '2rem' }}
|
||||
/>
|
||||
{selectedReservations && (
|
||||
<span>
|
||||
¿Está seguro eliminar las reservaciones
|
||||
seleccionadas?
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Reservations);
|
Loading…
Reference in New Issue