Merge branch 'dev' into US-27-ListarAreasComunes

This commit is contained in:
Mariela 2022-08-01 16:19:28 -06:00
commit d4beea04aa
11 changed files with 102 additions and 93 deletions

View File

@ -32,7 +32,9 @@ export class CommonAreasService {
} }
async remove(id: string) { async remove(id: string) {
return this.commonAreaModel.findByIdAndRemove({ _id: id }).exec(); return this.commonAreaModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
async findByCommunity(community_id: string): Promise<CommonArea[]> { async findByCommunity(community_id: string): Promise<CommonArea[]> {

View File

@ -56,7 +56,9 @@ export class CommunitiesService {
} }
async remove(id: string) { async remove(id: string) {
return this.communityModel.findByIdAndRemove({ _id: id }).exec(); return this.communityModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
async findCommunityAdmin(community: string, user_type: string) { async findCommunityAdmin(community: string, user_type: string) {

View File

@ -33,6 +33,8 @@ export class PostCommentsService {
} }
async remove(id: string) { async remove(id: string) {
return this.commentModel.findByIdAndRemove({ _id: id }).exec(); return this.commentModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
} }

View File

@ -32,6 +32,8 @@ export class GuestsService {
} }
async remove(id: string) { async remove(id: string) {
return this.guestModel.findByIdAndRemove({ _id: id }).exec(); return this.guestModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
} }

View File

@ -31,6 +31,9 @@ export class ReportsService {
} }
async remove(id: string) { async remove(id: string) {
return this.reportModel.findByIdAndRemove({ _id: id }).exec(); return this.reportModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
} }

View File

@ -41,6 +41,8 @@ export class ReservationsService {
} }
async remove(id: string) { async remove(id: string) {
return this.reservationModel.findByIdAndRemove({ _id: id }).exec(); return this.reservationModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
} }

View File

@ -76,8 +76,14 @@ export class UsersService {
}); });
} }
async remove(id: string) { /* async remove(id: string) {
return this.userModel.findByIdAndRemove({ _id: id }).exec(); return this.userModel.findByIdAndRemove({ _id: id }).exec();
}*/
async remove(id: string) {
return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
//inicio de sesion //inicio de sesion
@ -142,7 +148,9 @@ export class UsersService {
} }
async deleteAdminSystem(id: string) { async deleteAdminSystem(id: string) {
return this.userModel.deleteOne({ _id: id }).exec(); return this.userModel.findOneAndUpdate({ _id: id }, {status: '-1'}, {
new: true,
});
} }
async validateEmail(email: string) { async validateEmail(email: string) {

View File

@ -345,15 +345,7 @@ const AdministradoresComunidad = () => {
</> </>
) )
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) || '';
@ -389,9 +381,9 @@ const AdministradoresComunidad = () => {
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> <Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
</Column> </Column>
<Column field="email" sortable header={headerEmail} 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="phone" 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 field="community_name" sortable 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> <Column style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdminCommunity}></Column>
</DataTable> </DataTable>
<Dialog visible={deleteAdminCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminCommunityDialogFooter} onHide={hideDeleteAdminCommunityDialog}> <Dialog visible={deleteAdminCommunityDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminCommunityDialogFooter} onHide={hideDeleteAdminCommunityDialog}>
<div className="flex align-items-center justify-content-center"> <div className="flex align-items-center justify-content-center">

View File

@ -313,15 +313,6 @@ const AdministradoresSistema = () => {
</> </>
); );
const headerOptions = (
<>
<p>
Opciones{' '}
<FontAwesomeIcon icon={faEllipsis} style={{ color: '#D7A86E' }} />
</p>
</>
);
return ( return (
<div className="grid"> <div className="grid">
<div className="col-12"> <div className="col-12">
@ -402,7 +393,6 @@ const AdministradoresSistema = () => {
></Column> ></Column>
<Column <Column
field="phone" field="phone"
sortable
header={headerPhone} header={headerPhone}
style={{ style={{
flexGrow: 1, flexGrow: 1,
@ -412,7 +402,7 @@ const AdministradoresSistema = () => {
}} }}
></Column> ></Column>
<Column <Column
header={headerOptions}
style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }}
body={actionsAdmin} body={actionsAdmin}
></Column> ></Column>

View File

@ -432,7 +432,7 @@ const Communities = () => {
icon={faMapLocationDot} icon={faMapLocationDot}
style={{ color: '#D7A86E' }} style={{ color: '#D7A86E' }}
/>{' '} />{' '}
Pronvincia Provincia
</p> </p>
</> </>
); );
@ -493,15 +493,6 @@ const Communities = () => {
</> </>
); );
const headerOptions = (
<>
<p>
Opciones{' '}
<FontAwesomeIcon icon={faEllipsis} style={{ color: '#D7A86E' }} />
</p>
</>
);
return ( return (
<div className="grid"> <div className="grid">
<div className="col-12"> <div className="col-12">
@ -537,21 +528,25 @@ const Communities = () => {
></Column> ></Column>
<Column <Column
field="name" field="name"
sortable
header={headerName} header={headerName}
style={{ flexGrow: 1, flexBasis: '160px' }} style={{ flexGrow: 1, flexBasis: '160px' }}
></Column> ></Column>
<Column <Column
field="province" field="province"
sortable
header={headerProvince} header={headerProvince}
style={{ flexGrow: 1, flexBasis: '160px' }} style={{ flexGrow: 1, flexBasis: '160px' }}
></Column> ></Column>
<Column <Column
field="canton" field="canton"
sortable
header={headerCanton} header={headerCanton}
style={{ flexGrow: 1, flexBasis: '160px' }} style={{ flexGrow: 1, flexBasis: '160px' }}
></Column> ></Column>
<Column <Column
field="district" field="district"
sortable
header={headerDistrict} header={headerDistrict}
style={{ flexGrow: 1, flexBasis: '160px' }} style={{ flexGrow: 1, flexBasis: '160px' }}
></Column> ></Column>
@ -562,15 +557,16 @@ const Communities = () => {
></Column> ></Column>
<Column <Column
field="num_houses" field="num_houses"
sortable
header={headerNumberHouses} header={headerNumberHouses}
style={{ flexGrow: 1, flexBasis: '180px' }} style={{ flexGrow: 1, flexBasis: '180px' }}
></Column> ></Column>
<Column <Column
field="name_admin" field="name_admin"
header={headerAdministrator} sortable
style={{ flexGrow: 1, flexBasis: '180px' }} style={{ flexGrow: 1, flexBasis: '180px' }}
></Column> ></Column>
<Column header={headerOptions} body={actionsCommunity}></Column> <Column body={actionsCommunity}></Column>
</DataTable> </DataTable>
<Dialog <Dialog
visible={deleteCommunityDialog} visible={deleteCommunityDialog}

View File

@ -14,8 +14,8 @@ import { faIdCardAlt } from '@fortawesome/free-solid-svg-icons';
import { faEllipsis } from '@fortawesome/free-solid-svg-icons'; import { faEllipsis } from '@fortawesome/free-solid-svg-icons';
const GuardasSeguridad = () => { const GuardasSeguridad = () => {
const [listaGuardas,setListaGuardas]=useState([]); const [listaGuardas, setListaGuardas] = useState([]);
const [urlFetch,setUrlFetch]=useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134'); const [urlFetch, setUrlFetch] = useState('http://localhost:4000/user/findGuards/62be68215692582bbfd77134');
const [guarda, setGuarda] = useState(emptyGuarda); const [guarda, setGuarda] = useState(emptyGuarda);
const [selectedGuardas, setSelectedGuardas] = useState(null); const [selectedGuardas, setSelectedGuardas] = useState(null);
const [globalFilter, setGlobalFilter] = useState(null); const [globalFilter, setGlobalFilter] = useState(null);
@ -37,14 +37,14 @@ const GuardasSeguridad = () => {
async function listaGuardasF(){ async function listaGuardasF() {
let nombres=await fetch(urlFetch, {method:'GET'}); let nombres = await fetch(urlFetch, { method: 'GET' });
let listaGuardasRes= await nombres.json(); let listaGuardasRes = await nombres.json();
setListaGuardas(listaGuardasRes.message); setListaGuardas(listaGuardasRes.message);
} }
useEffect(()=>{ useEffect(() => {
listaGuardasF(); listaGuardasF();
},[]) }, [])
function registrarGuarda() { function registrarGuarda() {
var data = { var data = {
@ -56,9 +56,9 @@ const GuardasSeguridad = () => {
password: document.getElementById('correo_electronico').value, password: document.getElementById('correo_electronico').value,
user_type: "4", //4 es guarda user_type: "4", //4 es guarda
status: "1", status: "1",
community_id:"62be68215692582bbfd77134" community_id: "62be68215692582bbfd77134"
}; };
var data2={ var data2 = {
dni: "11979037", dni: "11979037",
name: "Jorge", name: "Jorge",
last_name: "Soto", last_name: "Soto",
@ -67,35 +67,35 @@ const GuardasSeguridad = () => {
password: "1203", password: "1203",
user_type: "2", user_type: "2",
status: "4", status: "4",
community_id:"62be68215692582bbfd77134" community_id: "62be68215692582bbfd77134"
} }
console.log('ssss'); console.log('ssss');
fetch('http://localhost:4000/user/createGuard', { fetch('http://localhost:4000/user/createGuard', {
cache: 'no-cache', cache: 'no-cache',
method: 'POST', method: 'POST',
mode:'cors', mode: 'cors',
body: JSON.stringify(data2), body: JSON.stringify(data2),
headers: { headers: {
'Content-Type': 'application/json' 'Content-Type': 'application/json'
} }
}) })
.then( .then(
function (response) { function (response) {
if (response.status != 201) if (response.status != 201)
console.log('Ocurrió un error con el servicio: ' + response.status); console.log('Ocurrió un error con el servicio: ' + response.status);
else else
return response.json(); return response.json();
} }
) )
.then( .then(
function (response) { function (response) {
console.log('fff'); console.log('fff');
listaGuardasF(); listaGuardasF();
} }
) )
.catch( .catch(
err => console.log('Ocurrió un error con el fetch', err) err => console.log('Ocurrió un error con el fetch', err)
); );
} }
const hideDeleteGuardaDialog = () => { const hideDeleteGuardaDialog = () => {
@ -218,48 +218,58 @@ console.log('ssss');
const headerName = ( const headerName = (
<> <>
<p>Nombre</p> <p>{' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#C08135" }} /> {' '}
Nombre
</p>
</> </>
) )
const headerLastName = ( const headerLastName = (
<> <>
<p>Apellidos</p> <p>
{' '}
<FontAwesomeIcon icon={faUserAlt} style={{ color: "#D7A86E" }} />{' '}
Apellido(s)
</p>
</> </>
) )
const headerDNI = ( const headerDNI = (
<> <p> {' '}
<p>Identificación</p> <FontAwesomeIcon icon={faIdCardAlt} style={{ color: "#C08135" }} />{' '}
</> Identificación
</p>
) )
const headerEmail = ( const headerEmail = (
<> <>
<p>Correo Electrónico</p> <p> {' '}
<FontAwesomeIcon icon={faAt} style={{ color: "#D7A86E" }} />{' '}
Correo Electrónico
</p>
</> </>
) )
const headerPhone = ( const headerPhone = (
<> <>
<p>Teléfono</p> <p>
{' '}
<FontAwesomeIcon icon={faPhoneAlt} style={{ color: '#C08135' }} />{' '}
Teléfono
</p>
</> </>
) )
const headerOptions = (
<>
<p>Opciones</p>
</>
)
return ( return (
<div className="grid"> <div className="grid">
<div className="col-12"> <div className="col-12">
<Toast ref={toast} /> <Toast ref={toast} />
<div className="card"> <div className="card">
<Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar> <Toolbar className="mb-4" left={leftToolbarTemplate} right={rightToolbarTemplate}></Toolbar>
<DataTable ref={dt} value={listaGuardas} dataKey="_id" paginator rows={5} selection={selectedGuardas} onSelectionChange={(e) => setSelectedGuardas(e.value)} <DataTable ref={dt} value={listaGuardas} dataKey="_id" paginator rows={5} selection={selectedGuardas} onSelectionChange={(e) => setSelectedGuardas(e.value)}
responsiveLayout="scroll" header={header} responsiveLayout="scroll" header={header}
rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3" rowsPerPageOptions={[5, 10, 25]} className="datatable-responsive mt-3"
paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown" paginatorTemplate="FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink CurrentPageReport RowsPerPageDropdown"
currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords}" currentPageReportTemplate="Mostrando {first} a {last} de {totalRecords}"
@ -270,8 +280,8 @@ console.log('ssss');
<Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}> <Column field="dni" sortable header={headerDNI} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}>
</Column> </Column>
<Column field="email" sortable header={headerEmail} 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="phone" header={headerPhone} style={{ flexGrow: 1, flexBasis: '160px', minWidth: '160px', wordBreak: 'break-word' }}></Column>
<Column header={headerOptions} style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdmin}></Column> <Column style={{ flexGrow: 1, flexBasis: '130px', minWidth: '130px' }} body={actionsAdmin}></Column>
</DataTable> </DataTable>
<Dialog visible={deleteGuardaDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminSystemDialogFooter} onHide={hideDeleteGuardaDialog}> <Dialog visible={deleteGuardaDialog} style={{ width: '450px' }} header="Confirmar" modal footer={deleteAdminSystemDialogFooter} onHide={hideDeleteGuardaDialog}>
<div className="flex align-items-center justify-content-center"> <div className="flex align-items-center justify-content-center">
@ -316,7 +326,7 @@ console.log('ssss');
</div> </div>
</div> </div>
</div> </div>
); );
}; };
export default React.memo(GuardasSeguridad); export default React.memo(GuardasSeguridad);