diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 59e389dc56..82eebc0d09 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -731,10 +731,7 @@ export class AppComponent implements OnInit, AfterViewInit { && !(await this.commonUtilService.isIpLocationAvailable())) { this.deviceRegisterService.getDeviceProfile().toPromise().then(async (response) => { if (response.userDeclaredLocation) { - const locationMap = new Map(); - locationMap['state'] = response.userDeclaredLocation.state; - locationMap['district'] = response.userDeclaredLocation.district; - await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(locationMap)).toPromise(); + await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(response.userDeclaredLocation)).toPromise(); } else if (response.ipLocation) { const ipLocationMap = new Map(); if (response.ipLocation.state) { diff --git a/src/app/district-mapping/district-mapping.page.ts b/src/app/district-mapping/district-mapping.page.ts index dbe938c91a..bb2f90bb77 100644 --- a/src/app/district-mapping/district-mapping.page.ts +++ b/src/app/district-mapping/district-mapping.page.ts @@ -1,7 +1,7 @@ import {Component, OnInit, Inject, ChangeDetectorRef, NgZone, ViewChild} from '@angular/core'; import { LocationSearchCriteria, ProfileService, - SharedPreferences, Profile, DeviceRegisterRequest, DeviceRegisterService, DeviceInfo + SharedPreferences, Profile, DeviceRegisterRequest, DeviceRegisterService, DeviceInfo, LocationSearchResult } from 'sunbird-sdk'; import { Location as loc, PreferenceKey, RouterLinks, LocationConfig } from '../../app/app.constant'; import { AppHeaderService, CommonUtilService, AppGlobalService, FormAndFrameworkUtilService } from '@app/services'; @@ -104,8 +104,8 @@ export class DistrictMappingPage { } name; - stateList = []; - districtList = []; + stateList: LocationSearchResult[] = []; + districtList: LocationSearchResult[] = []; stateCode; districtCode; backButtonFunc: Subscription; @@ -435,15 +435,14 @@ export class DistrictMappingPage { const req: DeviceRegisterRequest = { userDeclaredLocation: { state: this.stateName, + stateId: this.stateList.find((s) => s.name === this.stateName).id, district: this.districtName, + districtId: this.districtList.find((d) => d.name === this.districtName).id, + declaredOffline: !this.commonUtilService.networkInfo.isNetworkAvailable } }; this.deviceRegisterService.registerDevice(req).toPromise(); - - const locationMap = new Map(); - locationMap['state'] = this.stateName ? this.stateName : this.availableLocationState; - locationMap['district'] = this.districtName ? this.districtName : this.availableLocationDistrict; - await this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(locationMap)).toPromise(); + this.preferences.putString(PreferenceKey.DEVICE_LOCATION, JSON.stringify(req.userDeclaredLocation)).toPromise(); await loader.dismiss(); }