diff --git a/web-ui/web-react/src/components/ComunidadViviendas.js b/web-ui/web-react/src/components/ComunidadViviendas.js index db3da58b..bb4e549d 100644 --- a/web-ui/web-react/src/components/ComunidadViviendas.js +++ b/web-ui/web-react/src/components/ComunidadViviendas.js @@ -45,6 +45,7 @@ const Communities = () => { const [globalFilter, setGlobalFilter] = useState(null); const [deleteCommunityDialog, setDeleteCommunityDialog] = useState(false); const [deleteCommunitiesDialog, setDeleteCommunitiesDialog] = useState(false); + const [editCommunityDialog, setEditCommunityDialog] = useState(false); const toast = useRef(null); const dt = useRef(null); @@ -54,7 +55,6 @@ const Communities = () => { const [tenants, setTenants] = useState([]); const [communityDialog, setCommunityDialog] = useState(false); - const [editcommunityDialog, setEditCommunityDialog] = useState(false); @@ -315,6 +315,93 @@ const Communities = () => { setEditCommunityDialog(true); }; + const hideEditCommunityDialog = () => { + setEditCommunityDialog(false); + }; + + const confirmEditCommunity = (community) => { + setCommunity(community); + setEditCommunityDialog(true); + }; + //desactivar o activar una comunidad + const cambiarDesactivarEstadoCommunity = () => { + var data = { + id: community._id, + status: "0", + }; + console.log(data); + + fetch('http://localhost:4000/community/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) { + setEditCommunityDialog(false); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Comunidad de Viviendas Actualizada', + life: 3000, + }); + } + ) + .catch( + err => console.log('Ocurrió un error con el fetch', err) + ); + } + //desactivar o activar una comunidad + const cambiarActivarEstadoCommunity = () => { + var data = { + id: community._id, + status: "1", + }; + console.log(data); + fetch('http://localhost:4000/community/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) { + setEditCommunityDialog(false); + toast.current.show({ + severity: 'success', + summary: 'Éxito', + detail: 'Comunidad de Viviendas Actualizada', + life: 3000, + }); + } + ) + .catch( + err => console.log('Ocurrió un error con el fetch', err) + ); + } + + const deleteCommunity = () => { /* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, { cache: 'no-cache', @@ -387,14 +474,24 @@ const Communities = () => { const actionsCommunity = (rowData) => { return (
+
@@ -488,6 +585,39 @@ const Communities = () => { /> ); + const editDesactivarCommunityDialogFooter = ( + <> +