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;
}
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' })
async postHTMLEmail(@Payload() user: any) {
const url = "http://localhost:3000/";

View File

@ -57,7 +57,7 @@ const AdministradoresComunidad = () => {
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
.then((response2) => response2.json())
.then(data => data.message)
.then( data => {
.then(data => {
item.community_name = data['name']
return item
})
@ -66,17 +66,9 @@ const AdministradoresComunidad = () => {
.then(data => setListaAdmins(data));
}
useEffect(() => {
listaAdmin();
useEffect(() => {
listaAdmin();
}, [])
const deleteAdminCommunity = () => {
/* fetch('http://localhost:4000/community/deleteCommunity/' + community._id, {
}, [])
async function getCommunites() {
@ -89,9 +81,13 @@ const AdministradoresComunidad = () => {
}
useEffect(() => {
getCommunites();
listaAdmin();
}, [])
useEffect(() => {
getCommunites();
},[])
const cList = communitiesList.map((item) => ({
label: item.name,
value: item._id,
@ -163,19 +159,15 @@ const AdministradoresComunidad = () => {
toast.current.show({
severity: 'success',
summary: 'Éxito',
detail: 'Administradores de Comunidad de Viviendas Eliminado',
detail: 'Administradores de Comunidad de Viviendas Eliminados',
life: 3000,
});
};
const hideDeleteAdminCommunityDialog = () => {
setDeleteAdminCommunityDialog(false);
};
const saveAdminCommunity = () => {
if (adminCommunity.name && adminCommunity.dni && adminCommunity.last_name && adminCommunity.email && adminCommunity.phone) {
let _administrators= [...listaAdmins];
let _administrators = [...listaAdmins];
let _adminCommunity = { ...adminCommunity };
_adminCommunity.community_id = communityId;
console.log(_adminCommunity)
@ -224,10 +216,21 @@ const AdministradoresComunidad = () => {
setDeleteAdminCommunityDialog(false);
}
const hideDeleteAdminsCommunitysDialog = () => {
setDeleteAdminsCommunitiesDialog(false);
}
const confirmDeleteAdminCommunity = (adminCommunity) => {
setAdminCommunity(adminCommunity);
setDeleteAdminCommunityDialog(true);
}
const confirmDeleteSelected = () => {
setDeleteAdminsCommunitiesDialog(true);
};
const actionsAdminCommunity = (rowData) => {
return (
<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 = (
<>
@ -288,6 +279,8 @@ const AdministradoresComunidad = () => {
const header = (
<React.Fragment>
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
<h5 className="m-0">Administradores de Comunidades</h5>
<span className="block mt-2 md:mt-0 p-input-icon-left">
@ -297,80 +290,70 @@ const AdministradoresComunidad = () => {
</div>
</React.Fragment>
);
};
const headerName = (
<>
<p> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> Nombre</p>
</>
)
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>{' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> {' '}
Nombre
</p>
</>
);
)
const headerLastName = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#D7A86E' }} />{' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#D7A86E" }} />{' '}
Apellidos
</p>
</>
);
)
const headerDNI = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: '#C08135' }} />{' '}
<p> {' '}
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: "#C08135" }} />{' '}
Identificación
</p>
</>
);
)
const headerEmail = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faAt} style={{ color: '#D7A86E' }} /> Correo
Electrónico
<p> {' '}
<FontAwesomeIcon icon={faAt} style={{ color: "#D7A86E" }} />{' '}
Correo Electrónic
</p>
</>
);
)
const headerPhone = (
<>
<p>
{' '}
<FontAwesomeIcon icon={faPhoneAlt} style={{ color: '#C08135' }} />{' '}
<p> <FontAwesomeIcon icon={faPhoneAlt} style={{ color: "#C08135" }} />{' '}
Teléfono
</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 val = (e.target && e.target.value) || '';
@ -380,118 +363,15 @@ const AdministradoresComunidad = () => {
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 getCommunityValue = event.target.value;
setCommunityId(getCommunityValue);
console.log(getCommunityValue)
}
return (
<div className="grid">
<div className="col-12">
<Toast ref={toast} />
@ -610,8 +490,6 @@ const AdministradoresComunidad = () => {
</div>
</div>
</div>
</div>
</div>
);
};

View File

@ -36,10 +36,20 @@ const AdministradoresSistema = () => {
phone: '',
password: '',
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() {
var data = {
@ -93,6 +103,15 @@ const AdministradoresSistema = () => {
setDeleteAdminsSystemDialog(true);
};
const hideDeleteAdminSystemDialog = () => {
setDeleteAdminSystemDialog(false);
};
const hideDeleteAdminsSystemDialog = () => {
setDeleteAdminsSystemDialog(false);
};
const deleteSysAdmin = () => {
fetch('http://localhost:4000/user/deleteAdminSystem/' + sysadmin._id, {
cache: 'no-cache',
@ -198,7 +217,7 @@ const AdministradoresSistema = () => {
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>
Administradores del sistema <i className="fal fa-user"></i>
</h5>
<span className="block mt-2 md:mt-0 p-input-icon-left">
<i className="pi pi-search" />
@ -234,7 +253,7 @@ const AdministradoresSistema = () => {
label="No"
icon="pi pi-times"
className="p-button-text"
onClick={hideDeleteAdminsSystemsDialog}
onClick={hideDeleteAdminsSystemDialog}
/>
<Button
label="Yes"
@ -424,7 +443,7 @@ const AdministradoresSistema = () => {
header="Confirmar"
modal
footer={deleteAdminsSystemDialogFooter}
onHide={hideDeleteAdminsSystemsDialog}
onHide={hideDeleteAdminsSystemDialog}
>
<div className="flex align-items-center justify-content-center">
<i

View File

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