@salesforcedevs/dw-components 1.3.212 → 1.3.214

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@salesforcedevs/dw-components",
3
- "version": "1.3.212",
3
+ "version": "1.3.214",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -24,5 +24,5 @@
24
24
  "@types/setimmediate": "^1.0.2",
25
25
  "setimmediate": "^1.0.5"
26
26
  },
27
- "gitHead": "c44b761d642918baab3ab00a40ac29a599d26f6e"
27
+ "gitHead": "9e7c77ace387fd5b0aa4abd5d1ab160c6c902926"
28
28
  }
@@ -4,6 +4,8 @@
4
4
  communicate-step-changes="true"
5
5
  force-initially-visible={forceInitiallyVisible}
6
6
  initial-step-index={initialStepIndex}
7
+ lwc:ref="stepSequence"
8
+ onslotchange={handleStepSequenceSlotChange}
7
9
  onstepsequencechange={handleStepSequenceChange}
8
10
  optimize-position-after-animation="true"
9
11
  session-storage-id={sessionStorageId}
@@ -4,6 +4,8 @@ import { getListWithUuids } from "dxUtils/list";
4
4
  import { toJson } from "dxUtils/normalizers";
5
5
  import J2sCardSequenceStep from "dw/j2sCardSequenceStep";
6
6
 
7
+ const DRM_SUCCESS_STRING = "success";
8
+
7
9
  export type StepDatum = {
8
10
  bodyHtml?:
9
11
  | string
@@ -79,8 +81,8 @@ export default class J2sCardSequence extends LightningElement {
79
81
  _recaptchaResetTimeoutId: number | null = null;
80
82
  _stepsData: StepDatum[] = [];
81
83
  @api drmDomain: string = "https://drm.my.salesforce-sites.com";
82
- @api formHandler: string =
83
- "https://formhandlermule-1s9xrb.5sc6y6-4.usa-e2.cloudhub.io/form_handler";
84
+ @api drmHandlerBaseUrl: string =
85
+ "https://dev1-infta-proxy.us-w2.cloudhub.io";
84
86
  @api tbidApiBaseUrl: string | undefined;
85
87
  @api useHistory: boolean = false;
86
88
 
@@ -128,6 +130,14 @@ export default class J2sCardSequence extends LightningElement {
128
130
  return Boolean(this.tbidUserInfo);
129
131
  }
130
132
 
133
+ private get drmEmailUrl() {
134
+ return `${this.drmHandlerBaseUrl}/getEmail`;
135
+ }
136
+
137
+ private get formHandlerUrl() {
138
+ return `${this.drmHandlerBaseUrl}/form_handler`;
139
+ }
140
+
131
141
  private get formIncomingUserInfo() {
132
142
  if (!this.tbidUserInfo) {
133
143
  return {} as DrmFormData;
@@ -141,8 +151,8 @@ export default class J2sCardSequence extends LightningElement {
141
151
  Company__c: this.tbidUserInfo.custom_attributes?.CompanyName,
142
152
  MailingCountry: this.tbidUserInfo.custom_attributes?.Country,
143
153
  MailingState: this.tbidUserInfo.address?.region,
144
- RelationshipToSalesforce: this.tbidUserInfo.custom_attributes
145
- ?.RelationshipToSalesforce
154
+ RelationshipToSalesforce:
155
+ this.tbidUserInfo.custom_attributes?.RelationshipToSalesforce
146
156
  };
147
157
 
148
158
  // Return above object but only with keys that have a truthy value, and with any URI-encoded values decoded
@@ -219,18 +229,16 @@ export default class J2sCardSequence extends LightningElement {
219
229
 
220
230
  renderedCallback() {
221
231
  if (!this.isLoading) {
222
- ((this.template.querySelector(
223
- "dx-step-sequence"
224
- ) as unknown) as StepSequence)?.remeasureSteps();
232
+ (this.refs.stepSequence as StepSequence)?.remeasureSteps();
225
233
  }
226
234
 
227
235
  if (
228
236
  this.formSubmissionFailureState &&
229
237
  this.stepsData[this.currentSequenceStep].formData
230
238
  ) {
231
- const j2sCardStep = (this.template.querySelectorAll(
239
+ const j2sCardStep = this.template.querySelectorAll(
232
240
  "dw-j2s-card-sequence-step"
233
- ) as unknown) as J2sCardSequenceStep[];
241
+ ) as unknown as J2sCardSequenceStep[];
234
242
  j2sCardStep[this.currentSequenceStep]?.notifyFormSubmitFailure(
235
243
  this.formSubmissionFailureState
236
244
  );
@@ -267,6 +275,19 @@ export default class J2sCardSequence extends LightningElement {
267
275
  }
268
276
  }
269
277
 
278
+ handleStepSequenceSlotChange() {
279
+ requestAnimationFrame(() => {
280
+ // After the slots have slotted and there's been time to animate, we know the browser's layout of the
281
+ // sequence has completed.
282
+ this.dispatchEvent(
283
+ new CustomEvent("j2ssequencelaidout", {
284
+ bubbles: true,
285
+ composed: true
286
+ })
287
+ );
288
+ });
289
+ }
290
+
270
291
  handleGetStarted() {
271
292
  // If the user is not yet logged in, we need to prevent moving immediately to the next
272
293
  // step, but set storage up so that they are on the second step when they return to the
@@ -285,14 +306,14 @@ export default class J2sCardSequence extends LightningElement {
285
306
  }
286
307
 
287
308
  async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
288
- if (!this.formHandler || !this.isLoggedIn) {
309
+ if (!this.formHandlerUrl || !this.isLoggedIn) {
289
310
  return;
290
311
  }
291
312
 
292
313
  this._isFormSubmitting = true;
293
314
 
294
315
  try {
295
- const res = await fetch(this.formHandler, {
316
+ const res = await fetch(this.formHandlerUrl, {
296
317
  method: "POST",
297
318
  headers: {
298
319
  "Content-Type": "application/json",
@@ -308,7 +329,7 @@ export default class J2sCardSequence extends LightningElement {
308
329
  if (res.ok) {
309
330
  const resData = await res.json();
310
331
  const resOutput = resData.handlePostRequestOutput || resData;
311
- if (resOutput?.status === "success") {
332
+ if (resOutput?.status === DRM_SUCCESS_STRING) {
312
333
  this.dispatchEvent(
313
334
  new CustomEvent("registration", {
314
335
  bubbles: true,
@@ -374,9 +395,7 @@ export default class J2sCardSequence extends LightningElement {
374
395
  if (andStoreIndex) {
375
396
  this.initialStepIndex = stepIndex; // update sessionStorage value
376
397
  }
377
- ((this.template.querySelector(
378
- "dx-step-sequence"
379
- ) as unknown) as StepSequence)?.jumpToStep(stepIndex);
398
+ (this.refs.stepSequence as StepSequence)?.jumpToStep(stepIndex);
380
399
  }
381
400
 
382
401
  private async getCountryList() {
@@ -409,7 +428,16 @@ export default class J2sCardSequence extends LightningElement {
409
428
  try {
410
429
  const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
411
430
  if (res.ok) {
412
- this.tbidUserInfo = await res.json();
431
+ const userInfo = await res.json();
432
+ const emailOverride = await this.getDrmEmailOverride(
433
+ userInfo?.user_id
434
+ );
435
+ this.tbidUserInfo = !emailOverride
436
+ ? userInfo
437
+ : {
438
+ ...userInfo,
439
+ email: emailOverride
440
+ };
413
441
  this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
414
442
  }
415
443
  } catch (ex) {
@@ -424,4 +452,30 @@ export default class J2sCardSequence extends LightningElement {
424
452
 
425
453
  this._isTbidLoading = false;
426
454
  }
455
+
456
+ private async getDrmEmailOverride(
457
+ tbid: string
458
+ ): Promise<string | undefined> {
459
+ let resolvedEmail = "";
460
+
461
+ if (!tbid) {
462
+ return resolvedEmail;
463
+ }
464
+
465
+ try {
466
+ const res = await fetch(`${this.drmEmailUrl}?tbid=${tbid}`);
467
+ if (res.ok) {
468
+ const resData = await res.json();
469
+ if (resData.message === DRM_SUCCESS_STRING) {
470
+ resolvedEmail = resData.Email;
471
+ }
472
+ }
473
+ } catch (ex) {
474
+ console.warn(
475
+ `Could not fetch email address from DRM, defaulting to TBID info. (Exception: ${ex})`
476
+ );
477
+ }
478
+
479
+ return resolvedEmail;
480
+ }
427
481
  }