-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/2014 add region admin (#2038)
* #2014 region admin CRUD added --------- Co-authored-by: Viktor Patraboi <vpatr@softserveinc.com>
- Loading branch information
Showing
25 changed files
with
1,071 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export interface AdminFormModel { | ||
email: string; | ||
firstName: string; | ||
lastName: string; | ||
middleName: string; | ||
phoneNumber: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { PaginationParameters } from './queryParameters.model'; | ||
|
||
export class BaseAdmin { | ||
id?: string; | ||
email: string; | ||
phoneNumber: string; | ||
lastName: string; | ||
middleName?: string; | ||
firstName: string; | ||
accountStatus?: string; | ||
institutionId: string; | ||
institutionTitle?: string; | ||
|
||
constructor(info, institutionId: string, id?: string, accountStatus?: string) { | ||
this.email = info.email; | ||
this.phoneNumber = info.phoneNumber; | ||
this.lastName = info.lastName; | ||
this.middleName = info.middleName; | ||
this.firstName = info.firstName; | ||
this.institutionId = institutionId; | ||
this.institutionTitle = info.institutionTitle; | ||
if (id) { | ||
this.id = id; | ||
} | ||
if (accountStatus) { | ||
this.accountStatus = accountStatus; | ||
} | ||
} | ||
} | ||
|
||
export interface BaseAdminParameters extends PaginationParameters { | ||
tabTitle?: string; | ||
searchString?: string; | ||
} | ||
|
||
export interface BaseAdminBlockData { | ||
adminId: string; | ||
isBlocked: boolean; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,7 @@ | ||
import { PaginationParameters } from './queryParameters.model'; | ||
import { BaseAdmin, BaseAdminBlockData, BaseAdminParameters } from './admin.model'; | ||
|
||
export class MinistryAdmin { | ||
id?: string; | ||
email: string; | ||
phoneNumber: string; | ||
lastName: string; | ||
middleName?: string; | ||
firstName: string; | ||
accountStatus?: string; | ||
institutionId: string; | ||
institutionTitle?: string; | ||
export class MinistryAdmin extends BaseAdmin { } | ||
|
||
constructor(info, institutionId: string, id?: string, accountStatus?: string) { | ||
this.email = info.email; | ||
this.phoneNumber = info.phoneNumber; | ||
this.lastName = info.lastName; | ||
this.middleName = info.middleName; | ||
this.firstName = info.firstName; | ||
this.institutionId = institutionId; | ||
this.institutionTitle = info.institutionTitle; | ||
if (id) { | ||
this.id = id; | ||
} | ||
if (accountStatus) { | ||
this.accountStatus = accountStatus; | ||
} | ||
} | ||
} | ||
export interface MinistryAdminParameters extends BaseAdminParameters { } | ||
|
||
export interface MinistryAdminParameters extends PaginationParameters { | ||
tabTitle?: string; | ||
searchString?: string; | ||
} | ||
|
||
export interface MinistryAdminBlockData { | ||
ministryAdminId: string; | ||
isBlocked: boolean; | ||
} | ||
export interface MinistryAdminBlockData extends BaseAdminBlockData { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { BaseAdmin, BaseAdminBlockData, BaseAdminParameters } from './admin.model'; | ||
|
||
export class RegionAdmin extends BaseAdmin { | ||
public catottgId: string; | ||
public catottgName: string; | ||
|
||
constructor(info, institutionId: string, regionId: string, id?: string, accountStatus?: string) { | ||
super(info, institutionId, id, accountStatus) | ||
this.catottgId = regionId | ||
} | ||
} | ||
|
||
export interface RegionAdminParameters extends BaseAdminParameters { } | ||
export interface RegionAdminBlockData extends BaseAdminBlockData { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
import { Observable } from "rxjs"; | ||
|
||
import { HttpClient, HttpParams } from "@angular/common/http"; | ||
|
||
import { BaseAdminParameters, BaseAdmin } from "../../models/admin.model"; | ||
import { PaginationConstants } from "../../constants/constants"; | ||
import { SearchResponse } from "../../models/search.model"; | ||
import { AdminIds, AdminRoles } from "../../enum/admins"; | ||
|
||
export class BaseAdminService { | ||
protected adminType = ""; | ||
constructor(protected http: HttpClient, adminType: AdminRoles) { | ||
this.adminType = adminType; | ||
} | ||
|
||
protected get adminBaseUrl(): string { | ||
return `/api/v1/${this.adminType}`; | ||
} | ||
|
||
protected setParams(parameters: BaseAdminParameters = { searchString: '' }): HttpParams { | ||
let params = new HttpParams(); | ||
|
||
if (parameters.searchString) { | ||
params = params.set('SearchString', parameters.searchString); | ||
} | ||
|
||
const size = parameters?.size?.toString() || PaginationConstants.TABLE_ITEMS_PER_PAGE; | ||
const from = parameters?.from?.toString() || "0"; | ||
|
||
params = params.set('Size', size).set('From', from); | ||
|
||
return params; | ||
} | ||
|
||
/** | ||
* This method get Profile of authorized Admin | ||
*/ | ||
protected getAdminProfile(): Observable<BaseAdmin> { | ||
return this.http.get<BaseAdmin>(`${this.adminBaseUrl}/Profile`); | ||
} | ||
|
||
/** | ||
* This method get Admin by Id | ||
* * @param adminId: string | ||
*/ | ||
protected getAdminById(adminId: string): Observable<BaseAdmin> { | ||
let params = new HttpParams().set('id', `${adminId}`); | ||
|
||
return this.http.get<BaseAdmin>(`${this.adminBaseUrl}/GetById`, { params }); | ||
} | ||
|
||
/** | ||
* This method get All Admins | ||
*/ | ||
protected getAllAdmin(parameters: BaseAdminParameters): Observable<SearchResponse<BaseAdmin[]>> { | ||
const options = { params: this.setParams(parameters) }; | ||
|
||
return this.http.get<SearchResponse<BaseAdmin[]>>(`${this.adminBaseUrl}/GetByFilter`, options); | ||
} | ||
|
||
/** | ||
* This method create Admin | ||
* @param baseAdmin: BaseAdmin | ||
*/ | ||
protected createAdmin(baseAdmin: BaseAdmin): Observable<BaseAdmin> { | ||
return this.http.post<BaseAdmin>(`${this.adminBaseUrl}/Create`, baseAdmin); | ||
} | ||
|
||
/** | ||
* This method delete Admin by id | ||
* @param adminId: string | ||
*/ | ||
protected deleteAdmin(adminId: string): Observable<void> { | ||
let params = new HttpParams().set(AdminIds[this.adminType], `${adminId}`); | ||
|
||
return this.http.delete<void>(`${this.adminBaseUrl}/Delete`, { params }); | ||
} | ||
|
||
/** | ||
* This method block Admin | ||
* @param adminId: string | ||
*/ | ||
protected blockAdmin(adminId: string, isBlocked: boolean): Observable<void> { | ||
let params = new HttpParams().set(AdminIds[this.adminType], `${adminId}`).set('isBlocked', `${isBlocked}`); | ||
|
||
return this.http.put<void>(`${this.adminBaseUrl}/Block`, {}, { params }); | ||
} | ||
|
||
/** | ||
* This method update Admin | ||
* @param baseAdmin: BaseAdmin | ||
*/ | ||
protected updateAdmin(admin: BaseAdmin): Observable<BaseAdmin> { | ||
return this.http.put<BaseAdmin>(`${this.adminBaseUrl}/Update`, admin); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.