@salesforcedevs/dw-components 1.3.196 → 1.3.197-canary.0
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.
|
|
3
|
+
"version": "1.3.197-canary.0",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -23,6 +23,5 @@
|
|
|
23
23
|
"@types/lodash.uniqby": "^4.7.7",
|
|
24
24
|
"@types/setimmediate": "^1.0.2",
|
|
25
25
|
"setimmediate": "^1.0.5"
|
|
26
|
-
}
|
|
27
|
-
"gitHead": "3ca1796a050dd87c8083f73e41d8cb0cfb15328d"
|
|
26
|
+
}
|
|
28
27
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
communicate-step-changes="true"
|
|
5
5
|
force-initially-visible={forceInitiallyVisible}
|
|
6
6
|
initial-step-index={initialStepIndex}
|
|
7
|
+
lwc:ref="stepSequence"
|
|
7
8
|
onstepsequencechange={handleStepSequenceChange}
|
|
8
9
|
optimize-position-after-animation="true"
|
|
9
10
|
session-storage-id={sessionStorageId}
|
|
@@ -79,8 +79,8 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
79
79
|
_recaptchaResetTimeoutId: number | null = null;
|
|
80
80
|
_stepsData: StepDatum[] = [];
|
|
81
81
|
@api drmDomain: string = "https://drm.my.salesforce-sites.com";
|
|
82
|
-
@api
|
|
83
|
-
"https://
|
|
82
|
+
@api drmHandlerBaseUrl: string =
|
|
83
|
+
"https://dev-sapi-th-ms-infra-form-handler-proxy.us-w2.cloudhub.io";
|
|
84
84
|
@api tbidApiBaseUrl: string | undefined;
|
|
85
85
|
@api useHistory: boolean = false;
|
|
86
86
|
|
|
@@ -128,6 +128,14 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
128
128
|
return Boolean(this.tbidUserInfo);
|
|
129
129
|
}
|
|
130
130
|
|
|
131
|
+
private get drmEmailUrl() {
|
|
132
|
+
return `${this.drmHandlerBaseUrl}/getEmail`;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
private get formHandlerUrl() {
|
|
136
|
+
return `${this.drmHandlerBaseUrl}/form_handler`;
|
|
137
|
+
}
|
|
138
|
+
|
|
131
139
|
private get formIncomingUserInfo() {
|
|
132
140
|
if (!this.tbidUserInfo) {
|
|
133
141
|
return {} as DrmFormData;
|
|
@@ -141,8 +149,8 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
141
149
|
Company__c: this.tbidUserInfo.custom_attributes?.CompanyName,
|
|
142
150
|
MailingCountry: this.tbidUserInfo.custom_attributes?.Country,
|
|
143
151
|
MailingState: this.tbidUserInfo.address?.region,
|
|
144
|
-
RelationshipToSalesforce:
|
|
145
|
-
?.RelationshipToSalesforce
|
|
152
|
+
RelationshipToSalesforce:
|
|
153
|
+
this.tbidUserInfo.custom_attributes?.RelationshipToSalesforce
|
|
146
154
|
};
|
|
147
155
|
|
|
148
156
|
// Return above object but only with keys that have a truthy value, and with any URI-encoded values decoded
|
|
@@ -219,18 +227,16 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
219
227
|
|
|
220
228
|
renderedCallback() {
|
|
221
229
|
if (!this.isLoading) {
|
|
222
|
-
(
|
|
223
|
-
"dx-step-sequence"
|
|
224
|
-
) as unknown) as StepSequence)?.remeasureSteps();
|
|
230
|
+
(this.refs.stepSequence as StepSequence)?.remeasureSteps();
|
|
225
231
|
}
|
|
226
232
|
|
|
227
233
|
if (
|
|
228
234
|
this.formSubmissionFailureState &&
|
|
229
235
|
this.stepsData[this.currentSequenceStep].formData
|
|
230
236
|
) {
|
|
231
|
-
const j2sCardStep =
|
|
237
|
+
const j2sCardStep = this.template.querySelectorAll(
|
|
232
238
|
"dw-j2s-card-sequence-step"
|
|
233
|
-
) as unknown
|
|
239
|
+
) as unknown as J2sCardSequenceStep[];
|
|
234
240
|
j2sCardStep[this.currentSequenceStep]?.notifyFormSubmitFailure(
|
|
235
241
|
this.formSubmissionFailureState
|
|
236
242
|
);
|
|
@@ -285,14 +291,14 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
285
291
|
}
|
|
286
292
|
|
|
287
293
|
async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
|
|
288
|
-
if (!this.
|
|
294
|
+
if (!this.formHandlerUrl || !this.isLoggedIn) {
|
|
289
295
|
return;
|
|
290
296
|
}
|
|
291
297
|
|
|
292
298
|
this._isFormSubmitting = true;
|
|
293
299
|
|
|
294
300
|
try {
|
|
295
|
-
const res = await fetch(this.
|
|
301
|
+
const res = await fetch(this.formHandlerUrl, {
|
|
296
302
|
method: "POST",
|
|
297
303
|
headers: {
|
|
298
304
|
"Content-Type": "application/json",
|
|
@@ -374,9 +380,7 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
374
380
|
if (andStoreIndex) {
|
|
375
381
|
this.initialStepIndex = stepIndex; // update sessionStorage value
|
|
376
382
|
}
|
|
377
|
-
(
|
|
378
|
-
"dx-step-sequence"
|
|
379
|
-
) as unknown) as StepSequence)?.jumpToStep(stepIndex);
|
|
383
|
+
(this.refs.stepSequence as StepSequence)?.jumpToStep(stepIndex);
|
|
380
384
|
}
|
|
381
385
|
|
|
382
386
|
private async getCountryList() {
|
|
@@ -409,7 +413,16 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
409
413
|
try {
|
|
410
414
|
const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
|
|
411
415
|
if (res.ok) {
|
|
412
|
-
|
|
416
|
+
const userInfo = await res.json();
|
|
417
|
+
const emailOverride = await this.getDrmEmailOverride(
|
|
418
|
+
userInfo?.user_id
|
|
419
|
+
);
|
|
420
|
+
this.tbidUserInfo = !emailOverride
|
|
421
|
+
? userInfo
|
|
422
|
+
: {
|
|
423
|
+
...userInfo,
|
|
424
|
+
email: emailOverride
|
|
425
|
+
};
|
|
413
426
|
this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
|
|
414
427
|
}
|
|
415
428
|
} catch (ex) {
|
|
@@ -424,4 +437,30 @@ export default class J2sCardSequence extends LightningElement {
|
|
|
424
437
|
|
|
425
438
|
this._isTbidLoading = false;
|
|
426
439
|
}
|
|
440
|
+
|
|
441
|
+
private async getDrmEmailOverride(
|
|
442
|
+
tbid: string
|
|
443
|
+
): Promise<string | undefined> {
|
|
444
|
+
let resolvedEmail = "";
|
|
445
|
+
|
|
446
|
+
if (!tbid) {
|
|
447
|
+
return resolvedEmail;
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
try {
|
|
451
|
+
const res = await fetch(`${this.drmEmailUrl}?tbid=${tbid}`);
|
|
452
|
+
if (res.ok) {
|
|
453
|
+
const resData = await res.json();
|
|
454
|
+
if (resData.message === "success") {
|
|
455
|
+
resolvedEmail = resData.Email;
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
} catch (ex) {
|
|
459
|
+
console.warn(
|
|
460
|
+
`Could not fetch email address from DRM, defaulting to TBID info. (Exception: ${ex})`
|
|
461
|
+
);
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
return resolvedEmail;
|
|
465
|
+
}
|
|
427
466
|
}
|
package/LICENSE
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
Copyright (c) 2020, Salesforce.com, Inc.
|
|
2
|
-
All rights reserved.
|
|
3
|
-
|
|
4
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
5
|
-
|
|
6
|
-
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
7
|
-
|
|
8
|
-
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
9
|
-
|
|
10
|
-
* Neither the name of Salesforce.com nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
|
11
|
-
|
|
12
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|