diff --git a/servicio-areas-comunes/src/schemas/common_area.schema.ts b/servicio-areas-comunes/src/schemas/common_area.schema.ts index c01a32d8..927cdbbb 100644 --- a/servicio-areas-comunes/src/schemas/common_area.schema.ts +++ b/servicio-areas-comunes/src/schemas/common_area.schema.ts @@ -19,6 +19,9 @@ export class CommonArea { @Prop() bookable: number; //saber si es necesario reservarlo o no + @Prop() + status: string; + @Prop() community_id: string; } diff --git a/web-ui/web-react/src/components/AreasComunes.js b/web-ui/web-react/src/components/AreasComunes.js index 7eefc66c..09943617 100644 --- a/web-ui/web-react/src/components/AreasComunes.js +++ b/web-ui/web-react/src/components/AreasComunes.js @@ -29,6 +29,8 @@ const AreasComunes = () => { community_id: '', bookable: '1', bookable_text: '', + status: '1', + status_text: '', }; const [commonAreaList, setCommonAreaList] = useState([]); @@ -48,12 +50,20 @@ const AreasComunes = () => { .then((response) => response.json()) .then(data => data.message) .then(data => { - if(data) { + if (data) { data.map(item => { - if(item.bookable == '1') { - item.bookable_text = 'Disponible'; - } else{ - item.bookable_text = 'Cerrado'; + if (item.bookable == '1') { + item.bookable_text = 'Obligatoria'; + } else { + item.bookable_text = 'Libre'; + } + + if (item.status == '1') { + item.status_text = 'Activo'; + } else if(item.status == '0') { + item.status_text = 'Inactivo'; + } else { + item.status_text = 'Eliminado'; } }) } @@ -67,49 +77,44 @@ const AreasComunes = () => { const deleteCommonArea = () => { - /* 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 _common_areas = commonAreaList.filter( - (val) => val._id !== commonArea._id, - ); - setCommonAreaList(_common_areas); - setDeleteCommonAreaDialog(false); - setCommonArea(emptyCommonArea); - toast.current.show({ - severity: 'success', - summary: 'Área Común Eliminada', - life: 3000, - }); + fetch('http://localhost:4000/commonArea/deleteCommonArea/' + commonArea._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 _common_areas = commonAreaList.filter( + (val) => val._id !== commonArea._id, + ); + setCommonAreaList(_common_areas); + setDeleteCommonAreaDialog(false); + setCommonArea(emptyCommonArea); + toast.current.show({ + severity: 'success', + summary: 'Área Común Eliminada', + life: 3000, + }); + } + ) + .catch( + err => { + console.log('Ocurrió un error con el fetch', err) + toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Área Común no se pudo eliminar', life: 3000 }); + } + ); + }; const deleteSelectedCommonAreas = () => { @@ -247,23 +252,44 @@ const AreasComunes = () => { <>

{' '} {' '} - Reservable + Reservación +

+ + ) + + const headerStatus = ( + <> +

{' '} + {' '} + Estado

) + const bookableBodyTemplate = (rowData) => { + return ( + <> + + {rowData.bookable_text} + + + ); + }; + const statusBodyTemplate = (rowData) => { return ( - <> - - {rowData.bookable_text} - - + <> + + {rowData.status_text} + + ); - }; + }; return (
@@ -279,9 +305,10 @@ const AreasComunes = () => { globalFilter={globalFilter} emptyMessage="No hay áreas comunes registrados."> - - - + + + +