listar inquilinos de una comunidad
This commit is contained in:
parent
06084ed899
commit
8ff8382d54
|
@ -108,9 +108,9 @@ export class AppController {
|
|||
return this.appService.findGuardsCommunity(community_id);
|
||||
}
|
||||
|
||||
@Get('user/findTenants')
|
||||
allUsersTenants() {
|
||||
return this.appService.allUsersTenants();
|
||||
@Get('user/findTenants/:community_id')
|
||||
allUsersTenants(@Param('community_id') paramCommunity_id: string) {
|
||||
return this.appService.findTenantsCommunity(paramCommunity_id);
|
||||
}
|
||||
|
||||
@Get('user/find/:dni')
|
||||
|
|
|
@ -147,6 +147,13 @@ export class AppService {
|
|||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
findTenantsCommunity(community_id: string) {
|
||||
const pattern = { cmd: 'findTenantsCommunity' };
|
||||
const payload = { community_id: community_id };
|
||||
return this.clientUserApp
|
||||
.send<string>(pattern, payload)
|
||||
.pipe(map((message: string) => ({ message })));
|
||||
}
|
||||
|
||||
deleteAdminSystem(id: string) {
|
||||
const pattern = { cmd: 'deleteAdminSystem' };
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"prismjs": "1.9.0",
|
||||
"react": "^17.0.1",
|
||||
"react-app-polyfill": "^1.0.6",
|
||||
"react-cookie": "^4.1.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "3.4.1",
|
||||
|
@ -2475,6 +2476,11 @@
|
|||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/cookie": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
|
||||
"integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
|
||||
},
|
||||
"node_modules/@types/eslint-visitor-keys": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
|
||||
|
@ -2489,6 +2495,15 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/hoist-non-react-statics": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz",
|
||||
"integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==",
|
||||
"dependencies": {
|
||||
"@types/react": "*",
|
||||
"hoist-non-react-statics": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/istanbul-lib-coverage": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
|
||||
|
@ -2531,11 +2546,31 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
|
||||
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA=="
|
||||
},
|
||||
"node_modules/@types/prop-types": {
|
||||
"version": "15.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
|
||||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
||||
},
|
||||
"node_modules/@types/q": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.5.tgz",
|
||||
"integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ=="
|
||||
},
|
||||
"node_modules/@types/react": {
|
||||
"version": "18.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.15.tgz",
|
||||
"integrity": "sha512-iz3BtLuIYH1uWdsv6wXYdhozhqj20oD4/Hk2DNXIn1kFsmp9x8d9QB6FnPhfkbhd2PgEONt9Q1x/ebkwjfFLow==",
|
||||
"dependencies": {
|
||||
"@types/prop-types": "*",
|
||||
"@types/scheduler": "*",
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"node_modules/@types/scheduler": {
|
||||
"version": "0.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
|
||||
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
|
||||
},
|
||||
"node_modules/@types/stack-utils": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz",
|
||||
|
@ -13402,6 +13437,19 @@
|
|||
"node": ">=6"
|
||||
}
|
||||
},
|
||||
"node_modules/react-cookie": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz",
|
||||
"integrity": "sha512-ffn7Y7G4bXiFbnE+dKhHhbP+b8I34mH9jqnm8Llhj89zF4nPxPutxHT1suUqMeCEhLDBI7InYwf1tpaSoK5w8A==",
|
||||
"dependencies": {
|
||||
"@types/hoist-non-react-statics": "^3.0.1",
|
||||
"hoist-non-react-statics": "^3.0.0",
|
||||
"universal-cookie": "^4.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": ">= 16.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dev-utils": {
|
||||
"version": "10.2.1",
|
||||
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz",
|
||||
|
@ -16599,6 +16647,23 @@
|
|||
"imurmurhash": "^0.1.4"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-cookie": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz",
|
||||
"integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==",
|
||||
"dependencies": {
|
||||
"@types/cookie": "^0.3.3",
|
||||
"cookie": "^0.4.0"
|
||||
}
|
||||
},
|
||||
"node_modules/universal-cookie/node_modules/cookie": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
|
||||
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA==",
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
}
|
||||
},
|
||||
"node_modules/universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
|
@ -19769,6 +19834,11 @@
|
|||
"@babel/types": "^7.3.0"
|
||||
}
|
||||
},
|
||||
"@types/cookie": {
|
||||
"version": "0.3.3",
|
||||
"resolved": "https://registry.npmjs.org/@types/cookie/-/cookie-0.3.3.tgz",
|
||||
"integrity": "sha512-LKVP3cgXBT9RYj+t+9FDKwS5tdI+rPBXaNSkma7hvqy35lc7mAokC2zsqWJH0LaqIt3B962nuYI77hsJoT1gow=="
|
||||
},
|
||||
"@types/eslint-visitor-keys": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/@types/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz",
|
||||
|
@ -19783,6 +19853,15 @@
|
|||
"@types/node": "*"
|
||||
}
|
||||
},
|
||||
"@types/hoist-non-react-statics": {
|
||||
"version": "3.3.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/hoist-non-react-statics/-/hoist-non-react-statics-3.3.1.tgz",
|
||||
"integrity": "sha512-iMIqiko6ooLrTh1joXodJK5X9xeEALT1kM5G3ZLhD3hszxBdIEd5C75U834D9mLcINgD4OyZf5uQXjkuYydWvA==",
|
||||
"requires": {
|
||||
"@types/react": "*",
|
||||
"hoist-non-react-statics": "^3.3.0"
|
||||
}
|
||||
},
|
||||
"@types/istanbul-lib-coverage": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz",
|
||||
|
@ -19825,11 +19904,31 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/parse-json/-/parse-json-4.0.0.tgz",
|
||||
"integrity": "sha512-//oorEZjL6sbPcKUaCdIGlIUeH26mgzimjBB77G6XRgnDl/L5wOnpyBGRe/Mmf5CVW3PwEBE1NjiMZ/ssFh4wA=="
|
||||
},
|
||||
"@types/prop-types": {
|
||||
"version": "15.7.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.5.tgz",
|
||||
"integrity": "sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w=="
|
||||
},
|
||||
"@types/q": {
|
||||
"version": "1.5.5",
|
||||
"resolved": "https://registry.npmjs.org/@types/q/-/q-1.5.5.tgz",
|
||||
"integrity": "sha512-L28j2FcJfSZOnL1WBjDYp2vUHCeIFlyYI/53EwD/rKUBQ7MtUUfbQWiyKJGpcnv4/WgrhWsFKrcPstcAt/J0tQ=="
|
||||
},
|
||||
"@types/react": {
|
||||
"version": "18.0.15",
|
||||
"resolved": "https://registry.npmjs.org/@types/react/-/react-18.0.15.tgz",
|
||||
"integrity": "sha512-iz3BtLuIYH1uWdsv6wXYdhozhqj20oD4/Hk2DNXIn1kFsmp9x8d9QB6FnPhfkbhd2PgEONt9Q1x/ebkwjfFLow==",
|
||||
"requires": {
|
||||
"@types/prop-types": "*",
|
||||
"@types/scheduler": "*",
|
||||
"csstype": "^3.0.2"
|
||||
}
|
||||
},
|
||||
"@types/scheduler": {
|
||||
"version": "0.16.2",
|
||||
"resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz",
|
||||
"integrity": "sha512-hppQEBDmlwhFAXKJX2KnWLYu5yMfi91yazPb2l+lbJiwW+wdo1gNeRA+3RgNSO39WYX2euey41KEwnqesU2Jew=="
|
||||
},
|
||||
"@types/stack-utils": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/@types/stack-utils/-/stack-utils-1.0.1.tgz",
|
||||
|
@ -28396,6 +28495,16 @@
|
|||
"whatwg-fetch": "^3.0.0"
|
||||
}
|
||||
},
|
||||
"react-cookie": {
|
||||
"version": "4.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-cookie/-/react-cookie-4.1.1.tgz",
|
||||
"integrity": "sha512-ffn7Y7G4bXiFbnE+dKhHhbP+b8I34mH9jqnm8Llhj89zF4nPxPutxHT1suUqMeCEhLDBI7InYwf1tpaSoK5w8A==",
|
||||
"requires": {
|
||||
"@types/hoist-non-react-statics": "^3.0.1",
|
||||
"hoist-non-react-statics": "^3.0.0",
|
||||
"universal-cookie": "^4.0.0"
|
||||
}
|
||||
},
|
||||
"react-dev-utils": {
|
||||
"version": "10.2.1",
|
||||
"resolved": "https://registry.npmjs.org/react-dev-utils/-/react-dev-utils-10.2.1.tgz",
|
||||
|
@ -30926,6 +31035,22 @@
|
|||
"imurmurhash": "^0.1.4"
|
||||
}
|
||||
},
|
||||
"universal-cookie": {
|
||||
"version": "4.0.4",
|
||||
"resolved": "https://registry.npmjs.org/universal-cookie/-/universal-cookie-4.0.4.tgz",
|
||||
"integrity": "sha512-lbRVHoOMtItjWbM7TwDLdl8wug7izB0tq3/YVKhT/ahB4VDvWMyvnADfnJI8y6fSvsjh51Ix7lTGC6Tn4rMPhw==",
|
||||
"requires": {
|
||||
"@types/cookie": "^0.3.3",
|
||||
"cookie": "^0.4.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"cookie": {
|
||||
"version": "0.4.2",
|
||||
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.2.tgz",
|
||||
"integrity": "sha512-aSWTXFzaKWkvHO1Ny/s+ePFpvKsPnjc551iI41v3ny/ow6tBG5Vd+FuqGNhh1LxOmVzOlGUriIlOaokOvhaStA=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"universalify": {
|
||||
"version": "0.1.2",
|
||||
"resolved": "https://registry.npmjs.org/universalify/-/universalify-0.1.2.tgz",
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
"prismjs": "1.9.0",
|
||||
"react": "^17.0.1",
|
||||
"react-app-polyfill": "^1.0.6",
|
||||
"react-cookie": "^4.1.1",
|
||||
"react-dom": "^17.0.1",
|
||||
"react-router-dom": "^5.2.0",
|
||||
"react-scripts": "3.4.1",
|
||||
|
|
|
@ -75,7 +75,6 @@ const AdministradoresComunidad = () => {
|
|||
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
|
||||
let resList = await response.json();
|
||||
let list = await resList.message;
|
||||
console.log(list);
|
||||
|
||||
setCommunitiesList(await list);
|
||||
}
|
||||
|
@ -323,7 +322,7 @@ const AdministradoresComunidad = () => {
|
|||
<>
|
||||
<p> {' '}
|
||||
<FontAwesomeIcon icon={faAt} style={{ color: "#D7A86E" }} />{' '}
|
||||
Correo Electrónic
|
||||
Correo Electrónico
|
||||
</p>
|
||||
</>
|
||||
)
|
||||
|
@ -389,7 +388,7 @@ const AdministradoresComunidad = () => {
|
|||
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
|
||||
</Column>
|
||||
<Column field="email" sortable header={headerEmail} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="phone" sortable header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="phone" header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="community_name" header={headerCommuntiy} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column header={headerOptions} style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdminCommunity}></Column>
|
||||
</DataTable>
|
||||
|
|
|
@ -4,8 +4,6 @@ import React, { useEffect, useState, useRef } from 'react'
|
|||
import { DataTable } from 'primereact/datatable';
|
||||
import { Column } from 'primereact/column';
|
||||
import { Dropdown } from 'primereact/dropdown';
|
||||
import { InputText } from 'primereact/inputtext';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Toast } from 'primereact/toast';
|
||||
import { Dialog } from 'primereact/dialog';
|
||||
import { Toolbar } from 'primereact/toolbar';
|
||||
|
@ -18,24 +16,70 @@ import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons';
|
|||
import { faEllipsis } from '@fortawesome/free-solid-svg-icons';
|
||||
import { faHashtag } from '@fortawesome/free-solid-svg-icons';
|
||||
|
||||
import { useCookies } from "react-cookie";
|
||||
|
||||
|
||||
const Inquilinos = () => {
|
||||
|
||||
let emptyTenant = {
|
||||
_id: null,
|
||||
dni: '',
|
||||
name: '',
|
||||
last_name: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
password: '',
|
||||
community_id: '',
|
||||
community_name: '',
|
||||
user_type: '4',
|
||||
date_entry: new Date(),
|
||||
status: '1'
|
||||
};
|
||||
|
||||
const [tenants, setTenants] = useState([]);
|
||||
const [tenant, setTenant] = useState(emptyTenant);
|
||||
const [selectedTentants, setSelectedTenants] = useState(null);
|
||||
const [globalFilter, setGlobalFilter] = useState(null);
|
||||
const [deleteTenantDialog, setDeleteTenantDialog] = useState(false);
|
||||
const [deleteTenantsDialog, setDeleteTenantsDialog,] = useState(false);
|
||||
const [communitiesList, setCommunitiesList] = useState([]);
|
||||
const communityIdList = communitiesList.map((community) => community.id);
|
||||
const [communityId, setCommunityId] = useState(null);
|
||||
const [submitted, setSubmitted] = useState(false);
|
||||
const toast = useRef(null);
|
||||
const dt = useRef(null);
|
||||
|
||||
const [cookies, setCookie] = useCookies();
|
||||
|
||||
|
||||
async function tenantsList() {
|
||||
await fetch(`http://localhost:4000/user/findTenants/${cookies.community_id}`, { method: 'GET' })
|
||||
.then((response) => response.json())
|
||||
.then(data => data.message)
|
||||
.then(data => setTenants(data));
|
||||
}
|
||||
|
||||
|
||||
async function getCommunites() {
|
||||
let response = await fetch(
|
||||
'http://localhost:4000/community/allCommunities',
|
||||
{ method: 'GET' },
|
||||
);
|
||||
let list = await response.json();
|
||||
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
|
||||
let resList = await response.json();
|
||||
let list = await resList.message;
|
||||
|
||||
setCommunitiesList(await list);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
tenantsList();
|
||||
}, [])
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getCommunites();
|
||||
}, [])
|
||||
|
||||
const cList = communitiesList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item._id,
|
||||
}))
|
||||
|
||||
function registrarInquilino() {
|
||||
let data = {
|
||||
|
@ -66,16 +110,99 @@ const Inquilinos = () => {
|
|||
});
|
||||
}
|
||||
|
||||
const cList = communitiesList.map((item) => ({
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
}))
|
||||
const deleteTenant = () => {
|
||||
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
|
||||
cache: 'no-cache',
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
.then(
|
||||
function (response) {
|
||||
if (response.status != 201)
|
||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||
else
|
||||
return response.json();
|
||||
}
|
||||
)
|
||||
.then(
|
||||
function (response) {
|
||||
|
||||
let _community = communities.filter(val => val._id !== community._id);
|
||||
setCommunities(_community);
|
||||
setDeleteCommunityDialog(false);
|
||||
setCommunity(emptyCommunity);
|
||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 });
|
||||
}
|
||||
)
|
||||
.catch(
|
||||
err => {
|
||||
console.log('Ocurrió un error con el fetch', err)
|
||||
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Comunidad de Viviendas no se pudo eliminar', life: 3000 });
|
||||
}
|
||||
);
|
||||
*/
|
||||
let _tenants = tenants.filter(
|
||||
(val) => val._id !== tenant._id,
|
||||
);
|
||||
setTenants(_tenants);
|
||||
setDeleteTenantDialog(false);
|
||||
setTenant(emptyTenant);
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Inquilino Eliminado',
|
||||
life: 3000,
|
||||
});
|
||||
};
|
||||
|
||||
const deleteSelectedTenants = () => {
|
||||
let _tenants = tenants.filter(
|
||||
(val) => !selectedTentants.includes(val),
|
||||
);
|
||||
/* selectedCommunities.map((item) => {
|
||||
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, {
|
||||
cache: 'no-cache',
|
||||
method: 'DELETE',
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
})
|
||||
})*/
|
||||
setTenants(_tenants);
|
||||
setDeleteTenantsDialog(false);
|
||||
setSelectedTenants(null);
|
||||
toast.current.show({
|
||||
severity: 'success',
|
||||
summary: 'Éxito',
|
||||
detail: 'Inquilinos Eliminados',
|
||||
life: 3000,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
const actionsAdmin = (rowData) => {
|
||||
const hideDeleteTenantDialog = () => {
|
||||
setDeleteTenantDialog(false);
|
||||
}
|
||||
|
||||
const hideDeleteTenantsDialog = () => {
|
||||
setDeleteTenantsDialog(false);
|
||||
}
|
||||
|
||||
const confirmDeleteTenant = (tenant) => {
|
||||
setTenant(tenant);
|
||||
setDeleteTenantDialog(true);
|
||||
}
|
||||
|
||||
const confirmDeleteSelected = () => {
|
||||
setDeleteTenantsDialog(true);
|
||||
};
|
||||
|
||||
|
||||
const actionsTenant = (rowData) => {
|
||||
return (
|
||||
<div className="actions">
|
||||
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteAdminSystem(rowData)} />
|
||||
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteTenant(rowData)} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
@ -84,7 +211,7 @@ const leftToolbarTemplate = () => {
|
|||
return (
|
||||
<React.Fragment>
|
||||
<div className="my-2">
|
||||
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedAdministrators || !selectedAdministrators.length} />
|
||||
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedTentants || !selectedTentants.length} />
|
||||
</div>
|
||||
</React.Fragment>
|
||||
)
|
||||
|
@ -100,7 +227,7 @@ const rightToolbarTemplate = () => {
|
|||
|
||||
const header = (
|
||||
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||
<h5 className="m-0">Administradores del sistema</h5>
|
||||
<h5 className="m-0">Inquilinos</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..." />
|
||||
|
@ -108,17 +235,17 @@ const header = (
|
|||
</div>
|
||||
);
|
||||
|
||||
const deleteAdminSystemDialogFooter = (
|
||||
const deleteTenantDialogFooter = (
|
||||
<>
|
||||
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminSystemDialog} />
|
||||
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSysAdmin} />
|
||||
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteTenantDialog} />
|
||||
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteTenant} />
|
||||
</>
|
||||
);
|
||||
|
||||
const deleteAdminsSystemDialogFooter = (
|
||||
const deleteTenantsDialogFooter = (
|
||||
<>
|
||||
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminsSystemsDialog} />
|
||||
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedAdminsSystem} />
|
||||
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteTenantsDialog} />
|
||||
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedTenants} />
|
||||
</>
|
||||
);
|
||||
|
||||
|
@ -171,6 +298,40 @@ const headerOptions = (
|
|||
)
|
||||
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={tenants} dataKey="_id" paginator rows={5} selection={selectedTentants} onSelectionChange={(e) => setSelectedTenants(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} inquilinos"
|
||||
globalFilter={globalFilter} emptyMessage="No hay inquilinos en esta comunidad 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="last_name" sortable header={headerLastName} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }} alignFrozen="left"></Column>
|
||||
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
|
||||
</Column>
|
||||
<Column field="email" sortable header={headerEmail} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="phone" header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column field="community_name" header={headerCommuntiy} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||
<Column header={headerOptions} style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsTenant}></Column>
|
||||
</DataTable>
|
||||
<Dialog visible={deleteTenantDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteTenantDialogFooter} onHide={hideDeleteTenantDialog}>
|
||||
<div className="flex align-items-center justify-content-center">
|
||||
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||
{tenant && <span>¿Estás seguro que desea eliminar a <b>{tenant.name}</b>?</span>}
|
||||
</div>
|
||||
</Dialog>
|
||||
<Dialog visible={deleteTenantsDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteTenantsDialogFooter} onHide={hideDeleteTenantsDialog}>
|
||||
<div className="flex align-items-center justify-content-center">
|
||||
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||
{selectedTentants && <span>¿Está seguro eliminar los Inquilinos seleccionados?</span>}
|
||||
</div>
|
||||
</Dialog>
|
||||
</div>
|
||||
</div>
|
||||
<div className="col-12">
|
||||
<div className="card">
|
||||
<h5 className="card-header">Registrar Inquilino</h5>
|
||||
|
|
|
@ -5,11 +5,14 @@ import App from './App';
|
|||
//import * as serviceWorker from './serviceWorker';
|
||||
import { HashRouter } from 'react-router-dom';
|
||||
import ScrollToTop from './ScrollToTop';
|
||||
import { CookiesProvider } from "react-cookie";
|
||||
|
||||
ReactDOM.render(
|
||||
<HashRouter>
|
||||
<ScrollToTop>
|
||||
<CookiesProvider>
|
||||
<App></App>
|
||||
</CookiesProvider>
|
||||
</ScrollToTop>
|
||||
</HashRouter>,
|
||||
document.getElementById('root'),
|
||||
|
|
Loading…
Reference in New Issue