Skip to content

Commit e5626ff

Browse files
Merge pull request #155 from KB-iGOT/spv-pagination-Issue
STATE Admin Org creation Flow fix (KB-7901)
2 parents f9bcfa9 + a991680 commit e5626ff

File tree

3 files changed

+50
-14
lines changed

3 files changed

+50
-14
lines changed

project/ws/app/src/lib/head/ui-admin-table/create-organisation/create-organisation.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565

6666
</ng-container>
6767

68-
<ng-container *ngIf="this.openMode !== 'editMode'">
68+
<ng-container *ngIf="this.openMode !== 'editMode' && !disableStateBlock">
6969
<mat-radio-group aria-labelledby="example-radio-group-label" class="flex gap-12 organisation-form mt-3"
7070
formControlName="category">
7171

@@ -82,7 +82,7 @@
8282
</mat-radio-group>
8383
</ng-container>
8484

85-
<ng-container *ngIf="getCategory === 'state'">
85+
<ng-container *ngIf="getCategory === 'state' && !disableStateBlock">
8686
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
8787
<div class="flex items-center gap-1 required">
8888
<span class="lable">State</span>

project/ws/app/src/lib/head/ui-admin-table/create-organisation/create-organisation.component.ts

Lines changed: 47 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,11 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
4646
ORG_NAME_PATTERN = /^[a-zA-Z0-9 ().,@\-\$\/\\:\[\]!\s]*$/
4747

4848
untilDestroyed$ = new Subject<void>();
49-
isMatcompleteOpened = false;
49+
isMatcompleteOpened = false
50+
isStateLogin = false
51+
disableStateBlock = false
5052
EXCLUDED_MINISRIES: string[] = []
53+
stateName: string = ''
5154
constructor(
5255
private formBuilder: FormBuilder,
5356
private snackBar: MatSnackBar,
@@ -70,7 +73,31 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
7073
}
7174

7275
this.organizationNameList = this.orgList.map(org => org.organisation.trim().toLowerCase())
76+
this.checkState()
7377
}
78+
checkState() {
79+
this.statesList = _.get(this.dropdownList, 'statesList', [])
80+
const userOrgName = _.get(this.activatedRoute?.snapshot.parent?.data, 'configService.unMappedUser.rootOrg', null)
81+
82+
if (userOrgName && userOrgName.isState) {
83+
this.isStateLogin = userOrgName.isState
84+
this.stateName = userOrgName.channel
85+
const findOrgDetails = (org: string) => {
86+
const result = _.find(this.statesList, { orgName: org })
87+
return result ? { orgName: result.orgName, mapId: result.mapId } : null
88+
}
89+
const orgDetails = findOrgDetails(this.stateName)
90+
if (orgDetails && orgDetails?.mapId && orgDetails?.orgName) {
91+
// Setting form values for organization
92+
this.organisationForm.controls['category'].setValue('state')
93+
this.organisationForm.controls['state'].setValue(orgDetails.orgName)
94+
// Fetching organization details
95+
this.getOrganization(this.stateName, 'state')
96+
this.disableStateBlock = true
97+
}
98+
}
99+
}
100+
74101

75102
ngOnDestroy(): void {
76103
this.removeOverflowHidden()
@@ -190,24 +217,33 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
190217
}
191218

192219
onSubmitCreateOrganization() {
193-
const payload = {
194-
orgName: this.controls['organisationName'].value,
195-
channel: this.controls['organisationName'].value,
220+
let payload: any = {
221+
orgName: this.controls['organisationName']?.value || "",
222+
channel: this.controls['organisationName']?.value || "",
196223
organisationType: "mdo",
197224
organisationSubType: "board",
198225
isTenant: true,
199226
requestedBy: this.loggedInUserId,
200-
201227
logo: this.uploadedLogoResponse?.qrcodepath || "",
202-
description: this.controls['description'].value,
228+
description: this.controls['description']?.value || "",
203229
parentMapId: "",
204-
sbRootOrgId: this.heirarchyObject?.sbRootOrgId || "",
205230
}
206-
if (this.controls['category'].value === 'state') {
207-
payload.parentMapId = this.controls['state'].value.mapId
231+
// if (this.heirarchyObject.sbRootOrgId) {
232+
// payload['sbRootOrgId'] = this.heirarchyObject.sbRootOrgId
233+
// }
234+
if (this.controls['category']?.value === 'state') {
235+
const orgDetails = _.find(this.statesList, { orgName: this.stateName })
236+
if (orgDetails) {
237+
payload.parentMapId = orgDetails.mapId || "" // Assign mapId from orgDetails
238+
} else if (this.controls['state']?.value?.mapId) {
239+
payload.parentMapId = this.controls['state'].value.mapId // Fallback to state control mapId
240+
} else {
241+
return // Exit function in case of error
242+
}
243+
} else if (this.controls['ministry']?.value?.mapId) {
244+
payload.parentMapId = this.controls['ministry'].value.mapId // Assign ministry mapId
208245
} else {
209-
payload.parentMapId = this.controls['ministry'].value.mapId
210-
246+
return // Exit function in case of error
211247
}
212248

213249
if (this.openMode === 'editMode') {

project/ws/app/src/lib/routes/home/routes/directory/directroy.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class DirectoryViewComponent implements OnInit {
3838
pagination = { limit: 20, offset: 0 }
3939
totalCount = 0
4040
userRoles: any
41-
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER']
41+
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER', 'STATE_ADMIN']
4242
constructor(
4343
public dialog: MatDialog,
4444
private route: ActivatedRoute,

0 commit comments

Comments
 (0)