@salesforcedevs/dw-components
Advanced tools
Comparing version
@@ -28,2 +28,3 @@ { | ||
"dw/rcgTable", | ||
"dw/recaptcha", | ||
"dw/slackCta", | ||
@@ -30,0 +31,0 @@ "dw/slackSuccess", |
{ | ||
"name": "@salesforcedevs/dw-components", | ||
"version": "1.3.397-canary.3", | ||
"version": "1.3.397-canary.4", | ||
"description": "Lightning web components for https://developer.salesforce.com", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
@@ -7,2 +7,3 @@ import { LightningElement, api, track } from "lwc"; | ||
import { stateMap } from "dwUtils/forms"; | ||
import Recaptcha from "packages/@salesforcedevs/dw-components/src/modules/dw/recaptcha/recaptcha"; | ||
@@ -51,3 +52,3 @@ type SelectOption = { value: string; label: string }; | ||
private privacyText: string = ""; | ||
private recaptchaToken = ""; | ||
private recaptchaComponent: Recaptcha | null = null; | ||
@@ -79,22 +80,2 @@ @track knownDuplicateUsers: string[] = []; | ||
@api | ||
recaptchaCallback(responseToken: string) { | ||
this.recaptchaToken = responseToken; | ||
} | ||
@api | ||
recaptchaExpiredCallback() { | ||
this.recaptchaToken = ""; | ||
} | ||
@api | ||
recaptchaErrorCallback() { | ||
this.resetRecaptcha(); | ||
} | ||
private resetRecaptcha() { | ||
this.recaptchaToken = ""; | ||
(window as any).grecaptcha?.reset(); | ||
} | ||
connectedCallback(): void { | ||
@@ -110,2 +91,6 @@ this.getCountryList(); | ||
onSlotChange(e: Event) { | ||
this.recaptchaComponent = e.target as Recaptcha; | ||
} | ||
createUUID() { | ||
@@ -176,3 +161,3 @@ if ("crypto" in window && "randomUUID" in crypto) { | ||
const formData = this.prepareUserData(); | ||
if (!formData || !this.recaptchaToken) { | ||
if (!formData) { | ||
return; | ||
@@ -196,3 +181,3 @@ } | ||
this.setSubmitButtonDisabled(true); | ||
submitForm(formData, this.recaptchaToken) | ||
submitForm(formData) | ||
.then(() => { | ||
@@ -221,3 +206,3 @@ trackGtm(event.target!, "custEv_signUp", { | ||
this.setSubmitButtonDisabled(false); | ||
this.resetRecaptcha(); | ||
this.recaptchaComponent?.reset(); | ||
if (error.message === ErrorCode.DUPLICATE) { | ||
@@ -267,3 +252,11 @@ this.knownDuplicateUsers.push(formData.user.username); | ||
if (fields.some((field) => !field.valid) || !validCheckboxes) { | ||
const hasInvalidCaptcha = | ||
this.recaptchaComponent && | ||
!this.recaptchaComponent.reportValidity(); | ||
if ( | ||
fields.some((field) => !field.valid) || | ||
!validCheckboxes || | ||
hasInvalidCaptcha | ||
) { | ||
return null; | ||
@@ -288,3 +281,4 @@ } | ||
info_email: InfoEmail, | ||
form_join_id_unique: this.createUUID() | ||
form_join_id_unique: this.createUUID(), | ||
"g-recaptcha-response": this.recaptchaComponent?.value | ||
}; | ||
@@ -291,0 +285,0 @@ |
@@ -27,2 +27,3 @@ const CREATE_PATH = `/deorgs/trialforce`; | ||
form_join_id_unique: string; | ||
"g-recaptcha-response"?: string; | ||
}; | ||
@@ -83,6 +84,3 @@ | ||
export const submitForm = async ( | ||
formData: SignupForm, | ||
recaptchaToken: string | ||
): Promise<void> => { | ||
export const submitForm = async (formData: SignupForm): Promise<void> => { | ||
const response = await fetch(CREATE_PATH, { | ||
@@ -93,6 +91,3 @@ method: "POST", | ||
}, | ||
body: JSON.stringify({ | ||
...formData, | ||
"g-recaptcha-response": recaptchaToken | ||
}) | ||
body: JSON.stringify(formData) | ||
}); | ||
@@ -99,0 +94,0 @@ |
Sorry, the diff of this file is not supported yet
509151
0.6%89
3.49%9415
0.77%