Merge pull request #123 from DeimosPr4/fix-style-list
Fix estilos de administradores y comunidad de viviendas
This commit is contained in:
commit
166448625b
|
@ -25,7 +25,7 @@ export class CommunitiesController {
|
||||||
|
|
||||||
@MessagePattern({cmd: 'findCommunityName'})
|
@MessagePattern({cmd: 'findCommunityName'})
|
||||||
findOneName(@Payload() id: string) {
|
findOneName(@Payload() id: string) {
|
||||||
let _id = id['_id'];
|
let _id = id['id'];
|
||||||
return this.communitiesService.findOneName(_id);
|
return this.communitiesService.findOneName(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ export class CommunitiesService {
|
||||||
return this.communityModel.findOne({ _id: id }).exec();
|
return this.communityModel.findOne({ _id: id }).exec();
|
||||||
}
|
}
|
||||||
findOneName(id: string): Promise<Community> {
|
findOneName(id: string): Promise<Community> {
|
||||||
return this.communityModel.findOne({ _id: "62be68215692582bbfd77134" }).exec();
|
return this.communityModel.findOne({ _id: id }).exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
update(id: string, community: CommunityDocument) {
|
update(id: string, community: CommunityDocument) {
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
"version": "7.0.3-SNAPSHOT",
|
"version": "7.0.3-SNAPSHOT",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^6.1.1",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "^6.1.1",
|
||||||
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||||
"@fullcalendar/core": "^5.7.2",
|
"@fullcalendar/core": "^5.7.2",
|
||||||
"@fullcalendar/daygrid": "^5.7.2",
|
"@fullcalendar/daygrid": "^5.7.2",
|
||||||
"@fullcalendar/interaction": "^5.7.2",
|
"@fullcalendar/interaction": "^5.7.2",
|
||||||
|
@ -1874,6 +1877,51 @@
|
||||||
"resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz",
|
||||||
"integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg=="
|
"integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg=="
|
||||||
},
|
},
|
||||||
|
"node_modules/@fortawesome/fontawesome-common-types": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-wVn5WJPirFTnzN6tR95abCx+ocH+3IFLXAgyavnf9hUmN0CfWoDjPT/BAWsUVwSlYYVBeCLJxaqi7ZGe4uSjBA==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fortawesome/fontawesome-svg-core": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-NCg0w2YIp81f4V6cMGD9iomfsIj7GWrqmsa0ZsPh59G7PKiGN1KymZNxmF00ssuAlo/VZmpK6xazsGOwzKYUMg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-common-types": "6.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fortawesome/free-solid-svg-icons": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-0/5exxavOhI/D4Ovm2r3vxNojGZioPwmFrKg0ZUH69Q68uFhFPs6+dhAToh6VEQBntxPRYPuT5Cg1tpNa9JUPg==",
|
||||||
|
"hasInstallScript": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-common-types": "6.1.1"
|
||||||
|
},
|
||||||
|
"engines": {
|
||||||
|
"node": ">=6"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"node_modules/@fortawesome/react-fontawesome": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==",
|
||||||
|
"dependencies": {
|
||||||
|
"prop-types": "^15.8.1"
|
||||||
|
},
|
||||||
|
"peerDependencies": {
|
||||||
|
"@fortawesome/fontawesome-svg-core": "~1 || ~6",
|
||||||
|
"react": ">=16.3"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/@fullcalendar/common": {
|
"node_modules/@fullcalendar/common": {
|
||||||
"version": "5.11.0",
|
"version": "5.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz",
|
||||||
|
@ -19237,6 +19285,35 @@
|
||||||
"resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz",
|
"resolved": "https://registry.npmjs.org/@csstools/normalize.css/-/normalize.css-10.1.0.tgz",
|
||||||
"integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg=="
|
"integrity": "sha512-ij4wRiunFfaJxjB0BdrYHIH8FxBJpOwNPhhAcunlmPdXudL1WQV1qoP9un6JsEBAgQH+7UXyyjh0g7jTxXK6tg=="
|
||||||
},
|
},
|
||||||
|
"@fortawesome/fontawesome-common-types": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-common-types/-/fontawesome-common-types-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-wVn5WJPirFTnzN6tR95abCx+ocH+3IFLXAgyavnf9hUmN0CfWoDjPT/BAWsUVwSlYYVBeCLJxaqi7ZGe4uSjBA=="
|
||||||
|
},
|
||||||
|
"@fortawesome/fontawesome-svg-core": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/fontawesome-svg-core/-/fontawesome-svg-core-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-NCg0w2YIp81f4V6cMGD9iomfsIj7GWrqmsa0ZsPh59G7PKiGN1KymZNxmF00ssuAlo/VZmpK6xazsGOwzKYUMg==",
|
||||||
|
"requires": {
|
||||||
|
"@fortawesome/fontawesome-common-types": "6.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@fortawesome/free-solid-svg-icons": {
|
||||||
|
"version": "6.1.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/free-solid-svg-icons/-/free-solid-svg-icons-6.1.1.tgz",
|
||||||
|
"integrity": "sha512-0/5exxavOhI/D4Ovm2r3vxNojGZioPwmFrKg0ZUH69Q68uFhFPs6+dhAToh6VEQBntxPRYPuT5Cg1tpNa9JUPg==",
|
||||||
|
"requires": {
|
||||||
|
"@fortawesome/fontawesome-common-types": "6.1.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@fortawesome/react-fontawesome": {
|
||||||
|
"version": "0.2.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@fortawesome/react-fontawesome/-/react-fontawesome-0.2.0.tgz",
|
||||||
|
"integrity": "sha512-uHg75Rb/XORTtVt7OS9WoK8uM276Ufi7gCzshVWkUJbHhh3svsUUeqXerrM96Wm7fRiDzfKRwSoahhMIkGAYHw==",
|
||||||
|
"requires": {
|
||||||
|
"prop-types": "^15.8.1"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@fullcalendar/common": {
|
"@fullcalendar/common": {
|
||||||
"version": "5.11.0",
|
"version": "5.11.0",
|
||||||
"resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz",
|
"resolved": "https://registry.npmjs.org/@fullcalendar/common/-/common-5.11.0.tgz",
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
},
|
},
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^6.1.1",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "^6.1.1",
|
||||||
|
"@fortawesome/react-fontawesome": "^0.2.0",
|
||||||
"@fullcalendar/core": "^5.7.2",
|
"@fullcalendar/core": "^5.7.2",
|
||||||
"@fullcalendar/daygrid": "^5.7.2",
|
"@fullcalendar/daygrid": "^5.7.2",
|
||||||
"@fullcalendar/interaction": "^5.7.2",
|
"@fullcalendar/interaction": "^5.7.2",
|
||||||
|
|
|
@ -1,51 +1,293 @@
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState, useRef } from 'react';
|
||||||
import { InputText } from 'primereact/inputtext';
|
import { InputText } from 'primereact/inputtext';
|
||||||
import { Button } from 'primereact/button';
|
import { Button } from 'primereact/button';
|
||||||
import { DataTable } from 'primereact/datatable';
|
import { DataTable } from 'primereact/datatable';
|
||||||
import { Column } from 'primereact/column';
|
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 { faHome, 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 { faEllipsis } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { faHomeAlt } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
|
|
||||||
const AdministradoresComunidad = () => {
|
const AdministradoresComunidad = () => {
|
||||||
|
|
||||||
const [listaAdmins,setListaAdmins]=useState([]);
|
const [listaAdmins, setListaAdmins] = useState([]);
|
||||||
const [listaAdminComunidad,setListaAdminComunidad]=useState([]);
|
const [listaAdminComunidad, setListaAdminComunidad] = useState([]);
|
||||||
|
const [adminCommunity, setAdminCommunity] = useState(emptyAdminCommunity);
|
||||||
|
const [selectedAdminsCommunities, setSelectedAdminsCommunities] = useState(null);
|
||||||
|
const [globalFilter, setGlobalFilter] = useState(null);
|
||||||
|
const [deleteAdminCommunityDialog, setDeleteAdminCommunityDialog] = useState(false);
|
||||||
|
const [deleteAdminsCommunitiesDialog, setDeleteAdminsCommunitiesDialog] = useState(false);
|
||||||
|
const toast = useRef(null);
|
||||||
|
const dt = useRef(null);
|
||||||
|
|
||||||
async function listaAdmin(){
|
let emptyAdminCommunity = {
|
||||||
let nombres=await fetch('http://localhost:4000/user/findAdminComunidad/', {method:'GET'});
|
_id: null,
|
||||||
let nombresRes= await nombres.json();
|
dni: '',
|
||||||
setListaAdmins(nombresRes.message);
|
name: '',
|
||||||
}
|
last_name: '',
|
||||||
|
email: '',
|
||||||
|
phone: '',
|
||||||
|
password: '',
|
||||||
|
community_id: '',
|
||||||
|
community_name: '',
|
||||||
|
user_type: '2',
|
||||||
|
status: ''
|
||||||
|
};
|
||||||
|
|
||||||
async function listaComunidades(nombre){
|
async function listaAdmin() {
|
||||||
let nombres=await fetch('http://localhost:4000/community/findCommunityName/'+nombre, {method:'GET'});
|
let nombres = await fetch('http://localhost:4000/user/findAdminComunidad/', { method: 'GET' })
|
||||||
let nombresRes= await nombres.json();
|
.then((response) => response.json())
|
||||||
setListaAdminComunidad(nombresRes.message);
|
.then((data) => {
|
||||||
}
|
return Promise.all(data.message.map(item => {
|
||||||
listaAdmins.map(function(administrador){
|
//item.full_name returns the repositorie name
|
||||||
listaComunidades(administrador.community_id);
|
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
|
||||||
administrador.community_id=listaAdminComunidad.name;
|
.then((response2) => response2.json())
|
||||||
})
|
.then(data => {
|
||||||
useEffect(()=>{
|
console.log(data.message.name);
|
||||||
|
item.community_name = data.message.name
|
||||||
|
return item
|
||||||
|
})
|
||||||
|
}));
|
||||||
|
}).then(data => setListaAdmins(data)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
async function nombreComunidad(id) {
|
||||||
|
let nombres = await fetch('http://localhost:4000/community/findCommunityName/' + id, { method: 'GET' });
|
||||||
|
let nombresRes = await nombres.json();
|
||||||
|
return await nombresRes.message['name'];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async function setNameCommunities() {
|
||||||
|
Promise.all(listaAdmins.map(async function (administrador) {
|
||||||
|
// await listaComunidades(administrador.community_id);
|
||||||
|
administrador.community_id = await listaAdminComunidad.name;
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
listaAdmin();
|
listaAdmin();
|
||||||
},[])
|
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
|
const deleteAdminCommunity = () => {
|
||||||
|
/* 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 _administrators = listaAdmins.filter(val => val._id !== adminCommunity._id);
|
||||||
|
setListaAdmins(_administrators);
|
||||||
|
setDeleteAdminCommunityDialog(false);
|
||||||
|
setAdminCommunity(emptyAdminCommunity);
|
||||||
|
toast.current.show({ severity: 'success', summary: 'Administrador de Comunidad Eliminada', life: 3000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteSelectedAdminsCommunity = () => {
|
||||||
|
let _admins = listaAdmins.filter(val => !selectedAdminsCommunities.includes(val));
|
||||||
|
/* selectedCommunities.map((item) => {
|
||||||
|
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, {
|
||||||
|
cache: 'no-cache',
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})*/
|
||||||
|
setListaAdmins(_admins);
|
||||||
|
setDeleteAdminsCommunitiesDialog(false);
|
||||||
|
setSelectedAdminsCommunities(null);
|
||||||
|
toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Administradores de Comunidad de Viviendas Eliminado', life: 3000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
const hideDeleteAdminCommunityDialog = () => {
|
||||||
|
setDeleteAdminCommunityDialog(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideDeleteAdminsCommunitysDialog = () => {
|
||||||
|
setDeleteAdminsCommunitiesDialog(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDeleteAdminCommunity = (adminCommunity) => {
|
||||||
|
setAdminCommunity(adminCommunity);
|
||||||
|
setDeleteAdminCommunityDialog(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDeleteSelected = () => {
|
||||||
|
setDeleteAdminsCommunitiesDialog(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionsAdminCommunity = (rowData) => {
|
||||||
|
return (
|
||||||
|
<div className="actions">
|
||||||
|
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteAdminCommunity(rowData)} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftToolbarTemplate = () => {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<div className="my-2">
|
||||||
|
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedAdminsCommunities || !selectedAdminsCommunities.length} />
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const rightToolbarTemplate = () => {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Button label="Exportar" icon="pi pi-upload" className="p-button-help" />
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const header = (
|
||||||
|
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||||
|
<h5 className="m-0">Administradores de Comunidades</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 deleteAdminCommunityDialogFooter = (
|
||||||
|
<>
|
||||||
|
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminCommunityDialog} />
|
||||||
|
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteAdminCommunity} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
const deleteAdminsCommunityDialogFooter = (
|
||||||
|
<>
|
||||||
|
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminsCommunitysDialog} />
|
||||||
|
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedAdminsCommunity} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
const headerName = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> Nombre</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerLastName = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#D7A86E" }} /> Apellidos</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 headerCommuntiy = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faHomeAlt} style={{ color: "#D7A86E" }} /> Comunidad</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerOptions = (
|
||||||
|
<>
|
||||||
|
<p><FontAwesomeIcon icon={faEllipsis} size="2x" style={{ color: "#C08135" }} /></p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
|
<Toast ref={toast} />
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<h5>Administradores de comunidad</h5>
|
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
|
||||||
<DataTable value={listaAdmins} scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
|
<DataTable ref={dt} value={listaAdmins} dataKey="_id" paginator rows={5} selection={selectedAdminsCommunities} onSelectionChange={(e) => setSelectedAdminsCommunities(e.value)}
|
||||||
<Column field="name" header="Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
scrollable scrollHeight="400px" scrollDirection="both" header={header}
|
||||||
<Column field="last_name" header="Apellidos" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
|
||||||
<Column field="dni" header="Identificación" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||||
<Column field="email" header="Correo electrónico" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} administradores de comunidades de viviendas"
|
||||||
<Column field="phone" header="Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
globalFilter={globalFilter} emptyMessage="No hay administradores de comunidades registrados.">
|
||||||
<Column field="community_id" header="Comunidad" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
<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" sortable 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>
|
</DataTable>
|
||||||
|
<Dialog visible={deleteAdminCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminCommunityDialogFooter} onHide={hideDeleteAdminCommunityDialog}>
|
||||||
|
<div className="flex align-items-center justify-content-center">
|
||||||
|
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||||
|
{adminCommunity && <span>¿Estás seguro que desea eliminar a <b>{adminCommunity.name}</b>?</span>}
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
<Dialog visible={deleteAdminsCommunitiesDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminsCommunityDialogFooter} onHide={hideDeleteAdminsCommunitysDialog}>
|
||||||
|
<div className="flex align-items-center justify-content-center">
|
||||||
|
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||||
|
{selectedAdminsCommunities && <span>¿Está seguro eliminar los administradores de las comunidades de viviendas seleccionados?</span>}
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,13 @@ import { Column } from 'primereact/column';
|
||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
import { Dialog } from 'primereact/dialog';
|
import { Dialog } from 'primereact/dialog';
|
||||||
import { Toolbar } from 'primereact/toolbar';
|
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 { faEllipsis } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
|
|
||||||
const AdministradoresSistema = () => {
|
const AdministradoresSistema = () => {
|
||||||
|
|
||||||
|
@ -19,7 +26,6 @@ const AdministradoresSistema = () => {
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
const dt = useRef(null);
|
const dt = useRef(null);
|
||||||
|
|
||||||
|
|
||||||
let emptySysAdmin = {
|
let emptySysAdmin = {
|
||||||
_id: null,
|
_id: null,
|
||||||
dni: '',
|
dni: '',
|
||||||
|
@ -123,17 +129,15 @@ const AdministradoresSistema = () => {
|
||||||
function (response) {
|
function (response) {
|
||||||
let _sysadmin = administrators.filter(val => val._id !== sysadmin._id);
|
let _sysadmin = administrators.filter(val => val._id !== sysadmin._id);
|
||||||
setAdministrators(_sysadmin);
|
setAdministrators(_sysadmin);
|
||||||
|
|
||||||
setDeleteAdminSystemDialog(false);
|
setDeleteAdminSystemDialog(false);
|
||||||
setSysAdmin(emptySysAdmin);
|
setSysAdmin(emptySysAdmin);
|
||||||
|
toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Administrador del Sistema Eliminado', life: 3000 });
|
||||||
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador del Sistema Eliminado', life: 3000 });
|
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.catch(
|
.catch(
|
||||||
err => {
|
err => {
|
||||||
console.log('Ocurrió un error con el fetch', err)
|
console.log('Ocurrió un error con el fetch', err)
|
||||||
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador del Sistema no se pudo eliminar', life: 3000 });
|
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador del Sistema no se pudo Eliminar', life: 3000 });
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -152,10 +156,9 @@ const AdministradoresSistema = () => {
|
||||||
setAdministrators(_administrators);
|
setAdministrators(_administrators);
|
||||||
setDeleteAdminsSystemDialog(false);
|
setDeleteAdminsSystemDialog(false);
|
||||||
setSelectedAdministrators(null);
|
setSelectedAdministrators(null);
|
||||||
toast.current.show({ severity: 'success', summary: 'Successful', detail: 'Products Deleted', life: 3000 });
|
toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Administradores del Sistema Eliminados', life: 3000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const actionsAdmin = (rowData) => {
|
const actionsAdmin = (rowData) => {
|
||||||
return (
|
return (
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
|
@ -177,7 +180,7 @@ const AdministradoresSistema = () => {
|
||||||
const rightToolbarTemplate = () => {
|
const rightToolbarTemplate = () => {
|
||||||
return (
|
return (
|
||||||
<React.Fragment>
|
<React.Fragment>
|
||||||
<Button label="Exportar" icon="pi pi-upload" className="p-button-help" />
|
<Button label="Exportar" icon="pi pi-upload" className="p-button-help" />
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -205,31 +208,64 @@ const AdministradoresSistema = () => {
|
||||||
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedAdminsSystem} />
|
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedAdminsSystem} />
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const headerName = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faUserAlt} style={{color: "#C08135"}} /> Nombre</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerLastName = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faUserAlt} style={{color: "#D7A86E"}} /> Apellidos</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 headerOptions = (
|
||||||
|
<>
|
||||||
|
<p>Opciones <FontAwesomeIcon icon={faEllipsis} style={{color: "#D7A86E"}} /></p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<Toast ref={toast} />
|
<Toast ref={toast} />
|
||||||
|
|
||||||
<div className="card">
|
<div className="card">
|
||||||
< Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
|
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
|
||||||
|
|
||||||
<DataTable ref={dt} value={administrators} dataKey="_id" paginator rows={5} selection={selectedAdministrators} onSelectionChange={(e) => setSelectedAdministrators(e.value)}
|
<DataTable ref={dt} value={administrators} dataKey="_id" paginator rows={5} selection={selectedAdministrators} onSelectionChange={(e) => setSelectedAdministrators(e.value)}
|
||||||
scrollable scrollHeight="400px" scrollDirection="both" header={header}
|
scrollable scrollHeight="400px" scrollDirection="both" header={header}
|
||||||
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
|
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
|
||||||
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||||
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} administradores del sistema"
|
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} administradores del sistema"
|
||||||
globalFilter={globalFilter} emptyMessage="No hay administradores del sistema registrados."
|
globalFilter={globalFilter} emptyMessage="No hay administradores del sistema registrados.">
|
||||||
>
|
|
||||||
<Column selectionMode="multiple" headerStyle={{ width: '3rem' }}></Column>
|
<Column selectionMode="multiple" headerStyle={{ width: '3rem' }}></Column>
|
||||||
<Column field="name" sortable header="👩🏻💼👨🏻💼 Nombre" style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
<Column field="name" sortable header={headerName} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||||
<Column field="last_name" sortable header="👩🏻💼👨🏻💼 Apellidos" style={{ flexGrow: 1,flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }} alignFrozen="left"></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="💳 Identificación" style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
|
||||||
<Column field="email" sortable header="📧 Correo electrónico" style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
</Column>
|
||||||
<Column field="phone" sortable header="📞 Telefóno" 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 header="Acciones" style={{ flexGrow: 1,flexBasis: '60px' }} body={actionsAdmin}></Column>
|
<Column field="phone" sortable header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
|
||||||
|
<Column header={headerOptions} style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdmin}></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
|
||||||
<Dialog visible={deleteAdminSystemDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminSystemDialogFooter} onHide={hideDeleteAdminSystemDialog}>
|
<Dialog visible={deleteAdminSystemDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminSystemDialogFooter} onHide={hideDeleteAdminSystemDialog}>
|
||||||
<div className="flex align-items-center justify-content-center">
|
<div className="flex align-items-center justify-content-center">
|
||||||
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||||
|
@ -239,7 +275,7 @@ const AdministradoresSistema = () => {
|
||||||
<Dialog visible={deleteAdminsSystemDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminsSystemDialogFooter} onHide={hideDeleteAdminsSystemsDialog}>
|
<Dialog visible={deleteAdminsSystemDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminsSystemDialogFooter} onHide={hideDeleteAdminsSystemsDialog}>
|
||||||
<div className="flex align-items-center justify-content-center">
|
<div className="flex align-items-center justify-content-center">
|
||||||
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||||
{sysadmin && <span>¿Está seguro eliminar los adminsitradores del sistema seleccionados?</span>}
|
{selectedAdministrators && <span>¿Está seguro eliminar los adminsitradores del sistema seleccionados?</span>}
|
||||||
</div>
|
</div>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
|
@ -266,19 +302,18 @@ const AdministradoresSistema = () => {
|
||||||
</div>
|
</div>
|
||||||
<div className="field col-12">
|
<div className="field col-12">
|
||||||
<label htmlFor="telefono">Teléfono</label>
|
<label htmlFor="telefono">Teléfono</label>
|
||||||
<InputText type="tel" id="telefono" pattern="[0-9]{8}"/>
|
<InputText type="tel" id="telefono" pattern="[0-9]{8}" />
|
||||||
</div>
|
</div>
|
||||||
<Button label="Registrar" onClick={registrarAdmin}></Button>
|
<Button label="Registrar" onClick={registrarAdmin}></Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
const comparisonFn = function (prevProps, nextProps) {
|
const comparisonFn = function (prevProps, nextProps) {
|
||||||
return prevProps.location.pathname === nextProps.location.pathname;
|
return prevProps.location.pathname === nextProps.location.pathname;
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(AdministradoresSistema, comparisonFn);
|
export default React.memo(AdministradoresSistema, comparisonFn);
|
|
@ -6,11 +6,18 @@ import { Column } from 'primereact/column';
|
||||||
import { Dropdown } from 'primereact/dropdown';
|
import { Dropdown } from 'primereact/dropdown';
|
||||||
import { Toast } from 'primereact/toast';
|
import { Toast } from 'primereact/toast';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import { Dialog } from 'primereact/dialog';
|
||||||
|
import { Toolbar } from 'primereact/toolbar';
|
||||||
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||||
|
import { faHome } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { faMapLocationDot } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
import { faEllipsis } from '@fortawesome/free-solid-svg-icons';
|
||||||
|
|
||||||
const Communities = () => {
|
const Communities = () => {
|
||||||
|
|
||||||
let emptyCommunity = {
|
let emptyCommunity = {
|
||||||
|
_id: null,
|
||||||
name: '',
|
name: '',
|
||||||
province: provinciaId,
|
province: provinciaId,
|
||||||
canton: cantonId,
|
canton: cantonId,
|
||||||
|
@ -35,6 +42,10 @@ const Communities = () => {
|
||||||
const [districtId, setDistrictId] = useState(null);
|
const [districtId, setDistrictId] = useState(null);
|
||||||
const [codeHouses, setCodeHouses] = useState('');
|
const [codeHouses, setCodeHouses] = useState('');
|
||||||
const [submitted, setSubmitted] = useState(false);
|
const [submitted, setSubmitted] = useState(false);
|
||||||
|
const [selectedCommunities, setSelectedCommunities] = useState(null);
|
||||||
|
const [globalFilter, setGlobalFilter] = useState(null);
|
||||||
|
const [deleteCommunityDialog, setDeleteCommunityDialog] = useState(false);
|
||||||
|
const [deleteCommunitiesDialog, setDeleteCommunitiesDialog] = useState(false);
|
||||||
const toast = useRef(null);
|
const toast = useRef(null);
|
||||||
const dt = useRef(null);
|
const dt = useRef(null);
|
||||||
|
|
||||||
|
@ -60,8 +71,6 @@ const Communities = () => {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
fillProvinces();
|
fillProvinces();
|
||||||
|
|
||||||
|
@ -156,7 +165,7 @@ const Communities = () => {
|
||||||
|
|
||||||
const saveCommunity = () => {
|
const saveCommunity = () => {
|
||||||
|
|
||||||
if (community.name && community.num_houses > 0 && provinciaId && cantonId && districtId && community.phone ) {
|
if (community.name && community.num_houses > 0 && provinciaId && cantonId && districtId && community.phone) {
|
||||||
let _communities = [...communitiesList];
|
let _communities = [...communitiesList];
|
||||||
let _community = { ...community };
|
let _community = { ...community };
|
||||||
_community.province = provinciaId;
|
_community.province = provinciaId;
|
||||||
|
@ -227,27 +236,219 @@ const Communities = () => {
|
||||||
setCommunity(_community);
|
setCommunity(_community);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const hideDeleteCommunityDialog = () => {
|
||||||
|
setDeleteCommunityDialog(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const hideDeleteCommunitiesDialog = () => {
|
||||||
|
setDeleteCommunitiesDialog(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDeleteCommunity = (community) => {
|
||||||
|
setCommunity(community);
|
||||||
|
setDeleteCommunityDialog(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const confirmDeleteSelected = () => {
|
||||||
|
setDeleteCommunitiesDialog(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteCommunity = () => {
|
||||||
|
|
||||||
|
/* 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 _community = communitiesList.filter(val => val._id !== community._id);
|
||||||
|
setCommunitiesList(_community);
|
||||||
|
setDeleteCommunityDialog(false);
|
||||||
|
setCommunity(emptyCommunity);
|
||||||
|
toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Comunidad de Viviendas Eliminada', life: 3000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const deleteSelectedCommunities = () => {
|
||||||
|
let _communities = communitiesList.filter(val => !selectedCommunities.includes(val));
|
||||||
|
/* selectedCommunities.map((item) => {
|
||||||
|
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, {
|
||||||
|
cache: 'no-cache',
|
||||||
|
method: 'DELETE',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})*/
|
||||||
|
setCommunitiesList(_communities);
|
||||||
|
setDeleteCommunitiesDialog(false);
|
||||||
|
setSelectedCommunities(null);
|
||||||
|
toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Comunidades de Viviendas Eliminadas', life: 3000 });
|
||||||
|
}
|
||||||
|
|
||||||
|
const actionsCommunity = (rowData) => {
|
||||||
|
return (
|
||||||
|
<div className="actions">
|
||||||
|
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteCommunity(rowData)} />
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
const leftToolbarTemplate = () => {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<div className="my-2">
|
||||||
|
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" onClick={confirmDeleteSelected} disabled={!selectedCommunities || !selectedCommunities.length} />
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const rightToolbarTemplate = () => {
|
||||||
|
return (
|
||||||
|
<React.Fragment>
|
||||||
|
<Button label="Exportar" icon="pi pi-upload" className="p-button-help" />
|
||||||
|
</React.Fragment>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
const header = (
|
||||||
|
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||||
|
<h5 className="m-0">Comunidade de Viviendas</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 deleteCommunityDialogFooter = (
|
||||||
|
<>
|
||||||
|
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteCommunityDialog} />
|
||||||
|
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteCommunity} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
const deleteCommutitiesDialogFooter = (
|
||||||
|
<>
|
||||||
|
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteCommunitiesDialog} />
|
||||||
|
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedCommunities} />
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
|
||||||
|
const headerName = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faHome} style={{ color: "#C08135" }} /> Nombre</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerProvince = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faMapLocationDot} style={{ color: "#D7A86E" }} /> Pronvincia</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerCanton = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faMapLocationDot} style={{ color: "#C08135" }} /> Cantón</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerDistrict = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faMapLocationDot} style={{ color: "#D7A86E" }} /> Distrito</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerPhone = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faPhoneAlt} style={{ color: "#C08135" }} /> Teléfono</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerNumberHouses = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faPhoneAlt} style={{ color: "#D7A86E" }} /> Número de viviendas</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerAdministrator = (
|
||||||
|
<>
|
||||||
|
<p> <FontAwesomeIcon icon={faPhoneAlt} style={{ color: "#C08135" }} /> Administrador</p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
|
const headerOptions = (
|
||||||
|
<>
|
||||||
|
<p>Opciones <FontAwesomeIcon icon={faEllipsis} style={{ color: "#D7A86E" }} /></p>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid">
|
<div className="grid">
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
|
<Toast ref={toast} />
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<h5>Comunidades de Viviendas</h5>
|
< Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
|
||||||
|
<DataTable ref={dt} value={communitiesList} dataKey="_id" paginator rows={5} selection={selectedCommunities} onSelectionChange={(e) => setSelectedCommunities(e.value)}
|
||||||
<DataTable value={communitiesList} scrollable scrollHeight="400px" scrollDirection="both" className="mt-3">
|
scrollable scrollHeight="400px" scrollDirection="both" header={header}
|
||||||
<Column field="name" header="🏘️ Nombre" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
|
||||||
<Column field="province" header="📍 Provincia" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
|
||||||
<Column field="canton" header="📍 Cantón" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} comunidades de viviendas"
|
||||||
<Column field="district" header="📍 Distrito" style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
globalFilter={globalFilter} emptyMessage="No hay comunidades de viviendas registrados.">
|
||||||
<Column field="phone" header="📞 Telefóno" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
<Column selectionMode="multiple" headerStyle={{ width: '3rem' }}></Column>
|
||||||
<Column field="num_houses" header="#️⃣ Número de viviendas" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
<Column field="name" header={headerName} style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||||
<Column field="name_admin" header="👩🏻💼👨🏻💼 Administrador" style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
<Column field="province" header={headerProvince} style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||||
|
<Column field="canton" header={headerCanton} style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||||
|
<Column field="district" header={headerDistrict} style={{ flexGrow: 1, flexBasis: '160px' }}></Column>
|
||||||
|
<Column field="phone" header={headerPhone} style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||||
|
<Column field="num_houses" header={headerNumberHouses} style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||||
|
<Column field="name_admin" header={headerAdministrator} style={{ flexGrow: 1, flexBasis: '180px' }}></Column>
|
||||||
|
<Column header={headerOptions} body={actionsCommunity}></Column>
|
||||||
</DataTable>
|
</DataTable>
|
||||||
|
<Dialog visible={deleteCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteCommunityDialogFooter} onHide={hideDeleteCommunityDialog}>
|
||||||
|
<div className="flex align-items-center justify-content-center">
|
||||||
|
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||||
|
{community && <span>¿Estás seguro que desea eliminar a <b>{community.name}</b>?</span>}
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
|
<Dialog visible={deleteCommunitiesDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteCommutitiesDialogFooter} onHide={hideDeleteCommunitiesDialog}>
|
||||||
|
<div className="flex align-items-center justify-content-center">
|
||||||
|
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
|
||||||
|
{selectedCommunities && <span>¿Está seguro eliminar los adminsitradores del sistema seleccionados?</span>}
|
||||||
|
</div>
|
||||||
|
</Dialog>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="col-12">
|
<div className="col-12">
|
||||||
<div className="card">
|
<div className="card">
|
||||||
<Toast ref={toast} />
|
|
||||||
|
|
||||||
<h5>Registro de comunidad de viviendas</h5>
|
<h5>Registro de comunidad de viviendas</h5>
|
||||||
<div className="p-fluid formgrid grid">
|
<div className="p-fluid formgrid grid">
|
||||||
<div className="field col-12 md:col-12">
|
<div className="field col-12 md:col-12">
|
||||||
|
@ -257,7 +458,7 @@ const Communities = () => {
|
||||||
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
<span className="p-inputgroup-addon p-button p-icon-input-khaki">
|
||||||
<i className="pi pi-home"></i>
|
<i className="pi pi-home"></i>
|
||||||
</span>
|
</span>
|
||||||
<InputText id="name" value={community.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames({'p-invalid' : submitted && community.name === ''})} />
|
<InputText id="name" value={community.name} onChange={(e) => onInputChange(e, 'name')} required autoFocus className={classNames({ 'p-invalid': submitted && community.name === '' })} />
|
||||||
</div>
|
</div>
|
||||||
{submitted && community.name === '' && <small className="p-invalid">Nombre es requirido.</small>}
|
{submitted && community.name === '' && <small className="p-invalid">Nombre es requirido.</small>}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -245,7 +245,7 @@ const Crud = () => {
|
||||||
const statusBodyTemplate = (rowData) => {
|
const statusBodyTemplate = (rowData) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span className="p-column-title">Status</span>
|
<span className="p-column-title">Hi Status</span>
|
||||||
<span className={`product-badge status-${rowData.inventoryStatus.toLowerCase()}`}>{rowData.inventoryStatus}</span>
|
<span className={`product-badge status-${rowData.inventoryStatus.toLowerCase()}`}>{rowData.inventoryStatus}</span>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
Loading…
Reference in New Issue