Skip to content

Commit 1e89f45

Browse files
committed
WEB-339 replace custom api of share.service.ts
1 parent 61f63cd commit 1e89f45

File tree

20 files changed

+159
-157
lines changed

20 files changed

+159
-157
lines changed

src/app/customApis.service.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,3 +231,18 @@ export class OrganizationService {
231231
});
232232
}
233233
}
234+
235+
@Injectable({
236+
providedIn: 'root'
237+
})
238+
export class SharesService {
239+
constructor(private http: HttpClient) {}
240+
241+
/**
242+
* @param {string} accountId shares account Id
243+
* @returns {Observable<any>}
244+
*/
245+
deleteSharesAccount(accountId: string): Observable<any> {
246+
return this.http.delete(`/accounts/share/${accountId}`);
247+
}
248+
}

src/app/shares/common-resolvers/share-account-actions.resolver.ts

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

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

1111
/**
1212
* Shares Account Actions data resolver.
1313
*/
1414
@Injectable()
1515
export class ShareAccountActionsResolver {
1616
/**
17-
* @param {sharesService} SharesService Shares service.
17+
* @param {ShareAccountService} ShareAccountService Shares account service.
1818
*/
19-
constructor(private sharesService: SharesService) {}
19+
constructor(private shareAccountService: ShareAccountService) {}
2020

2121
/**
2222
* Returns the Shares account actions data.
@@ -31,7 +31,10 @@ export class ShareAccountActionsResolver {
3131
case 'Redeem Shares':
3232
case 'Approve Additional Shares':
3333
case 'Reject Additional Shares':
34-
return this.sharesService.getSharesAccountData(shareAccountId, true);
34+
return this.shareAccountService.retrieveAccount({
35+
accountId: Number(shareAccountId),
36+
type: 'full'
37+
});
3538
default:
3639
return undefined;
3740
}

src/app/shares/common-resolvers/share-account-and-template.resolver.ts

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

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

1111
/**
1212
* Shares Account data and template resolver.
1313
*/
1414
@Injectable()
1515
export class SharesAccountAndTemplateResolver {
1616
/**
17-
* @param {SharesService} SharesService Shares service.
17+
* @param {ShareAccountService} ShareAccountService Share account service.
1818
*/
19-
constructor(private sharesService: SharesService) {}
19+
constructor(private shareAccountService: ShareAccountService) {}
2020

2121
/**
2222
* Returns the Shares Account data and template.
@@ -25,6 +25,9 @@ export class SharesAccountAndTemplateResolver {
2525
*/
2626
resolve(route: ActivatedRouteSnapshot): Observable<any> {
2727
const shareAccountId = route.paramMap.get('shareAccountId');
28-
return this.sharesService.getSharesAccountData(shareAccountId, true);
28+
return this.shareAccountService.retrieveAccount({
29+
accountId: Number(shareAccountId),
30+
type: 'true'
31+
});
2932
}
3033
}

src/app/shares/common-resolvers/share-account-view.resolver.ts

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

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

1111
/**
1212
* Shares Account data resolver.
1313
*/
1414
@Injectable()
1515
export class SharesAccountViewResolver {
1616
/**
17-
* @param {SharesService} SharesService Shares service.
17+
* @param {ShareAccountService} ShareAccountService Shares account service.
1818
*/
19-
constructor(private sharesService: SharesService) {}
19+
constructor(private shareAccountService: ShareAccountService) {}
2020

2121
/**
2222
* Returns the Shares Account data.
@@ -25,6 +25,9 @@ export class SharesAccountViewResolver {
2525
*/
2626
resolve(route: ActivatedRouteSnapshot): Observable<any> {
2727
const shareAccountId = route.paramMap.get('shareAccountId') || route.parent.paramMap.get('shareAccountId');
28-
return this.sharesService.getSharesAccountData(shareAccountId, false);
28+
return this.shareAccountService.retrieveAccount({
29+
accountId: Number(shareAccountId),
30+
type: 'default'
31+
});
2932
}
3033
}

src/app/shares/common-resolvers/shares-account-template.resolver.ts

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

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

1111
/**
1212
* Shares Account Template resolver.
1313
*/
1414
@Injectable()
1515
export class SharesAccountTemplateResolver {
1616
/**
17-
* @param {SharesService} SharesService Shares service.
17+
* @param {ShareAccountService} ShareAccountService Shares account service.
1818
*/
19-
constructor(private sharesService: SharesService) {}
19+
constructor(private shareAccountService: ShareAccountService) {}
2020

2121
/**
2222
* Returns the Shares Account Template.
@@ -25,6 +25,6 @@ export class SharesAccountTemplateResolver {
2525
*/
2626
resolve(route: ActivatedRouteSnapshot): Observable<any> {
2727
const clientId = route.parent.parent.paramMap.get('clientId');
28-
return this.sharesService.getSharesAccountTemplate(clientId);
28+
return this.shareAccountService.template7({ type: 'client', clientId: clientId ? +clientId : undefined });
2929
}
3030
}

src/app/shares/create-shares-account/create-shares-account.component.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { SharesAccountTermsStepComponent } from '../shares-account-stepper/share
88
import { SharesAccountChargesStepComponent } from '../shares-account-stepper/shares-account-charges-step/shares-account-charges-step.component';
99

1010
/** Custom Services */
11-
import { SharesService } from '../shares.service';
11+
import { ShareAccountService } from '@fineract/client';
1212
import { SettingsService } from 'app/settings/settings.service';
1313
import { Dates } from 'app/core/utils/dates';
1414
import { MatStepper, MatStepperIcon, MatStep, MatStepLabel } from '@angular/material/stepper';
@@ -56,14 +56,14 @@ export class CreateSharesAccountComponent {
5656
* @param {ActivatedRoute} route Activated Route
5757
* @param {Router} router Router
5858
* @param {Dates} dateUtils Date Utils
59-
* @param {SharesService} sharesService Shares Service
59+
* @param {ShareAccountService} ShareAccountService Shares Account Service
6060
* @param {SettingsService} settingsService Settings Service
6161
*/
6262
constructor(
6363
private route: ActivatedRoute,
6464
private router: Router,
6565
private dateUtils: Dates,
66-
private sharesService: SharesService,
66+
private shareAccountService: ShareAccountService,
6767
private settingsService: SettingsService
6868
) {
6969
this.route.data.subscribe((data: { sharesAccountTemplate: any }) => {
@@ -128,7 +128,7 @@ export class CreateSharesAccountComponent {
128128
dateFormat,
129129
locale
130130
};
131-
this.sharesService.createSharesAccount(sharesAccount).subscribe((response: any) => {
131+
this.shareAccountService.createAccount(sharesAccount).subscribe((response: any) => {
132132
this.router.navigate(
133133
[
134134
'../',

src/app/shares/edit-shares-account/edit-shares-account.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { SharesAccountTermsStepComponent } from '../shares-account-stepper/share
88
import { SharesAccountChargesStepComponent } from '../shares-account-stepper/shares-account-charges-step/shares-account-charges-step.component';
99

1010
/** Custom Services */
11-
import { SharesService } from '../shares.service';
11+
import { ShareAccountService } from '@fineract/client';
1212
import { SettingsService } from 'app/settings/settings.service';
1313
import { Dates } from 'app/core/utils/dates';
1414
import { MatStepper, MatStepperIcon, MatStep, MatStepLabel } from '@angular/material/stepper';
@@ -56,14 +56,14 @@ export class EditSharesAccountComponent {
5656
* @param {ActivatedRoute} route Activated Route
5757
* @param {Router} router Router
5858
* @param {Dates} dateUtils Date Utils
59-
* @param {SharesService} sharesService Shares Service
59+
* @param {ShareAccountService} shareAccountService Shares Account Service
6060
* @param {SettingsService} settingsService Settings Service
6161
*/
6262
constructor(
6363
private route: ActivatedRoute,
6464
private router: Router,
6565
private dateUtils: Dates,
66-
private sharesService: SharesService,
66+
private shareAccountService: ShareAccountService,
6767
private settingsService: SettingsService
6868
) {
6969
this.route.data.subscribe((data: { sharesAccountAndTemplate: any }) => {
@@ -134,8 +134,8 @@ export class EditSharesAccountComponent {
134134
dateFormat,
135135
locale
136136
};
137-
this.sharesService
138-
.updateSharesAccount(this.sharesAccountAndTemplate.id, sharesAccount)
137+
this.shareAccountService
138+
.updateAccount(this.sharesAccountAndTemplate.id, sharesAccount)
139139
.subscribe((response: any) => {
140140
this.router.navigate(['../'], { relativeTo: this.route });
141141
});

src/app/shares/shares-account-actions/activate-shares-account/activate-shares-account.component.ts

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

66
/** Custom Services */
7-
import { SharesService } from 'app/shares/shares.service';
7+
import { ShareAccountService } from '@fineract/client';
88
import { SettingsService } from 'app/settings/settings.service';
99
import { Dates } from 'app/core/utils/dates';
1010
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@@ -32,15 +32,15 @@ export class ActivateSharesAccountComponent implements OnInit {
3232

3333
/**
3434
* @param {FormBuilder} formBuilder Form Builder
35-
* @param {SharesService} sharesService Shares Service
35+
* @param {ShareAccountService} shareAccountService Shares Account Service
3636
* @param {Dates} dateUtils Date Utils
3737
* @param {ActivatedRoute} route Activated Route
3838
* @param {Router} router Router
3939
* @param {SettingsService} settingsService Settings Service.
4040
*/
4141
constructor(
4242
private formBuilder: UntypedFormBuilder,
43-
private sharesService: SharesService,
43+
private shareAccountService: ShareAccountService,
4444
private dateUtils: Dates,
4545
private route: ActivatedRoute,
4646
private router: Router,
@@ -86,7 +86,13 @@ export class ActivateSharesAccountComponent implements OnInit {
8686
dateFormat,
8787
locale
8888
};
89-
this.sharesService.executeSharesAccountCommand(this.accountId, 'activate', data).subscribe(() => {
89+
const params = {
90+
type: 'shares',
91+
accountId: this.accountId,
92+
postAccountsTypeAccountIdRequest: data,
93+
command: 'activate'
94+
};
95+
this.shareAccountService.handleCommands2(params).subscribe(() => {
9096
this.router.navigate(['../../'], { relativeTo: this.route });
9197
});
9298
}

src/app/shares/shares-account-actions/apply-shares/apply-shares.component.ts

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

66
/** Custom Services */
7-
import { SharesService } from 'app/shares/shares.service';
7+
import { ShareAccountService } from '@fineract/client';
88
import { SettingsService } from 'app/settings/settings.service';
99
import { Dates } from 'app/core/utils/dates';
1010
import { STANDALONE_SHARED_IMPORTS } from 'app/standalone-shared.module';
@@ -35,15 +35,15 @@ export class ApplySharesComponent implements OnInit {
3535

3636
/**
3737
* @param {FormBuilder} formBuilder Form Builder
38-
* @param {SharesService} sharesService Shares Service
38+
* @param {ShareAccountService} shareAccountService Shares Account Service
3939
* @param {Dates} dateUtils Date Utils
4040
* @param {ActivatedRoute} route Activated Route
4141
* @param {Router} router Router
4242
* @param {SettingsService} settingsService Settings Service
4343
*/
4444
constructor(
4545
private formBuilder: UntypedFormBuilder,
46-
private sharesService: SharesService,
46+
private shareAccountService: ShareAccountService,
4747
private dateUtils: Dates,
4848
private route: ActivatedRoute,
4949
private router: Router,
@@ -101,7 +101,13 @@ export class ApplySharesComponent implements OnInit {
101101
dateFormat,
102102
locale
103103
};
104-
this.sharesService.executeSharesAccountCommand(this.accountId, 'applyadditionalshares', data).subscribe(() => {
104+
const params = {
105+
type: 'shares',
106+
accountId: this.accountId,
107+
postAccountsTypeAccountIdRequest: data,
108+
command: 'applyadditionalshares'
109+
};
110+
this.shareAccountService.handleCommands2(params).subscribe(() => {
105111
this.router.navigate(['../../'], { relativeTo: this.route });
106112
});
107113
}

src/app/shares/shares-account-actions/approve-shares-account/approve-shares-account.component.ts

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

66
/** Custom Services */
7-
import { SharesService } from 'app/shares/shares.service';
7+
import { ShareAccountService } from '@fineract/client';
88
import { SettingsService } from 'app/settings/settings.service';
99
import { Dates } from 'app/core/utils/dates';
1010
import { CdkTextareaAutosize } from '@angular/cdk/text-field';
@@ -34,15 +34,15 @@ export class ApproveSharesAccountComponent implements OnInit {
3434

3535
/**
3636
* @param {FormBuilder} formBuilder Form Builder
37-
* @param {SharesService} sharesService Shares Service
37+
* @param {ShareAccountService} ShareAccountService Shares Account Service.
3838
* @param {Dates} dateUtils Date Utils
3939
* @param {ActivatedRoute} route Activated Route
4040
* @param {Router} router Router
4141
* @param {SettingsService} settingsService Settings Service.
4242
*/
4343
constructor(
4444
private formBuilder: UntypedFormBuilder,
45-
private sharesService: SharesService,
45+
private shareAccountService: ShareAccountService,
4646
private dateUtils: Dates,
4747
private route: ActivatedRoute,
4848
private router: Router,
@@ -89,7 +89,13 @@ export class ApproveSharesAccountComponent implements OnInit {
8989
dateFormat,
9090
locale
9191
};
92-
this.sharesService.executeSharesAccountCommand(this.accountId, 'approve', data).subscribe(() => {
92+
const params = {
93+
type: 'shares',
94+
accountId: this.accountId,
95+
postAccountsTypeAccountIdRequest: data,
96+
command: 'approve'
97+
};
98+
this.shareAccountService.handleCommands2(params).subscribe(() => {
9399
this.router.navigate(['../../'], { relativeTo: this.route });
94100
});
95101
}

0 commit comments

Comments
 (0)