@meetelise/chat 1.43.29 → 1.43.30

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.
@@ -29,7 +29,12 @@ import { DatePicker } from "./date-picker";
29
29
  import { MESelect } from "../me-select";
30
30
  import { TimePicker } from "./time-picker";
31
31
  import { LabeledOption } from "../../fetchBuildingInfo";
32
- import { isMobile, isValidPhoneNumber, snakify } from "../../utils";
32
+ import {
33
+ isMobile,
34
+ isValidEmail,
35
+ isValidPhoneNumber,
36
+ snakify,
37
+ } from "../../utils";
33
38
  import axios, { AxiosError } from "axios";
34
39
  import mapValues from "lodash/mapValues";
35
40
  import classnames from "classnames";
@@ -558,7 +563,7 @@ export class TourScheduler extends LitElement {
558
563
  leadInfo: (): boolean => {
559
564
  return (
560
565
  (!!this.firstNameInput?.value || !!this.lastNameInput?.value) &&
561
- this.emailInput?.value.includes("@") &&
566
+ isValidEmail(this.emailInput?.value ?? "") &&
562
567
  // TODO: deleting phone number doesn't cause validation to fail, at least on mobile
563
568
  !!this.phoneNumber &&
564
569
  this.phoneNumber.length === 14 &&
@@ -1146,6 +1151,8 @@ export class TourScheduler extends LitElement {
1146
1151
  ["webchat-input"]: true,
1147
1152
  ["webchat-font__desktop"]: !isMobile(),
1148
1153
  ["webchat-font__mobile"]: isMobile(),
1154
+ ["webchat-input__error"]:
1155
+ !!this.email && !isValidEmail(this.email),
1149
1156
  })}
1150
1157
  type="email"
1151
1158
  inputmode="email"
@@ -1155,6 +1162,9 @@ export class TourScheduler extends LitElement {
1155
1162
  .value=${this.email}
1156
1163
  @input=${this.onChangeEmail}
1157
1164
  />
1165
+ ${!!this.email && !isValidEmail(this.email)
1166
+ ? html`<p class="error-message">Invalid email address</p>`
1167
+ : ""}
1158
1168
  </div>
1159
1169
  <div class="inputContainer" id="phone">
1160
1170
  <input
@@ -17,7 +17,7 @@ import axios from "axios";
17
17
  import { FeatureFlagsShowDropdown } from "../../fetchFeatureFlag";
18
18
  import { pushGtmEvent } from "../../gtm";
19
19
  import formDisclaimer from "../../disclaimers";
20
- import { isMobile, snakify } from "../../utils";
20
+ import { isMobile, isValidEmail, snakify } from "../../utils";
21
21
  import LeadSourceClient, {
22
22
  getDefaultLeadSourceAttribution,
23
23
  } from "../LeadSourceClient";
@@ -233,8 +233,7 @@ export class EmailUsWindow extends LitElement {
233
233
  if (!this.firstName || !this.lastName) {
234
234
  this.hasNameError = true;
235
235
  }
236
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
237
- if (!this.email || !emailRegex.test(this.email)) {
236
+ if (!this.email || !isValidEmail(this.email)) {
238
237
  this.hasEmailError = true;
239
238
  }
240
239
  if (!this.phoneNumber || this.phoneNumber.length !== 14) {
package/src/utils.ts CHANGED
@@ -78,6 +78,11 @@ export const isValidPhoneNumber = (phoneNumber: string): boolean => {
78
78
  return phoneNumberRegex.test(phoneNumber);
79
79
  };
80
80
 
81
+ export const isValidEmail = (email: string): boolean => {
82
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
83
+ return emailRegex.test(email);
84
+ };
85
+
81
86
  export const isContainingEmail = (message: string): boolean => {
82
87
  try {
83
88
  const emailRegex = /\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,7}\b/;