diff --git a/api-gateway/src/app.controller.ts b/api-gateway/src/app.controller.ts index b261b444..3884c89a 100644 --- a/api-gateway/src/app.controller.ts +++ b/api-gateway/src/app.controller.ts @@ -118,6 +118,11 @@ export class AppController { return this.appService.findUser(paramUserDNI); } + @Get('user/findUserById/:id') + findUserById(@Param('id') id: string) { + return this.appService.findUserById(id); + } + @Delete('user/deleteAdminSystem/:id') deleteAdminSystem(@Param('id') id: string) { return this.appService.deleteAdminSystem(id); diff --git a/api-gateway/src/app.service.ts b/api-gateway/src/app.service.ts index ca2a0aaa..52c79492 100644 --- a/api-gateway/src/app.service.ts +++ b/api-gateway/src/app.service.ts @@ -187,6 +187,17 @@ export class AppService { .pipe(map((message: string) => ({ message }))); } + + //GET parameter from API + findUserById(id: string) { + const pattern = { cmd: 'findById' }; + const payload = { id: id }; + return this.clientUserApp + .send(pattern, payload) + .pipe(map((message: string) => ({ message }))); + } + + // ====================== COMMUNITIES =============================== //POST parameter from API diff --git a/servicio-usuarios/src/users/users.controller.ts b/servicio-usuarios/src/users/users.controller.ts index 0b8a00be..bd875b12 100644 --- a/servicio-usuarios/src/users/users.controller.ts +++ b/servicio-usuarios/src/users/users.controller.ts @@ -40,6 +40,12 @@ export class UsersController { return this.userService.findOneByDNI(dni); } + @MessagePattern({ cmd: 'findById' }) + findById(@Payload() id: string) { + let _id = id['id']; + return this.userService.findOne(_id); + } + @MessagePattern({ cmd: 'findGuardsCommunity' }) findGuardsCommunity(@Payload() community_id: string) { let pcommunity_id = community_id['community_id']; diff --git a/web-ui/web-react/public/assets/themes/khaki/theme.css b/web-ui/web-react/public/assets/themes/khaki/theme.css index 5aa7ff7b..10393ffd 100644 --- a/web-ui/web-react/public/assets/themes/khaki/theme.css +++ b/web-ui/web-react/public/assets/themes/khaki/theme.css @@ -7120,6 +7120,15 @@ } +.icon-khaki { + color: var(--primary-color); +} + +.row { + display: flex; +} + + .status { border-radius: var(--border-radius); padding: 0.25em 0.5rem; diff --git a/web-ui/web-react/src/App.js b/web-ui/web-react/src/App.js index a70c89ec..46d3b946 100644 --- a/web-ui/web-react/src/App.js +++ b/web-ui/web-react/src/App.js @@ -184,7 +184,7 @@ const App = () => { to: '/guardasSeguridad', }, { - label: 'Comunidadades', + label: 'Comunidades', icon: PrimeIcons.BUILDING, to: '/comunidadesViviendas', }, diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index c0d9a92c..db3da58b 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -9,10 +9,11 @@ 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 { faHome, faUserAlt } from '@fortawesome/free-solid-svg-icons'; import { faMapLocationDot } from '@fortawesome/free-solid-svg-icons'; import { faPhoneAlt } from '@fortawesome/free-solid-svg-icons'; import { faEllipsis } from '@fortawesome/free-solid-svg-icons'; +import { faHashtag } from '@fortawesome/free-solid-svg-icons'; const Communities = () => { let emptyCommunity = { @@ -47,6 +48,16 @@ const Communities = () => { const toast = useRef(null); const dt = useRef(null); + + + //para el perfil de la comunidad + const [tenants, setTenants] = useState([]); + + const [communityDialog, setCommunityDialog] = useState(false); + const [editcommunityDialog, setEditCommunityDialog] = useState(false); + + + const p = provincesList.map((item) => ({ label: item.name, value: item.code, @@ -120,7 +131,7 @@ const Communities = () => { fillDistricts(); }, [cantonId]); - + const handleProvinces = (event) => { const getprovinciaId = event.target.value; setProvinciaId(getprovinciaId); @@ -165,6 +176,20 @@ const Communities = () => { getCommunites(); }, []); + async function tenantsList(id) { + await fetch(`http://localhost:4000/user/findTenants/${id}`, { method: 'GET' }) + .then((response) => response.json()) + .then(data => data.message) + .then(data => { + setTenants(data) + }); + } + + useEffect(() => { + tenantsList(community._id); + }, []) + + const saveCommunity = () => { if ( community.name && @@ -233,6 +258,20 @@ const Communities = () => { } }; + + + function findNameTenant(tenant_id) { + let name = ''; + if (tenant_id == '') { + name = 'Sin inquilino'; + } else { + let tenant = tenants.find(t => t._id == tenant_id ) + name = tenant['name'] + ' ' + tenant['last_name']; + } + console.log(name); + return name; + } + const onInputChange = (e, name) => { const val = (e.target && e.target.value) || ''; let _community = { ...community }; @@ -241,6 +280,11 @@ const Communities = () => { setCommunity(_community); }; + const hideCommunityDialog = () => { + setSubmitted(false); + setCommunityDialog(false); + }; + const hideDeleteCommunityDialog = () => { setDeleteCommunityDialog(false); }; @@ -258,6 +302,19 @@ const Communities = () => { setDeleteCommunitiesDialog(true); }; + + const infoCommunity = async (community) => { + await tenantsList(community._id); + + setCommunity({ ...community }); + setCommunityDialog(true); + }; + + const editCommunity = (community) => { + setCommunity({ ...community }); + setEditCommunityDialog(true); + }; + const deleteCommunity = () => { /* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, { cache: 'no-cache', @@ -330,6 +387,11 @@ const Communities = () => { const actionsCommunity = (rowData) => { return (
+
); + const communityDialogFooter = ( + <> +