@salesforcedevs/dw-components 1.3.151-canary.1 → 1.3.155
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/LICENSE +12 -0
- package/lwc.config.json +0 -3
- package/package.json +3 -2
- package/src/modules/dw/blogsGrid/blogsGrid.css +2 -2
- package/src/modules/dw/contentArchive/contentArchive.css +1 -1
- package/src/modules/dw/contentArchive/contentArchive.html +2 -2
- package/src/modules/dw/podcastSubscription/podcastSubscription.css +2 -2
- package/src/modules/dw/podcastSubscription/podcastSubscription.ts +9 -15
- package/src/modules/dw/slackCta/slackCta.css +2 -2
- package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.html +2 -2
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.css +0 -14
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.html +0 -37
- package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +0 -403
- package/src/modules/dw/j2sCardSequence/mockProps.ts +0 -61
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.css +0 -47
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.html +0 -59
- package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.ts +0 -152
- package/src/modules/dw/j2sForm/j2sForm.css +0 -56
- package/src/modules/dw/j2sForm/j2sForm.html +0 -162
- package/src/modules/dw/j2sForm/j2sForm.ts +0 -319
- package/src/modules/dw/j2sForm/mockProps.ts +0 -3095
package/LICENSE
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
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.
|
package/lwc.config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforcedevs/dw-components",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.155",
|
|
4
4
|
"description": "Lightning web components for https://developer.salesforce.com",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -23,5 +23,6 @@
|
|
|
23
23
|
"@types/lodash.uniqby": "^4.7.7",
|
|
24
24
|
"@types/setimmediate": "^1.0.2",
|
|
25
25
|
"setimmediate": "^1.0.5"
|
|
26
|
-
}
|
|
26
|
+
},
|
|
27
|
+
"gitHead": "49e14e97f56c7c2978f7dc7e8609ec921344e939"
|
|
27
28
|
}
|
|
@@ -73,8 +73,8 @@ dx-section.section-reduced-padding {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
.box {
|
|
76
|
-
background-image: url("/
|
|
77
|
-
url("/
|
|
76
|
+
background-image: url("https://a.sfdcstatic.com/developer-website/images/subscribe-background-left.svg"),
|
|
77
|
+
url("https://a.sfdcstatic.com/developer-website/images/subscribe-background-right.svg");
|
|
78
78
|
background-position: 4% 25%, 90% 60%;
|
|
79
79
|
background-repeat: no-repeat;
|
|
80
80
|
width: 100%;
|
|
@@ -101,7 +101,7 @@ button:active {
|
|
|
101
101
|
}
|
|
102
102
|
|
|
103
103
|
.empty-state-container {
|
|
104
|
-
background-image: url(/
|
|
104
|
+
background-image: url("https://a.sfdcstatic.com/developer-website/images/no-results-combined.svg");
|
|
105
105
|
background-repeat: no-repeat;
|
|
106
106
|
background-position: center;
|
|
107
107
|
background-size: contain;
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
<dx-modal-drawer open={modalOpen} onclickclose={toggleModal}>
|
|
12
12
|
<img
|
|
13
13
|
if:true={filtersLoading}
|
|
14
|
-
src="/
|
|
14
|
+
src="https://a.sfdcstatic.com/developer-website/images/sidebar-loading.svg"
|
|
15
15
|
alt="loading"
|
|
16
16
|
class="modal-loading"
|
|
17
17
|
/>
|
|
@@ -60,7 +60,7 @@
|
|
|
60
60
|
<template if:false={isMobile}>
|
|
61
61
|
<img
|
|
62
62
|
if:true={filtersLoading}
|
|
63
|
-
src="/
|
|
63
|
+
src="https://a.sfdcstatic.com/developer-website/images/sidebar-loading.svg"
|
|
64
64
|
alt="loading"
|
|
65
65
|
/>
|
|
66
66
|
<template if:false={filtersLoading}>
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
|
|
15
15
|
@media screen and (max-width: 768px) {
|
|
16
16
|
.container {
|
|
17
|
-
background-image: url("/
|
|
17
|
+
background-image: url("https://a.sfdcstatic.com/developer-website/images/podcast-subscription-clouds-small.svg");
|
|
18
18
|
background-size: auto 200px;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
|
|
49
49
|
@media screen and (min-width: 768px) {
|
|
50
50
|
.container {
|
|
51
|
-
background-image: url("/
|
|
51
|
+
background-image: url("https://a.sfdcstatic.com/developer-website/images/podcast-subscription-clouds.svg");
|
|
52
52
|
min-height: 230px;
|
|
53
53
|
}
|
|
54
54
|
|
|
@@ -3,19 +3,17 @@ import { LightningElement } from "lwc";
|
|
|
3
3
|
export default class PodcastSubscription extends LightningElement {
|
|
4
4
|
badgeLinks = [
|
|
5
5
|
{
|
|
6
|
-
href:
|
|
7
|
-
"https://podcasts.apple.com/us/podcast/salesforce-developer-podcast/id1482325260",
|
|
6
|
+
href: "https://podcasts.apple.com/us/podcast/salesforce-developer-podcast/id1482325260",
|
|
8
7
|
imgAlt: "Listen on Apple Podcasts",
|
|
9
|
-
imgSrc: "/
|
|
8
|
+
imgSrc: "https://a.sfdcstatic.com/developer-website/images/podcasts-subscription-apple.svg"
|
|
10
9
|
},
|
|
11
10
|
{
|
|
12
|
-
href:
|
|
13
|
-
"https://www.google.com/podcasts?feed=aHR0cHM6Ly9zYWxlc2ZvcmNlZGV2cG9kY2FzdC5saWJzeW4uY29tL3Jzcw%3D%3D",
|
|
11
|
+
href: "https://www.google.com/podcasts?feed=aHR0cHM6Ly9zYWxlc2ZvcmNlZGV2cG9kY2FzdC5saWJzeW4uY29tL3Jzcw%3D%3D",
|
|
14
12
|
imgAlt: "Listen on Google Podcasts",
|
|
15
|
-
imgSrc: "/
|
|
13
|
+
imgSrc: "https://a.sfdcstatic.com/developer-website/images/podcasts-subscription-google.svg"
|
|
16
14
|
},
|
|
17
15
|
{
|
|
18
|
-
imgSrc: "/
|
|
16
|
+
imgSrc: "https://a.sfdcstatic.com/developer-website/images/podcasts-subscription-spotify.svg",
|
|
19
17
|
imgAlt: "Listen on Spotify",
|
|
20
18
|
href: "https://open.spotify.com/show/75y378cB3FM6RQ8MGUDJ5M"
|
|
21
19
|
}
|
|
@@ -27,23 +25,19 @@ export default class PodcastSubscription extends LightningElement {
|
|
|
27
25
|
text: "Stitcher"
|
|
28
26
|
},
|
|
29
27
|
{
|
|
30
|
-
href:
|
|
31
|
-
"https://www.amazon.com/Emerald-City-Productions-Salesforce-Developer/dp/B082PPXMLN/",
|
|
28
|
+
href: "https://www.amazon.com/Emerald-City-Productions-Salesforce-Developer/dp/B082PPXMLN/",
|
|
32
29
|
text: "Alexa"
|
|
33
30
|
},
|
|
34
31
|
{
|
|
35
|
-
href:
|
|
36
|
-
"https://www.pandora.com/podcast/salesforce-developer-podcast/PC:34746",
|
|
32
|
+
href: "https://www.pandora.com/podcast/salesforce-developer-podcast/PC:34746",
|
|
37
33
|
text: "Pandora"
|
|
38
34
|
},
|
|
39
35
|
{
|
|
40
|
-
href:
|
|
41
|
-
"https://www.iheart.com/podcast/263-salesforce-developer-podca-56252827",
|
|
36
|
+
href: "https://www.iheart.com/podcast/263-salesforce-developer-podca-56252827",
|
|
42
37
|
text: "iHeartRadio"
|
|
43
38
|
},
|
|
44
39
|
{
|
|
45
|
-
href:
|
|
46
|
-
"https://tunein.com/podcasts/Technology-Podcasts/Salesforce-Developer-Podcast-p1255006/",
|
|
40
|
+
href: "https://tunein.com/podcasts/Technology-Podcasts/Salesforce-Developer-Podcast-p1255006/",
|
|
47
41
|
text: "Tune-in"
|
|
48
42
|
},
|
|
49
43
|
{
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
.podcast {
|
|
19
|
-
background-image: url("/
|
|
20
|
-
url("/
|
|
19
|
+
background-image: url("https://a.sfdcstatic.com/developer-website/images/slack-cta-podcast-background-left.svg"),
|
|
20
|
+
url("https://a.sfdcstatic.com/developer-website/images/slack-cta-podcast-background-right.svg");
|
|
21
21
|
background-position: 20% 0%, 80% 100%;
|
|
22
22
|
padding-top: 20px;
|
|
23
23
|
margin-top: -20px;
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
<div if:true={isLoggedIn}>
|
|
11
11
|
<div class="login-container logged-in">
|
|
12
12
|
<img
|
|
13
|
-
src="/
|
|
13
|
+
src="https://a.sfdcstatic.com/developer-website/images/login-widget-bg.png"
|
|
14
14
|
class="header-img"
|
|
15
15
|
alt="Light blue background image showing line-drawn hills and trees"
|
|
16
16
|
/>
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
</span>
|
|
115
115
|
<img
|
|
116
116
|
class="login-link-img"
|
|
117
|
-
src="/
|
|
117
|
+
src="https://a.sfdcstatic.com/developer-website/images/salesforce-cloud.svg"
|
|
118
118
|
alt="Salesforce logo"
|
|
119
119
|
/>
|
|
120
120
|
<dx-icon
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
@import "dxHelpers/reset";
|
|
2
|
-
|
|
3
|
-
:host {
|
|
4
|
-
--dx-c-button-custom-color: var(--dx-g-blue-vibrant-50);
|
|
5
|
-
--dx-c-button-custom-background: white;
|
|
6
|
-
--dx-c-button-custom-border: var(--dx-g-blue-vibrant-50);
|
|
7
|
-
--dx-c-button-custom-color-hover: var(--dx-g-blue-vibrant-50);
|
|
8
|
-
--dx-c-button-custom-background-hover: var(--dx-g-cloud-blue-vibrant-90);
|
|
9
|
-
--dx-c-button-custom-border-hover: var(--dx-g-cloud-blue-vibrant-50);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
dx-step-sequence {
|
|
13
|
-
scroll-margin-top: var(--dx-g-global-header-height);
|
|
14
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<dx-step-sequence
|
|
3
|
-
animate-transitions={animateTransitions}
|
|
4
|
-
communicate-step-changes="true"
|
|
5
|
-
force-initially-visible={forceInitiallyVisible}
|
|
6
|
-
initial-step-index={initialStepIndex}
|
|
7
|
-
onstepsequencechange={handleStepSequenceChange}
|
|
8
|
-
optimize-position-after-animation="true"
|
|
9
|
-
session-storage-id={sessionStorageId}
|
|
10
|
-
use-history={useHistory}
|
|
11
|
-
>
|
|
12
|
-
<template for:each={stepsData} for:item="stepDatum" for:index="index">
|
|
13
|
-
<dx-step-sequence-step key={stepDatum.id}>
|
|
14
|
-
<dw-j2s-card-sequence-step
|
|
15
|
-
country-options={countries}
|
|
16
|
-
is-loading={isLoading}
|
|
17
|
-
oncountrychange={handleCountryChange}
|
|
18
|
-
ongetstarted={handleGetStarted}
|
|
19
|
-
onformsubmit={handleFormSubmit}
|
|
20
|
-
recaptcha-token={recaptchaToken}
|
|
21
|
-
selected-country={selectedCountry}
|
|
22
|
-
step-datum={stepDatum}
|
|
23
|
-
step-index={index}
|
|
24
|
-
step-total-count={stepsData.length}
|
|
25
|
-
user-info={formIncomingUserInfo}
|
|
26
|
-
>
|
|
27
|
-
<div
|
|
28
|
-
if:true={stepDatum.formData}
|
|
29
|
-
slot="card-step-captcha-slot"
|
|
30
|
-
>
|
|
31
|
-
<slot name="captcha-slot"></slot>
|
|
32
|
-
</div>
|
|
33
|
-
</dw-j2s-card-sequence-step>
|
|
34
|
-
</dx-step-sequence-step>
|
|
35
|
-
</template>
|
|
36
|
-
</dx-step-sequence>
|
|
37
|
-
</template>
|
|
@@ -1,403 +0,0 @@
|
|
|
1
|
-
import { api, LightningElement } from "lwc";
|
|
2
|
-
import StepSequence from "dx/stepSequence";
|
|
3
|
-
import { getListWithUuids } from "dxUtils/list";
|
|
4
|
-
import { toJson } from "dxUtils/normalizers";
|
|
5
|
-
import J2sCardSequenceStep from "dw/j2sCardSequenceStep";
|
|
6
|
-
|
|
7
|
-
export type StepDatum = {
|
|
8
|
-
bodyHtml?:
|
|
9
|
-
| string
|
|
10
|
-
| {
|
|
11
|
-
default: string;
|
|
12
|
-
[countryCode: string]: string;
|
|
13
|
-
};
|
|
14
|
-
formData?: {
|
|
15
|
-
countriesWithReferralInput?: string[];
|
|
16
|
-
countriesWithRequiredJobRole?: string[];
|
|
17
|
-
formId?: string;
|
|
18
|
-
j2sTerms?: string;
|
|
19
|
-
notAvailableAlertInfo?: {
|
|
20
|
-
title: string;
|
|
21
|
-
body: string;
|
|
22
|
-
};
|
|
23
|
-
participatingCountryCodes?: string[];
|
|
24
|
-
};
|
|
25
|
-
headerData?: {
|
|
26
|
-
backgroundColor?: string;
|
|
27
|
-
iconColor?: string;
|
|
28
|
-
iconSprite?: string;
|
|
29
|
-
iconSymbol?: string;
|
|
30
|
-
textColor?: string;
|
|
31
|
-
};
|
|
32
|
-
primaryAction: {
|
|
33
|
-
iconSprite?: string;
|
|
34
|
-
iconSymbol?: string;
|
|
35
|
-
link?:
|
|
36
|
-
| string
|
|
37
|
-
| {
|
|
38
|
-
default: string;
|
|
39
|
-
[countryCode: string]: string;
|
|
40
|
-
};
|
|
41
|
-
linkTarget?: string;
|
|
42
|
-
text:
|
|
43
|
-
| string
|
|
44
|
-
| {
|
|
45
|
-
default: string;
|
|
46
|
-
[countryCode: string]: string;
|
|
47
|
-
};
|
|
48
|
-
variant?: string;
|
|
49
|
-
};
|
|
50
|
-
secondaryActionHtml?: string;
|
|
51
|
-
showStepNumber?: boolean;
|
|
52
|
-
stepTitle: string;
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
// Field names expected by DRM; see: https://salesforce.quip.com/daInAFETbPGm
|
|
56
|
-
export type DrmFormData = {
|
|
57
|
-
Email: string;
|
|
58
|
-
FirstName: string;
|
|
59
|
-
LastName: string;
|
|
60
|
-
MailingCountry: string;
|
|
61
|
-
Company__c: string;
|
|
62
|
-
DRM_Role__c: string;
|
|
63
|
-
TBID__c: string;
|
|
64
|
-
Opt_In__c?: boolean;
|
|
65
|
-
Privacy_Statement__c?: boolean;
|
|
66
|
-
j2s_terms?: boolean;
|
|
67
|
-
Referral_Email__c?: string;
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export default class J2sCardSequence extends LightningElement {
|
|
71
|
-
_isDrmLoading = false;
|
|
72
|
-
_isFormSubmitting = false;
|
|
73
|
-
_isTbidLoading = false;
|
|
74
|
-
_recaptchaResetTimeoutId: number | null = null;
|
|
75
|
-
_stepsData: StepDatum[] = [];
|
|
76
|
-
@api animateTransitions = false;
|
|
77
|
-
@api drmDomain: string = "https://drm.my.salesforce-sites.com";
|
|
78
|
-
@api formHandler: string =
|
|
79
|
-
"https://formhandlermule-1s9xrb.5sc6y6-4.usa-e2.cloudhub.io/form_handler";
|
|
80
|
-
@api tbidApiBaseUrl: string | undefined;
|
|
81
|
-
@api useHistory: boolean = false;
|
|
82
|
-
|
|
83
|
-
@api
|
|
84
|
-
get stepsData() {
|
|
85
|
-
return this._stepsData;
|
|
86
|
-
}
|
|
87
|
-
set stepsData(value) {
|
|
88
|
-
// normalize incoming value with uuid keys and non-required props (for cleaner HTML template), etc.
|
|
89
|
-
const valueWithUuids = getListWithUuids<StepDatum>(toJson(value));
|
|
90
|
-
this._stepsData = valueWithUuids.map((stepDatum) => {
|
|
91
|
-
const normalizedStepDatum = {
|
|
92
|
-
...stepDatum,
|
|
93
|
-
headerData: stepDatum.headerData || {},
|
|
94
|
-
primaryAction: {
|
|
95
|
-
...stepDatum.primaryAction,
|
|
96
|
-
variant: stepDatum.primaryAction.variant || "primary",
|
|
97
|
-
iconSprite: stepDatum.primaryAction.iconSprite || "general",
|
|
98
|
-
iconSymbol:
|
|
99
|
-
stepDatum.primaryAction.iconSymbol || "arrow-right"
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
return normalizedStepDatum;
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private countries: any[] = [];
|
|
108
|
-
private currentSequenceStep = 0;
|
|
109
|
-
private forceInitiallyVisible = false;
|
|
110
|
-
private formSubmissionFailureState: Partial<DrmFormData> | null = null;
|
|
111
|
-
private recaptchaToken = "";
|
|
112
|
-
private selectedCountry = "";
|
|
113
|
-
private sessionStorageId = "j2s-card-sequence";
|
|
114
|
-
private tbidUserInfo: any; // TODO typings?
|
|
115
|
-
|
|
116
|
-
private get isLoading() {
|
|
117
|
-
return (
|
|
118
|
-
this._isDrmLoading || this._isTbidLoading || this._isFormSubmitting
|
|
119
|
-
);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
private get isLoggedIn() {
|
|
123
|
-
return Boolean(this.tbidUserInfo);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
private get formIncomingUserInfo() {
|
|
127
|
-
if (!this.tbidUserInfo) {
|
|
128
|
-
return {} as DrmFormData;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
return {
|
|
132
|
-
FirstName: decodeURIComponent(this.tbidUserInfo.given_name),
|
|
133
|
-
LastName: decodeURIComponent(this.tbidUserInfo.family_name),
|
|
134
|
-
Email: decodeURIComponent(this.tbidUserInfo.email),
|
|
135
|
-
DRM_Role__c: decodeURIComponent(
|
|
136
|
-
this.tbidUserInfo.custom_attributes?.Role
|
|
137
|
-
),
|
|
138
|
-
Company__c: decodeURIComponent(
|
|
139
|
-
this.tbidUserInfo.custom_attributes?.CompanyName
|
|
140
|
-
),
|
|
141
|
-
MailingCountry: decodeURIComponent(
|
|
142
|
-
this.tbidUserInfo.custom_attributes?.Country
|
|
143
|
-
)
|
|
144
|
-
} as DrmFormData;
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
private get initialStepIndex() {
|
|
148
|
-
let initialStepIndex = 0;
|
|
149
|
-
|
|
150
|
-
const storedSessionData = sessionStorage.getItem(this.sessionStorageId);
|
|
151
|
-
if (storedSessionData) {
|
|
152
|
-
try {
|
|
153
|
-
const { currentStepIndex } = JSON.parse(storedSessionData);
|
|
154
|
-
initialStepIndex = currentStepIndex;
|
|
155
|
-
} catch (ex) {
|
|
156
|
-
// noop
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return initialStepIndex;
|
|
161
|
-
}
|
|
162
|
-
private set initialStepIndex(value: number) {
|
|
163
|
-
sessionStorage.setItem(
|
|
164
|
-
this.sessionStorageId,
|
|
165
|
-
JSON.stringify({
|
|
166
|
-
currentStepIndex: value
|
|
167
|
-
})
|
|
168
|
-
);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
@api
|
|
172
|
-
recaptchaCallback(responseToken: string) {
|
|
173
|
-
this.recaptchaToken = responseToken;
|
|
174
|
-
clearTimeout(this._recaptchaResetTimeoutId as number);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
@api
|
|
178
|
-
recaptchaExpiredCallback() {
|
|
179
|
-
this.recaptchaToken = "";
|
|
180
|
-
clearTimeout(this._recaptchaResetTimeoutId as number);
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
connectedCallback() {
|
|
184
|
-
this.getCountryList();
|
|
185
|
-
this.getTbidUserInfo();
|
|
186
|
-
// This has to be defined here since it depends on a variable that depends on sessionStorage.
|
|
187
|
-
this.currentSequenceStep = this.initialStepIndex;
|
|
188
|
-
this.resetCustomButtonColors();
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
const isLoggingIn = sessionStorage.getItem(
|
|
192
|
-
`${this.sessionStorageId}__isLoginRedirect`
|
|
193
|
-
);
|
|
194
|
-
if (isLoggingIn) {
|
|
195
|
-
this.forceInitiallyVisible = true;
|
|
196
|
-
sessionStorage.removeItem(
|
|
197
|
-
`${this.sessionStorageId}__isLoginRedirect`
|
|
198
|
-
);
|
|
199
|
-
}
|
|
200
|
-
} catch (ex) {
|
|
201
|
-
// noop
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
renderedCallback() {
|
|
206
|
-
if (!this.isLoading) {
|
|
207
|
-
(
|
|
208
|
-
this.template.querySelector(
|
|
209
|
-
"dx-step-sequence"
|
|
210
|
-
) as unknown as StepSequence
|
|
211
|
-
)?.remeasureSteps();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
if (
|
|
215
|
-
this.formSubmissionFailureState &&
|
|
216
|
-
this.stepsData[this.currentSequenceStep].formData
|
|
217
|
-
) {
|
|
218
|
-
const j2sCardStep = this.template.querySelectorAll(
|
|
219
|
-
"dw-j2s-card-sequence-step"
|
|
220
|
-
) as unknown as J2sCardSequenceStep[];
|
|
221
|
-
j2sCardStep[this.currentSequenceStep]?.notifyFormSubmitFailure(
|
|
222
|
-
this.formSubmissionFailureState
|
|
223
|
-
);
|
|
224
|
-
this.formSubmissionFailureState = null;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
handleCountryChange({ detail }: CustomEvent) {
|
|
229
|
-
this.selectedCountry = detail;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
handleStepSequenceChange({ detail }: CustomEvent) {
|
|
233
|
-
this.currentSequenceStep = detail.stepIndex;
|
|
234
|
-
this.resetCustomButtonColors();
|
|
235
|
-
|
|
236
|
-
if (
|
|
237
|
-
this.currentSequenceStep !== 1 &&
|
|
238
|
-
this.recaptchaToken &&
|
|
239
|
-
this._recaptchaResetTimeoutId === null
|
|
240
|
-
) {
|
|
241
|
-
// If the recaptcha element expires on its own while you are not on the 2nd (form) step, it messes with the
|
|
242
|
-
// page's layout (basically breaks it). So, we need to reset it _before_ expiration if you leave that step.
|
|
243
|
-
// We do it with a timeout so that the token is not immediately wiped if the user goes back and forth a bit.
|
|
244
|
-
this._recaptchaResetTimeoutId = window.setTimeout(
|
|
245
|
-
() => this.resetRecaptcha(),
|
|
246
|
-
1000 * 30 /* 30 seconds */
|
|
247
|
-
);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
handleGetStarted() {
|
|
252
|
-
// If the user is not yet logged in, we need to prevent moving immediately to the next
|
|
253
|
-
// step, but set storage up so that they are on the second step when they return to the
|
|
254
|
-
// site in a logged-in state; then, we need to get them to log in.
|
|
255
|
-
if (!this.isLoggedIn) {
|
|
256
|
-
this.initialStepIndex = 1;
|
|
257
|
-
this._isTbidLoading = true;
|
|
258
|
-
sessionStorage.setItem(
|
|
259
|
-
`${this.sessionStorageId}__isLoginRedirect`,
|
|
260
|
-
"1" /* value doesn't matter */
|
|
261
|
-
);
|
|
262
|
-
(window as any).__startTbidLogin?.(); // call out to DSC tbid controller
|
|
263
|
-
} else {
|
|
264
|
-
this.jumpToStepIndex(1);
|
|
265
|
-
}
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
async handleFormSubmit({ detail: formData }: CustomEvent<DrmFormData>) {
|
|
269
|
-
if (!this.formHandler || !this.isLoggedIn) {
|
|
270
|
-
return;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
this._isFormSubmitting = true;
|
|
274
|
-
|
|
275
|
-
try {
|
|
276
|
-
const res = await fetch(this.formHandler, {
|
|
277
|
-
method: "POST",
|
|
278
|
-
headers: {
|
|
279
|
-
"Content-Type": "application/json",
|
|
280
|
-
"Captcha-Response": this.recaptchaToken
|
|
281
|
-
},
|
|
282
|
-
body: JSON.stringify({
|
|
283
|
-
...formData,
|
|
284
|
-
handlerName: "J2S Registration Page",
|
|
285
|
-
TBID__c: this.tbidUserInfo.user_id
|
|
286
|
-
})
|
|
287
|
-
});
|
|
288
|
-
|
|
289
|
-
if (res.ok) {
|
|
290
|
-
const resData = await res.json();
|
|
291
|
-
const resOutput = resData.handlePostRequestOutput || resData;
|
|
292
|
-
if (resOutput?.status === "success") {
|
|
293
|
-
this.jumpToStepIndex(2, false);
|
|
294
|
-
this.initialStepIndex = 0; // don't save final step in storage; rather, reset the starting step
|
|
295
|
-
this.resetRecaptcha();
|
|
296
|
-
} else {
|
|
297
|
-
throw new Error(
|
|
298
|
-
`Form submission failed. (status: ${resOutput.status}, message: ${resOutput.errorMessage})`
|
|
299
|
-
);
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
throw new Error(
|
|
303
|
-
`Form submission failed. Non-ok response received from DRM.`
|
|
304
|
-
);
|
|
305
|
-
}
|
|
306
|
-
} catch (ex) {
|
|
307
|
-
this.formSubmissionFailureState = formData;
|
|
308
|
-
console.error(ex);
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
this._isFormSubmitting = false;
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
private resetCustomButtonColors() {
|
|
315
|
-
let bgColor;
|
|
316
|
-
let textColor;
|
|
317
|
-
|
|
318
|
-
if (this.currentSequenceStep === 1) {
|
|
319
|
-
bgColor = "var(--dx-g-gray-80)";
|
|
320
|
-
textColor = "white";
|
|
321
|
-
} else {
|
|
322
|
-
bgColor = "white";
|
|
323
|
-
textColor = "var(--dx-g-blue-vibrant-50)";
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
this.template.host.style.setProperty(
|
|
327
|
-
"--dx-c-button-custom-color",
|
|
328
|
-
textColor
|
|
329
|
-
);
|
|
330
|
-
this.template.host.style.setProperty(
|
|
331
|
-
"--dx-c-button-custom-background",
|
|
332
|
-
bgColor
|
|
333
|
-
);
|
|
334
|
-
this.template.host.style.setProperty(
|
|
335
|
-
"--dx-c-button-custom-border",
|
|
336
|
-
bgColor
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
private resetRecaptcha() {
|
|
341
|
-
clearTimeout(this._recaptchaResetTimeoutId as number);
|
|
342
|
-
this._recaptchaResetTimeoutId = null;
|
|
343
|
-
this.recaptchaToken = "";
|
|
344
|
-
(window as any).grecaptcha.reset();
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
private jumpToStepIndex(stepIndex: number, andStoreIndex = true) {
|
|
348
|
-
if (andStoreIndex) {
|
|
349
|
-
this.initialStepIndex = stepIndex; // update sessionStorage value
|
|
350
|
-
}
|
|
351
|
-
(
|
|
352
|
-
this.template.querySelector(
|
|
353
|
-
"dx-step-sequence"
|
|
354
|
-
) as unknown as StepSequence
|
|
355
|
-
)?.jumpToStep(stepIndex);
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
private async getCountryList() {
|
|
359
|
-
this._isDrmLoading = true;
|
|
360
|
-
|
|
361
|
-
const errorMsg = "Error while getting country list";
|
|
362
|
-
try {
|
|
363
|
-
const res = await fetch(
|
|
364
|
-
`${this.drmDomain}/utilities/services/apexrest/countries`
|
|
365
|
-
);
|
|
366
|
-
if (!res.ok) {
|
|
367
|
-
throw new Error(errorMsg);
|
|
368
|
-
}
|
|
369
|
-
this.countries = await res.json();
|
|
370
|
-
} catch (error) {
|
|
371
|
-
console.error(error);
|
|
372
|
-
if (this.initialStepIndex > 0) {
|
|
373
|
-
// Page loaded on a step higher than the first, but we can't get data for the form;
|
|
374
|
-
// send user back to the start for now.
|
|
375
|
-
this.jumpToStepIndex(0);
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
this._isDrmLoading = false;
|
|
380
|
-
}
|
|
381
|
-
|
|
382
|
-
private async getTbidUserInfo() {
|
|
383
|
-
this._isTbidLoading = true;
|
|
384
|
-
|
|
385
|
-
try {
|
|
386
|
-
const res = await fetch(`${this.tbidApiBaseUrl}/userinfo`);
|
|
387
|
-
if (res.ok) {
|
|
388
|
-
this.tbidUserInfo = await res.json();
|
|
389
|
-
this.selectedCountry = this.formIncomingUserInfo.MailingCountry;
|
|
390
|
-
}
|
|
391
|
-
} catch (ex) {
|
|
392
|
-
// noop; nothing to do here
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (!this.tbidUserInfo && this.initialStepIndex > 0) {
|
|
396
|
-
// login failed and the user was previously beyond the start step; need to send them
|
|
397
|
-
// back to the start:
|
|
398
|
-
this.jumpToStepIndex(0);
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
this._isTbidLoading = false;
|
|
402
|
-
}
|
|
403
|
-
}
|