Merge pull request #115 from DeimosPr4/UH-registroComunidadVivienda
registroComunidadVivienda
This commit is contained in:
commit
b8492a2ea7
|
@ -78,16 +78,15 @@ export class AppController {
|
|||
@Body('canton') canton: string,
|
||||
@Body('district') district: string,
|
||||
@Body('num_houses') num_houses: number,
|
||||
@Body('phone') phone: number,
|
||||
@Body('quote') quote: number,
|
||||
@Body('phone') phone: string,
|
||||
@Body('status') status: string,
|
||||
@Body('date_entry') date_entry: Date,
|
||||
@Body('houses') houses: [{}],
|
||||
@Body('houses') houses: [],
|
||||
|
||||
) {
|
||||
return this.appService.createCommunity(name, province, canton,
|
||||
district, num_houses, phone,
|
||||
quote, status, date_entry, houses);
|
||||
status, date_entry, houses);
|
||||
}
|
||||
|
||||
@Get('community/allCommunities')
|
||||
|
|
|
@ -131,11 +131,11 @@ export class AppService {
|
|||
|
||||
//POST parameter from API
|
||||
createCommunity(name: string, province: string, canton: string, district: string
|
||||
, num_houses: number, phone: number, quote: number, status: string, date_entry: Date, houses: [{}]) {
|
||||
, num_houses: number, phone: string, status: string, date_entry: Date, houses: []) {
|
||||
const pattern = { cmd: 'createCommunity' };
|
||||
const payload = {
|
||||
name: name, province: province, canton: canton, district: district, num_houses: num_houses,
|
||||
phone: phone, quote: quote, status: status, date_entry: date_entry, houses
|
||||
phone: phone, status: status, date_entry: date_entry, houses: houses
|
||||
};
|
||||
return this.clientCommunityApp
|
||||
.send<string>(pattern, payload)
|
||||
|
|
|
@ -27,24 +27,20 @@ export class CommunitiesService {
|
|||
.find()
|
||||
.setOptions({ sanitizeFilter: true })
|
||||
.exec()
|
||||
.then( async community => {
|
||||
if(community){
|
||||
.then(async community => {
|
||||
if (community) {
|
||||
await Promise.all(community.map(async c => {
|
||||
//buscar al usuario con el id de la comunidad anexado
|
||||
let admin = await this.findCommunityAdmin(c["_id"], "2")
|
||||
if(admin){
|
||||
if (admin) {
|
||||
c["id_admin"] = admin["_id"]
|
||||
c["name_admin"] = admin["name"]
|
||||
}
|
||||
return c
|
||||
}))
|
||||
|
||||
console.log(community)
|
||||
}
|
||||
|
||||
return community;
|
||||
return community;
|
||||
})
|
||||
|
||||
//buscar al usuario con el id de la comunidad anexado
|
||||
}
|
||||
|
||||
findOne(id: string): Promise<Community> {
|
||||
|
|
|
@ -10,7 +10,7 @@ export class Community {
|
|||
@Prop()
|
||||
id_admin: string;
|
||||
|
||||
@Prop({ default: "Sin Administrador" })
|
||||
@Prop()
|
||||
name_admin: string ;
|
||||
|
||||
@Prop()
|
||||
|
@ -29,10 +29,7 @@ export class Community {
|
|||
num_houses: number;
|
||||
|
||||
@Prop()
|
||||
phone: number;
|
||||
|
||||
@Prop()
|
||||
quote: number;
|
||||
phone: string;
|
||||
|
||||
@Prop()
|
||||
status: string;
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
||||
import e from 'express';
|
||||
import { Document } from 'mongoose';
|
||||
import { empty } from 'rxjs';
|
||||
import { Tenant, TenantSchema } from './tenant.schema';
|
||||
|
||||
|
||||
|
@ -9,13 +11,10 @@ export class House extends Document {
|
|||
@Prop({ default: " " })
|
||||
number_house: string;
|
||||
|
||||
@Prop({ default: " " })
|
||||
description: string;
|
||||
|
||||
@Prop({ default: "desocupada" })
|
||||
state: string;
|
||||
|
||||
@Prop({ type: TenantSchema, default: " " })
|
||||
@Prop({ type: TenantSchema })
|
||||
tenants: Tenant;
|
||||
}
|
||||
export const HouseSchema = SchemaFactory.createForClass(House);
|
|
@ -4,7 +4,7 @@ import { Schema, Prop, SchemaFactory } from '@nestjs/mongoose';
|
|||
|
||||
@Schema()
|
||||
export class Tenant {
|
||||
@Prop()
|
||||
@Prop( {default: ''})
|
||||
tenant_id: string;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,489 @@
|
|||
[
|
||||
{
|
||||
"name": "San José",
|
||||
"code": "101",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Escazú",
|
||||
"code": "102",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Desamparados",
|
||||
"code": "103",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Puriscal",
|
||||
"code": "104",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Tarrazú",
|
||||
"code": "105",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Aserrí",
|
||||
"code": "106",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Mora",
|
||||
"code": "107",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Goicoechea",
|
||||
"code": "108",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Santa Ana",
|
||||
"code": "109",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Alajuelita",
|
||||
"code": "110",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Vasquez de Coronado",
|
||||
"code": "111",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Acosta",
|
||||
"code": "112",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Tibás",
|
||||
"code": "113",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Moravia",
|
||||
"code": "114",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Montes de Oca",
|
||||
"code": "115",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Turrubares",
|
||||
"code": "116",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Dota",
|
||||
"code": "117",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Curridabat",
|
||||
"code": "118",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Pérez Zeledón",
|
||||
"code": "119",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "León Cortés",
|
||||
"code": "120",
|
||||
"parentCode": "1",
|
||||
"isoParent": "SJ"
|
||||
},
|
||||
{
|
||||
"name": "Alajuela",
|
||||
"code": "201",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "San Ramón",
|
||||
"code": "202",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Grecia",
|
||||
"code": "203",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "San Mateo",
|
||||
"code": "204",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Atenas",
|
||||
"code": "205",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Naranjo",
|
||||
"code": "206",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Palmares",
|
||||
"code": "207",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Poás",
|
||||
"code": "208",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Orotina",
|
||||
"code": "209",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "San Carlos",
|
||||
"code": "210",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Alfaro Ruiz",
|
||||
"code": "211",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Valverde Vega",
|
||||
"code": "212",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Upala",
|
||||
"code": "213",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Los Chiles",
|
||||
"code": "214",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Guatuso",
|
||||
"code": "215",
|
||||
"parentCode": "2",
|
||||
"isoParent": "ALAJ"
|
||||
},
|
||||
{
|
||||
"name": "Cartago",
|
||||
"code": "301",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "Paraíso",
|
||||
"code": "302",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "La Unión",
|
||||
"code": "303",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "Jiménez",
|
||||
"code": "304",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "Turrialba",
|
||||
"code": "305",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "Alvarado",
|
||||
"code": "306",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "Oreamuno",
|
||||
"code": "307",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "El Guarco",
|
||||
"code": "308",
|
||||
"parentCode": "3",
|
||||
"isoParent": "CAR"
|
||||
},
|
||||
{
|
||||
"name": "Heredia",
|
||||
"code": "401",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Barva",
|
||||
"code": "402",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Santo Domingo",
|
||||
"code": "403",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Santa Bárbara",
|
||||
"code": "404",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "San Rafael",
|
||||
"code": "405",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "San Isidro",
|
||||
"code": "406",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Belén",
|
||||
"code": "407",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Flores",
|
||||
"code": "408",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "San Pablo",
|
||||
"code": "409",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Sarapiquí ",
|
||||
"code": "410",
|
||||
"parentCode": "4",
|
||||
"isoParent": "HER"
|
||||
},
|
||||
{
|
||||
"name": "Liberia",
|
||||
"code": "501",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Nicoya",
|
||||
"code": "502",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Santa Cruz",
|
||||
"code": "503",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Bagaces",
|
||||
"code": "504",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Carrillo",
|
||||
"code": "505",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Cañas",
|
||||
"code": "506",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Abangares",
|
||||
"code": "507",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Tilarán",
|
||||
"code": "508",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Nandayure",
|
||||
"code": "509",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "La Cruz",
|
||||
"code": "510",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Hojancha",
|
||||
"code": "511",
|
||||
"parentCode": "5",
|
||||
"isoParent": "GUANA"
|
||||
},
|
||||
{
|
||||
"name": "Puntarenas",
|
||||
"code": "601",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Esparza",
|
||||
"code": "602",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Buenos Aires",
|
||||
"code": "603",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Montes de Oro",
|
||||
"code": "604",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Osa",
|
||||
"code": "605",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Aguirre",
|
||||
"code": "606",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Golfito",
|
||||
"code": "607",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Coto Brus",
|
||||
"code": "608",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Parrita",
|
||||
"code": "609",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Corredores",
|
||||
"code": "610",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Garabito",
|
||||
"code": "611",
|
||||
"parentCode": "6",
|
||||
"isoParent": "PUNT"
|
||||
},
|
||||
{
|
||||
"name": "Limón",
|
||||
"code": "701",
|
||||
"parentCode": "7",
|
||||
"isoParent": "LIM"
|
||||
},
|
||||
{
|
||||
"name": "Pococí",
|
||||
"code": "702",
|
||||
"parentCode": "7",
|
||||
"isoParent": "LIM"
|
||||
},
|
||||
{
|
||||
"name": "Siquirres ",
|
||||
"code": "703",
|
||||
"parentCode": "7",
|
||||
"isoParent": "LIM"
|
||||
},
|
||||
{
|
||||
"name": "Talamanca",
|
||||
"code": "704",
|
||||
"parentCode": "7",
|
||||
"isoParent": "LIM"
|
||||
},
|
||||
{
|
||||
"name": "Matina",
|
||||
"code": "705",
|
||||
"parentCode": "7",
|
||||
"isoParent": "LIM"
|
||||
},
|
||||
{
|
||||
"name": "Guácimo",
|
||||
"code": "706",
|
||||
"parentCode": "7",
|
||||
"isoParent": "LIM"
|
||||
}
|
||||
]
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,30 @@
|
|||
[
|
||||
{
|
||||
"name":"San José",
|
||||
"code":"1"
|
||||
},
|
||||
{
|
||||
"name":"Alajuela",
|
||||
"code":"2"
|
||||
},
|
||||
{
|
||||
"name":"Cartago",
|
||||
"code":"3"
|
||||
},
|
||||
{
|
||||
"name":"Heredia",
|
||||
"code":"4"
|
||||
},
|
||||
{
|
||||
"name":"Guanacaste",
|
||||
"code":"5"
|
||||
},
|
||||
{
|
||||
"name":"Puntarenas",
|
||||
"code":"6"
|
||||
},
|
||||
{
|
||||
"name":"Limón",
|
||||
"code":"7"
|
||||
}
|
||||
]
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
File diff suppressed because it is too large
Load Diff
|
@ -9,7 +9,7 @@
|
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<link rel="icon" type="image/x-icon" href="%PUBLIC_URL%/favicon.ico" />
|
||||
<link id="theme-link" rel="stylesheet" href="%PUBLIC_URL%/assets/themes/lara-light-indigo/theme.css">
|
||||
<link id="theme-link" rel="stylesheet" href="%PUBLIC_URL%/assets/themes/khaki/theme.css">
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
|
|
@ -2,14 +2,14 @@ import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|||
import { RadioButton } from 'primereact/radiobutton';
|
||||
import { InputSwitch } from 'primereact/inputswitch';
|
||||
import classNames from 'classnames';
|
||||
import {Button} from "primereact/button";
|
||||
import { Button } from "primereact/button";
|
||||
|
||||
export const AppConfig = (props) => {
|
||||
|
||||
const [active, setActive] = useState(false);
|
||||
const [scale, setScale] = useState(14);
|
||||
const [scales] = useState([12,13,14,15,16]);
|
||||
const [theme, setTheme] = useState('lara-light-indigo');
|
||||
const [scales] = useState([12, 13, 14, 15, 16]);
|
||||
const [theme, setTheme] = useState('khaki');
|
||||
const config = useRef(null);
|
||||
let outsideClickListener = useRef(null);
|
||||
|
||||
|
@ -96,14 +96,14 @@ export const AppConfig = (props) => {
|
|||
}
|
||||
});
|
||||
}
|
||||
},[])
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
let themeElement = document.getElementById('theme-link');
|
||||
const themeHref = 'assets/themes/' + theme + '/theme.css';
|
||||
replaceLink(themeElement, themeHref);
|
||||
|
||||
},[theme,replaceLink])
|
||||
}, [theme, replaceLink])
|
||||
|
||||
const isIE = () => {
|
||||
return /(MSIE|Trident\/|Edge\/)/i.test(window.navigator.userAgent)
|
||||
|
@ -119,7 +119,7 @@ export const AppConfig = (props) => {
|
|||
<button className="layout-config-button p-link" id="layout-config-button" onClick={toggleConfigurator}>
|
||||
<i className="pi pi-cog"></i>
|
||||
</button>
|
||||
<Button className="p-button-danger layout-config-close p-button-rounded p-button-text" icon="pi pi-times" onClick={hideConfigurator}/>
|
||||
<Button className="p-button-danger layout-config-close p-button-rounded p-button-text" icon="pi pi-times" onClick={hideConfigurator} />
|
||||
|
||||
<div className="layout-config-content">
|
||||
<h5 className="mt-0">Component Scale</h5>
|
||||
|
@ -127,7 +127,7 @@ export const AppConfig = (props) => {
|
|||
<Button icon="pi pi-minus" onClick={decrementScale} className="p-button-text" disabled={scale === scales[0]} />
|
||||
{
|
||||
scales.map((item) => {
|
||||
return <i className={classNames('pi pi-circle-on', {'scale-active': item === scale})} key={item}/>
|
||||
return <i className={classNames('pi pi-circle-on', { 'scale-active': item === scale })} key={item} />
|
||||
})
|
||||
}
|
||||
<Button icon="pi pi-plus" onClick={incrementScale} className="p-button-text" disabled={scale === scales[scales.length - 1]} />
|
||||
|
@ -165,22 +165,22 @@ export const AppConfig = (props) => {
|
|||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'bootstrap4-light-blue', 'light')}>
|
||||
<img src="assets/layout/images/themes/bootstrap4-light-blue.svg" alt="Bootstrap Light Blue"/>
|
||||
<img src="assets/layout/images/themes/bootstrap4-light-blue.svg" alt="Bootstrap Light Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'bootstrap4-light-purple', 'light')}>
|
||||
<img src="assets/layout/images/themes/bootstrap4-light-purple.svg" alt="Bootstrap Light Purple"/>
|
||||
<img src="assets/layout/images/themes/bootstrap4-light-purple.svg" alt="Bootstrap Light Purple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'bootstrap4-dark-blue', 'dark')}>
|
||||
<img src="assets/layout/images/themes/bootstrap4-dark-blue.svg" alt="Bootstrap Dark Blue"/>
|
||||
<img src="assets/layout/images/themes/bootstrap4-dark-blue.svg" alt="Bootstrap Dark Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'bootstrap4-dark-purple', 'dark')}>
|
||||
<img src="assets/layout/images/themes/bootstrap4-dark-purple.svg" alt="Bootstrap Dark Purple"/>
|
||||
<img src="assets/layout/images/themes/bootstrap4-dark-purple.svg" alt="Bootstrap Dark Purple" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -189,22 +189,27 @@ export const AppConfig = (props) => {
|
|||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'md-light-indigo', 'light')}>
|
||||
<img src="assets/layout/images/themes/md-light-indigo.svg" alt="Material Light Indigo"/>
|
||||
<img src="assets/layout/images/themes/md-light-indigo.svg" alt="Material Light Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'md-light-indigo', 'light')}>
|
||||
<img src="assets/layout/images/themes/md-light-indigo.svg" alt="Material Light Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'md-light-deeppurple', 'light')}>
|
||||
<img src="assets/layout/images/themes/md-light-deeppurple.svg" alt="Material Light DeepPurple"/>
|
||||
<img src="assets/layout/images/themes/md-light-deeppurple.svg" alt="Material Light DeepPurple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'md-dark-indigo', 'dark')}>
|
||||
<img src="assets/layout/images/themes/md-dark-indigo.svg" alt="Material Dark Indigo"/>
|
||||
<img src="assets/layout/images/themes/md-dark-indigo.svg" alt="Material Dark Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'md-dark-deeppurple', 'dark')}>
|
||||
<img src="assets/layout/images/themes/md-dark-deeppurple.svg" alt="Material Dark DeepPurple"/>
|
||||
<img src="assets/layout/images/themes/md-dark-deeppurple.svg" alt="Material Dark DeepPurple" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -213,22 +218,22 @@ export const AppConfig = (props) => {
|
|||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'mdc-light-indigo', 'light')}>
|
||||
<img src="assets/layout/images/themes/md-light-indigo.svg" alt="Material Light Indigo"/>
|
||||
<img src="assets/layout/images/themes/md-light-indigo.svg" alt="Material Light Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'mdc-light-deeppurple', 'light')}>
|
||||
<img src="assets/layout/images/themes/md-light-deeppurple.svg" alt="Material Light DeepPurple"/>
|
||||
<img src="assets/layout/images/themes/md-light-deeppurple.svg" alt="Material Light DeepPurple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'mdc-dark-indigo', 'dark')}>
|
||||
<img src="assets/layout/images/themes/md-dark-indigo.svg" alt="Material Dark Indigo"/>
|
||||
<img src="assets/layout/images/themes/md-dark-indigo.svg" alt="Material Dark Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'mdc-dark-deeppurple', 'dark')}>
|
||||
<img src="assets/layout/images/themes/md-dark-deeppurple.svg" alt="Material Dark DeepPurple"/>
|
||||
<img src="assets/layout/images/themes/md-dark-deeppurple.svg" alt="Material Dark DeepPurple" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -237,7 +242,7 @@ export const AppConfig = (props) => {
|
|||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'tailwind-light', 'light')}>
|
||||
<img src="assets/layout/images/themes/tailwind-light.png" alt="Tailwind Light"/>
|
||||
<img src="assets/layout/images/themes/tailwind-light.png" alt="Tailwind Light" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -246,51 +251,56 @@ export const AppConfig = (props) => {
|
|||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'fluent-light', 'light')}>
|
||||
<img src="assets/layout/images/themes/fluent-light.png" alt="Fluent Light"/>
|
||||
<img src="assets/layout/images/themes/fluent-light.png" alt="Fluent Light" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h6>PrimeOne Design - 2022</h6>
|
||||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'khaki', 'light')}>
|
||||
<img src="assets/layout/images/themes/lara-light-indigo.png" alt="Khaki" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-light-indigo', 'light')}>
|
||||
<img src="assets/layout/images/themes/lara-light-indigo.png" alt="Lara Light Indigo"/>
|
||||
<img src="assets/layout/images/themes/lara-light-indigo.png" alt="Lara Light Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-light-blue', 'light')}>
|
||||
<img src="assets/layout/images/themes/lara-light-blue.png" alt="Lara Light Blue"/>
|
||||
<img src="assets/layout/images/themes/lara-light-blue.png" alt="Lara Light Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-light-purple', 'light')}>
|
||||
<img src="assets/layout/images/themes/lara-light-purple.png" alt="Lara Light Purple"/>
|
||||
<img src="assets/layout/images/themes/lara-light-purple.png" alt="Lara Light Purple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-light-teal', 'light')}>
|
||||
<img src="assets/layout/images/themes/lara-light-teal.png" alt="Lara Light Teal"/>
|
||||
<img src="assets/layout/images/themes/lara-light-teal.png" alt="Lara Light Teal" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-dark-indigo', 'dark')}>
|
||||
<img src="assets/layout/images/themes/lara-dark-indigo.png" alt="Lara Dark Indigo"/>
|
||||
<img src="assets/layout/images/themes/lara-dark-indigo.png" alt="Lara Dark Indigo" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-dark-blue', 'dark')}>
|
||||
<img src="assets/layout/images/themes/lara-dark-blue.png" alt="Lara Dark Blue"/>
|
||||
<img src="assets/layout/images/themes/lara-dark-blue.png" alt="Lara Dark Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-dark-purple', 'dark')}>
|
||||
<img src="assets/layout/images/themes/lara-dark-purple.png" alt="Lara Dark Purple"/>
|
||||
<img src="assets/layout/images/themes/lara-dark-purple.png" alt="Lara Dark Purple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={(e) => changeTheme(e, 'lara-dark-teal', 'dark')}>
|
||||
<img src="assets/layout/images/themes/lara-dark-teal.png" alt="Lara Dark Teal"/>
|
||||
<img src="assets/layout/images/themes/lara-dark-teal.png" alt="Lara Dark Teal" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -299,62 +309,62 @@ export const AppConfig = (props) => {
|
|||
<div className="grid free-themes">
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'saga-blue', 'light')}>
|
||||
<img src="assets/layout/images/themes/saga-blue.png" alt="Saga Blue"/>
|
||||
<img src="assets/layout/images/themes/saga-blue.png" alt="Saga Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'saga-green', 'light')}>
|
||||
<img src="assets/layout/images/themes/saga-green.png" alt="Saga Green"/>
|
||||
<img src="assets/layout/images/themes/saga-green.png" alt="Saga Green" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'saga-orange', 'light')}>
|
||||
<img src="assets/layout/images/themes/saga-orange.png" alt="Saga Orange"/>
|
||||
<img src="assets/layout/images/themes/saga-orange.png" alt="Saga Orange" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'saga-purple', 'light')}>
|
||||
<img src="assets/layout/images/themes/saga-purple.png" alt="Saga Purple"/>
|
||||
<img src="assets/layout/images/themes/saga-purple.png" alt="Saga Purple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'vela-blue', 'dim')}>
|
||||
<img src="assets/layout/images/themes/vela-blue.png" alt="Vela Blue"/>
|
||||
<img src="assets/layout/images/themes/vela-blue.png" alt="Vela Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'vela-green', 'dim')}>
|
||||
<img src="assets/layout/images/themes/vela-green.png" alt="Vela Green"/>
|
||||
<img src="assets/layout/images/themes/vela-green.png" alt="Vela Green" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'vela-orange', 'dim')}>
|
||||
<img src="assets/layout/images/themes/vela-orange.png" alt="Vela Orange"/>
|
||||
<img src="assets/layout/images/themes/vela-orange.png" alt="Vela Orange" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'vela-purple', 'dim')}>
|
||||
<img src="assets/layout/images/themes/vela-purple.png" alt="Vela Purple"/>
|
||||
<img src="assets/layout/images/themes/vela-purple.png" alt="Vela Purple" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'arya-blue', 'dark')}>
|
||||
<img src="assets/layout/images/themes/arya-blue.png" alt="Arya Blue"/>
|
||||
<img src="assets/layout/images/themes/arya-blue.png" alt="Arya Blue" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'arya-green', 'dark')}>
|
||||
<img src="assets/layout/images/themes/arya-green.png" alt="Arya Green"/>
|
||||
<img src="assets/layout/images/themes/arya-green.png" alt="Arya Green" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'arya-orange', 'dark')}>
|
||||
<img src="assets/layout/images/themes/arya-orange.png" alt="Arya Orange"/>
|
||||
<img src="assets/layout/images/themes/arya-orange.png" alt="Arya Orange" />
|
||||
</button>
|
||||
</div>
|
||||
<div className="col-3 text-center">
|
||||
<button className="p-link" onClick={e => changeTheme(e, 'arya-purple', 'dark')}>
|
||||
<img src="assets/layout/images/themes/arya-purple.png" alt="Arya Purple"/>
|
||||
<img src="assets/layout/images/themes/arya-purple.png" alt="Arya Purple" />
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,47 +1,346 @@
|
|||
import React, { useEffect, useState } from 'react';
|
||||
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';
|
||||
|
||||
|
||||
const Communities = () => {
|
||||
const [communitiesList, setCommunitiesList] = useState([]);
|
||||
const [housesList, setHousesList] = useState([]);
|
||||
|
||||
let emptyCommunity = {
|
||||
name: '',
|
||||
province: provinciaId,
|
||||
canton: cantonId,
|
||||
district: districtId,
|
||||
phone: '',
|
||||
num_houses: 0,
|
||||
status: 'activo',
|
||||
date_entry: new Date(),
|
||||
houses: [],
|
||||
};
|
||||
|
||||
|
||||
const [communitiesList, setCommunitiesList] = useState([]);
|
||||
const [community, setCommunity] = useState(emptyCommunity);
|
||||
|
||||
const [housesList, setHousesList] = useState([]);
|
||||
const [provincesList, setProvincesList] = useState([]);
|
||||
const [provinciaId, setProvinciaId] = useState(null);
|
||||
const [cantonsList, setCantonsList] = useState([]);
|
||||
const [cantonId, setCantonId] = useState(null);
|
||||
const [districtsList, setDistrictsList] = useState([]);
|
||||
const [districtId, setDistrictId] = useState(null);
|
||||
const [codeHouses, setCodeHouses] = useState(null);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
const toast = useRef(null);
|
||||
const dt = useRef(null);
|
||||
|
||||
|
||||
|
||||
const p = provincesList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.code
|
||||
}))
|
||||
|
||||
|
||||
const c = cantonsList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.code,
|
||||
parent: item.parentCode
|
||||
}))
|
||||
|
||||
const d = districtsList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.code,
|
||||
parent: item.parentCode
|
||||
}))
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
fillProvinces();
|
||||
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
fillCantons();
|
||||
}, [provinciaId])
|
||||
|
||||
useEffect(() => {
|
||||
fillDistricts();
|
||||
}, [cantonId])
|
||||
|
||||
async function getProvinces() {
|
||||
const response = await fetch('assets/demo/data/provincias.json', { method: 'GET' });
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
async function fillProvinces() {
|
||||
const getP = await getProvinces();
|
||||
setProvincesList(await getP);
|
||||
}
|
||||
|
||||
async function getCantons() {
|
||||
const response = await fetch('assets/demo/data/cantones.json', { method: 'GET' });
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
async function fillCantons() {
|
||||
const resJson = await getCantons();
|
||||
const cantones = await resJson.filter(function (i, n) {
|
||||
return i.parentCode === provinciaId;
|
||||
});
|
||||
setCantonsList(await cantones);
|
||||
}
|
||||
|
||||
async function getDistricts() {
|
||||
const response = await fetch('assets/demo/data/distritos.json', { method: 'GET' });
|
||||
return await response.json();
|
||||
}
|
||||
|
||||
async function fillDistricts() {
|
||||
const resJson = await getDistricts();
|
||||
const districts = await resJson.filter(function (i, n) {
|
||||
return i.parentCode === cantonId;
|
||||
});
|
||||
setDistrictsList(await districts);
|
||||
}
|
||||
|
||||
const handleProvinces = (event) => {
|
||||
const getprovinciaId = event.target.value;
|
||||
setProvinciaId(getprovinciaId);
|
||||
}
|
||||
|
||||
const handleCanton = (event) => {
|
||||
const getCantonId = event.target.value;
|
||||
setCantonId(getCantonId);
|
||||
}
|
||||
|
||||
const handleDistrict = (event) => {
|
||||
const getDistrictId = event.target.value;
|
||||
setDistrictId(getDistrictId);
|
||||
}
|
||||
|
||||
|
||||
const handleCodeHouses = (event) => {
|
||||
const getcodehouse = event.target.value;
|
||||
setCodeHouses(getcodehouse);
|
||||
}
|
||||
|
||||
async function getCommunites() {
|
||||
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
|
||||
let list = await response.json();
|
||||
setCommunitiesList(list.message);
|
||||
let resJson = await response.json();
|
||||
let pList = await getProvinces();
|
||||
let cList = await getCantons();
|
||||
let dList = await getDistricts();
|
||||
await resJson.message.map((item) => {
|
||||
item.province = pList.find(p => p.code === item.province).name
|
||||
item.canton = cList.find(p => p.code === item.canton).name
|
||||
item.district = dList.find(p => p.code === item.district).name
|
||||
})
|
||||
setCommunitiesList(await resJson.message);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getCommunites();
|
||||
|
||||
}, [])
|
||||
|
||||
|
||||
const saveCommunity = () => {
|
||||
setSubmitted(true);
|
||||
|
||||
|
||||
if (community.name.trim()) {
|
||||
let _communities = [...communitiesList];
|
||||
let _community = { ...community };
|
||||
_community.province = provinciaId;
|
||||
_community.canton = cantonId;
|
||||
_community.district = districtId;
|
||||
|
||||
|
||||
|
||||
for (let i = 0; i < _community.num_houses; i++){
|
||||
_community.houses.push({
|
||||
number_house: codeHouses + (i+1),
|
||||
})
|
||||
}
|
||||
// console.log(houses)
|
||||
fetch('http://localhost:4000/community/createCommunity', {
|
||||
cache: 'no-cache',
|
||||
method: 'POST',
|
||||
body: JSON.stringify(_community),
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(
|
||||
function (response) {
|
||||
if (response.status != 201)
|
||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||
else
|
||||
return response.json();
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
|
||||
_community.province = provincesList.find(p => p.code === _community.province).name
|
||||
_community.canton = cantonsList.find(p => p.code === _community.canton).name
|
||||
_community.district = districtsList.find(p => p.code === _community.district).name
|
||||
|
||||
_communities.push(_community);
|
||||
toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Comunidad de vivienda Creada', life: 3000 });
|
||||
|
||||
setCommunitiesList(_communities);
|
||||
|
||||
|
||||
setProvinciaId('');
|
||||
setCantonId('');
|
||||
setDistrictId('');
|
||||
setCodeHouses('');
|
||||
|
||||
setCommunity(emptyCommunity);
|
||||
})
|
||||
.catch(
|
||||
err => console.log('Ocurrió un error con el fetch', err)
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const onInputChange = (e, name) => {
|
||||
const val = (e.target && e.target.value) || '';
|
||||
let _community = { ...community };
|
||||
_community[`${name}`] = val;
|
||||
|
||||
setCommunity(_community);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="grid">
|
||||
<div className="col-12">
|
||||
<div className="card">
|
||||
<h5>Comunidades de Viviendas</h5>
|
||||
<DataTable value={communitiesList} scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
|
||||
|
||||
<DataTable value={communitiesList} scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
|
||||
<Column field="name" header="Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||
<Column field="province" header="Provincia" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||
<Column field="canton" header="Cantón" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||
<Column field="district" header="Distrito" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||
<Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||
<Column field="num_houses" header="Número de viviendas" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||
<Column field="quote" header="Cuota mensual" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||
<Column field="name_admin" header="Administrador" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||
</DataTable>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div className="card">
|
||||
<Toast ref={toast} />
|
||||
|
||||
<h5>Registro de comunidad de viviendas</h5>
|
||||
<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" value={community.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames( submitted && community.name==='' ? 'p-invalid' : '' )} />
|
||||
</div>
|
||||
{submitted && community.name==='' && <small className="p-invalid">Nombre es requirido.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="provinces">Provincia</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-map-marker"></i>
|
||||
</span>
|
||||
<Dropdown placeholder="--Seleccione Provincia--" value={provinciaId} options={p} onChange={handleProvinces} required autoFocus className={classNames({ 'p-invalid': submitted && !provinciaId } )} />
|
||||
</div>
|
||||
{submitted && !provinciaId && <small className="p-invalid">Provincia es requirido.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="cantons">Cantó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-map-marker"></i>
|
||||
</span>
|
||||
<Dropdown placeholder="--Seleccione Cantón--" value={cantonId} options={c} onChange={handleCanton} required autoFocus className={classNames({ 'p-invalid': submitted && !cantonId } )}/>
|
||||
</div>
|
||||
{submitted && !cantonId && <small className="p-invalid">Cantón es requirido.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="districts">Distrito</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-map-marker"></i>
|
||||
</span>
|
||||
<Dropdown placeholder="--Seleccione Distrito--" value={districtId} options={d} onChange={handleDistrict} required autoFocus className={classNames({ 'p-invalid': submitted && !districtId } )}/>
|
||||
</div>
|
||||
{submitted && !districtId && <small className="p-invalid">Distrito es requirido.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="telefono">Número de Teléfono</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-phone"></i>
|
||||
</span>
|
||||
<InputText id="phone" value={community.phone} onChange={(e) => onInputChange(e, 'phone')} required autoFocus className={classNames({ 'p-invalid': submitted && community.phone==='' } )} />
|
||||
</div>
|
||||
{submitted && community.phone==='' && <small className="p-invalid">Número de teléfono es requirido.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="numHouse">Numero de Viviendas</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-hashtag"></i>
|
||||
</span>
|
||||
<InputText id="num_houses" value={community.num_houses} onChange={(e) => onInputChange(e, 'num_houses')} required autoFocus className={classNames({ 'p-invalid': submitted && community.num_houses < 1 } )} />
|
||||
</div>
|
||||
{submitted && community.num_houses < 1 && <small className="p-invalid">Número de viviendas es requirido y debe ser mayor que 0.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="field col-12 md:col-6">
|
||||
<label htmlFor="numHouse">Ingrese el prefijo para el código de las viviendas</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-hashtag"></i>
|
||||
</span>
|
||||
<InputText id="code_houses" value={codeHouses} onChange={handleCodeHouses} required autoFocus className={classNames({ 'p-invalid': submitted && !codeHouses } )} />
|
||||
</div>
|
||||
{submitted && !codeHouses && <small className="p-invalid">El código para las viviendas es requirido.</small>}
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12 md:col-12 py-2">
|
||||
<Button label="Registrar" icon="pi pi-check" onClick={saveCommunity}></Button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div >
|
||||
|
||||
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
export default React.memo(Communities);
|
Loading…
Reference in New Issue