informacion comunicados

This commit is contained in:
Mariela 2022-09-01 02:18:17 -06:00
parent 33d1a328a5
commit bc8486e1ba
3 changed files with 113 additions and 80 deletions

View File

@ -636,7 +636,7 @@ const AreasComunes = () => {
<Column field="hourMax" sortable header={headerHourMax} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> </Column> <Column field="hourMax" sortable header={headerHourMax} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> </Column>
<Column field="bookable" sortable header={headerBookable} body={bookableBodyTemplate} style={{ flexGrow: 1, flexBasis: '200px', minWidth: '200px', wordBreak: 'break-word' }}></Column> <Column field="bookable" sortable header={headerBookable} body={bookableBodyTemplate} style={{ flexGrow: 1, flexBasis: '200px', minWidth: '200px', wordBreak: 'break-word' }}></Column>
<Column field="status" sortable header={headerStatus} body={statusBodyTemplate} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column> <Column field="status" sortable header={headerStatus} body={statusBodyTemplate} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column style={{ flexGrow: 1, flexBasis: '80px', minWidth: '80px' }} body={actionsCommonArea}></Column> <Column style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px' }} body={actionsCommonArea}></Column>
</DataTable> </DataTable>
<Dialog <Dialog
visible={areaDialog} visible={areaDialog}

View File

@ -37,6 +37,9 @@ const RegistroComunicado = () => {
const dt = useRef(null); const dt = useRef(null);
const [cookies, setCookie] = useCookies(); const [cookies, setCookie] = useCookies();
const [globalFilter, setGlobalFilter] = useState(null); const [globalFilter, setGlobalFilter] = useState(null);
const [postDialog, setPostDialog] = useState(false);
async function listaComunis() { async function listaComunis() {
let comunicadosResponse = await fetch('http://localhost:4000/post/allPosts', { method: 'GET' }); let comunicadosResponse = await fetch('http://localhost:4000/post/allPosts', { method: 'GET' });
@ -127,6 +130,12 @@ const RegistroComunicado = () => {
return ( return (
<React.Fragment> <React.Fragment>
<div className="my-2"> <div className="my-2">
<Button
label="Agregar Comunicado"
icon="pi pi-plus"
className="p-button-primary mr-2"
onClick={openNewPost}
/>
<Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" /> <Button label="Eliminar" icon="pi pi-trash" className="p-button-danger" />
</div> </div>
</React.Fragment> </React.Fragment>
@ -145,6 +154,8 @@ const RegistroComunicado = () => {
setComunicado(rowData); setComunicado(rowData);
setComunicadoId(rowData._id); setComunicadoId(rowData._id);
setSaveButtonLabel('Actualizar'); setSaveButtonLabel('Actualizar');
setPostDialog(true)
} }
const cancelEdit = () => { const cancelEdit = () => {
@ -177,6 +188,20 @@ const RegistroComunicado = () => {
setShowDeleteDialog(true); setShowDeleteDialog(true);
} }
const openNewPost = () => {
setComunicado(emptyComunicado);
setPostDialog(true)
setSubmitted(false);
};
const hidePostDialog = () => {
setSubmitted(false);
setPostDialog(false)
setComunicado(emptyComunicado);
setSaveButtonLabel('Registrar');
}
const deleteDialogFooter = ( const deleteDialogFooter = (
<> <>
<Button label="Cancelar" icon="pi pi-times" className="p-button-secondary" onClick={() => setShowDeleteDialog(false)} /> <Button label="Cancelar" icon="pi pi-times" className="p-button-secondary" onClick={() => setShowDeleteDialog(false)} />
@ -184,6 +209,23 @@ const RegistroComunicado = () => {
</> </>
); );
const postDialogFooter = (
<>
<Button
label={`${saveButtonLabel}`}
icon="pi pi-check"
className="p-button-primary"
onClick={saveComunicado}
/>
<Button
label="Cerrar"
icon="pi pi-times"
className="p-button-text"
onClick={hidePostDialog}
/>
</>
);
const deleteComunicado = () => { const deleteComunicado = () => {
fetch(`http://localhost:4000/post/deletePost/${comunicado._id}`, { fetch(`http://localhost:4000/post/deletePost/${comunicado._id}`, {
cache: 'no-cache', cache: 'no-cache',
@ -235,11 +277,14 @@ const RegistroComunicado = () => {
}} }}
body={actions} /> body={actions} />
</DataTable> </DataTable>
</div> <Dialog
</div> visible={postDialog}
<div className="col-12"> style={{ width: '650px' }}
<div className="card"> header="Mantenimiento del Comunicado"
<h5>Registro de un comunicado para la comunidad</h5> modal
className="p-fluid"
footer={postDialogFooter}
onHide={hidePostDialog}>
<div className="p-fluid formgrid grid"> <div className="p-fluid formgrid grid">
<div className="field col-12 md:col-12"> <div className="field col-12 md:col-12">
<label htmlFor="name">Contenido del comunicado</label> <label htmlFor="name">Contenido del comunicado</label>
@ -261,25 +306,13 @@ const RegistroComunicado = () => {
</div> </div>
</div> </div>
</div> </div>
<div style={{
display: "flex", </div>
justifyContent: "center",
gap: "10px", </Dialog>
width: "100%"
}}>
<Button
label={`${saveButtonLabel}`}
onClick={saveComunicado}
/>
{saveButtonLabel === 'Actualizar' && (
<Button
label="Cancelar"
onClick={cancelEdit}
className="p-button-danger" />)}
</div>
</div>
</div> </div>
</div> </div>
</div> </div>
); );
}; };