Skip to content

Commit

Permalink
feat: add support to request account activation/deactivate and attend it
Browse files Browse the repository at this point in the history
  • Loading branch information
josephatJ committed Jul 4, 2023
1 parent 45e508f commit cc584ea
Show file tree
Hide file tree
Showing 12 changed files with 397 additions and 117 deletions.
38 changes: 20 additions & 18 deletions src/app/core/services/datastore.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,24 +195,26 @@ export class DataStoreDataService {
if (configurations?.category == 'UA') {
return {
...dataItem,
searchingText: dataItem?.payload
?.map((user) =>
user?.firstName +
user?.surname +
user?.phoneNumber +
user?.email +
dataItem?.ticketNumber +
user?.organisationUnits?.length >
0
? user?.organisationUnits
?.map((ou) => ou?.name)
.join('')
: '' +
dataItem?.user?.organisationUnits[0]?.name +
dataItem?.user?.displayName +
dataItem?.user?.email
)
.join(','),
searchingText: !dataItem?.payload?.userCredentials
? dataItem?.payload?.userCredentials
?.map((user) =>
user?.firstName +
user?.surname +
user?.phoneNumber +
user?.email +
dataItem?.ticketNumber +
user?.organisationUnits?.length >
0
? user?.organisationUnits
?.map((ou) => ou?.name)
.join('')
: '' +
dataItem?.user?.organisationUnits[0]?.name +
dataItem?.user?.displayName +
dataItem?.user?.email
)
.join(',')
: '',
};
} else {
return dataItem;
Expand Down
34 changes: 32 additions & 2 deletions src/app/core/services/users.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import { NgxDhis2HttpClientService } from '@iapps/ngx-dhis2-http-client';
import { Observable, of, zip } from 'rxjs';
import { catchError, map } from 'rxjs/operators';
import { FeedbackRecepientModel } from 'src/app/shared/models/users.model';
import { HttpClient } from '@angular/common/http';

@Injectable({
providedIn: 'root',
})
export class UsersDataService {
constructor(private httpClient: NgxDhis2HttpClientService) {}
constructor(
private httpClient: NgxDhis2HttpClientService,
private httpClientService: HttpClient
) {}

getUsersByUserGroup(
userGroupId: string
Expand All @@ -34,7 +38,8 @@ export class UsersDataService {
.pipe(
map((response) => {
return response;
})
}),
catchError((error) => of(error))
);
}

Expand Down Expand Up @@ -77,6 +82,31 @@ export class UsersDataService {
map((response) => response),
catchError((error) => of(error))
);
} else if (data?.method === 'PATCH') {
return zip(
data?.payload
? this.httpClientService.patch(
`../../../api/${data?.url}`,
data?.payload
)
: of(null),
this.httpClient.delete(`dataStore/dhis2-user-support/${data?.id}`),
data?.messageConversation
? this.httpClient.post(
`messageConversations/${data?.messageConversation?.id}`,
data?.messageConversation?.approvalMessage
)
: of(null),
data?.messageConversation
? this.httpClient.post(
`messageConversations/${data?.messageConversation?.id}/status?messageConversationStatus=SOLVED`,
null
)
: this.httpClient.post(`messageConversations`, data?.messageBody)
).pipe(
map((response) => response),
catchError((error) => of(error))
);
} else {
return of(null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ export class RequestUserAccountsComponent implements OnInit {

onSave(event: Event): void {
event.stopPropagation();
console.log('formDataToStoreLocally', this.formDataToStoreLocally);
// console.log('formDataToStoreLocally', this.formDataToStoreLocally);
this.dialog
.open(ConfirmSendingAccountsRequestComponent, {
minWidth: '30%',
Expand Down Expand Up @@ -352,7 +352,7 @@ export class RequestUserAccountsComponent implements OnInit {
.subscribe((response) => {
window.localStorage.removeItem('usersToCreate');
this.saving = false;
this.openSnackBar('Successfully sent form request', 'Close');
this.openSnackBar('Successfully sent the request', 'Close');
setTimeout(() => {
this._snackBar.dismiss();
this.router.navigate(['/user-accounts/list']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
mode="indeterminate"
*ngIf="!params?.allDataForUserSupport"
></mat-progress-bar>
<!-- {{ params?.allDataForUserSupport?.data | json }} -->
<div class="w-100 p-3" style="overflow: auto">
<table class="table">
<thead class="custom-header-bg">
Expand Down Expand Up @@ -52,6 +53,7 @@
</td>
<td class="d-flext justify-content-end">
<button
*ngIf="!dataRow?.type"
mat-flat-button
(click)="onToggleDetails($event, dataRow)"
>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
<div>
<div class="w-100" *ngIf="isFeedbackRecepient">
<mat-tab-group>
<mat-tab label="Requests">
<ng-template matTabContent>
<app-user-account-requests-home
[configurations]="configurations"
[currentUser]="currentUser"
[isFeedbackRecepient]="isFeedbackRecepient"
></app-user-account-requests-home>
</ng-template>
</mat-tab>
<mat-tab label="Requesting">
<ng-template matTabContent>
<div class="w-100">
<mat-tab-group>
<mat-tab label="Pending requests">
<ng-template matTabContent>
<app-requests-list-dashboard
*ngIf="
currentUser && currentUser?.organisationUnits?.length > 0
"
[configurations]="configurations"
[currentUser]="currentUser"
[isSecondTier]="isSecondTier"
></app-requests-list-dashboard>
</ng-template>
</mat-tab>
<mat-tab label="Users">
<ng-template matTabContent>
<app-users-list
[systemConfigs]="systemConfigs"
[currentUser]="currentUser"
></app-users-list>
</ng-template>
</mat-tab>
<mat-tab *ngIf="isSecondTier" label="Requests">
<ng-template matTabContent>
<app-user-account-requests-home
[configurations]="configurations"
[currentUser]="currentUser"
[isSecondTier]="isSecondTier"
></app-user-account-requests-home>
</ng-template>
</mat-tab>
</mat-tab-group>
</div>
</ng-template>
</mat-tab>
</mat-tab-group>
</div>
<div class="w-100" *ngIf="!isFeedbackRecepient">
<mat-tab-group>
<mat-tab label="Pending requests">
Expand All @@ -13,7 +63,10 @@
</mat-tab>
<mat-tab label="Users">
<ng-template matTabContent>
<app-users-list></app-users-list>
<app-users-list
[systemConfigs]="systemConfigs"
[currentUser]="currentUser"
></app-users-list>
</ng-template>
</mat-tab>
<mat-tab *ngIf="isSecondTier" label="Requests">
Expand All @@ -27,11 +80,4 @@
</mat-tab>
</mat-tab-group>
</div>
<div class="w-100" *ngIf="isFeedbackRecepient">
<app-user-account-requests-home
[configurations]="configurations"
[currentUser]="currentUser"
[isFeedbackRecepient]="isFeedbackRecepient"
></app-user-account-requests-home>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export class UserAccountsFeedbacksListComponent implements OnInit {
event.stopPropagation();
this.dialog
.open(ApproveUserAccountsModalComponent, {
width: '50%',
minWidth: '50%',
data: {
request,
configurations: this.configurations,
Expand Down
Loading

0 comments on commit cc584ea

Please sign in to comment.