@salesforcedevs/dw-components 0.0.0 → 0.0.1

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.
Files changed (75) hide show
  1. package/lwc.config.json +10 -1
  2. package/package.json +8 -4
  3. package/src/modules/dw/blogsGrid/blogsGrid.css +10 -7
  4. package/src/modules/dw/blogsGrid/blogsGrid.html +15 -12
  5. package/src/modules/dw/blogsGrid/blogsGrid.ts +23 -9
  6. package/src/modules/dw/browseTrials/browseTrials.css +35 -0
  7. package/src/modules/dw/browseTrials/browseTrials.html +86 -0
  8. package/src/modules/dw/browseTrials/browseTrials.ts +116 -0
  9. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.css +2 -0
  10. package/src/modules/dw/cardBlogPostProvider/cardBlogPostProvider.html +3 -3
  11. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.css +2 -0
  12. package/src/modules/dw/cardPodcastEpisodeProvider/cardPodcastEpisodeProvider.html +2 -1
  13. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.css +6 -8
  14. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.html +11 -7
  15. package/src/modules/dw/codeSamplesGrid/codeSamplesGrid.ts +71 -40
  16. package/src/modules/dw/contentArchive/contentArchive.css +5 -4
  17. package/src/modules/dw/contentArchive/contentArchive.html +58 -24
  18. package/src/modules/dw/contentArchive/contentArchive.ts +46 -8
  19. package/src/modules/dw/contentArchive/contentArchive.types.ts +8 -4
  20. package/src/modules/dw/contentArchive/utils.ts +30 -14
  21. package/src/modules/dw/deSignupForm/deSignupForm.css +11 -10
  22. package/src/modules/dw/deSignupForm/deSignupForm.html +39 -25
  23. package/src/modules/dw/deSignupForm/deSignupForm.ts +200 -133
  24. package/src/modules/dw/deSignupForm/submitForm.ts +7 -3
  25. package/src/modules/dw/docsGrid/docsGrid.css +0 -1
  26. package/src/modules/dw/docsGrid/docsGrid.html +6 -2
  27. package/src/modules/dw/docsGrid/docsGrid.ts +103 -38
  28. package/src/modules/dw/eventsList/eventsList.css +4 -4
  29. package/src/modules/dw/eventsList/eventsList.html +5 -5
  30. package/src/modules/dw/eventsList/eventsList.ts +47 -48
  31. package/src/modules/dw/j2sCardSequence/j2sCardSequence.css +14 -0
  32. package/src/modules/dw/j2sCardSequence/j2sCardSequence.html +41 -0
  33. package/src/modules/dw/j2sCardSequence/j2sCardSequence.ts +487 -0
  34. package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.css +76 -0
  35. package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.html +64 -0
  36. package/src/modules/dw/j2sCardSequenceStep/j2sCardSequenceStep.ts +157 -0
  37. package/src/modules/dw/j2sForm/j2sForm.css +65 -0
  38. package/src/modules/dw/j2sForm/j2sForm.html +217 -0
  39. package/src/modules/dw/j2sForm/j2sForm.ts +371 -0
  40. package/src/modules/dw/j2sForm/mockProps.ts +3102 -0
  41. package/src/modules/dw/languageSelector/languageSelector.html +11 -0
  42. package/src/modules/dw/languageSelector/languageSelector.ts +106 -0
  43. package/src/modules/dw/newsletterForm/newsletterForm.css +2 -2
  44. package/src/modules/dw/newsletterForm/newsletterForm.html +35 -10
  45. package/src/modules/dw/newsletterForm/newsletterForm.ts +107 -78
  46. package/src/modules/dw/podcastSubscription/podcastSubscription.css +6 -7
  47. package/src/modules/dw/podcastSubscription/podcastSubscription.html +2 -2
  48. package/src/modules/dw/podcastSubscription/podcastSubscription.ts +4 -4
  49. package/src/modules/dw/podcastsGrid/podcastsGrid.css +7 -0
  50. package/src/modules/dw/podcastsGrid/podcastsGrid.html +6 -1
  51. package/src/modules/dw/podcastsGrid/podcastsGrid.ts +3 -3
  52. package/src/modules/dw/podcastsPromo/podcastsPromo.css +14 -0
  53. package/src/modules/dw/podcastsPromo/podcastsPromo.html +16 -8
  54. package/src/modules/dw/podcastsPromo/podcastsPromo.ts +11 -2
  55. package/src/modules/dw/rcgTable/altData.ts +72 -9
  56. package/src/modules/dw/rcgTable/getTableData.ts +1 -1
  57. package/src/modules/dw/rcgTable/rcgTable.ts +3 -3
  58. package/src/modules/dw/slackCta/slackCta.css +5 -6
  59. package/src/modules/dw/slackCta/slackCta.html +1 -1
  60. package/src/modules/dw/slackSuccess/slackSuccess.css +1 -1
  61. package/src/modules/dw/slackSuccess/slackSuccess.html +2 -2
  62. package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.css +119 -0
  63. package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.html +192 -0
  64. package/src/modules/dw/tbidLoginMenu/tbidLoginMenu.ts +148 -0
  65. package/src/modules/dw/videoGrid/types.ts +12 -0
  66. package/src/modules/dw/videoGrid/videoGrid.css +24 -0
  67. package/src/modules/dw/videoGrid/videoGrid.html +41 -0
  68. package/src/modules/dw/videoGrid/videoGrid.ts +41 -0
  69. package/src/modules/dw/youtubeVideoGrid/types.ts +8 -0
  70. package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.css +14 -0
  71. package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.html +24 -0
  72. package/src/modules/dw/youtubeVideoGrid/youtubeVideoGrid.ts +66 -0
  73. package/src/modules/dwHelpers/mobileDividers/mobileDividers.css +19 -0
  74. package/src/modules/dwUtils/forms/forms.ts +514 -0
  75. package/src/modules/{dwBaseElements → dwUtils}/postsGrid/postsGrid.ts +10 -13
@@ -15,6 +15,18 @@ const ARCHIVE_CONTENT_URL = `${ARCHIVE_BASE_URL}/latest-post-per-site`;
15
15
  const ARCHIVE_FILTER_LIST_URL = `${ARCHIVE_BASE_URL}/archives-filters?order=DESC`;
16
16
  export const PER_PAGE_COUNT = 10;
17
17
 
18
+ const normalizePostLink = (post: {
19
+ acf: { language: string };
20
+ link: string;
21
+ }) => {
22
+ switch (post.acf.language) {
23
+ case "japanese":
24
+ return post.link.replace("/blogs/", "/jpblogs/");
25
+ default:
26
+ return post.link;
27
+ }
28
+ };
29
+
18
30
  async function postsFetchHandler(url: string) {
19
31
  if (postsController) {
20
32
  postsController.abort();
@@ -36,7 +48,7 @@ async function postsFetchHandler(url: string) {
36
48
  console.error("Error fetching posts");
37
49
 
38
50
  return {
39
- posts: [],
51
+ posts: [] as Array<ArchivePost>,
40
52
  totalResults: 0,
41
53
  totalPages: 0
42
54
  };
@@ -60,19 +72,17 @@ function normalizePosts(posts: Array<ArchivePost>, contentType: string) {
60
72
  id: post.id,
61
73
  title: post.title.rendered,
62
74
  date: post.date,
63
- contentType: post.sitename,
64
- href: post.link,
75
+ contentType: post.sitename.toLowerCase(),
76
+ href: normalizePostLink(post),
65
77
  ...(contentType === "expanded" && {
66
78
  excerpt: post.excerpt,
67
79
  duration: getAudioDuration(post.podcast_audio.duration),
68
- ...(post._embedded &&
69
- post._embedded.author[0].id && {
70
- author: post._embedded.author[0],
71
- authorImgSrc: post._embedded.author[0].avatar_urls["24"],
72
- topics: post._embedded["wp:term"][0].map(
73
- (term: any) => term.name
74
- )
75
- })
80
+ authors: post.authors,
81
+ ...(post._embedded && {
82
+ topics: post._embedded["wp:term"][0].map(
83
+ (term: any) => term.name
84
+ )
85
+ })
76
86
  })
77
87
  }));
78
88
  }
@@ -85,7 +95,8 @@ export async function getArchivePosts({
85
95
  contentType: [],
86
96
  dates: [],
87
97
  authors: [],
88
- categories: []
98
+ categories: [],
99
+ language: []
89
100
  }
90
101
  }: {
91
102
  count: number;
@@ -105,6 +116,9 @@ export async function getArchivePosts({
105
116
  ),
106
117
  category: filterMenuData.categories.map(
107
118
  (category: FilterMenuItem) => category.id
119
+ ),
120
+ language: filterMenuData.language.map(
121
+ (language: FilterMenuItem) => language.id
108
122
  )
109
123
  };
110
124
 
@@ -114,7 +128,9 @@ export async function getArchivePosts({
114
128
  "date",
115
129
  "sitename",
116
130
  "link",
117
- "podcast_audio"
131
+ "acf",
132
+ "podcast_audio",
133
+ "authors"
118
134
  ];
119
135
  const EXPANDED_FIELDS = [
120
136
  "excerpt",
@@ -125,7 +141,7 @@ export async function getArchivePosts({
125
141
 
126
142
  const query: any = {
127
143
  ...filterQuery,
128
- _fields: ["id", "title", "date", "sitename", "link"],
144
+ _fields: ["id", "title", "date", "sitename", "link", "acf"],
129
145
  per_page: count,
130
146
  page
131
147
  };
@@ -1,4 +1,11 @@
1
1
  :host {
2
+ --dx-c-button-custom-background: var(--dx-g-blue-vibrant-50);
3
+ --dx-c-button-custom-color: white;
4
+ --dx-c-button-custom-border: var(--dx-g-blue-vibrant-50);
5
+ --dx-c-button-custom-color-hover: white;
6
+ --dx-c-button-custom-background-hover: var(--dx-g-blue-vibrant-40);
7
+ --dx-c-button-custom-border-hover: var(--dx-g-blue-vibrant-40);
8
+
2
9
  display: block;
3
10
  }
4
11
 
@@ -25,7 +32,10 @@ span {
25
32
  }
26
33
 
27
34
  dx-checkbox,
28
- :not(dx-checkbox) > span {
35
+ .privacy-notice,
36
+ span.privacy-terms,
37
+ span.marketing-terms {
38
+ width: 100%;
29
39
  margin-bottom: var(--dx-g-spacing-lg);
30
40
  }
31
41
 
@@ -48,19 +58,10 @@ form > .full-name-field {
48
58
  width: calc(50% - var(--dx-g-spacing-lg) / 2);
49
59
  }
50
60
 
51
- .legal-terms {
52
- margin-top: var(--dx-g-spacing-lg);
53
- }
54
-
55
61
  .submit-button {
56
62
  width: 100%;
57
63
  }
58
64
 
59
- .form-submit:hover {
60
- background-color: var(--dx-g-blue-vibrant-40);
61
- border-color: var(--dx-g-blue-vibrant-40);
62
- }
63
-
64
65
  @media screen and (min-width: 641px) {
65
66
  form > .full-name-field:first-of-type {
66
67
  margin-right: var(--dx-g-spacing-lg);
@@ -51,8 +51,18 @@
51
51
  options={countries}
52
52
  placeholder="Select Country/Region"
53
53
  required
54
- value=""
55
- onchange={handleCountryChange}
54
+ value={country}
55
+ onchange={handleConsent}
56
+ ></dx-select>
57
+ <dx-select
58
+ if:true={showStateSelect}
59
+ label="State/Province"
60
+ message-when-value-missing="Select your state/province"
61
+ name="state"
62
+ options={states}
63
+ placeholder="Select State/Province"
64
+ required
65
+ value={state}
56
66
  ></dx-select>
57
67
  <dx-input
58
68
  label="Postal Code"
@@ -76,36 +86,40 @@
76
86
  validity-on-blur={checkUsernameValidity}
77
87
  onchange={handleUsernameChange}
78
88
  ></dx-input>
79
- <dx-checkbox
80
- if:true={showMarketingField}
81
- name="opt_in"
82
- value="explicit"
83
- >
84
- <span lwc:dom="manual" class="marketing-terms"></span>
89
+
90
+ <dx-checkbox required name="eula" value="accepted" if:true={legalText}>
91
+ <span lwc:dom="manual" class="legal-terms"></span>
85
92
  </dx-checkbox>
93
+
94
+ <template if:false={showMarketingCheckbox}>
95
+ <span lwc:dom="manual" class="marketing-terms"></span>
96
+ </template>
97
+ <template if:true={showMarketingCheckbox}>
98
+ <dx-checkbox
99
+ name="marketingCheckbox"
100
+ class="marketing-terms"
101
+ value="false"
102
+ onchange={handleMarketingCheckbox}
103
+ >
104
+ <span>{marketingText}</span>
105
+ </dx-checkbox>
106
+ </template>
107
+
108
+ <template if:false={showLegalCheckbox}>
109
+ <span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
110
+ </template>
86
111
  <dx-checkbox
87
112
  if:true={showLegalCheckbox}
88
- required
89
- name="eula"
90
- value="accepted"
113
+ class="privacy-terms"
114
+ value={legalCheckbox}
115
+ required="true"
91
116
  >
92
- <span lwc:dom="manual" class="legal-terms"></span>
93
- <span
94
- if:true={learnMore}
95
- lwc:dom="manual"
96
- class="learn-more"
97
- ></span>
117
+ <span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
98
118
  </dx-checkbox>
99
- <template if:false={showLegalCheckbox}>
100
- <span lwc:dom="manual" class="legal-terms"></span>
101
- <span
102
- if:true={learnMore}
103
- lwc:dom="manual"
104
- class="learn-more"
105
- ></span>
106
- </template>
119
+
107
120
  <dx-button
108
121
  class="submit-button"
122
+ variant="custom"
109
123
  disabled={disableSubmit}
110
124
  size="large"
111
125
  type="submit"
@@ -1,84 +1,54 @@
1
1
  import { LightningElement, api, track } from "lwc";
2
2
  import { toJson } from "dxUtils/normalizers";
3
3
  import { track as trackGtm } from "dxUtils/analytics";
4
- import {
5
- submitForm,
6
- ErrorCode,
7
- SignupForm,
8
- UserData,
9
- OptIn
10
- } from "./submitForm";
4
+ import { submitForm, ErrorCode, SignupForm, UserData } from "./submitForm";
5
+ import { CountryOptions } from "typings/custom";
6
+ import { stateMap } from "dwUtils/forms";
11
7
 
12
8
  type SelectOption = { value: string; label: string };
13
9
  type Country = SelectOption & {
14
- showMarketingField: boolean;
15
- showLegalCheckbox: boolean;
16
- checkboxTextSet?: string;
17
- };
18
-
19
- type CheckboxSet = {
20
- marketingText: string;
21
- legalText: string;
22
- learnMore?: string;
23
- };
24
- type CheckboxTextMap = {
25
- [key: string]: CheckboxSet;
10
+ showMarketingCheckbox: boolean;
11
+ privacyText?: string;
12
+ privacyOptIn?: boolean;
26
13
  };
27
14
 
28
15
  const DEFAULT_DRIVER = "7013000000005wb";
29
16
  const DUPLICATE_USERNAME_MESSAGE =
30
17
  "You are already using that username in another Salesforce login credential. Your username needs to be unique and in the form of an email address.";
31
- const ACCEPTED = "accepted";
32
18
  const SIGN_UP_LABEL = "Sign me Up";
19
+ const SIGN_UP_FORM_TIMEOUT_MS = 18.5 * 1000; // Something in trialforce/DRM's backend (still under investigation) is causing requests to timeout around 20 seconds; we use 18.5 here in case it's sometimes a little faster than that
33
20
 
34
- const ANALYTICS_INFO = {
35
- clickText: "Sign me Up",
36
- itemTitle: "Dev Edition Sign Up Button",
37
- formType: "Dev Edition Sign Up",
38
- formName: "DEVELOPER:xx:signup:Developer-Edition",
39
- method: "email",
40
- clickUrl: "/signup/success",
41
- elementType: "button",
42
- destinationType: "internal",
43
- ctaClick: true,
44
- offerType: "Free Trial"
45
- };
46
21
  export default class DeSignupForm extends LightningElement {
47
- @api
48
- get countries() {
49
- return this._countries;
50
- }
51
-
52
- set countries(value) {
53
- this._countries = toJson(value);
54
- }
55
-
56
22
  @api
57
23
  get roles() {
58
24
  return this._roles;
59
25
  }
60
26
 
61
27
  set roles(value) {
62
- this._roles = toJson(value);
28
+ this._roles = toJson(value!);
63
29
  }
64
-
65
30
  @api
66
- get checkboxTextMap() {
67
- return this._checkboxTextMap;
31
+ get countries() {
32
+ return this._countries;
68
33
  }
69
-
70
- set checkboxTextMap(value) {
71
- this._checkboxTextMap = toJson(value);
34
+ set countries(value) {
35
+ this._countries = value;
72
36
  }
37
+ @api drmDomain: string = "";
38
+ @api legalText: string = "";
73
39
 
74
- private country: Country = null;
40
+ private country: Country | null = null;
41
+ private _countries: string = "";
75
42
  private disableSubmit = false;
76
43
  private username = "";
77
- private updateCheckboxLabels = true;
78
- private _checkboxTextMap: CheckboxTextMap = null;
79
- private _countries: Array<Country>;
80
- private _roles: Array<SelectOption>;
81
- @track knownDuplicateUsers = [];
44
+ private _roles: Array<SelectOption> | undefined;
45
+ private showMarketingCheckbox: boolean = false;
46
+ private marketingCheckbox: boolean = false;
47
+ private marketingText: string = "";
48
+ private showLegalCheckbox: boolean = false;
49
+ private privacyText: string = "";
50
+
51
+ @track knownDuplicateUsers: string[] = [];
82
52
 
83
53
  get usernameError(): string {
84
54
  return this.knownDuplicateUsers.includes(this.username)
@@ -90,58 +60,63 @@ export default class DeSignupForm extends LightningElement {
90
60
  return !this.knownDuplicateUsers.includes(this.username);
91
61
  }
92
62
 
93
- get showMarketingField(): boolean {
94
- return this.country && this.country.showMarketingField;
63
+ get buttonLabel(): string {
64
+ return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
95
65
  }
96
66
 
97
- get marketingText(): string {
98
- return (
99
- this.checkboxSetByCountry && this.checkboxSetByCountry.marketingText
100
- );
67
+ get showStateSelect(): boolean {
68
+ return !!(this.country && (this.country as any) in stateMap);
101
69
  }
102
70
 
103
- get showLegalCheckbox(): boolean {
104
- return this.country && this.country.showLegalCheckbox;
71
+ get states(): string[] {
72
+ // @ts-ignore we're doing something dumb here where we use an entire object as the key of the stateMap
73
+ return stateMap[this.country] || [];
105
74
  }
106
75
 
107
- get legalText(): string {
108
- return this.checkboxSetByCountry && this.checkboxSetByCountry.legalText;
76
+ connectedCallback(): void {
77
+ this.getCountryList();
109
78
  }
110
79
 
111
- get learnMore(): string | undefined {
112
- return this.checkboxSetByCountry && this.checkboxSetByCountry.learnMore;
80
+ renderedCallback(): void {
81
+ this.updateInnerHtml("span.legal-terms", this.legalText);
82
+ this.updateInnerHtml("span.marketing-terms", this.marketingText);
83
+ this.updateInnerHtml("span.legal-checkbox", this.privacyText);
113
84
  }
114
85
 
115
- get checkboxSetByCountry(): CheckboxSet {
116
- return (
117
- (this.country &&
118
- this.country.checkboxTextSet &&
119
- this.checkboxTextMap[this.country.checkboxTextSet]) ||
120
- this.checkboxTextMap.default
86
+ createUUID() {
87
+ if ("crypto" in window && "randomUUID" in crypto) {
88
+ return crypto.randomUUID();
89
+ }
90
+ let dt = new Date().getTime();
91
+ const uuid = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(
92
+ /[xy]/g,
93
+ function (c) {
94
+ var r = (dt + Math.random() * 16) % 16 | 0;
95
+ dt = Math.floor(dt / 16);
96
+ return (c === "x" ? r : (r & 0x3) | 0x8).toString(16);
97
+ }
121
98
  );
99
+ return uuid;
122
100
  }
123
101
 
124
- get buttonLabel(): string {
125
- return this.disableSubmit ? "Beep boop processing" : SIGN_UP_LABEL;
126
- }
102
+ setSubmitButtonDisabled(isDisabled: boolean): void {
103
+ this.disableSubmit = isDisabled;
127
104
 
128
- renderedCallback(): void {
129
- if (!this.updateCheckboxLabels) {
130
- return;
105
+ let backgroundAndBorderColor: string;
106
+ if (isDisabled) {
107
+ backgroundAndBorderColor = "var(--dx-g-gray-80)";
108
+ } else {
109
+ backgroundAndBorderColor = "var(--dx-g-blue-vibrant-50)";
131
110
  }
132
111
 
133
- this.updateCheckboxLabels =
134
- this.updateInnerHtml("span.legal-terms", this.legalText) ||
135
- this.updateInnerHtml(
136
- "span.marketing-terms",
137
- this.marketingText,
138
- this.showMarketingField
139
- ) ||
140
- this.updateInnerHtml(
141
- "span.learn-more",
142
- this.learnMore,
143
- !!this.learnMore
144
- );
112
+ this.template.host.style.setProperty(
113
+ "--dx-c-button-custom-background",
114
+ backgroundAndBorderColor
115
+ );
116
+ this.template.host.style.setProperty(
117
+ "--dx-c-button-custom-border",
118
+ backgroundAndBorderColor
119
+ );
145
120
  }
146
121
 
147
122
  handleSubmit(event: Event): void {
@@ -159,24 +134,64 @@ export default class DeSignupForm extends LightningElement {
159
134
  return;
160
135
  }
161
136
 
162
- this.disableSubmit = true;
137
+ // Due to Heroku's non-configurable 30 second request timeout, the POST request that
138
+ // submits the form can "fail" even though org creation is actually succeeding (but
139
+ // taking longer than 30 seconds). The back-end only gives us a "generic" error in that
140
+ // case, so we use a "good enough" heuristic here and direct the user to an "account-verification"
141
+ // page that doesn't ultimately say things worked, but tells them to watch their email.
142
+ // This should be a temporary bandaid, not a full solution.
143
+ let didSubmitTimeout = false;
144
+ let formSubmissionTimeoutId: number | undefined = window.setTimeout(
145
+ () => {
146
+ didSubmitTimeout = true;
147
+ },
148
+ SIGN_UP_FORM_TIMEOUT_MS
149
+ );
150
+
151
+ this.setSubmitButtonDisabled(true);
163
152
  submitForm(formData)
164
153
  .then(() => {
165
154
  trackGtm(event.target!, "custEv_signUp", {
166
- ...ANALYTICS_INFO,
167
- formId: "form-builder|DEVELOPER:xx:signup|<null>"
155
+ authentication_method: "email",
156
+ authentication_type: "dev edition",
157
+ new_registration: true
158
+ });
159
+ trackGtm(event.target!, "custEv_formCompletion", {
160
+ converting_page: "SFDC:us:signup:success",
161
+ converting_page_url:
162
+ "https://developer.salesforce.com/signup/success",
163
+ form_country: formData.user.country,
164
+ form_name: "Dev Edition Signup",
165
+ form_primary_product_interest: "Developer Edition",
166
+ offer_id: `form-builder|dev-edition-signup|${DEFAULT_DRIVER}AAA`,
167
+ offer_type: "free trial",
168
+ name_capture_campaign_id: `${DEFAULT_DRIVER}AAA`,
169
+ form_join_id_unique: formData.form_join_id_unique
168
170
  });
169
- window.location.href = ANALYTICS_INFO.clickUrl;
171
+ window.location.href = "/signup/success";
170
172
  })
171
173
  .catch((error) => {
172
- if (error.message === ErrorCode.DUPLICATE) {
173
- this.knownDuplicateUsers.push(formData.user.username);
174
- return;
174
+ if (error.message === ErrorCode.GENERIC && didSubmitTimeout) {
175
+ // If the timeout time has passed at the point of error, and the error code is simply "GENERIC",
176
+ // we do not know whether the org will ultimately be created (and we have no current way of confirming),
177
+ // so we navigate the user to an interim page that tells them to watch their email.
178
+ window.location.href = "/signup/account-verification";
179
+ } else {
180
+ this.setSubmitButtonDisabled(false);
181
+ if (error.message === ErrorCode.DUPLICATE) {
182
+ this.knownDuplicateUsers.push(formData.user.username);
183
+ } else {
184
+ console.warn(
185
+ "Oops, something went wrong",
186
+ error.message
187
+ );
188
+ }
175
189
  }
176
-
177
- console.log("Oops, something went wrong", error.message);
178
190
  })
179
- .finally(() => (this.disableSubmit = false));
191
+ .finally(() => {
192
+ clearTimeout(formSubmissionTimeoutId);
193
+ formSubmissionTimeoutId = undefined;
194
+ });
180
195
  }
181
196
 
182
197
  handleKeyDown(e: KeyboardEvent): void {
@@ -189,13 +204,6 @@ export default class DeSignupForm extends LightningElement {
189
204
  this.username = event.detail;
190
205
  }
191
206
 
192
- handleCountryChange(event: CustomEvent<{ value: string }>): void {
193
- this.country = this.countries.find(
194
- ({ value }) => value === event.detail.value
195
- );
196
- this.updateCheckboxLabels = true;
197
- }
198
-
199
207
  private prepareUserData(): SignupForm | null {
200
208
  const fields = Array.from(
201
209
  this.template.querySelectorAll<HTMLFormElement>(
@@ -207,48 +215,107 @@ export default class DeSignupForm extends LightningElement {
207
215
  value: element.value
208
216
  }));
209
217
 
210
- const checkboxes = this.getCheckboxesResult();
218
+ let validCheckboxes = true;
219
+ Array.from(
220
+ this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
221
+ ).forEach((checkbox) => {
222
+ validCheckboxes = validCheckboxes && checkbox.reportValidity();
223
+ });
211
224
 
212
- if (fields.some((field) => !field.valid) || !checkboxes.valid) {
225
+ if (fields.some((field) => !field.valid) || !validCheckboxes) {
213
226
  return null;
214
227
  }
215
228
 
216
- const userData = {};
229
+ const userData: any = {};
217
230
  fields.forEach((field) => {
218
231
  userData[field.name] = field.value;
219
232
  });
220
233
 
221
- (userData as UserData).opt_in = this.country.showMarketingField
222
- ? checkboxes.values.opt_in
223
- : "implied";
224
-
234
+ (userData as UserData).consent = this.showMarketingCheckbox
235
+ ? "Explicit"
236
+ : "Implied";
237
+ const InfoEmail =
238
+ this.showMarketingCheckbox && !this.marketingCheckbox
239
+ ? "False"
240
+ : "True";
225
241
  const formData: SignupForm = {
226
242
  user: userData as UserData,
227
- eula: this.showLegalCheckbox ? checkboxes.values.eula : ACCEPTED,
228
- default_driver: DEFAULT_DRIVER
243
+ default_driver: DEFAULT_DRIVER,
244
+ info_email: InfoEmail,
245
+ form_join_id_unique: this.createUUID()
229
246
  };
230
247
 
231
248
  return formData;
232
249
  }
233
250
 
234
- private getCheckboxesResult(): {
235
- valid: boolean;
236
- values: { eula: string; opt_in: OptIn };
237
- } {
238
- let valid = true;
239
- const values: { eula: string; opt_in: OptIn } = {
240
- eula: "",
241
- opt_in: ""
242
- };
251
+ handleConsent(countrySelectElement: any) {
252
+ this.country = countrySelectElement.target.value;
253
+ countrySelectElement = countrySelectElement.target;
254
+ const countryOptions = countrySelectElement.options.find(
255
+ (option: any) => option.value === countrySelectElement.value
256
+ );
257
+ this.setLegalAndMarketingData(countryOptions);
258
+ this.marketingCheckbox = false;
259
+ }
243
260
 
244
- Array.from(
245
- this.template.querySelectorAll<HTMLInputElement>("dx-checkbox")
246
- ).forEach((checkbox) => {
247
- valid = valid && checkbox.reportValidity();
248
- values[checkbox.name] = (checkbox.checked && checkbox.value) || "";
249
- });
261
+ handleMarketingCheckbox(marketingCheckbox: any) {
262
+ this.marketingCheckbox = marketingCheckbox.target.checked;
263
+ }
250
264
 
251
- return { valid, values };
265
+ setLegalAndMarketingData(countryOptions: CountryOptions) {
266
+ // Set the checkbox text
267
+ this.setCheckboxTextSet(
268
+ countryOptions.marketingText,
269
+ countryOptions.learnMore
270
+ ? `${countryOptions.legalText} </br> ${countryOptions.learnMore}`
271
+ : countryOptions.legalText
272
+ );
273
+
274
+ // Toggle visibility of legal/marketing data
275
+ this.toggleLegalAndMarketingVisibility(
276
+ countryOptions.showMarketingText,
277
+ countryOptions.showLegalCheckbox
278
+ );
279
+ }
280
+
281
+ setCheckboxTextSet(marketingText: string, privacyText: string) {
282
+ this.marketingText = marketingText;
283
+ this.privacyText = privacyText;
284
+ }
285
+
286
+ toggleLegalAndMarketingVisibility(
287
+ showMarketingCheckbox: boolean,
288
+ showLegalCheckbox: boolean
289
+ ) {
290
+ this.showMarketingCheckbox = showMarketingCheckbox;
291
+ this.showLegalCheckbox = showLegalCheckbox;
292
+ }
293
+
294
+ setInnerHtml(element: HTMLElement, value: string) {
295
+ // disable lwc warning because text received from json has HTML
296
+ // eslint-disable-next-line @lwc/lwc/no-inner-html
297
+ element.innerHTML = value;
298
+ }
299
+
300
+ async getCountryList() {
301
+ if (!this.drmDomain) {
302
+ return;
303
+ }
304
+ const errorMsg = "Error while getting country list";
305
+ try {
306
+ const res = await fetch(
307
+ `${this.drmDomain}/utilities/services/apexrest/countries`
308
+ );
309
+
310
+ if (!res.ok) {
311
+ throw new Error(errorMsg);
312
+ }
313
+
314
+ const data = await res.json();
315
+ this._countries = JSON.stringify(data);
316
+ } catch (error) {
317
+ console.error(error);
318
+ }
252
319
  }
253
320
 
254
321
  private updateInnerHtml(
@@ -256,7 +323,7 @@ export default class DeSignupForm extends LightningElement {
256
323
  html: string,
257
324
  shouldUpdate = true
258
325
  ): boolean {
259
- let element: HTMLElement;
326
+ let element: HTMLElement | null = null;
260
327
  if (shouldUpdate) {
261
328
  element = this.template.querySelector(selector);
262
329
  if (element) {