@idsoftsource/initial-process 0.1.5 → 0.1.6

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.
@@ -4961,6 +4961,9 @@ class ProvidersService {
4961
4961
  createProviderUserMapping(model) {
4962
4962
  return this.http.post(this.baseUrl, model);
4963
4963
  }
4964
+ updateProviderUserMapping(model) {
4965
+ return this.http.put(this.baseUrl, model);
4966
+ }
4964
4967
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: ProvidersService, deps: [{ token: i1.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable });
4965
4968
  static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.16", ngImport: i0, type: ProvidersService, providedIn: 'root' });
4966
4969
  }
@@ -4982,6 +4985,7 @@ class RoleSelectComponent {
4982
4985
  fb;
4983
4986
  previewUrl = null;
4984
4987
  initialSelectedJobValue;
4988
+ previousEmployeeType;
4985
4989
  selectedTab;
4986
4990
  industries = [];
4987
4991
  selectedIndustries = [];
@@ -5153,13 +5157,13 @@ class RoleSelectComponent {
5153
5157
  return;
5154
5158
  this.userDetails = data;
5155
5159
  this.previewUrl = this.cloudfrontUrl + data.headshotUrl;
5156
- // BUILD ITEMS FIRST (this was missing)
5157
- this.jobTitles = (data.userJobTitle || []).map((t) => ({
5158
- text: t,
5159
- value: t
5160
- }));
5160
+ this.previousEmployeeType = data.employeeType; // 🔑 store old value
5161
5161
  this.jobTitles = UserJobTitlesList;
5162
- const selectedJobTitles = (data.userJobTitle || []).map((name) => UserJobTitlesList[name]).filter(Boolean);
5162
+ const selectedJobTitles = UserJobTitlesList
5163
+ .filter(j => (data.userJobTitle || [])
5164
+ .map((t) => t.trim().toLowerCase())
5165
+ .includes(j.text.trim().toLowerCase()))
5166
+ .map(j => j.value);
5163
5167
  const selectedIds = this.industries
5164
5168
  .filter(i => data.userIndustryNames.includes(i.industryName))
5165
5169
  .map(i => i.id);
@@ -5361,13 +5365,16 @@ class RoleSelectComponent {
5361
5365
  saveProviderUserMapping() {
5362
5366
  const form = this.userForm.value;
5363
5367
  const saved = profileSignal();
5368
+ const currentEmployeeType = this.selectedJobValue;
5364
5369
  const model = {
5365
5370
  providerId: this.providerId,
5366
5371
  userId: this.userId,
5367
5372
  userName: `${form.firstName} ${form.lastName}`.trim(),
5368
5373
  emailId: form.email,
5369
5374
  phoneNumber: form.phoneNumber,
5370
- headshotUrl: saved?.userDetail?.headshotUrl || this.user?.headshotUrl || this.previewUrl,
5375
+ headshotUrl: saved?.userDetail?.headshotUrl ||
5376
+ this.user?.headshotUrl ||
5377
+ this.previewUrl,
5371
5378
  address1: form.address1,
5372
5379
  address2: form.address2,
5373
5380
  city: form.city,
@@ -5376,18 +5383,23 @@ class RoleSelectComponent {
5376
5383
  county: form.county,
5377
5384
  country: form.country,
5378
5385
  category: UserCategory.ManuallyAdded,
5379
- employeeType: EmployeeDesignation.Employee,
5386
+ employeeType: currentEmployeeType,
5380
5387
  status: ProviderUserMappingStatus.WaitingForApproval
5381
5388
  };
5382
- this.provideruser
5383
- .createProviderUserMapping(model)
5384
- .subscribe({
5389
+ const hasEmployeeTypeChanged = this.previousEmployeeType !== currentEmployeeType;
5390
+ this.showLoader = true;
5391
+ const apiCall$ = hasEmployeeTypeChanged
5392
+ ? this.provideruser.updateProviderUserMapping(model) // 🔁 PUT
5393
+ : this.provideruser.createProviderUserMapping(model); // ➕ POST
5394
+ apiCall$.subscribe({
5385
5395
  next: (res) => {
5386
5396
  this.showLoader = false;
5387
5397
  if (res?.failed) {
5388
5398
  this.userError = res.failures?.[0]?.message;
5389
5399
  return;
5390
5400
  }
5401
+ // update stored value after success
5402
+ this.previousEmployeeType = currentEmployeeType;
5391
5403
  this.store.nextStep();
5392
5404
  },
5393
5405
  error: (err) => {