add backend plumbing to update guard

This commit is contained in:
Eduardo Quiros 2022-08-22 05:15:29 -06:00
parent 40d0c8d1d1
commit 46db01d30b
No known key found for this signature in database
GPG Key ID: B77F36C3F12720B4
4 changed files with 68 additions and 0 deletions

View File

@ -82,6 +82,35 @@ export class AppController {
);
}
@Put('user/updateGuard/:id')
updateGuard(
@Param('id') id: string,
@Body('dni') dni: string,
@Body('name') name: string,
@Body('last_name') last_name: string,
@Body('email') email: string,
@Body('phone') phone: number,
@Body('password') password: string,
@Body('user_type') user_type: string,
@Body('status') status: string,
@Body('date_entry') date_entry: Date,
@Body('community_id') community_id: string,
) {
return this.appService.updateGuard(
id,
dni,
name,
last_name,
email,
phone,
password,
user_type,
status,
date_entry,
community_id,
);
}
@Put('user/updateUser/:id')
updateUser(
@Param('id') id: string,

View File

@ -89,6 +89,38 @@ export class AppService {
.pipe(map((message: string) => ({ message })));
}
updateGuard(
_id: string,
dni: string,
name: string,
last_name: string,
email: string,
phone: number,
password: string,
user_type: string,
status: string,
date_entry: Date,
community_id: string,
) {
const pattern = { cmd: 'updateGuard' };
const payload = {
id: _id,
dni: dni,
name: name,
last_name: last_name,
email: email,
phone: phone,
password: password,
user_type: user_type,
status: status,
date_entry: date_entry,
community_id: community_id,
};
return this.clientUserApp
.send<string>(pattern, payload)
.pipe(map((message: string) => ({ message })));
}
//POST parameter from API
createAdminSystem(dni: string, name: string, last_name: string, email: string, phone: number
, user_type: string, status: string, date_entry: Date) {

View File

@ -69,6 +69,11 @@ export class UsersController {
return this.userService.update(user.id, user);
}
@MessagePattern({ cmd: 'updateGuard' })
updateGuard(@Payload() guard: UserDocument) {
return this.userService.update(guard.id, guard);
}
@MessagePattern({ cmd: 'removeUser' })
remove(@Payload() id: string) {
let dni = id['dni'];

View File

@ -28,6 +28,7 @@ const GuardasSeguridad = () => {
user_type: '1',
status: '1',
status_text: '',
date_entry: Date.now(),
community_id: '',
};
@ -77,6 +78,7 @@ const GuardasSeguridad = () => {
password: document.getElementById('email').value,
user_type: "4", //4 es guarda
status: "1",
date_entry: Date.now(),
community_id: cookies.community_id
};
if (guarda._id === null) {