diff --git a/web-ui/web-react/src/components/GuardasSeguridad.js b/web-ui/web-react/src/components/GuardasSeguridad.js index d09b09fc..f9c7054e 100644 --- a/web-ui/web-react/src/components/GuardasSeguridad.js +++ b/web-ui/web-react/src/components/GuardasSeguridad.js @@ -15,8 +15,23 @@ import { faCircleQuestion } from '@fortawesome/free-solid-svg-icons'; import { useCookies } from "react-cookie"; const GuardasSeguridad = () => { + + let emptyGuarda = { + _id: null, + dni: '', + name: '', + last_name: '', + email: '', + phone: '', + password: '', + user_type: '1', + status: '1', + status_text: '', + }; + + const [listaGuardas, setListaGuardas] = useState([]); - const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134'); + const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/'); const [guarda, setGuarda] = useState(emptyGuarda); const [selectedGuardas, setSelectedGuardas] = useState(null); const [globalFilter, setGlobalFilter] = useState(null); @@ -28,23 +43,12 @@ const GuardasSeguridad = () => { const [cookies, setCookie] = useCookies(); const [changeStatusGuardDialog, setChangeStatusGuardDialog] = useState(false); - let emptyGuarda = { - _id: null, - dni: '', - name: '', - last_name: '', - email: '', - phone: '', - password: '', - user_type: '1', - status: '', - status_text: '', - }; - + 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(); let data = await listaGuardasRes.message.filter( (val) => val.status != -1, @@ -58,6 +62,7 @@ const GuardasSeguridad = () => { }) setListaGuardas(await data); } + useEffect(() => { listaGuardasF(); }, []) @@ -236,8 +241,18 @@ const GuardasSeguridad = () => { setChangeStatusGuardDialog(true); }; + const hideGuardDialog = () => { + setSubmitted(false); + setGuardDialog(false); + }; - const actionsAdmin = (rowData) => { + const infoGuard = (guard) => { + setGuarda(guard); + setGuardDialog(true); + }; + + + const actionsGuard = (rowData) => { let icono = ''; let text = ''; if (rowData.status == '0') { @@ -250,6 +265,11 @@ const GuardasSeguridad = () => { } return (
+