@salesforcedevs/dw-components 1.3.397-canary.0 → 1.3.397-canary.2

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.397-canary.0",
3
+ "version": "1.3.397-canary.2",
4
4
  "description": "Lightning web components for https://developer.salesforce.com",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -32,9 +32,9 @@ span {
32
32
  }
33
33
 
34
34
  dx-checkbox,
35
- .privacy-notice,
36
- span.privacy-terms,
37
- span.marketing-terms {
35
+ .privacy-notice:not(:empty),
36
+ span.privacy-terms:not(:empty),
37
+ span.marketing-terms:not(:empty) {
38
38
  width: 100%;
39
39
  margin-bottom: var(--dx-g-spacing-lg);
40
40
  }
@@ -52,6 +52,7 @@ span a:hover {
52
52
  dx-input.username-field {
53
53
  height: initial;
54
54
  min-height: 105px;
55
+ margin-bottom: var(--dx-g-spacing-lg);
55
56
  }
56
57
 
57
58
  form > .full-name-field {
@@ -117,6 +117,8 @@
117
117
  <span lwc:dom="manual" class="legal-checkbox privacy-terms"></span>
118
118
  </dx-checkbox>
119
119
 
120
+ <slot class="form-captcha-slot" name="form-captcha-slot"></slot>
121
+
120
122
  <dx-button
121
123
  class="submit-button"
122
124
  variant="custom"
@@ -47,6 +47,7 @@ export default class DeSignupForm extends LightningElement {
47
47
  private marketingText: string = "";
48
48
  private showLegalCheckbox: boolean = false;
49
49
  private privacyText: string = "";
50
+ private recaptchaToken = "";
50
51
 
51
52
  @track knownDuplicateUsers: string[] = [];
52
53
 
@@ -73,6 +74,26 @@ export default class DeSignupForm extends LightningElement {
73
74
  return stateMap[this.country] || [];
74
75
  }
75
76
 
77
+ @api
78
+ recaptchaCallback(responseToken: string) {
79
+ this.recaptchaToken = responseToken;
80
+ }
81
+
82
+ @api
83
+ recaptchaExpiredCallback() {
84
+ this.recaptchaToken = "";
85
+ }
86
+
87
+ @api
88
+ recaptchaErrorCallback() {
89
+ this.resetRecaptcha();
90
+ }
91
+
92
+ private resetRecaptcha() {
93
+ this.recaptchaToken = "";
94
+ (window as any).grecaptcha?.reset();
95
+ }
96
+
76
97
  connectedCallback(): void {
77
98
  this.getCountryList();
78
99
  }
@@ -126,7 +147,7 @@ export default class DeSignupForm extends LightningElement {
126
147
  ) {
127
148
  trackGtm(target!, "custEv_formCompletion", {
128
149
  converting_page: `SFDC:us:signup:${convertingPage}`,
129
- converting_page_url: `https://developer.salesforce.com/developer-legacy/signup/${convertingPage}`,
150
+ converting_page_url: `https://developer.salesforce.com/signup/${convertingPage}`,
130
151
  form_country: formData.user.country,
131
152
  form_name: "Dev Edition Signup",
132
153
  form_primary_product_interest: "Developer Edition",
@@ -148,7 +169,7 @@ export default class DeSignupForm extends LightningElement {
148
169
  }
149
170
 
150
171
  const formData = this.prepareUserData();
151
- if (!formData) {
172
+ if (!formData || !this.recaptchaToken) {
152
173
  return;
153
174
  }
154
175
 
@@ -167,7 +188,7 @@ export default class DeSignupForm extends LightningElement {
167
188
  );
168
189
 
169
190
  this.setSubmitButtonDisabled(true);
170
- submitForm(formData)
191
+ submitForm(formData, this.recaptchaToken)
171
192
  .then(() => {
172
193
  trackGtm(event.target!, "custEv_signUp", {
173
194
  authentication_method: "email",
@@ -175,7 +196,7 @@ export default class DeSignupForm extends LightningElement {
175
196
  new_registration: true
176
197
  });
177
198
  this.trackFormCompletion(event.target!, formData, "success");
178
- window.location.href = "/developer-legacy/signup/success";
199
+ window.location.href = "/signup/success";
179
200
  })
180
201
  .catch((error) => {
181
202
  if (error.message === ErrorCode.GENERIC && didSubmitTimeout) {
@@ -187,10 +208,10 @@ export default class DeSignupForm extends LightningElement {
187
208
  // If the timeout time has passed at the point of error, and the error code is simply "GENERIC",
188
209
  // we do not know whether the org will ultimately be created (and we have no current way of confirming),
189
210
  // so we navigate the user to an interim page that tells them to watch their email.
190
- window.location.href =
191
- "/developer-legacy/signup/account-verification";
211
+ window.location.href = "/signup/account-verification";
192
212
  } else {
193
213
  this.setSubmitButtonDisabled(false);
214
+ this.resetRecaptcha();
194
215
  if (error.message === ErrorCode.DUPLICATE) {
195
216
  this.knownDuplicateUsers.push(formData.user.username);
196
217
  } else {
@@ -79,13 +79,19 @@ const checkOrgStatus = (id: string, retries = 0): Promise<void> => {
79
79
  });
80
80
  };
81
81
 
82
- export const submitForm = async (formData: SignupForm): Promise<void> => {
82
+ export const submitForm = async (
83
+ formData: SignupForm,
84
+ recaptchaToken: string
85
+ ): Promise<void> => {
83
86
  const response = await fetch(CREATE_PATH, {
84
87
  method: "POST",
85
88
  headers: {
86
89
  "Content-Type": "application/json"
87
90
  },
88
- body: JSON.stringify(formData)
91
+ body: JSON.stringify({
92
+ ...formData,
93
+ "g-recaptcha-response": recaptchaToken
94
+ })
89
95
  });
90
96
 
91
97
  if (!response.ok) {