fixes errores luego de merch de dev
This commit is contained in:
parent
7b435df0e3
commit
d1c96e641f
|
@ -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/";
|
||||||
|
|
|
@ -57,7 +57,7 @@ const AdministradoresComunidad = () => {
|
||||||
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
|
return fetch(`http://localhost:4000/community/findCommunityName/${item.community_id}`, { method: 'GET' })
|
||||||
.then((response2) => response2.json())
|
.then((response2) => response2.json())
|
||||||
.then(data => data.message)
|
.then(data => data.message)
|
||||||
.then( data => {
|
.then(data => {
|
||||||
item.community_name = data['name']
|
item.community_name = data['name']
|
||||||
return item
|
return item
|
||||||
})
|
})
|
||||||
|
@ -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() {
|
||||||
|
@ -89,9 +81,13 @@ const AdministradoresComunidad = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getCommunites();
|
listaAdmin();
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
getCommunites();
|
||||||
|
},[])
|
||||||
|
|
||||||
const cList = communitiesList.map((item) => ({
|
const cList = communitiesList.map((item) => ({
|
||||||
label: item.name,
|
label: item.name,
|
||||||
value: item._id,
|
value: item._id,
|
||||||
|
@ -131,51 +127,47 @@ const AdministradoresComunidad = () => {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
*/
|
*/
|
||||||
let _administrators = listaAdmins.filter(
|
let _administrators = listaAdmins.filter(
|
||||||
(val) => val._id !== adminCommunity._id,
|
(val) => val._id !== adminCommunity._id,
|
||||||
);
|
);
|
||||||
setListaAdmins(_administrators);
|
setListaAdmins(_administrators);
|
||||||
setDeleteAdminCommunityDialog(false);
|
setDeleteAdminCommunityDialog(false);
|
||||||
setAdminCommunity(emptyAdminCommunity);
|
setAdminCommunity(emptyAdminCommunity);
|
||||||
toast.current.show({
|
toast.current.show({
|
||||||
severity: 'success',
|
severity: 'success',
|
||||||
summary: 'Administrador de Comunidad Eliminada',
|
summary: 'Administrador de Comunidad Eliminada',
|
||||||
life: 3000,
|
life: 3000,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const deleteSelectedAdminsCommunity = () => {
|
const deleteSelectedAdminsCommunity = () => {
|
||||||
let _admins = listaAdmins.filter(
|
let _admins = listaAdmins.filter(
|
||||||
(val) => !selectedAdminsCommunities.includes(val),
|
(val) => !selectedAdminsCommunities.includes(val),
|
||||||
);
|
);
|
||||||
/* selectedCommunities.map((item) => {
|
/* selectedCommunities.map((item) => {
|
||||||
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, {
|
fetch('http://localhost:4000/user/deleteCommunity/' + item._id, {
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})*/
|
})*/
|
||||||
setListaAdmins(_admins);
|
setListaAdmins(_admins);
|
||||||
setDeleteAdminsCommunitiesDialog(false);
|
setDeleteAdminsCommunitiesDialog(false);
|
||||||
setSelectedAdminsCommunities(null);
|
setSelectedAdminsCommunities(null);
|
||||||
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) {
|
||||||
|
|
||||||
let _administrators= [...listaAdmins];
|
let _administrators = [...listaAdmins];
|
||||||
let _adminCommunity = { ...adminCommunity };
|
let _adminCommunity = { ...adminCommunity };
|
||||||
_adminCommunity.community_id = communityId;
|
_adminCommunity.community_id = communityId;
|
||||||
console.log(_adminCommunity)
|
console.log(_adminCommunity)
|
||||||
|
@ -199,7 +191,7 @@ const AdministradoresComunidad = () => {
|
||||||
)
|
)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
|
|
||||||
// _adminCommunity.community_id = communitiesList.find(c => c._id === _adminCommunity.community_id).name
|
// _adminCommunity.community_id = communitiesList.find(c => c._id === _adminCommunity.community_id).name
|
||||||
|
|
||||||
_administrators.push(_adminCommunity);
|
_administrators.push(_adminCommunity);
|
||||||
toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Administrador de Comunidad de vivienda Creada', life: 3000 });
|
toast.current.show({ severity: 'success', summary: 'Registro exitoso', detail: 'Administrador de Comunidad de vivienda Creada', life: 3000 });
|
||||||
|
@ -224,34 +216,33 @@ const AdministradoresComunidad = () => {
|
||||||
setDeleteAdminCommunityDialog(false);
|
setDeleteAdminCommunityDialog(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
const confirmDeleteSelected = () => {
|
const hideDeleteAdminsCommunitysDialog = () => {
|
||||||
setDeleteAdminsCommunitiesDialog(true);
|
setDeleteAdminsCommunitiesDialog(false);
|
||||||
};
|
}
|
||||||
|
|
||||||
const actionsAdminCommunity = (rowData) => {
|
const confirmDeleteAdminCommunity = (adminCommunity) => {
|
||||||
return (
|
setAdminCommunity(adminCommunity);
|
||||||
<div className="actions">
|
setDeleteAdminCommunityDialog(true);
|
||||||
<Button
|
}
|
||||||
icon="pi pi-trash"
|
|
||||||
className="p-button-rounded p-button-danger mt-2"
|
|
||||||
onClick={() => confirmDeleteAdminCommunity(rowData)}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const confirmDeleteSelected = () => {
|
const confirmDeleteSelected = () => {
|
||||||
setDeleteAdminsCommunitiesDialog(true);
|
setDeleteAdminsCommunitiesDialog(true);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const actionsAdminCommunity = (rowData) => {
|
const actionsAdminCommunity = (rowData) => {
|
||||||
return (
|
return (
|
||||||
<div className="actions">
|
<div className="actions">
|
||||||
<Button icon="pi pi-trash" className="p-button-rounded p-button-danger mt-2" onClick={() => confirmDeleteAdminCommunity(rowData)} />
|
<Button
|
||||||
|
icon="pi pi-trash"
|
||||||
|
className="p-button-rounded p-button-danger mt-2"
|
||||||
|
onClick={() => confirmDeleteAdminCommunity(rowData)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
const deleteAdminCommunityDialogFooter = (
|
const deleteAdminCommunityDialogFooter = (
|
||||||
<>
|
<>
|
||||||
|
@ -288,89 +279,81 @@ const AdministradoresComunidad = () => {
|
||||||
|
|
||||||
|
|
||||||
const header = (
|
const header = (
|
||||||
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
<React.Fragment>
|
||||||
<h5 className="m-0">Administradores de Comunidades</h5>
|
|
||||||
<span className="block mt-2 md:mt-0 p-input-icon-left">
|
<div className="flex flex-column md:flex-row md:justify-content-between md:align-items-center">
|
||||||
<i className="pi pi-search" />
|
<h5 className="m-0">Administradores de Comunidades</h5>
|
||||||
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />
|
<span className="block mt-2 md:mt-0 p-input-icon-left">
|
||||||
</span>
|
<i className="pi pi-search" />
|
||||||
</div>
|
<InputText type="search" onInput={(e) => setGlobalFilter(e.target.value)} placeholder="Buscar..." />
|
||||||
</React.Fragment>
|
</span>
|
||||||
|
</div>
|
||||||
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
};
|
|
||||||
|
|
||||||
const headerName = (
|
const headerName = (
|
||||||
<>
|
<>
|
||||||
<p> <FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> Nombre</p>
|
<p>{' '}
|
||||||
|
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> {' '}
|
||||||
|
Nombre
|
||||||
|
</p>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|
||||||
const deleteAdminsCommunityDialogFooter = (
|
const headerLastName = (
|
||||||
<>
|
<>
|
||||||
<Button
|
<p>
|
||||||
label="No"
|
{' '}
|
||||||
icon="pi pi-times"
|
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#D7A86E" }} />{' '}
|
||||||
className="p-button-text"
|
Apellidos
|
||||||
onClick={hideDeleteAdminsCommunitysDialog}
|
</p>
|
||||||
/>
|
</>
|
||||||
<Button
|
)
|
||||||
label="Yes"
|
|
||||||
icon="pi pi-check"
|
|
||||||
className="p-button-text"
|
|
||||||
onClick={deleteSelectedAdminsCommunity}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
const headerName = (
|
const headerDNI = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p> {' '}
|
||||||
{' '}
|
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: "#C08135" }} />{' '}
|
||||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#C08135' }} /> Nombre
|
Identificación
|
||||||
</p>
|
</p>
|
||||||
</>
|
</>
|
||||||
);
|
)
|
||||||
|
|
||||||
const headerLastName = (
|
const headerEmail = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p> {' '}
|
||||||
{' '}
|
<FontAwesomeIcon icon={faAt} style={{ color: "#D7A86E" }} />{' '}
|
||||||
<FontAwesomeIcon icon={faUserAlt} style={{ color: '#D7A86E' }} />{' '}
|
Correo Electrónic
|
||||||
Apellidos
|
</p>
|
||||||
</p>
|
</>
|
||||||
</>
|
)
|
||||||
);
|
|
||||||
|
|
||||||
const headerDNI = (
|
const headerPhone = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p> <FontAwesomeIcon icon={faPhoneAlt} style={{ color: "#C08135" }} />{' '}
|
||||||
{' '}
|
Teléfono
|
||||||
<FontAwesomeIcon icon={faIdCardAlt} style={{ color: '#C08135' }} />{' '}
|
</p>
|
||||||
Identificación
|
</>
|
||||||
</p>
|
)
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
const headerEmail = (
|
const headerCommuntiy = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
{' '}
|
{' '}
|
||||||
<FontAwesomeIcon icon={faAt} style={{ color: '#D7A86E' }} /> Correo
|
<FontAwesomeIcon icon={faHomeAlt} style={{ color: "#D7A86E" }} />{' '}
|
||||||
Electrónico
|
Comunidad</p>
|
||||||
</p>
|
</>
|
||||||
</>
|
)
|
||||||
);
|
|
||||||
|
|
||||||
const headerPhone = (
|
const headerOptions = (
|
||||||
<>
|
<>
|
||||||
<p>
|
<p>
|
||||||
{' '}
|
{' '}
|
||||||
<FontAwesomeIcon icon={faPhoneAlt} style={{ color: '#C08135' }} />{' '}
|
<FontAwesomeIcon icon={faEllipsis} size="2x" style={{ color: "#C08135" }} />{' '}
|
||||||
Teléfono
|
|
||||||
</p>
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
|
|
||||||
|
</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,9 +490,7 @@ const AdministradoresComunidad = () => {
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
);
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default React.memo(AdministradoresComunidad);
|
export default React.memo(AdministradoresComunidad);
|
||||||
|
|
|
@ -36,53 +36,63 @@ const AdministradoresSistema = () => {
|
||||||
phone: '',
|
phone: '',
|
||||||
password: '',
|
password: '',
|
||||||
user_type: '1',
|
user_type: '1',
|
||||||
status: '',
|
status: '1',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function registrarAdmin() {
|
async function fetchP() {
|
||||||
var data = {
|
let nombres = await fetch(urlFetch, { method: 'GET' });
|
||||||
dni: document.getElementById('identificacion').value,
|
let adminRes = await nombres.json();
|
||||||
name: document.getElementById('nombre').value,
|
setAdministrators(adminRes.message);
|
||||||
last_name: document.getElementById('apellidos').value,
|
console.log(administrators);
|
||||||
email: document.getElementById('correo_electronico').value,
|
}
|
||||||
phone: document.getElementById('telefono').value,
|
useEffect(() => {
|
||||||
password: document.getElementById('correo_electronico').value,
|
fetchP();
|
||||||
user_type: "1", //1 es admin
|
}, [])
|
||||||
status: "1"
|
|
||||||
};
|
|
||||||
setSysAdmin(data)
|
|
||||||
// console.log(data);
|
|
||||||
|
|
||||||
fetch('http://localhost:4000/user/createAdminSystem/', {
|
|
||||||
cache: 'no-cache',
|
function registrarAdmin() {
|
||||||
method: 'POST',
|
var data = {
|
||||||
body: JSON.stringify(data),
|
dni: document.getElementById('identificacion').value,
|
||||||
headers: {
|
name: document.getElementById('nombre').value,
|
||||||
'Content-Type': 'application/json'
|
last_name: document.getElementById('apellidos').value,
|
||||||
}
|
email: document.getElementById('correo_electronico').value,
|
||||||
})
|
phone: document.getElementById('telefono').value,
|
||||||
.then(
|
password: document.getElementById('correo_electronico').value,
|
||||||
function (response) {
|
user_type: "1", //1 es admin
|
||||||
if (response.status != 201)
|
status: "1"
|
||||||
console.log('Ocurrió un error con el servicio: ' + response.status);
|
};
|
||||||
else
|
setSysAdmin(data)
|
||||||
return response.json();
|
// console.log(data);
|
||||||
}
|
|
||||||
)
|
fetch('http://localhost:4000/user/createAdminSystem/', {
|
||||||
.then(
|
cache: 'no-cache',
|
||||||
function (response) {
|
method: 'POST',
|
||||||
let _administrators = [...administrators];
|
body: JSON.stringify(data),
|
||||||
let _admin = { ...sysadmin };
|
headers: {
|
||||||
_administrators.push(_admin);
|
'Content-Type': 'application/json'
|
||||||
setAdministrators(_administrators)
|
}
|
||||||
}
|
})
|
||||||
)
|
.then(
|
||||||
.catch(
|
function (response) {
|
||||||
err => console.log('Ocurrió un error con el fetch', err)
|
if (response.status != 201)
|
||||||
);
|
console.log('Ocurrió un error con el servicio: ' + response.status);
|
||||||
}
|
else
|
||||||
|
return response.json();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.then(
|
||||||
|
function (response) {
|
||||||
|
let _administrators = [...administrators];
|
||||||
|
let _admin = { ...sysadmin };
|
||||||
|
_administrators.push(_admin);
|
||||||
|
setAdministrators(_administrators)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
.catch(
|
||||||
|
err => console.log('Ocurrió un error con el fetch', err)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
const confirmDeleteAdminSystem = (sysAdmin) => {
|
const confirmDeleteAdminSystem = (sysAdmin) => {
|
||||||
setSysAdmin(sysAdmin);
|
setSysAdmin(sysAdmin);
|
||||||
|
@ -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
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Reference in New Issue