@mychoice/mychoice-sdk-modules 2.1.32 → 2.1.34

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.
@@ -13,6 +13,7 @@ export type PostalCodeDataProps = {
13
13
  className?: string;
14
14
  title?: string;
15
15
  postalCode?: string;
16
+ id?: string;
16
17
  };
17
18
  export type ButtonBoxProps = {
18
19
  isMobile?: boolean;
package/dist/esm/index.js CHANGED
@@ -157,9 +157,8 @@ const OfferSection = ({ offerCompany, brokerCompany, offerPrice, phoneNumber, is
157
157
  }
158
158
  postRequestQuoteOnliaUrl(true, redirectUrl);
159
159
  };
160
- console.log(offerCompany, "offer c");
161
160
  return (jsxs("div", { className: `offer-section ${mychoiceCls}`, children: [jsx(OfferHeader, { className: isTheBig ? 'thebig-bold' : '', companyName: offerCompany?.name, isBestOffer: isBestOffer }), jsx(OfferPrice, { className: isTheBig ? 'thebig' : '', companyLogo: offerCompany?.logo, price: offerPrice }), !isTheBig && offsiteUrl
162
- ? (jsxs("div", { className: "offer-phone", children: [jsx("h3", { children: "Click below to get this rate" }), jsx(ButtonBase, { className: `offer-phone-number ${mychoiceCls}`, label: "Buy Online", type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium, onClick: handleCTAClick })] })) : (jsxs("div", { className: "offer-phone", children: [jsx("h3", { className: isTheBig ? 'thebig-bold' : '', children: "Call now to get this rate" }), jsx("a", { target: "_blank", rel: "noreferrer noopener", href: `tel:${phoneNumber?.number}`, children: jsx(ButtonBase, { className: `${isTheBig ? 'thebig-bold' : 'mychoice'} offer-phone-number`, label: phoneNumber?.title, type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium }) })] })), jsxs("button", { className: "dropdown", onClick: handleDropdownClick, children: [jsx("span", { children: detailsIsOpen ? 'Less Info' : 'More Info' }), jsx(IconDropdownArrow, { color: "grey", className: detailsIsOpen ? 'rotated' : '' })] }), detailsIsOpen && (jsxs("div", { className: "offer-details", children: [jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', name: offerCompany?.name, logo: offerCompany?.logo, companyType: CompanyRoleTypes.Offering, description: offerCompany?.description }), jsx("hr", {}), (isTheBig || !offsiteUrl)
161
+ ? (jsxs("div", { className: "offer-phone", children: [jsx("h3", { children: "Click below to get this rate" }), jsx(ButtonBase, { className: `offer-phone-number ${mychoiceCls}`, label: "Buy Online", type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium, onClick: handleCTAClick })] })) : (jsxs("div", { className: "offer-phone", children: [jsx("h3", { className: isTheBig ? 'thebig-bold' : '', children: "Call now to get this rate" }), jsx("a", { target: "_blank", rel: "noreferrer noopener", href: `tel:${phoneNumber?.number}`, children: jsx(ButtonBase, { className: `${isTheBig ? 'thebig-bold' : 'mychoice'} offer-phone-number`, label: phoneNumber?.title, type: ButtonTypes.Button, category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Medium }) })] })), jsxs("button", { className: "dropdown", onClick: handleDropdownClick, children: [jsx("span", { children: detailsIsOpen ? 'Less Info' : 'More Info' }), jsx(IconDropdownArrow, { color: "grey", className: detailsIsOpen ? 'rotated' : '' })] }), detailsIsOpen && (jsxs("div", { className: "offer-details", children: [jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', name: offerCompany?.name, companyType: CompanyRoleTypes.Offering, description: offerCompany?.description }), jsx("hr", {}), (isTheBig || !offsiteUrl)
163
162
  && (jsxs(Fragment, { children: [jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', logo: brokerCompany?.logo, name: brokerCompany?.title, companyType: CompanyRoleTypes.Broker, description: brokerCompany?.description }), jsx("hr", {})] })), jsx(OfferDetail, { className: isTheBig ? 'thebig-bold' : '', name: "Hours of Operation", children: jsx(OperationHoursInfo, { weekdayHours: weekdayHours, saturdayHours: saturdayHours, sundayHours: sundayHours }) })] }))] }));
164
163
  };
165
164
  OfferSection.defaultProps = {
@@ -3237,7 +3236,9 @@ const ModalQuoteRequest = ({ title, description, phoneNumber, }) => (jsxs("div",
3237
3236
  && jsx("p", { children: description }), jsxs("div", { className: "modal-buttons", children: [jsx(ButtonBase, { type: ButtonTypes.Button, label: "OK", category: CategoryTypes.Filled, color: ColorTypes.Primary, variant: ButtonVariantTypes.Rectangle, size: SizeTypes.Large }), phoneNumber
3238
3237
  && (jsx("a", { target: "_blank", rel: "noreferrer noopener", href: `tel:1${phoneNumber}`, className: "phoneNumber", children: "Call the Broker" }))] })] }));
3239
3238
 
3240
- const PostalCodeDataBox = ({ title, postalCode, className }) => (jsxs("div", { className: `${className} postal-code-data-box`, children: [jsx("h2", { children: title }), postalCode && (jsxs("p", { children: ["Your postal code:", ' ', postalCode] }))] }));
3239
+ const PostalCodeDataBox = ({ title, postalCode, className, id }) => {
3240
+ return (jsx(Fragment, { children: jsxs("div", { id: id, className: `${className} postal-code-data-box`, children: [jsx("h2", { children: title }), postalCode && (jsxs("p", { children: ["Your postal code:", ' ', postalCode] }))] }) }));
3241
+ };
3241
3242
  PostalCodeDataBox.defaultProps = {
3242
3243
  title: '',
3243
3244
  postalCode: '',
@@ -3251,6 +3252,21 @@ const StepsBox = ({ formSteps, validationHooks, propertyIsCompleted, }) => {
3251
3252
  // const { dispatchAppModalState } = useStoreAppModal();
3252
3253
  // const [steps, setSteps] = useState(formSteps);
3253
3254
  // const [validations, setValidations] = useState(validationHooks);
3255
+ const [showContent, setShowContent] = useState(false);
3256
+ useEffect(() => {
3257
+ const checkTime = () => {
3258
+ const currentUTCDate = new Date();
3259
+ const currentHour = currentUTCDate.getUTCHours() - 5; // EST is UTC-5
3260
+ const currentDay = currentUTCDate.getUTCDay(); // Sunday is 0, Monday is 1, ..., Saturday is 6
3261
+ // Check if it's a weekday (Monday to Friday) and if the current hour is between 9 am and 6 pm
3262
+ const isWeekday = currentDay >= 1 && currentDay <= 5;
3263
+ const isWorkingHours = currentHour >= 9 && currentHour < 18;
3264
+ setShowContent(isWeekday && isWorkingHours);
3265
+ };
3266
+ checkTime(); // Initial check
3267
+ const interval = setInterval(checkTime, 60000); // Check every minute
3268
+ return () => clearInterval(interval); // Cleanup
3269
+ }, []); // Run effect only once on component mount
3254
3270
  const { pathname } = useLocation();
3255
3271
  const currentPath = pathname.split('/');
3256
3272
  const activeStep = formSteps.find((step) => currentPath[currentPath.length - 1] === step.path?.substring(1));
@@ -3314,6 +3330,22 @@ const StepsBox = ({ formSteps, validationHooks, propertyIsCompleted, }) => {
3314
3330
  }
3315
3331
  }
3316
3332
  };
3333
+ const [showQR, setShowQr] = useState(false);
3334
+ const containerRef = useRef(null);
3335
+ useEffect(() => {
3336
+ const handleClickOutside = (event) => {
3337
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
3338
+ setShowQr(false);
3339
+ }
3340
+ };
3341
+ document.addEventListener('mousedown', handleClickOutside);
3342
+ return () => {
3343
+ document.removeEventListener('mousedown', handleClickOutside);
3344
+ };
3345
+ }, []);
3346
+ const handleHelpButton = () => {
3347
+ setShowQr(!showQR);
3348
+ };
3317
3349
  return (jsxs("ol", { className: appType === AppTypes.MyChoice ? 'mychoice-navigation-steps-container' : 'navigation-steps-container', children: [!isMobile ? (jsx(Fragment, { children: formSteps?.map((item, index) => {
3318
3350
  let cls;
3319
3351
  switch (true) {
@@ -3330,9 +3362,11 @@ const StepsBox = ({ formSteps, validationHooks, propertyIsCompleted, }) => {
3330
3362
  return jsx(Fragment, {});
3331
3363
  }
3332
3364
  return (jsx("div", { role: "presentation", className: appType === AppTypes.MyChoice ? navigationCls : 'navigation-step-container', onKeyDown: handleStepClick(item, index), onClick: handleStepClick(item, index), children: appType === AppTypes.MyChoice
3333
- ? jsx(MychoiceStep, { className: cls, item: item, index: index }, `${index}-${item?.title}`)
3365
+ ? jsxs(Fragment, { children: [jsx(MychoiceStep, { className: cls, item: item, index: index }, `${index}-${item?.title}`), jsx(ButtonBase, {})] })
3334
3366
  : jsx(Step, { className: cls, item: item, index: index }, `${index}-${item?.title}`) }, `${index}-${item?.title}`));
3335
- }) })) : jsx(Step, { item: formSteps[activeIndex], index: activeIndex, itemsCount: formSteps.length, isMobile: true }), appType === AppTypes.MyChoice && (jsxs(Fragment, { children: [jsx("hr", {}), jsxs("div", { className: "estimated-minutes", children: [jsx(IconClock, {}), jsxs("div", { children: ["Estimated", ' ', jsxs("span", { className: "time", children: [formSteps.length - activeIndex - 1, ' ', formSteps.length - activeIndex - 1 > 1 ? 'minutes' : 'minute'] }), ' ', "to complete"] })] })] }))] }));
3367
+ }) })) : jsx(Step, { item: formSteps[activeIndex], index: activeIndex, itemsCount: formSteps.length, isMobile: true }), appType === AppTypes.MyChoice && (jsxs(Fragment, { children: [jsx("hr", {}), jsxs("div", { className: "estimated-minutes", children: [jsx(IconClock, {}), jsxs("div", { children: ["Estimated", ' ', jsxs("span", { className: "time", children: [formSteps.length - activeIndex - 1, ' ', formSteps.length - activeIndex - 1 > 1 ? 'minutes' : 'minute'] }), ' ', "to complete"] })] }), showContent && appType === AppTypes.MyChoice && (jsxs("div", { style: { gap: "1em", display: "flex", flexDirection: "column", marginTop: "1em", alignItems: "center", justifyContent: "center", marginLeft: "2em" }, children: [jsx("p", { style: { fontWeight: "600" }, children: "Need help? Call us at" }), jsxs("div", { ref: containerRef, style: { position: "relative", width: '180px' }, children: [jsx(ButtonBase, { size: SizeTypes.Medium, className: "button-with-text button-circle-medium", category: CategoryTypes.Filled, color: ColorTypes.Secondary, variant: ButtonVariantTypes.Circle, onClick: handleHelpButton, children: jsx("span", { style: { padding: "0 1rem", fontWeight: "700" }, children: "1-888-453-4644" }) }), showQR && (jsx("img", { style: { position: 'absolute', top: '355%', left: '50%', transform: 'translate(-50%, -50%)', opacity: 0, transition: 'opacity 500ms ease-in-out' }, onLoad: (e) => {
3368
+ e.currentTarget.style.opacity = '1';
3369
+ }, src: "https://www.mychoice.ca/wp-content/themes/mychoice-theme/img/svg/qr-phone-with-text.svg", alt: "QR code scan to call" }))] })] }))] }))] }));
3336
3370
  };
3337
3371
  StepsBox.defaultProps = {
3338
3372
  partnerId: '',
@@ -3417,7 +3451,7 @@ ButtonsBox.defaultProps = {
3417
3451
  activeIndex: 0,
3418
3452
  };
3419
3453
 
3420
- const NavigationTop = ({ title, postalCode, validationHooks, formSteps, clearForm, propertyIsCompleted, }) => {
3454
+ const NavigationTop = ({ title, postalCode, validationHooks, formSteps, clearForm, propertyIsCompleted, id, }) => {
3421
3455
  const { pathname } = useLocation();
3422
3456
  const { appConfigState: { appType, localIndex } } = useStoreAppConfig();
3423
3457
  const isTheBig = appType === AppTypes.TheBig;
@@ -3445,8 +3479,8 @@ const NavigationTop = ({ title, postalCode, validationHooks, formSteps, clearFor
3445
3479
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
3446
3480
  }
3447
3481
  }
3448
- return (jsx("div", { className: localIndex !== defaultLocalIndex ? 'navigation-container-partner' : 'navigation-container', children: jsxs("div", { className: `content ${appType === AppTypes.MyChoice ? 'mychoice' : ''}`, children: [jsx(PostalCodeDataBox, { className: isTheBig ? 'thebig' : '', title: title, postalCode: postalCode }), appType === AppTypes.MyChoice
3449
- ? (jsx(Fragment, { children: !isDesktop && (formSteps.length - activeIndex - 1) ? (jsxs("div", { className: "estimated-minutes", children: [jsx(IconClock, {}), jsxs("div", { children: [isMobile ? (jsx("div", { children: jsxs("span", { className: "time", children: [formSteps.length - activeIndex - 1, ' ', formSteps.length - activeIndex - 1 > 1 ? 'minutes' : 'minute'] }) })) : (jsx(Fragment, { children: jsxs("div", { children: ["Estimated", ' ', jsxs("span", { className: "time", children: [formSteps.length - activeIndex - 1, ' ', formSteps.length - activeIndex - 1 > 1 ? 'minutes' : 'minute'] }), ' ', "to complete"] }) })), jsx("span", { children: `Step ${activeIndex + 1}/${formSteps.length - 1}` })] })] })) : jsx("span", {}) })) : (jsx(StepsBox, { formSteps: formSteps, validationHooks: validationHooks, propertyIsCompleted: propertyIsCompleted })), jsx(ButtonsBox, { formSteps: formSteps, validationHooks: validationHooks, clearForm: clearForm, propertyIsCompleted: propertyIsCompleted })] }) }));
3482
+ return (jsx("div", { id: id, className: localIndex !== defaultLocalIndex ? 'navigation-container-partner' : 'navigation-container', children: jsxs("div", { className: `content ${appType === AppTypes.MyChoice ? 'mychoice' : ''}`, children: [jsx(PostalCodeDataBox, { className: isTheBig ? 'thebig' : '', title: title, postalCode: postalCode }), appType === AppTypes.MyChoice
3483
+ ? (jsx(Fragment, { children: !isDesktop && (formSteps.length - activeIndex - 1) ? (jsxs("div", { className: "estimated-minutes", children: [jsx(IconClock, {}), jsxs("div", { children: [isMobile ? (jsx(Fragment, { children: jsx("div", { children: jsxs("span", { className: "time", children: [formSteps.length - activeIndex - 1, ' ', formSteps.length - activeIndex - 1 > 1 ? 'minutes' : 'minute'] }) }) })) : (jsx(Fragment, { children: jsxs("div", { children: ["Estimated", ' ', jsxs("span", { className: "time", children: [formSteps.length - activeIndex - 1, ' ', formSteps.length - activeIndex - 1 > 1 ? 'minutes' : 'minute'] }), ' ', "to complete"] }) })), jsx("span", { children: `Step ${activeIndex + 1}/${formSteps.length - 1}` })] })] })) : jsx("span", {}) })) : (jsx(StepsBox, { formSteps: formSteps, validationHooks: validationHooks, propertyIsCompleted: propertyIsCompleted })), jsx(ButtonsBox, { formSteps: formSteps, validationHooks: validationHooks, clearForm: clearForm, propertyIsCompleted: propertyIsCompleted })] }) }));
3450
3484
  };
3451
3485
  NavigationTop.defaultProps = {
3452
3486
  isMobile: false,
@@ -3949,6 +3983,21 @@ const AppRouteWrapper = (props) => {
3949
3983
  const [steps, setSteps] = useState(formSteps[insuranceType]);
3950
3984
  const [validationHooks, setValidationHooks] = useState(formValidationHooks[insuranceType]);
3951
3985
  const [progressLength, setProgressLength] = useState('');
3986
+ const [showContent, setShowContent] = useState(false);
3987
+ useEffect(() => {
3988
+ const checkTime = () => {
3989
+ const currentUTCDate = new Date();
3990
+ const currentHour = currentUTCDate.getUTCHours() - 5; // EST is UTC-5
3991
+ const currentDay = currentUTCDate.getUTCDay(); // Sunday is 0, Monday is 1, ..., Saturday is 6
3992
+ // Check if it's a weekday (Monday to Friday) and if the current hour is between 9 am and 6 pm
3993
+ const isWeekday = currentDay >= 1 && currentDay <= 5;
3994
+ const isWorkingHours = currentHour >= 9 && currentHour < 18;
3995
+ setShowContent(isWeekday && isWorkingHours);
3996
+ };
3997
+ checkTime(); // Initial check
3998
+ const interval = setInterval(checkTime, 60000); // Check every minute
3999
+ return () => clearInterval(interval); // Cleanup
4000
+ }, []); // Run effect only once on component mount
3952
4001
  useEffect(() => {
3953
4002
  let filteredSteps = formSteps[insuranceType];
3954
4003
  let filteredHooks = formValidationHooks[insuranceType];
@@ -4019,7 +4068,23 @@ const AppRouteWrapper = (props) => {
4019
4068
  }
4020
4069
  }
4021
4070
  }, [carPostal, homePostal, lifePostal, isReady]);
4022
- return (jsx(Fragment, { children: isReady && (jsxs(Fragment, { children: [jsx(AppHeader, {}), jsx(AppModal, {}), insuranceType && (jsx(NavigationTop, { title: `${insuranceType.replace(/^./, insuranceType[0].toUpperCase())} Insurance Quote`, postalCode: postalCode, formSteps: steps, validationHooks: validationHooks, clearForm: clearFormData, propertyIsCompleted: isCompleted })), insuranceType && appType === AppTypes.MyChoice && (jsx("div", { className: localIndex !== defaultLocalIndex ? 'step-progress-bar-partner' : 'step-progress-bar', children: jsx("span", { style: { width: progressLength } }) })), jsx("div", { className: `${insuranceType ? 'form-page-content' : ''} ${insuranceType && appType === AppTypes.MyChoice ? 'mychoice' : ''}`, children: insuranceType && appType === AppTypes.MyChoice && isDesktop && progressLength ? (jsx(Fragment, { children: jsxs("div", { className: "mychoice-content", children: [jsx(StepsBox, { className: "step-box", formSteps: steps, validationHooks: validationHooks, propertyIsCompleted: isCompleted }), children, jsx("div", { className: "empty-steps-container" })] }) })) : children }), isMychoice && !appLoaderState.isOpen && jsx(ProviderImageFooter, {})] })) }));
4071
+ const isMobile = appDeviceType === DeviceTypes.Mobile;
4072
+ const [showStickyBanner, setShowStickyBanner] = useState(false);
4073
+ useEffect(() => {
4074
+ const handleScroll = () => {
4075
+ const postalCodeDataBox = document.getElementById('postalCodeData');
4076
+ if (postalCodeDataBox) {
4077
+ const postalCodeDataBoxRect = postalCodeDataBox.getBoundingClientRect();
4078
+ const isScrolledPast = postalCodeDataBoxRect.bottom <= 0; // Change to <= if you want the banner to appear when the bottom of the box touches the top of the viewport
4079
+ setShowStickyBanner(isScrolledPast);
4080
+ }
4081
+ };
4082
+ window.addEventListener('scroll', handleScroll);
4083
+ return () => {
4084
+ window.removeEventListener('scroll', handleScroll);
4085
+ };
4086
+ }, []);
4087
+ return (jsx(Fragment, { children: isReady && (jsxs(Fragment, { children: [jsx(AppHeader, {}), jsx(AppModal, {}), insuranceType && (jsx(Fragment, { children: jsx(NavigationTop, { title: `${insuranceType.replace(/^./, insuranceType[0].toUpperCase())} Insurance Quote`, postalCode: postalCode, formSteps: steps, validationHooks: validationHooks, clearForm: clearFormData, propertyIsCompleted: isCompleted, id: "postalCodeData" }) })), showStickyBanner && showContent && isMobile && appType === AppTypes.MyChoice && (jsxs("div", { id: "stickyBanner", style: { position: "sticky", top: 0, color: "#FFFFFF", backgroundColor: "#8ED6DC", width: "100%", height: "75px", zIndex: 5000, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center" }, children: [jsx("a", { style: { fontWeight: 700, fontSize: "22px" }, href: "tel:18884534644", children: "Need Help? Give us a call at" }), jsx("a", { style: { marginTop: "5px", textDecoration: "underline", fontWeight: 850 }, href: "tel:18884534644", children: "1-888-453-4644" })] })), insuranceType && appType === AppTypes.MyChoice && (jsx("div", { className: localIndex !== defaultLocalIndex ? 'step-progress-bar-partner' : 'step-progress-bar', children: jsx("span", { style: { width: progressLength } }) })), jsx("div", { className: `${insuranceType ? 'form-page-content' : ''} ${insuranceType && appType === AppTypes.MyChoice ? 'mychoice' : ''}`, children: insuranceType && appType === AppTypes.MyChoice && isDesktop && progressLength ? (jsx(Fragment, { children: jsxs("div", { className: "mychoice-content", children: [jsx(StepsBox, { className: "step-box", formSteps: steps, validationHooks: validationHooks, propertyIsCompleted: isCompleted }), children, jsx("div", { className: "empty-steps-container" })] }) })) : children }), isMychoice && !appLoaderState.isOpen && jsx(ProviderImageFooter, {})] })) }));
4023
4088
  };
4024
4089
  const NestedRoutes = () => {
4025
4090
  const insuranceType = getInsuranceType();