Skip to content

Commit

Permalink
Merge pull request #155 from KB-iGOT/spv-pagination-Issue
Browse files Browse the repository at this point in the history
STATE Admin Org creation Flow fix (KB-7901)
  • Loading branch information
vishnubansaltarento authored Jan 9, 2025
2 parents f9bcfa9 + a991680 commit e5626ff
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@

</ng-container>

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

Expand All @@ -82,7 +82,7 @@
</mat-radio-group>
</ng-container>

<ng-container *ngIf="getCategory === 'state'">
<ng-container *ngIf="getCategory === 'state' && !disableStateBlock">
<div class="grayBox p-4 mt-5 flex flex-column gap-1 organisation-form mat-field-rounded">
<div class="flex items-center gap-1 required">
<span class="lable">State</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
ORG_NAME_PATTERN = /^[a-zA-Z0-9 ().,@\-\$\/\\:\[\]!\s]*$/

untilDestroyed$ = new Subject<void>();
isMatcompleteOpened = false;
isMatcompleteOpened = false
isStateLogin = false
disableStateBlock = false
EXCLUDED_MINISRIES: string[] = []
stateName: string = ''
constructor(
private formBuilder: FormBuilder,
private snackBar: MatSnackBar,
Expand All @@ -70,7 +73,31 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
}

this.organizationNameList = this.orgList.map(org => org.organisation.trim().toLowerCase())
this.checkState()
}
checkState() {
this.statesList = _.get(this.dropdownList, 'statesList', [])
const userOrgName = _.get(this.activatedRoute?.snapshot.parent?.data, 'configService.unMappedUser.rootOrg', null)

if (userOrgName && userOrgName.isState) {
this.isStateLogin = userOrgName.isState
this.stateName = userOrgName.channel
const findOrgDetails = (org: string) => {
const result = _.find(this.statesList, { orgName: org })
return result ? { orgName: result.orgName, mapId: result.mapId } : null
}
const orgDetails = findOrgDetails(this.stateName)
if (orgDetails && orgDetails?.mapId && orgDetails?.orgName) {
// Setting form values for organization
this.organisationForm.controls['category'].setValue('state')
this.organisationForm.controls['state'].setValue(orgDetails.orgName)
// Fetching organization details
this.getOrganization(this.stateName, 'state')
this.disableStateBlock = true
}
}
}


ngOnDestroy(): void {
this.removeOverflowHidden()
Expand Down Expand Up @@ -190,24 +217,33 @@ export class CreateOrganisationComponent implements OnInit, OnDestroy {
}

onSubmitCreateOrganization() {
const payload = {
orgName: this.controls['organisationName'].value,
channel: this.controls['organisationName'].value,
let payload: any = {
orgName: this.controls['organisationName']?.value || "",
channel: this.controls['organisationName']?.value || "",
organisationType: "mdo",
organisationSubType: "board",
isTenant: true,
requestedBy: this.loggedInUserId,

logo: this.uploadedLogoResponse?.qrcodepath || "",
description: this.controls['description'].value,
description: this.controls['description']?.value || "",
parentMapId: "",
sbRootOrgId: this.heirarchyObject?.sbRootOrgId || "",
}
if (this.controls['category'].value === 'state') {
payload.parentMapId = this.controls['state'].value.mapId
// if (this.heirarchyObject.sbRootOrgId) {
// payload['sbRootOrgId'] = this.heirarchyObject.sbRootOrgId
// }
if (this.controls['category']?.value === 'state') {
const orgDetails = _.find(this.statesList, { orgName: this.stateName })
if (orgDetails) {
payload.parentMapId = orgDetails.mapId || "" // Assign mapId from orgDetails
} else if (this.controls['state']?.value?.mapId) {
payload.parentMapId = this.controls['state'].value.mapId // Fallback to state control mapId
} else {
return // Exit function in case of error
}
} else if (this.controls['ministry']?.value?.mapId) {
payload.parentMapId = this.controls['ministry'].value.mapId // Assign ministry mapId
} else {
payload.parentMapId = this.controls['ministry'].value.mapId

return // Exit function in case of error
}

if (this.openMode === 'editMode') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class DirectoryViewComponent implements OnInit {
pagination = { limit: 20, offset: 0 }
totalCount = 0
userRoles: any
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER']
allowedCreateRoles = ['DASHBOARD_ADMIN', 'SPV_ADMIN', 'SPV_PUBLISHER', 'STATE_ADMIN']
constructor(
public dialog: MatDialog,
private route: ActivatedRoute,
Expand Down

0 comments on commit e5626ff

Please sign in to comment.