@idsoftsource/initial-process 0.1.6 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4984,6 +4984,7 @@ class RoleSelectComponent {
4984
4984
  tokenService;
4985
4985
  fb;
4986
4986
  previewUrl = null;
4987
+ isMappingCreated = false;
4987
4988
  initialSelectedJobValue;
4988
4989
  previousEmployeeType;
4989
4990
  selectedTab;
@@ -5061,8 +5062,15 @@ class RoleSelectComponent {
5061
5062
  });
5062
5063
  this.userId = await this.tokenService.getUserId();
5063
5064
  this.useremail = await this.tokenService.getUserEmail();
5065
+ const stored = localStorage.getItem(this.mappingKey());
5066
+ if (stored === 'true') {
5067
+ this.isMappingCreated = true;
5068
+ }
5064
5069
  this.getUserDetail();
5065
5070
  }
5071
+ mappingKey() {
5072
+ return `provider-user-mapping-${this.providerId}-${this.userId}`;
5073
+ }
5066
5074
  getYears() {
5067
5075
  if (this.expYears?.length)
5068
5076
  return;
@@ -5386,11 +5394,21 @@ class RoleSelectComponent {
5386
5394
  employeeType: currentEmployeeType,
5387
5395
  status: ProviderUserMappingStatus.WaitingForApproval
5388
5396
  };
5389
- const hasEmployeeTypeChanged = this.previousEmployeeType !== currentEmployeeType;
5390
5397
  this.showLoader = true;
5391
- const apiCall$ = hasEmployeeTypeChanged
5392
- ? this.provideruser.updateProviderUserMapping(model) // 🔁 PUT
5393
- : this.provideruser.createProviderUserMapping(model); // POST
5398
+ let apiCall$;
5399
+ if (!this.isMappingCreated) {
5400
+ // 🆕 FIRST TIME POST
5401
+ apiCall$ = this.provideruser.createProviderUserMapping(model);
5402
+ }
5403
+ else if (this.previousEmployeeType !== currentEmployeeType) {
5404
+ // 🔁 SECOND TIME → PUT
5405
+ apiCall$ = this.provideruser.updateProviderUserMapping(model);
5406
+ }
5407
+ else {
5408
+ this.showLoader = false;
5409
+ this.store.nextStep();
5410
+ return;
5411
+ }
5394
5412
  apiCall$.subscribe({
5395
5413
  next: (res) => {
5396
5414
  this.showLoader = false;
@@ -5398,8 +5416,10 @@ class RoleSelectComponent {
5398
5416
  this.userError = res.failures?.[0]?.message;
5399
5417
  return;
5400
5418
  }
5401
- // update stored value after success
5419
+ // persist existence
5420
+ this.isMappingCreated = true;
5402
5421
  this.previousEmployeeType = currentEmployeeType;
5422
+ localStorage.setItem(this.mappingKey(), 'true');
5403
5423
  this.store.nextStep();
5404
5424
  },
5405
5425
  error: (err) => {