Skip to content

Commit 3a930f1

Browse files
authored
Merge pull request #2608 from gkbishnoi07/WEB-285-replace-custom-api-of-users-service-ts
Web 285 replace custom api of users-service.ts
2 parents 3a44ee6 + 269e4a8 commit 3a930f1

File tree

7 files changed

+24
-101
lines changed

7 files changed

+24
-101
lines changed

src/app/users/create-user/create-user.component.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { Router, ActivatedRoute, RouterLink } from '@angular/router';
1111
import { MatDialog } from '@angular/material/dialog';
1212

1313
/** Custom Services */
14-
import { UsersService } from '../users.service';
14+
import { UsersService, StaffService } from '@fineract/client';
1515
import { PopoverService } from '../../configuration-wizard/popover/popover.service';
1616

1717
/** Custom Dialog Component */
@@ -52,7 +52,8 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
5252
/**
5353
* Retrieves the offices and roles data from `resolve`.
5454
* @param {FormBuilder} formBuilder Form Builder.
55-
* @param {UsersService} UsersService Users Service.
55+
* @param {UsersService} usersService Users Service.
56+
* @param {StaffService} staffService Staff Service.
5657
* @param {ActivatedRoute} route Activated Route.
5758
* @param {Router} router Router for navigation.
5859
* @param {ConfigurationWizardService} configurationWizardService ConfigurationWizard Service.
@@ -61,6 +62,7 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
6162
constructor(
6263
private formBuilder: UntypedFormBuilder,
6364
private usersService: UsersService,
65+
private staffService: StaffService,
6466
private route: ActivatedRoute,
6567
private router: Router,
6668
private popoverService: PopoverService,
@@ -134,7 +136,7 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
134136
setStaffData() {
135137
this.userForm.get('officeId').valueChanges.subscribe((officeId: string) => {
136138
this.staffData = [];
137-
this.usersService.getStaff(officeId).subscribe((staff: any) => {
139+
this.staffService.retrieveAll16({ officeId: Number(officeId) }).subscribe((staff: any) => {
138140
this.staffData = staff;
139141
});
140142
});
@@ -175,7 +177,7 @@ export class CreateUserComponent implements OnInit, AfterViewInit {
175177
if (this.userForm.value.staffId == null || this.userForm.value.staffId === '') {
176178
delete user.staffId;
177179
}
178-
this.usersService.createUser(user).subscribe((response: any) => {
180+
this.usersService.create15({ postUsersRequest: user }).subscribe((response: any) => {
179181
if (this.configurationWizardService.showUsersForm === true) {
180182
this.configurationWizardService.showUsersForm = false;
181183
this.openDialog();

src/app/users/edit-user/edit-user.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
44
import { UntypedFormGroup, UntypedFormBuilder, Validators, ReactiveFormsModule } from '@angular/forms';
55

66
/** Custom Services */
7-
import { UsersService } from '../users.service';
7+
import { UsersService, StaffService } from '@fineract/client';
88
import { MatCheckbox } from '@angular/material/checkbox';
99
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
1010

@@ -36,12 +36,14 @@ export class EditUserComponent implements OnInit {
3636
* Retrieves the offices data from `resolve`.
3737
* @param {FormBuilder} formBuilder Form Builder.
3838
* @param {UsersService} UsersService Users Service.
39+
* @param {StaffService} staffService Staff Service.
3940
* @param {ActivatedRoute} route Activated Route.
4041
* @param {Router} router Router for navigation.
4142
*/
4243
constructor(
4344
private formBuilder: UntypedFormBuilder,
4445
private usersService: UsersService,
46+
private staffService: StaffService,
4547
private route: ActivatedRoute,
4648
private router: Router
4749
) {
@@ -105,7 +107,7 @@ export class EditUserComponent implements OnInit {
105107
*/
106108
officeChanged(officeId: number) {
107109
this.staffData = [];
108-
this.usersService.getStaff(officeId).subscribe((staff: any) => {
110+
this.staffService.retrieveAll16({ officeId }).subscribe((staff: any) => {
109111
this.staffData = staff;
110112
});
111113
}
@@ -116,7 +118,7 @@ export class EditUserComponent implements OnInit {
116118
*/
117119
submit() {
118120
const editedUser = this.editUserForm.value;
119-
this.usersService.editUser(this.userData.id, editedUser).subscribe((response: any) => {
121+
this.usersService.update26(this.userData.id, editedUser).subscribe((response: any) => {
120122
this.router.navigate(
121123
[
122124
'../../',

src/app/users/user.resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { ActivatedRouteSnapshot } from '@angular/router';
66
import { Observable } from 'rxjs';
77

88
/** Custom Services */
9-
import { UsersService } from './users.service';
9+
import { UsersService } from '@fineract/client';
1010

1111
/**
1212
* User data resolver.
@@ -24,6 +24,6 @@ export class UserResolver {
2424
*/
2525
resolve(route: ActivatedRouteSnapshot): Observable<any> {
2626
const userId = route.paramMap.get('id');
27-
return this.usersService.getUser(userId);
27+
return this.usersService.retrieveOne31({ userId: Number(userId) });
2828
}
2929
}

src/app/users/users-template.resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Injectable } from '@angular/core';
55
import { Observable } from 'rxjs';
66

77
/** Custom Services */
8-
import { UsersService } from './users.service';
8+
import { UsersService } from '@fineract/client';
99

1010
/**
1111
* Users template data resolver.
@@ -22,6 +22,6 @@ export class UsersTemplateResolver {
2222
* @returns {Observable<any>}
2323
*/
2424
resolve(): Observable<any> {
25-
return this.usersService.getUsersTemplate();
25+
return this.usersService.template22();
2626
}
2727
}

src/app/users/users.resolver.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Injectable } from '@angular/core';
55
import { Observable } from 'rxjs';
66

77
/** Custom Services */
8-
import { UsersService } from './users.service';
8+
import { UsersService } from '@fineract/client';
99

1010
/**
1111
* Users data resolver.
@@ -22,6 +22,6 @@ export class UsersResolver {
2222
* @returns {Observable<any>}
2323
*/
2424
resolve(): Observable<any> {
25-
return this.usersService.getUsers();
25+
return this.usersService.retrieveAll41();
2626
}
2727
}

src/app/users/users.service.ts

Lines changed: 0 additions & 85 deletions
This file was deleted.

src/app/users/view-user/view-user.component.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ActivatedRoute, Router, RouterLink } from '@angular/router';
44
import { MatDialog } from '@angular/material/dialog';
55

66
/** Custom Services */
7-
import { UsersService } from '../users.service';
7+
import { UsersService } from '@fineract/client';
88

99
/** Custom Components */
1010
import { DeleteDialogComponent } from 'app/shared/delete-dialog/delete-dialog.component';
@@ -56,7 +56,7 @@ export class ViewUserComponent {
5656
});
5757
deleteUserDialogRef.afterClosed().subscribe((response: any) => {
5858
if (response.delete) {
59-
this.usersService.deleteUser(this.userData.id).subscribe(() => {
59+
this.usersService.delete23(this.userData.id).subscribe(() => {
6060
this.router.navigate(['/appusers']);
6161
});
6262
}
@@ -76,7 +76,11 @@ export class ViewUserComponent {
7676
const repeatPassword = response.repeatPassword;
7777
const firstname = this.userData.firstname;
7878
const data = { password: password, repeatPassword: repeatPassword, firstname: firstname };
79-
this.usersService.changePassword(this.userData.id, data).subscribe(() => {
79+
const requestParams = {
80+
userId: this.userData.id,
81+
changePwdUsersUserIdRequest: data
82+
};
83+
this.usersService.changePassword(requestParams).subscribe(() => {
8084
this.router.navigate(['/appusers']);
8185
});
8286
}

0 commit comments

Comments
 (0)