fixes errores luego de merch de dev

This commit is contained in:
Mariela 2022-07-26 22:03:08 -06:00
parent 7b435df0e3
commit d1c96e641f
4 changed files with 206 additions and 315 deletions

View File

@ -19,15 +19,6 @@ export class EmailController {
return response; return response;
} }
var response = this.mailService.sendMail({
to: toEmail["email"],
from: "mbonilla.guti@gmail.com",
subject: 'Plain Text Email ✔',
text: 'Welcome NestJS Email Sending Tutorial',
});
return response;
}
@MessagePattern({ cmd: 'html' }) @MessagePattern({ cmd: 'html' })
async postHTMLEmail(@Payload() user: any) { async postHTMLEmail(@Payload() user: any) {
const url = "http://localhost:3000/"; const url = "http://localhost:3000/";

View File

@ -66,17 +66,9 @@ const AdministradoresComunidad = () => {
.then(data => setListaAdmins(data)); .then(data => setListaAdmins(data));
} }
useEffect(() => {
listaAdmin();
useEffect(() => {
listaAdmin();
}, [])
const deleteAdminCommunity = () => {
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
}, [])
async function getCommunites() { async function getCommunites() {
@ -88,6 +80,10 @@ const AdministradoresComunidad = () => {
setCommunitiesList(await list); setCommunitiesList(await list);
} }
useEffect(() => {
listaAdmin();
}, [])
useEffect(() => { useEffect(() => {
getCommunites(); getCommunites();
},[]) },[])
@ -163,15 +159,11 @@ const AdministradoresComunidad = () => {
toast.current.show({ toast.current.show({
severity: 'success', severity: 'success',
summary: 'Éxito', summary: 'Éxito',
detail: 'Administradores de Comunidad de Viviendas Eliminado', detail: 'Administradores de Comunidad de Viviendas Eliminados',
life: 3000, life: 3000,
}); });
}; };
const hideDeleteAdminCommunityDialog = () => {
setDeleteAdminCommunityDialog(false);
};
const saveAdminCommunity = () => { const saveAdminCommunity = () => {
if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.phone) { if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.phone) {
@ -224,10 +216,21 @@ const AdministradoresComunidad = () => {
setDeleteAdminCommunityDialog(false); setDeleteAdminCommunityDialog(false);
} }
const hideDeleteAdminsCommunitysDialog = () => {
setDeleteAdminsCommunitiesDialog(false);
}
const confirmDeleteAdminCommunity = (adminCommunity) => {
setAdminCommunity(adminCommunity);
setDeleteAdminCommunityDialog(true);
}
const confirmDeleteSelected = () => { const confirmDeleteSelected = () => {
setDeleteAdminsCommunitiesDialog(true); setDeleteAdminsCommunitiesDialog(true);
}; };
const actionsAdminCommunity = (rowData) => { const actionsAdminCommunity = (rowData) => {
return ( return (
<div className="actions"> <div className="actions">
@ -240,18 +243,6 @@ const AdministradoresComunidad = () => {
); );
}; };
const confirmDeleteSelected = () => {
setDeleteAdminsCommunitiesDialog(true);
}
const actionsAdminCommunity = (rowData) => {
return (
<div className="actions">
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteAdminCommunity(rowData)} />
</div>
);
}
const deleteAdminCommunityDialogFooter = ( const deleteAdminCommunityDialogFooter = (
<> <>
@ -288,6 +279,8 @@ const AdministradoresComunidad = () => {
const header = ( const header = (
<React.Fragment>
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center"> <div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0">Administradores de Comunidades</h5> <h5 className="m-0">Administradores de Comunidades</h5>
<span className="block mt-2 md:mt-0 p-input-icon-left"> <span className="block mt-2 md:mt-0 p-input-icon-left">
@ -297,80 +290,70 @@ const AdministradoresComunidad = () => {
</div> </div>
</React.Fragment> </React.Fragment>
); );
};
const headerName = ( const headerName = (
<> <>
<p> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> Nombre</p> <p>{' '}
</> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> {' '}
) Nombre
const deleteAdminsCommunityDialogFooter = (
<>
<Button
label="No"
icon="pi pi-times"
className="p-button-text"
onClick={hideDeleteAdminsCommunitysDialog}
/>
<Button
label="Yes"
icon="pi pi-check"
className="p-button-text"
onClick={deleteSelectedAdminsCommunity}
/>
</>
);
const headerName = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} /> Nombre
</p> </p>
</> </>
); )
const headerLastName = ( const headerLastName = (
<> <>
<p> <p>
{' '} {' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#D7A86E' }} />{' '} <FontAwesomeIcon icon={faUserAlt} style={{ color: "#D7A86E" }} />{' '}
Apellidos Apellidos
</p> </p>
</> </>
); )
const headerDNI = ( const headerDNI = (
<> <>
<p> <p> {' '}
{' '} <FontAwesomeIcon icon={faIdCardAlt} style={{ color: "#C08135" }} />{' '}
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: '#C08135' }} />{' '}
Identificación Identificación
</p> </p>
</> </>
); )
const headerEmail = ( const headerEmail = (
<> <>
<p> <p> {' '}
{' '} <FontAwesomeIcon icon={faAt} style={{ color: "#D7A86E" }} />{' '}
<FontAwesomeIcon icon={faAt} style={{ color: '#D7A86E' }} /> Correo Correo Electrónic
Electrónico
</p> </p>
</> </>
); )
const headerPhone = ( const headerPhone = (
<> <>
<p> <p> <FontAwesomeIcon icon={faPhoneAlt} style={{ color: "#C08135" }} />{' '}
{' '}
<FontAwesomeIcon icon={faPhoneAlt} style={{ color: '#C08135' }} />{' '}
Teléfono Teléfono
</p> </p>
</> </>
); )
const headerCommuntiy = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faHomeAlt} style={{ color: "#D7A86E" }} />{' '}
Comunidad</p>
</>
)
const headerOptions = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faEllipsis} size="2x" style={{ color: "#C08135" }} />{' '}
</p>
</>
)
const onInputChange = (e, name) => { const onInputChange = (e, name) => {
const val = (e.target && e.target.value) || ''; const val = (e.target && e.target.value) || '';
@ -380,118 +363,15 @@ const AdministradoresComunidad = () => {
setAdminCommunity(_adminCommunity); setAdminCommunity(_adminCommunity);
} }
const confirmDeleteSelected = () => {
setDeleteAdminsSystemDialog(true);
}
const deleteSysAdmin = () => {
fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._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 _sysadmin = listaAdmins.filter(val => val._id !== sysadmin._id);
setListaAdmins(_sysadmin);
setDeleteAdminSystemDialog(false);
setSysAdmin(emptySysAdmin);
toast.current.show({ severity: 'success', summary: 'Exito', detail: 'Administrador del Sistema Eliminado', life: 3000 });
}
)
.catch(
err => {
console.log('Ocurrió un error con el fetch', err)
toast.current.show({ severity: 'danger', summary: 'Error', detail: 'Administrador del Sistema no se pudo eliminar', life: 3000 });
}
);
}
const header = (
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0">Administradores del sistema <i class="fal fa-user"></i></h5>
<span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" />
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />
</span>
</div>
);
const deleteAdminSystemDialogFooter = (
<>
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminSystemDialog} />
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSysAdmin} />
</>
);
const deleteAdminsSystemDialogFooter = (
<>
<Button label="No" icon="pi pi-times" className="p-button-text" onClick={hideDeleteAdminsSystemsDialog} />
<Button label="Yes" icon="pi pi-check" className="p-button-text" onClick={deleteSelectedAdminsSystem} />
</>
);
return (
<div className="grid">
<div className="col-12">
<Toast ref={toast} />
<div className="card">
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
<DataTable ref={dt} value={listaAdmins} dataKey="_id" paginator rows={5} selection={selectedAdminsCommunities} onSelectionChange={(e) => setSelectedAdminsCommunities(e.value)}
scrollable scrollHeight="400px" scrollDirection="both" header={header}
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords} administradores de comunidades de viviendas"
globalFilter={globalFilter} emptyMessage="No hay administradores de comunidades registrados.">
<Column selectionMode="multiple" headerStyle={{ width: '3rem' }}></Column>
<Column field="name" sortable header={headerName} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column field="last_name" sortable header={headerLastName} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }} alignFrozen="left"></Column>
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
</Column>
<Column field="email" sortable header={headerEmail} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column field="phone" sortable header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column field="community_name" header={headerCommuntiy} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column header={headerOptions} style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdminCommunity}></Column>
</DataTable>
<Dialog visible={deleteAdminCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminCommunityDialogFooter} onHide={hideDeleteAdminCommunityDialog}>
<div className="flex align-items-center justify-content-center">
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
{adminCommunity && <span>¿Estás seguro que desea eliminar a <b>{adminCommunity.name}</b>?</span>}
</div>
</Dialog>
<Dialog visible={deleteAdminsCommunitiesDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminsCommunityDialogFooter} onHide={hideDeleteAdminsCommunitysDialog}>
<div className="flex align-items-center justify-content-center">
<i className="pi pi-exclamation-triangle mr-3" style={{ fontSize: '2rem' }} />
{selectedAdminsCommunities && <span>¿Está seguro eliminar los administradores de las comunidades de viviendas seleccionados?</span>}
</div>
</Dialog>
</div>
const handleCommunities = (event) => { const handleCommunities = (event) => {
const getCommunityValue = event.target.value; const getCommunityValue = event.target.value;
setCommunityId(getCommunityValue); setCommunityId(getCommunityValue);
console.log(getCommunityValue) console.log(getCommunityValue)
} }
return ( return (
<div className="grid"> <div className="grid">
<div className="col-12"> <div className="col-12">
<Toast ref={toast} /> <Toast ref={toast} />
@ -610,8 +490,6 @@ const AdministradoresComunidad = () => {
</div> </div>
</div> </div>
</div> </div>
</div>
</div>
); );
}; };

View File

@ -36,10 +36,20 @@ const AdministradoresSistema = () => {
phone: '', phone: '',
password: '', password: '',
user_type: '1', user_type: '1',
status: '', status: '1',
}; };
async function fetchP() {
let nombres = await fetch(urlFetch, { method: 'GET' });
let adminRes = await nombres.json();
setAdministrators(adminRes.message);
console.log(administrators);
}
useEffect(() => {
fetchP();
}, [])
function registrarAdmin() { function registrarAdmin() {
var data = { var data = {
@ -93,6 +103,15 @@ const AdministradoresSistema = () => {
setDeleteAdminsSystemDialog(true); setDeleteAdminsSystemDialog(true);
}; };
const hideDeleteAdminSystemDialog = () => {
setDeleteAdminSystemDialog(false);
};
const hideDeleteAdminsSystemDialog = () => {
setDeleteAdminsSystemDialog(false);
};
const deleteSysAdmin = () => { const deleteSysAdmin = () => {
fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._id, { fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._id, {
cache: 'no-cache', cache: 'no-cache',
@ -198,7 +217,7 @@ const AdministradoresSistema = () => {
const header = ( const header = (
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center"> <div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0"> <h5 className="m-0">
Administradores del sistema <i class="fal fa-user"></i> Administradores del sistema <i className="fal fa-user"></i>
</h5> </h5>
<span className="block mt-2 md:mt-0 p-input-icon-left"> <span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" /> <i className="pi pi-search" />
@ -234,7 +253,7 @@ const AdministradoresSistema = () => {
label="No" label="No"
icon="pi pi-times" icon="pi pi-times"
className="p-button-text" className="p-button-text"
onClick={hideDeleteAdminsSystemsDialog} onClick={hideDeleteAdminsSystemDialog}
/> />
<Button <Button
label="Yes" label="Yes"
@ -424,7 +443,7 @@ const AdministradoresSistema = () => {
header="Confirmar" header="Confirmar"
modal modal
footer={deleteAdminsSystemDialogFooter} footer={deleteAdminsSystemDialogFooter}
onHide={hideDeleteAdminsSystemsDialog} onHide={hideDeleteAdminsSystemDialog}
> >
<div className="flex align-items-center justify-content-center"> <div className="flex align-items-center justify-content-center">
<i <i

View File

@ -23,7 +23,7 @@ const Communities = () => {
district: districtId, district: districtId,
phone: '', phone: '',
num_houses: 0, num_houses: 0,
status: 'activo', status: '1',
date_entry: new Date(), date_entry: new Date(),
houses: [], houses: [],
}; };
@ -64,17 +64,6 @@ const Communities = () => {
parent: item.parentCode, parent: item.parentCode,
})); }));
useEffect(() => {
fillProvinces();
}, []);
useEffect(() => {
fillCantons();
}, [provinciaId]);
useEffect(() => {
fillDistricts();
}, [cantonId]);
async function getProvinces() { async function getProvinces() {
const response = await fetch('assets/demo/data/provincias.json', { const response = await fetch('assets/demo/data/provincias.json', {
@ -118,6 +107,20 @@ const Communities = () => {
setDistrictsList(await districts); setDistrictsList(await districts);
} }
useEffect(() => {
fillProvinces();
}, []);
useEffect(() => {
fillCantons();
}, [provinciaId]);
useEffect(() => {
fillDistricts();
}, [cantonId]);
const handleProvinces = (event) => { const handleProvinces = (event) => {
const getprovinciaId = event.target.value; const getprovinciaId = event.target.value;
setProvinciaId(getprovinciaId); setProvinciaId(getprovinciaId);