@mychoice/mychoice-sdk-modules 2.1.31 → 2.1.33

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
@@ -3123,29 +3123,21 @@ const PageLifeQuote = () => {
3123
3123
  behavior: 'smooth',
3124
3124
  });
3125
3125
  });
3126
- const uniqueItems = items.reduce((acc, currentItem) => {
3127
- // Check if the company is already added and if so, whether the current item has a lower priceMonthly.
3128
- if (!acc[currentItem.company] || currentItem.priceMonthly < acc[currentItem.company].priceMonthly) {
3129
- acc[currentItem.company] = currentItem; // Add or update the item for the company
3130
- }
3131
- return acc;
3132
- }, {});
3133
- const result = Object.values(uniqueItems);
3134
- console.log(result, "ach");
3126
+ console.log(items, "items");
3135
3127
  return (jsx("div", { className: "quote-page-content", children: !appLoaderState.isOpen
3136
- && (jsxs(Fragment, { children: [jsxs("div", { className: "form-section-container", children: [appDeviceType === DeviceTypes.Mobile && (jsx(Fragment, { children: !!result?.length && (jsx(Fragment, { children: !quoteState.showCallMessage
3137
- ? (jsx("div", { className: "offer-container", children: jsx(OfferSection, { isBestOffer: true, offerCompany: result[0]?.company, brokerCompany: result[0]?.brokerProfile, offerPrice: {
3138
- monthly: result[0]?.priceMonthly,
3139
- yearly: result[0]?.priceYearly,
3128
+ && (jsxs(Fragment, { children: [jsxs("div", { className: "form-section-container", children: [appDeviceType === DeviceTypes.Mobile && (jsx(Fragment, { children: !!items?.length && (jsx(Fragment, { children: !quoteState.showCallMessage
3129
+ ? (jsx("div", { className: "offer-container", children: jsx(OfferSection, { isBestOffer: true, offerCompany: items[0]?.company, brokerCompany: items[0]?.brokerProfile, offerPrice: {
3130
+ monthly: items[0]?.priceMonthly,
3131
+ yearly: items[0]?.priceYearly,
3140
3132
  }, operationHours: {
3141
- saturdayHours: result[0]?.brokerProfile.hoursSaturday,
3142
- sundayHours: result[0]?.brokerProfile.hoursSunday,
3143
- weekdayHours: result[0]?.brokerProfile.hoursWorkdays,
3133
+ saturdayHours: items[0]?.brokerProfile.hoursSaturday,
3134
+ sundayHours: items[0]?.brokerProfile.hoursSunday,
3135
+ weekdayHours: items[0]?.brokerProfile.hoursWorkdays,
3144
3136
  }, phoneNumber: formatPhoneObject(items[0]?.brokerProfile.phone), redirectUrl: items[0]?.brokerProfile.redirectUrl || '' }) }))
3145
3137
  : jsx(SplashScreen, {}) })) })), jsx(SectionQuoteEdit, {})] }), appDeviceType !== DeviceTypes.Mobile && quoteState.showCallMessage
3146
3138
  && jsx(SplashScreen, {}), !quoteState.showCallMessage
3147
- && (jsx("div", { className: "offer-container", children: !!result?.length
3148
- && result.map(({ company, brokerProfile, priceMonthly, priceYearly, }, index) => (jsx("div", { children: (appDeviceType !== DeviceTypes.Mobile || (appDeviceType === DeviceTypes.Mobile && index !== 0)) && (jsx(OfferSection, { isBestOffer: index === 0, offerCompany: company, brokerCompany: brokerProfile, offerPrice: {
3139
+ && (jsx("div", { className: "offer-container", children: !!items?.length
3140
+ && items.map(({ company, brokerProfile, priceMonthly, priceYearly, }, index) => (jsx("div", { children: (appDeviceType !== DeviceTypes.Mobile || (appDeviceType === DeviceTypes.Mobile && index !== 0)) && (jsx(OfferSection, { isBestOffer: index === 0, offerCompany: company, brokerCompany: brokerProfile, offerPrice: {
3149
3141
  monthly: priceMonthly,
3150
3142
  yearly: priceYearly,
3151
3143
  }, operationHours: {
@@ -3244,7 +3236,9 @@ const ModalQuoteRequest = ({ title, description, phoneNumber, }) => (jsxs("div",
3244
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
3245
3237
  && (jsx("a", { target: "_blank", rel: "noreferrer noopener", href: `tel:1${phoneNumber}`, className: "phoneNumber", children: "Call the Broker" }))] })] }));
3246
3238
 
3247
- 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
+ };
3248
3242
  PostalCodeDataBox.defaultProps = {
3249
3243
  title: '',
3250
3244
  postalCode: '',
@@ -3258,6 +3252,16 @@ const StepsBox = ({ formSteps, validationHooks, propertyIsCompleted, }) => {
3258
3252
  // const { dispatchAppModalState } = useStoreAppModal();
3259
3253
  // const [steps, setSteps] = useState(formSteps);
3260
3254
  // const [validations, setValidations] = useState(validationHooks);
3255
+ const [showContent, setShowContent] = useState(false);
3256
+ useEffect(() => {
3257
+ const checkTime = () => {
3258
+ const currentHour = new Date().getUTCHours() - 5; // EST is UTC-5
3259
+ setShowContent(currentHour >= 9 && currentHour < 18);
3260
+ };
3261
+ checkTime(); // Initial check
3262
+ const interval = setInterval(checkTime, 60000); // Check every minute
3263
+ return () => clearInterval(interval); // Cleanup
3264
+ }, []); // Run effect only once on component mount
3261
3265
  const { pathname } = useLocation();
3262
3266
  const currentPath = pathname.split('/');
3263
3267
  const activeStep = formSteps.find((step) => currentPath[currentPath.length - 1] === step.path?.substring(1));
@@ -3321,6 +3325,22 @@ const StepsBox = ({ formSteps, validationHooks, propertyIsCompleted, }) => {
3321
3325
  }
3322
3326
  }
3323
3327
  };
3328
+ const [showQR, setShowQr] = useState(false);
3329
+ const containerRef = useRef(null);
3330
+ useEffect(() => {
3331
+ const handleClickOutside = (event) => {
3332
+ if (containerRef.current && !containerRef.current.contains(event.target)) {
3333
+ setShowQr(false);
3334
+ }
3335
+ };
3336
+ document.addEventListener('mousedown', handleClickOutside);
3337
+ return () => {
3338
+ document.removeEventListener('mousedown', handleClickOutside);
3339
+ };
3340
+ }, []);
3341
+ const handleHelpButton = () => {
3342
+ setShowQr(!showQR);
3343
+ };
3324
3344
  return (jsxs("ol", { className: appType === AppTypes.MyChoice ? 'mychoice-navigation-steps-container' : 'navigation-steps-container', children: [!isMobile ? (jsx(Fragment, { children: formSteps?.map((item, index) => {
3325
3345
  let cls;
3326
3346
  switch (true) {
@@ -3337,9 +3357,11 @@ const StepsBox = ({ formSteps, validationHooks, propertyIsCompleted, }) => {
3337
3357
  return jsx(Fragment, {});
3338
3358
  }
3339
3359
  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
3340
- ? jsx(MychoiceStep, { className: cls, item: item, index: index }, `${index}-${item?.title}`)
3360
+ ? jsxs(Fragment, { children: [jsx(MychoiceStep, { className: cls, item: item, index: index }, `${index}-${item?.title}`), jsx(ButtonBase, {})] })
3341
3361
  : jsx(Step, { className: cls, item: item, index: index }, `${index}-${item?.title}`) }, `${index}-${item?.title}`));
3342
- }) })) : 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"] })] })] }))] }));
3362
+ }) })) : 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) => {
3363
+ e.currentTarget.style.opacity = '1';
3364
+ }, src: "https://www.mychoice.ca/wp-content/themes/mychoice-theme/img/svg/qr-phone-with-text.svg", alt: "QR code scan to call" }))] })] }))] }))] }));
3343
3365
  };
3344
3366
  StepsBox.defaultProps = {
3345
3367
  partnerId: '',
@@ -3424,7 +3446,7 @@ ButtonsBox.defaultProps = {
3424
3446
  activeIndex: 0,
3425
3447
  };
3426
3448
 
3427
- const NavigationTop = ({ title, postalCode, validationHooks, formSteps, clearForm, propertyIsCompleted, }) => {
3449
+ const NavigationTop = ({ title, postalCode, validationHooks, formSteps, clearForm, propertyIsCompleted, id, }) => {
3428
3450
  const { pathname } = useLocation();
3429
3451
  const { appConfigState: { appType, localIndex } } = useStoreAppConfig();
3430
3452
  const isTheBig = appType === AppTypes.TheBig;
@@ -3452,8 +3474,8 @@ const NavigationTop = ({ title, postalCode, validationHooks, formSteps, clearFor
3452
3474
  return `rgba(${r}, ${g}, ${b}, ${alpha})`;
3453
3475
  }
3454
3476
  }
3455
- 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
3456
- ? (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 })] }) }));
3477
+ 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
3478
+ ? (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 })] }) }));
3457
3479
  };
3458
3480
  NavigationTop.defaultProps = {
3459
3481
  isMobile: false,
@@ -3956,6 +3978,16 @@ const AppRouteWrapper = (props) => {
3956
3978
  const [steps, setSteps] = useState(formSteps[insuranceType]);
3957
3979
  const [validationHooks, setValidationHooks] = useState(formValidationHooks[insuranceType]);
3958
3980
  const [progressLength, setProgressLength] = useState('');
3981
+ const [showContent, setShowContent] = useState(false);
3982
+ useEffect(() => {
3983
+ const checkTime = () => {
3984
+ const currentHour = new Date().getUTCHours() - 5; // EST is UTC-5
3985
+ setShowContent(currentHour >= 9 && currentHour < 18);
3986
+ };
3987
+ checkTime(); // Initial check
3988
+ const interval = setInterval(checkTime, 60000); // Check every minute
3989
+ return () => clearInterval(interval); // Cleanup
3990
+ }, []); // Run effect only once on component mount
3959
3991
  useEffect(() => {
3960
3992
  let filteredSteps = formSteps[insuranceType];
3961
3993
  let filteredHooks = formValidationHooks[insuranceType];
@@ -4026,7 +4058,23 @@ const AppRouteWrapper = (props) => {
4026
4058
  }
4027
4059
  }
4028
4060
  }, [carPostal, homePostal, lifePostal, isReady]);
4029
- 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, {})] })) }));
4061
+ const isMobile = appDeviceType === DeviceTypes.Mobile;
4062
+ const [showStickyBanner, setShowStickyBanner] = useState(false);
4063
+ useEffect(() => {
4064
+ const handleScroll = () => {
4065
+ const postalCodeDataBox = document.getElementById('postalCodeData');
4066
+ if (postalCodeDataBox) {
4067
+ const postalCodeDataBoxRect = postalCodeDataBox.getBoundingClientRect();
4068
+ 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
4069
+ setShowStickyBanner(isScrolledPast);
4070
+ }
4071
+ };
4072
+ window.addEventListener('scroll', handleScroll);
4073
+ return () => {
4074
+ window.removeEventListener('scroll', handleScroll);
4075
+ };
4076
+ }, []);
4077
+ 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("p", { style: { fontWeight: 700, fontSize: "22px" }, children: "Need Help? Give us a call at" }), jsx("a", { style: { marginTop: "5px" }, 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, {})] })) }));
4030
4078
  };
4031
4079
  const NestedRoutes = () => {
4032
4080
  const insuranceType = getInsuranceType();