@axos-web-dev/shared-components 2.0.0-dev.13-stepForm.4 → 2.0.0-dev.13-stepForm.5

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.
@@ -43,7 +43,8 @@ const ChatWindow = ({
43
43
  toggleThankyouMessage,
44
44
  hasEscalated,
45
45
  isBlockedInput,
46
- isOpen
46
+ isOpen,
47
+ hasOpenedOnce
47
48
  } = useOpenChat();
48
49
  const [mounted, setMounted] = React.useState(false);
49
50
  const [menuOpen, setMenuOpen] = React.useState(false);
@@ -398,7 +399,7 @@ const ChatWindow = ({
398
399
  }
399
400
  ) }) : null,
400
401
  /* @__PURE__ */ jsxs("div", { className: clsx(messagesContainerStyle), children: [
401
- (status === "idle" || messages.length == 0) && /* @__PURE__ */ jsx(
402
+ (status === "idle" && messages.length == 0 || messages.length == 0) && /* @__PURE__ */ jsx(
402
403
  "div",
403
404
  {
404
405
  className: clsx(),
@@ -425,23 +426,28 @@ const ChatWindow = ({
425
426
  )
426
427
  }
427
428
  ),
428
- messages?.map((msg) => /* @__PURE__ */ jsx(
429
- ChatbotMessage,
430
- {
431
- msg,
432
- onSend,
433
- showAvatar,
434
- showName,
435
- virtualAgent,
436
- onCancelEndChat,
437
- onEndChat: () => {
438
- endChat();
439
- onCloseAfterThankYou();
429
+ messages?.map((msg) => {
430
+ if (!hasOpenedOnce) {
431
+ return null;
432
+ }
433
+ return /* @__PURE__ */ jsx(
434
+ ChatbotMessage,
435
+ {
436
+ msg,
437
+ onSend,
438
+ showAvatar,
439
+ showName,
440
+ virtualAgent,
441
+ onCancelEndChat,
442
+ onEndChat: () => {
443
+ endChat();
444
+ onCloseAfterThankYou();
445
+ },
446
+ inputRef
440
447
  },
441
- inputRef
442
- },
443
- msg?.$index
444
- )),
448
+ msg?.$index
449
+ );
450
+ }),
445
451
  showReconnect && /* @__PURE__ */ jsx(
446
452
  "button",
447
453
  {
@@ -39,13 +39,11 @@ const Chatbot = ({
39
39
  const clientRef = useRef(null);
40
40
  const menuRef = useRef(null);
41
41
  const isMountedRef = useRef(false);
42
- const hasLoadedBefore = useRef(true);
43
42
  const chatRef = useRef(null);
44
43
  const agent_virtual = useRef(null);
45
44
  const [status, setStatus] = useState("idle");
46
45
  const [hasStarted, setHasStarted] = useState(false);
47
46
  const [menusLoaded, setMenusLoaded] = useState(false);
48
- const [pendingStart, setPendingStart] = useState(false);
49
47
  const [isTyping, setIsTyping] = useState(false);
50
48
  const [scalationStarted, setScalationStarted] = useState(false);
51
49
  useEffect(() => {
@@ -100,6 +98,9 @@ const Chatbot = ({
100
98
  menuRef.current = await clientRef.current.getMenus();
101
99
  setMenusLoaded(true);
102
100
  console.log("menus:", menuRef.current);
101
+ if (menuRef.current !== null) {
102
+ await startChat();
103
+ }
103
104
  }
104
105
  };
105
106
  const onAuthenticatedHandler = async () => {
@@ -260,9 +261,10 @@ const Chatbot = ({
260
261
  return;
261
262
  };
262
263
  const startChat = async () => {
263
- console.log("Starting chat");
264
+ console.log("Starting chat", chatRef.current);
264
265
  const client = clientRef.current;
265
266
  if (!client) return;
267
+ if (hasStarted) return;
266
268
  if (!menuRef.current || !menuRef.current.menus) {
267
269
  let waited = 0;
268
270
  while ((!menuRef.current || !menuRef.current.menus) && waited < 5e3) {
@@ -275,19 +277,26 @@ const Chatbot = ({
275
277
  }
276
278
  }
277
279
  try {
280
+ console.log("menus: ->", menuRef.current);
278
281
  const ongoingChat = await client.loadOngoingChat();
282
+ console.log("theres a ongoing chat?: -->", ongoingChat);
279
283
  if (ongoingChat) {
280
284
  console.log("Ongoing chat found:", ongoingChat);
281
285
  console.log("Resuming chat:", ongoingChat.id);
282
- chatRef.current = await client.resumeChat(ongoingChat.id);
286
+ chatRef.current = ongoingChat;
283
287
  agent_virtual.current = ongoingChat.agent;
284
288
  return;
285
289
  }
290
+ console.log("not ongoing chat ");
291
+ console.log(!!ongoingChat);
286
292
  const foundMenu = menuRef.current.menus.find(
287
293
  (menu) => menu.name === menuOption
288
294
  );
289
295
  const menuId = foundMenu && foundMenu.id;
290
296
  console.log("Creating new chat with menu ID:", menuId);
297
+ if (!foundMenu) {
298
+ throw new Error("Menu not found: " + menuOption);
299
+ }
291
300
  const newChat = await client.createChat(menuId, { custom_data });
292
301
  if (newChat !== null) {
293
302
  chatRef.current = newChat;
@@ -297,6 +306,7 @@ const Chatbot = ({
297
306
  } catch (err) {
298
307
  console.error("Error creating chat:", err);
299
308
  } finally {
309
+ setHasStarted(true);
300
310
  if (clientRef?.current?.chat?.state?.status == "va_assigned") {
301
311
  const OriginalAudio = window.Audio;
302
312
  class PatchedAudio extends OriginalAudio {
@@ -312,10 +322,6 @@ const Chatbot = ({
312
322
  const handleClick = async () => {
313
323
  toggle();
314
324
  if (hasStarted) return;
315
- if (!menusLoaded) {
316
- setPendingStart(true);
317
- return;
318
- }
319
325
  if (!hasOpenedOnce) {
320
326
  await startChat();
321
327
  setHasStarted(true);
@@ -356,17 +362,9 @@ const Chatbot = ({
356
362
  isMountedRef.current = true;
357
363
  await createClient();
358
364
  });
359
- useEffect(() => {
360
- if (menusLoaded && pendingStart && !hasStarted) {
361
- startChat();
362
- setPendingStart(false);
363
- }
364
- }, [menusLoaded, pendingStart, hasStarted]);
365
365
  useUnmount(() => {
366
366
  console.log("Chatbot unmounted");
367
367
  deregisterEventHandlers();
368
- isMountedRef.current = false;
369
- hasLoadedBefore.current = true;
370
368
  reset();
371
369
  setHasStarted(false);
372
370
  setStatus("idle");
@@ -379,9 +377,13 @@ const Chatbot = ({
379
377
  const onClose = () => {
380
378
  toggle();
381
379
  };
382
- const onCloseAfterThankYou = () => {
380
+ const newChatSession = async () => {
381
+ console.log("create new session");
382
+ };
383
+ const onCloseAfterThankYou = async () => {
383
384
  reset();
384
385
  setHasStarted(false);
386
+ newChatSession();
385
387
  };
386
388
  const onPreviewTyping = async (msg) => {
387
389
  console.log("Preview typing message:", msg);
@@ -374,6 +374,15 @@ const AxosFooterSiteMap = ({
374
374
  ),
375
375
  children: "Treasury Management"
376
376
  }
377
+ ) }),
378
+ /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
379
+ "a",
380
+ {
381
+ href: resolveUrl(
382
+ "{AXOSBANK}/commercial/banking/technology-and-life-sciences-banking"
383
+ ),
384
+ children: "Technology and Life Sciences Banking"
385
+ }
377
386
  ) })
378
387
  ] })
379
388
  ] })
@@ -688,6 +697,15 @@ const AxosFooterSiteMap = ({
688
697
  ),
689
698
  children: "Treasury Management"
690
699
  }
700
+ ) }),
701
+ /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(
702
+ "a",
703
+ {
704
+ href: resolveUrl(
705
+ "{AXOSBANK}/commercial/banking/technology-and-life-sciences-banking"
706
+ ),
707
+ children: "Technology and Life Sciences Banking"
708
+ }
691
709
  ) })
692
710
  ] }),
693
711
  /* @__PURE__ */ jsxs("ul", { children: [
@@ -21,7 +21,10 @@ export type BoatMooringLocationInputs = {
21
21
  extraState: string;
22
22
  extraZip: string;
23
23
  extraCountry: string;
24
- charterType: "Limited Charter" | "Full-time Charter";
24
+ charterType: "Limited Charter" | "Full-time Charter" | "";
25
25
  charterCompany: string;
26
+ insuranceCompanyName: string;
27
+ insurancePolicyExpirationDate: string;
28
+ insuranceContactEmailAddress: string;
26
29
  };
27
30
  export declare const BoatMooringLocation: ({ icon, children, onSubmit, disclosure, variant: fullVariant, headline, callToAction, validateEmail, onValidate, description, id, }: FormProps) => import("react/jsx-runtime").JSX.Element;
@@ -54,8 +54,12 @@ const BoatMooringLocation = ({
54
54
  const cachedEmailValidator = useCachedEmailValidator(validateEmail);
55
55
  const schema = z.object({
56
56
  email: z.string().email({ message: "Email is required." }).refine(cachedEmailValidator, { message: "Invalid email address." }),
57
- firstName: z.string().regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g).trim().min(1, { message: "First Name is required." }),
58
- lastName: z.string().regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g).trim().min(1, { message: "First Name is required." }),
57
+ firstName: z.string().regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g, {
58
+ message: "First Name is required."
59
+ }).trim().min(1, { message: "First Name is required." }),
60
+ lastName: z.string().regex(/^[A-Za-z][^0-9_!¡?÷?¿/\\+=@#$%ˆ&*,.^(){}|~<>;:[\]]{1,}$/g, {
61
+ message: "Last Name is required."
62
+ }).trim().min(1, { message: "Last Name is required." }),
59
63
  boatOwnedByLlc: z.string().trim().optional().or(z.literal("")),
60
64
  llcName: z.string().trim().optional().or(z.literal("")),
61
65
  boatName: z.string().trim(),
@@ -74,7 +78,16 @@ const BoatMooringLocation = ({
74
78
  extraZip: z.string().trim().optional().or(z.literal("")),
75
79
  extraCountry: z.string().trim().optional().or(z.literal("")),
76
80
  charterType: z.string().trim().optional().or(z.literal("")),
77
- charterCompany: z.string().trim().optional().or(z.literal(""))
81
+ charterCompany: z.string().trim().optional().or(z.literal("")),
82
+ insuranceCompanyName: z.string().trim().optional().or(z.literal("")),
83
+ insurancePolicyExpirationDate: z.string().trim().optional().or(z.literal("")),
84
+ insuranceContactEmailAddress: z.string().trim().email({ message: "Invalid email address." }).optional().or(z.literal("")).refine(
85
+ async (value) => {
86
+ if (!value) return true;
87
+ return await cachedEmailValidator(value);
88
+ },
89
+ { message: "Invalid email address." }
90
+ )
78
91
  });
79
92
  const gen_schema = schema.merge(honeyPotSchema).superRefine((data, ctx) => {
80
93
  if (!isValidHoneyPot(data)) {
@@ -90,6 +103,29 @@ const BoatMooringLocation = ({
90
103
  path: ["llcName"]
91
104
  });
92
105
  }
106
+ if (data.charter === "No") {
107
+ if (!String(data.insuranceCompanyName ?? "").trim()) {
108
+ ctx.addIssue({
109
+ code: z.ZodIssueCode.custom,
110
+ message: "Insurance Company Name is required.",
111
+ path: ["insuranceCompanyName"]
112
+ });
113
+ }
114
+ if (!String(data.insurancePolicyExpirationDate ?? "").trim()) {
115
+ ctx.addIssue({
116
+ code: z.ZodIssueCode.custom,
117
+ message: "Insurance Policy Expiration Date is required.",
118
+ path: ["insurancePolicyExpirationDate"]
119
+ });
120
+ }
121
+ if (!String(data.insuranceContactEmailAddress ?? "").trim()) {
122
+ ctx.addIssue({
123
+ code: z.ZodIssueCode.custom,
124
+ message: "Insurance Contact Email Address is required.",
125
+ path: ["insuranceContactEmailAddress"]
126
+ });
127
+ }
128
+ }
93
129
  });
94
130
  const methods = useForm({
95
131
  resolver: zodResolver(gen_schema),
@@ -106,10 +142,11 @@ const BoatMooringLocation = ({
106
142
  formState: { errors, isValid, isSubmitting }
107
143
  } = methods;
108
144
  const seasonMove = watch("seasonallyMove");
109
- const isCharter = watch("charter");
145
+ const charter = watch("charter");
110
146
  const boatOwnedByLlc = watch("boatOwnedByLlc");
111
147
  const renderExtraFields = seasonMove === "Yes";
112
- const renderCharterFields = isCharter === "Yes";
148
+ const renderCharterFields = charter === "Yes";
149
+ const renderInsuranceFields = charter === "No";
113
150
  const renderLlcNameField = boatOwnedByLlc === "Yes";
114
151
  const submitForm = async (data) => {
115
152
  await onSubmit(data);
@@ -152,7 +189,7 @@ const BoatMooringLocation = ({
152
189
  label: "First Name",
153
190
  sizes: "medium",
154
191
  required: true,
155
- error: !!errors.email,
192
+ error: !!errors.firstName,
156
193
  helperText: errors.firstName?.message,
157
194
  variant
158
195
  }
@@ -167,56 +204,11 @@ const BoatMooringLocation = ({
167
204
  label: "Last Name",
168
205
  sizes: "medium",
169
206
  required: true,
170
- error: !!errors.email,
207
+ error: !!errors.lastName,
171
208
  helperText: errors.lastName?.message,
172
209
  variant
173
210
  }
174
211
  ) }),
175
- /* @__PURE__ */ jsx("div", { className: fullRowForm, children: /* @__PURE__ */ jsxs(
176
- RadioButtonSet,
177
- {
178
- id: "boatOwnedByLlc",
179
- label: "Is your boat owned by an LLC?",
180
- sizes: "medium",
181
- required: true,
182
- error: !!errors.boatOwnedByLlc,
183
- helperText: errors.boatOwnedByLlc?.message,
184
- variant,
185
- children: [
186
- /* @__PURE__ */ jsx(
187
- RadioButton,
188
- {
189
- ...register("boatOwnedByLlc"),
190
- value: "Yes",
191
- radioText: "Yes",
192
- groupName: "boatOwnedByLlc"
193
- }
194
- ),
195
- /* @__PURE__ */ jsx(
196
- RadioButton,
197
- {
198
- ...register("boatOwnedByLlc"),
199
- value: "No",
200
- radioText: "No",
201
- groupName: "boatOwnedByLlc"
202
- }
203
- )
204
- ]
205
- }
206
- ) }),
207
- renderLlcNameField && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
208
- Input,
209
- {
210
- id: "llcName",
211
- ...register("llcName"),
212
- label: "Name of LLC",
213
- sizes: "medium",
214
- required: true,
215
- error: !!errors.llcName,
216
- helperText: errors.llcName?.message,
217
- variant
218
- }
219
- ) }),
220
212
  /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
221
213
  Input,
222
214
  {
@@ -263,6 +255,7 @@ const BoatMooringLocation = ({
263
255
  Input,
264
256
  {
265
257
  id: "marinaAddress2",
258
+ ...register("marinaAddress2"),
266
259
  label: "Marina Address Line 2 (optional)",
267
260
  sizes: "medium",
268
261
  required: false,
@@ -318,6 +311,51 @@ const BoatMooringLocation = ({
318
311
  variant
319
312
  }
320
313
  ) }),
314
+ /* @__PURE__ */ jsx("div", { className: fullRowForm, children: /* @__PURE__ */ jsxs(
315
+ RadioButtonSet,
316
+ {
317
+ id: "boatOwnedByLlc",
318
+ label: "Is your boat owned by an LLC?",
319
+ sizes: "medium",
320
+ required: true,
321
+ error: !!errors.boatOwnedByLlc,
322
+ helperText: errors.boatOwnedByLlc?.message,
323
+ variant,
324
+ children: [
325
+ /* @__PURE__ */ jsx(
326
+ RadioButton,
327
+ {
328
+ ...register("boatOwnedByLlc"),
329
+ value: "Yes",
330
+ radioText: "Yes",
331
+ groupName: "boatOwnedByLlc"
332
+ }
333
+ ),
334
+ /* @__PURE__ */ jsx(
335
+ RadioButton,
336
+ {
337
+ ...register("boatOwnedByLlc"),
338
+ value: "No",
339
+ radioText: "No",
340
+ groupName: "boatOwnedByLlc"
341
+ }
342
+ )
343
+ ]
344
+ }
345
+ ) }),
346
+ renderLlcNameField && /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
347
+ Input,
348
+ {
349
+ id: "llcName",
350
+ ...register("llcName"),
351
+ label: "Name of LLC",
352
+ sizes: "medium",
353
+ required: true,
354
+ error: !!errors.llcName,
355
+ helperText: errors.llcName?.message,
356
+ variant
357
+ }
358
+ ) }),
321
359
  /* @__PURE__ */ jsx("div", { className: fullRowForm, children: /* @__PURE__ */ jsxs(
322
360
  RadioButtonSet,
323
361
  {
@@ -371,6 +409,7 @@ const BoatMooringLocation = ({
371
409
  Input,
372
410
  {
373
411
  id: "extraMarinaAddress2",
412
+ ...register("extraMarinaAddress2"),
374
413
  label: "Marina Address Line 2 (optional)",
375
414
  sizes: "medium",
376
415
  required: false,
@@ -431,7 +470,7 @@ const BoatMooringLocation = ({
431
470
  RadioButtonSet,
432
471
  {
433
472
  id: "charter",
434
- label: "Is your boat a charter?",
473
+ label: "Is your boat in charter?",
435
474
  sizes: "medium",
436
475
  required: true,
437
476
  error: !!errors.charter,
@@ -505,6 +544,48 @@ const BoatMooringLocation = ({
505
544
  }
506
545
  ) })
507
546
  ] }),
547
+ renderInsuranceFields && /* @__PURE__ */ jsxs(Fragment, { children: [
548
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
549
+ Input,
550
+ {
551
+ id: "insuranceCompanyName",
552
+ ...register("insuranceCompanyName"),
553
+ label: "Insurance Company Name",
554
+ sizes: "medium",
555
+ required: true,
556
+ error: !!errors.insuranceCompanyName,
557
+ helperText: errors.insuranceCompanyName?.message,
558
+ variant
559
+ }
560
+ ) }),
561
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
562
+ Input,
563
+ {
564
+ id: "insurancePolicyExpirationDate",
565
+ ...register("insurancePolicyExpirationDate"),
566
+ label: "Insurance Policy Expiration Date",
567
+ sizes: "medium",
568
+ type: "date",
569
+ required: true,
570
+ error: !!errors.insurancePolicyExpirationDate,
571
+ helperText: errors.insurancePolicyExpirationDate?.message,
572
+ variant
573
+ }
574
+ ) }),
575
+ /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(
576
+ Input,
577
+ {
578
+ id: "insuranceContactEmailAddress",
579
+ ...register("insuranceContactEmailAddress"),
580
+ label: "Insurance Contact Email Address",
581
+ sizes: "medium",
582
+ required: true,
583
+ error: !!errors.insuranceContactEmailAddress,
584
+ helperText: errors.insuranceContactEmailAddress?.message,
585
+ variant
586
+ }
587
+ ) })
588
+ ] }),
508
589
  /* @__PURE__ */ jsx(HoneyPot, { register, variant })
509
590
  ] }),
510
591
  children,
@@ -64,8 +64,8 @@ const RepresentativesFico = [
64
64
  ];
65
65
  const DocType = [
66
66
  { value: "FullDoc", text: "Full Doc" },
67
- { value: "AssetDepletion", text: "Asset Depletion" },
68
- { value: "AssetUtilization", text: "Asset Utilization" },
67
+ // { value: "AssetDepletion", text: "Asset Depletion" },
68
+ // { value: "AssetUtilization", text: "Asset Utilization" },
69
69
  { value: "PersonalBankStmt12Mos", text: "Personal Bank Stmt: 12 Mos" },
70
70
  { value: "BusinessBankStmt12Mos", text: "Business Bank Stmt: 12 Mos" },
71
71
  { value: "PersonalBankStmt24Mos", text: "Personal Bank Stmt: 24 Mos" },
@@ -46,3 +46,14 @@ export declare const autoAdvanceBar: string;
46
46
  export declare const mainTitle: string;
47
47
  export declare const mainDescription: string;
48
48
  export declare const overlayOpacity: string;
49
+ export declare const fieldSet: string;
50
+ export declare const selectWrap: string;
51
+ export declare const selectButton: string;
52
+ export declare const selectButtonPlaceholder: string;
53
+ export declare const selectChevron: string;
54
+ export declare const selectOptions: string;
55
+ export declare const selectOption: string;
56
+ export declare const selectLabel: string;
57
+ export declare const conditionalFieldWrap: string;
58
+ export declare const subStepLabel: string;
59
+ export declare const conditionalField: string;
@@ -48,6 +48,17 @@ var autoAdvanceBar = "_13s19j319";
48
48
  var mainTitle = "_13s19j31a";
49
49
  var mainDescription = "_13s19j31b";
50
50
  var overlayOpacity = "_13s19j31c";
51
+ var fieldSet = "_13s19j31d";
52
+ var selectWrap = "_13s19j31e";
53
+ var selectButton = "_13s19j31f";
54
+ var selectButtonPlaceholder = "_13s19j31g";
55
+ var selectChevron = "_13s19j31h";
56
+ var selectOptions = "_13s19j31i";
57
+ var selectOption = "_13s19j31j";
58
+ var selectLabel = "_13s19j31k";
59
+ var conditionalFieldWrap = "_13s19j31l";
60
+ var subStepLabel = "_13s19j31m";
61
+ var conditionalField = "_13s19j31n";
51
62
  export {
52
63
  actions,
53
64
  amountPreview,
@@ -59,6 +70,8 @@ export {
59
70
  autoAdvanceText,
60
71
  autoAdvanceTrack,
61
72
  buttonBase,
73
+ conditionalField,
74
+ conditionalFieldWrap,
62
75
  description,
63
76
  disclosure,
64
77
  disclosureText,
@@ -67,6 +80,7 @@ export {
67
80
  errorText,
68
81
  fieldBlock,
69
82
  fieldLabel,
83
+ fieldSet,
70
84
  formShell,
71
85
  helperText,
72
86
  input,
@@ -88,11 +102,19 @@ export {
88
102
  radioText,
89
103
  secondaryButton,
90
104
  section,
105
+ selectButton,
106
+ selectButtonPlaceholder,
107
+ selectChevron,
108
+ selectLabel,
109
+ selectOption,
110
+ selectOptions,
111
+ selectWrap,
91
112
  slider,
92
113
  sliderHeader,
93
114
  sliderValue,
94
115
  sliderWrap,
95
116
  stepPanel,
117
+ subStepLabel,
96
118
  successText,
97
119
  successTitle,
98
120
  successWrap,