diff --git a/web-ui/web-react/src/components/AdministradoresSistema.js b/web-ui/web-react/src/components/AdministradoresSistema.js
index 40529fc6..10f299f2 100644
--- a/web-ui/web-react/src/components/AdministradoresSistema.js
+++ b/web-ui/web-react/src/components/AdministradoresSistema.js
@@ -58,7 +58,7 @@ const AdministradoresSistema = () => {
item.status_text = 'Inactivo';
}
})
- setAdministrators(adminRes.message);
+ setAdministrators(await data);
}
useEffect(() => {
fetchP();
@@ -262,7 +262,7 @@ const AdministradoresSistema = () => {
diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js
index a092910f..1b2f069f 100644
--- a/web-ui/web-react/src/components/GuardasSeguridad.js
+++ b/web-ui/web-react/src/components/GuardasSeguridad.js
@@ -11,18 +11,11 @@ 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';
+import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
+import { useCookies } from "react-cookie";
const GuardasSeguridad = () => {
- const [listaGuardas, setListaGuardas] = useState([]);
- const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134');
- const [guarda, setGuarda] = useState(emptyGuarda);
- const [selectedGuardas, setSelectedGuardas] = useState(null);
- const [globalFilter, setGlobalFilter] = useState(null);
- const [deleteGuardaDialog, setDeleteGuardaDialog] = useState(false);
- const [deleteGuardasDialog, setDeleteGuardasDialog] = useState(false);
- const toast = useRef(null);
- const dt = useRef(null);
+
let emptyGuarda = {
_id: null,
dni: '',
@@ -32,16 +25,44 @@ const GuardasSeguridad = () => {
phone: '',
password: '',
user_type: '1',
- status: ''
+ status: '1',
+ status_text: '',
};
+ const [listaGuardas, setListaGuardas] = useState([]);
+ const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/');
+ const [guarda, setGuarda] = useState(emptyGuarda);
+ const [selectedGuardas, setSelectedGuardas] = useState(null);
+ const [globalFilter, setGlobalFilter] = useState(null);
+ const [deleteGuardaDialog, setDeleteGuardaDialog] = useState(false);
+ const [deleteGuardasDialog, setDeleteGuardasDialog] = useState(false);
+ const toast = useRef(null);
+ const dt = useRef(null);
+
+ const [cookies, setCookie] = useCookies();
+ const [changeStatusGuardDialog, setChangeStatusGuardDialog] = useState(false);
+
+ const [guardDialog, setGuardDialog] = useState(false);
+ const [submitted, setSubmitted] = useState(false);
+
async function listaGuardasF() {
- let nombres = await fetch(urlFetch, { method: 'GET' });
+ let nombres = await fetch((urlFetch + cookies.community_id), { method: 'GET' });
let listaGuardasRes = await nombres.json();
- setListaGuardas(listaGuardasRes.message);
+ let data = await listaGuardasRes.message.filter(
+ (val) => val.status != -1,
+ )
+ await data.map((item) => {
+ if (item.status == '1') {
+ item.status_text = 'Activo';
+ } else if (item.status == '0') {
+ item.status_text = 'Inactivo';
+ }
+ })
+ setListaGuardas(await data);
}
+
useEffect(() => {
listaGuardasF();
}, [])
@@ -56,7 +77,7 @@ const GuardasSeguridad = () => {
password: document.getElementById('correo_electronico').value,
user_type: "4", //4 es guarda
status: "1",
- community_id: "62be68215692582bbfd77134"
+ community_id: cookies.community_id
};
var data2 = {
dni: "11979037",
@@ -66,7 +87,7 @@ const GuardasSeguridad = () => {
phone: 84664515,
password: "1203",
user_type: "2",
- status: "4",
+ status: "1",
community_id: "62be68215692582bbfd77134"
}
console.log('ssss');
@@ -74,7 +95,7 @@ const GuardasSeguridad = () => {
cache: 'no-cache',
method: 'POST',
mode: 'cors',
- body: JSON.stringify(data2),
+ body: JSON.stringify(data),
headers: {
'Content-Type': 'application/json'
}
@@ -89,7 +110,6 @@ const GuardasSeguridad = () => {
)
.then(
function (response) {
- console.log('fff');
listaGuardasF();
}
)
@@ -98,22 +118,51 @@ const GuardasSeguridad = () => {
);
}
- const hideDeleteGuardaDialog = () => {
- setDeleteGuardaDialog(false);
+ const cambiarStatusUser = () => {
+ if (guarda.status == '1') {
+ guarda.status = '0';
+ guarda.status_text = 'Inactivo';
+
+ } else if (guarda.status == '0') {
+ guarda.status = '1';
+ guarda.status_text = 'Activo';
+ }
+ var data = {
+ id: guarda._id,
+ status: guarda.status,
+ };
+ fetch('http://localhost:4000/user/changeStatus', {
+ cache: 'no-cache',
+ method: 'POST',
+ body: JSON.stringify(data),
+ 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) {
+ setChangeStatusGuardDialog(false);
+ toast.current.show({
+ severity: 'success',
+ summary: 'Éxito',
+ detail: 'Guarda de Seguridad Actualizado',
+ life: 3000,
+ });
+ }
+ )
+ .catch(
+ err => console.log('Ocurrió un error con el fetch', err)
+ );
}
- const hideDeleteGuardasDialog = () => {
- setDeleteGuardasDialog(false);
- }
-
- const confirmDeleteGuarda = (guarda) => {
- setGuarda(guarda);
- setDeleteGuardaDialog(true);
- }
-
- const confirmDeleteSelected = () => {
- setDeleteGuardasDialog(true);
- }
const deleteGuarda = () => {
@@ -166,10 +215,70 @@ const GuardasSeguridad = () => {
toast.current.show({ severity: 'success', summary: 'Éxito', detail: 'Administradores del Sistema Eliminados', life: 3000 });
}
- const actionsAdmin = (rowData) => {
+ const hideDeleteGuardaDialog = () => {
+ setDeleteGuardaDialog(false);
+ }
+
+ const hideDeleteGuardasDialog = () => {
+ setDeleteGuardasDialog(false);
+ }
+
+ const confirmDeleteGuarda = (guarda) => {
+ setGuarda(guarda);
+ setDeleteGuardaDialog(true);
+ }
+
+ const confirmDeleteSelected = () => {
+ setDeleteGuardasDialog(true);
+ }
+
+ const hideChangeStatusGuardDialog = () => {
+ setChangeStatusGuardDialog(false);
+ };
+
+ const confirmChangeStatusGuard = (guard) => {
+ setGuarda(guard);
+ setChangeStatusGuardDialog(true);
+ };
+
+ const hideGuardDialog = () => {
+ setSubmitted(false);
+ setGuardDialog(false);
+ };
+
+ const infoGuard = (guard) => {
+ setGuarda(guard);
+ setGuardDialog(true);
+ };
+
+
+ const actionsGuard = (rowData) => {
+ let icono = '';
+ let text = '';
+ if (rowData.status == '0') {
+ icono = "pi pi-eye";
+ text = "Activar Guarda de Seguridad"
+ } else if (rowData.status == '1') {
+ icono = "pi pi-eye-slash";
+ text = "Inactivar Guarda de Seguridad"
+
+ }
return (
-
);
}
@@ -178,7 +287,11 @@ const GuardasSeguridad = () => {
return (
-
+
)
@@ -187,7 +300,9 @@ const GuardasSeguridad = () => {
const rightToolbarTemplate = () => {
return (
-
+
)
}
@@ -205,17 +320,47 @@ const GuardasSeguridad = () => {
const deleteAdminSystemDialogFooter = (
<>
-
+
>
);
const deleteAdminsSystemDialogFooter = (
<>
-
+
>
);
+ const changeStatusGuardDialogFooter = (
+ <>
+
+
+ >
+ );
+
+ const guardDialogFooter = (
+ <>
+
+
+ >
+ );
+
+
const headerName = (
<>
{' '}
@@ -261,6 +406,26 @@ const GuardasSeguridad = () => {
>
)
+ const headerStatus = (
+ <>
+
{' '}
+ {' '}
+ Estado
+
+ >
+ )
+
+ const statusBodyTemplate = (rowData) => {
+ return (
+ <>
+
+ {rowData.status_text}
+
+ >
+ );
+ };
return (
@@ -281,8 +446,85 @@ const GuardasSeguridad = () => {
-
+
+
+
+
-
+
-
+
@@ -319,7 +581,7 @@ const GuardasSeguridad = () => {
-
+
diff --git a/web-ui/web-react/src/components/Inquilinos.js b/web-ui/web-react/src/components/Inquilinos.js
index 78fa76df..26971e1f 100644
--- a/web-ui/web-react/src/components/Inquilinos.js
+++ b/web-ui/web-react/src/components/Inquilinos.js
@@ -15,6 +15,7 @@ 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 { faHashtag } from '@fortawesome/free-solid-svg-icons';
+import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons';
import { useCookies } from "react-cookie";
@@ -34,7 +35,8 @@ const Inquilinos = () => {
number_house: 'Sin número de vivienda',
user_type: '4',
date_entry: new Date(),
- status: '1'
+ status: '1',
+ status_text: '',
};
const [tenants, setTenants] = useState([]);
@@ -50,6 +52,7 @@ const Inquilinos = () => {
const dt = useRef(null);
const [cookies, setCookie] = useCookies();
+ const [changeStatusTenantDialog, setChangeStatusTenantDialog] = useState(false);
async function tenantsList() {
@@ -57,9 +60,18 @@ const Inquilinos = () => {
.then((response) => response.json())
.then(data => data.message)
.then(data => {
-
+ data = data.filter(
+ (val) => val.status != -1,
+ )
data.map((item) => {
- if(item.number_house ==""){
+ if (item.status == '1') {
+ item.status_text = 'Activo';
+ } else if (item.status == '0') {
+ item.status_text = 'Inactivo';
+ }
+
+
+ if (item.number_house == "") {
item.number_house = "Sin vivienda asignada";
}
})
@@ -72,7 +84,9 @@ const Inquilinos = () => {
let response = await fetch('http://localhost:4000/community/allCommunities', { method: 'GET' });
let resList = await response.json();
let list = await resList.message;
-
+ list = await list.filter(
+ (val) => val.status != -1,
+ )
setCommunitiesList(await list);
}
@@ -189,6 +203,50 @@ const Inquilinos = () => {
});
};
+ const cambiarStatusUser = () => {
+ if (tenant.status == '1') {
+ tenant.status = '0';
+ tenant.status_text = 'Inactivo';
+
+ } else if (tenant.status == '0') {
+ tenant.status = '1';
+ tenant.status_text = 'Activo';
+ }
+ var data = {
+ id: tenant._id,
+ status: tenant.status,
+ };
+ fetch('http://localhost:4000/user/changeStatus', {
+ cache: 'no-cache',
+ method: 'POST',
+ body: JSON.stringify(data),
+ 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) {
+ setChangeStatusTenantDialog(false);
+ toast.current.show({
+ severity: 'success',
+ summary: 'Éxito',
+ detail: 'Inquilino Actualizado',
+ life: 3000,
+ });
+ }
+ )
+ .catch(
+ err => console.log('Ocurrió un error con el fetch', err)
+ );
+ }
const hideDeleteTenantDialog = () => {
setDeleteTenantDialog(false);
@@ -207,11 +265,37 @@ const Inquilinos = () => {
setDeleteTenantsDialog(true);
};
+ const hideChangeStatusTenantDialog = () => {
+ setChangeStatusTenantDialog(false);
+ };
+
+ const confirmChangeStatusTenant = (tenant) => {
+ setTenant(tenant);
+ setChangeStatusTenantDialog(true);
+ };
const actionsTenant = (rowData) => {
+ let icono = '';
+ let text = '';
+ if (rowData.status == '0') {
+ icono = "pi pi-eye";
+ text = "Activar Inquilino"
+ } else if (rowData.status == '1') {
+ icono = "pi pi-eye-slash";
+ text = "Inactivar Inquilino"
+
+ }
return (