igloo-d2c-components 1.0.34 → 1.0.35

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.
package/dist/esm/index.js CHANGED
@@ -5,6 +5,7 @@ import { createContext, useMemo, useContext, useState, useEffect } from 'react';
5
5
  import { Button as Button$1, Card as Card$1, CardHeader, CardContent, CardActions, Box, Typography, Menu, MenuItem, Avatar, Drawer, IconButton, FormControlLabel, useTheme, useMediaQuery, Toolbar, Icon, RadioGroup, Radio, AppBar as AppBar$1, Divider, List, ListItem, ListItemButton, ListItemText, styled as styled$1, Dialog, ButtonBase, Slider, Checkbox, Accordion, AccordionSummary, AccordionDetails } from '@mui/material';
6
6
  import ArrowDropDownIcon from '@mui/icons-material/ArrowDropDown';
7
7
  import CloseIcon from '@mui/icons-material/Close';
8
+ import LanguageIcon from '@mui/icons-material/Language';
8
9
  import AppBar from '@mui/material/AppBar';
9
10
  import { styled } from '@mui/material/styles';
10
11
  import MenuIcon from '@mui/icons-material/Menu';
@@ -1150,11 +1151,31 @@ function DesktopHeaderMenuBar({ logo, logoAlt = 'Logo', menuItems,
1150
1151
  // Legacy props (deprecated)
1151
1152
  showLoginButton, loginButtonText, onLoginClick,
1152
1153
  // New CTA props
1153
- showCtaButton = true, ctaButtonText = 'Purchase Now', onCtaClick, ctaScrollTargetId, onScrollToSection, onLogoClick, formatMessage = (descriptor) => descriptor.id, className, }) {
1154
+ showCtaButton = true, ctaButtonText = 'Purchase Now', onCtaClick, ctaScrollTargetId, onScrollToSection, onLogoClick, formatMessage = (descriptor) => descriptor.id, className,
1155
+ // Language switcher props
1156
+ languages = [], currentLocale, onLanguageChange, }) {
1154
1157
  var _a;
1155
1158
  // Track which dropdown is currently open (for backward compatibility)
1156
1159
  const [openMenuKey, setOpenMenuKey] = React.useState(null);
1157
1160
  const [anchorEl, setAnchorEl] = React.useState(null);
1161
+ // Language menu state
1162
+ const [langAnchorEl, setLangAnchorEl] = React.useState(null);
1163
+ const isLangMenuOpen = Boolean(langAnchorEl);
1164
+ const handleLangMenuOpen = (event) => {
1165
+ setLangAnchorEl(event.currentTarget);
1166
+ };
1167
+ const handleLangMenuClose = () => {
1168
+ setLangAnchorEl(null);
1169
+ };
1170
+ const handleLangSelect = (locale, value) => {
1171
+ onLanguageChange === null || onLanguageChange === void 0 ? void 0 : onLanguageChange(locale, value);
1172
+ handleLangMenuClose();
1173
+ };
1174
+ // Derive current language label from locale
1175
+ const currentLangLabel = React.useMemo(() => {
1176
+ const match = languages.find((l) => l.locale === currentLocale);
1177
+ return (match === null || match === void 0 ? void 0 : match.label) || 'English';
1178
+ }, [languages, currentLocale]);
1158
1179
  // Determine which button props to use (support legacy props)
1159
1180
  const shouldShowCtaButton = (_a = showCtaButton !== null && showCtaButton !== void 0 ? showCtaButton : showLoginButton) !== null && _a !== void 0 ? _a : true;
1160
1181
  const ctaText = ctaButtonText || loginButtonText || 'Purchase Now';
@@ -1221,7 +1242,20 @@ showCtaButton = true, ctaButtonText = 'Purchase Now', onCtaClick, ctaScrollTarge
1221
1242
  horizontal: 'left',
1222
1243
  }, MenuListProps: {
1223
1244
  'aria-labelledby': `menu-button-${item.key}`,
1224
- } }, { children: item.subItems.map((subItem) => (jsxs(StyledMenuItem$1, Object.assign({ onClick: () => handleSubItemClick(item, subItem.key), "data-testid": `submenu-item-${subItem.key}` }, { children: [subItem.icon && (jsx(MenuItemIcon, { src: subItem.icon, alt: subItem.label })), formatMessage({ id: subItem.label })] }), subItem.key))) })))] }, item.key))), shouldShowCtaButton && (jsx(PurchaseButton, Object.assign({ onClick: handleCtaButtonClick, "data-testid": "header-cta-button" }, { children: formatMessage({ id: ctaText }) })))] })] }) })));
1245
+ } }, { children: item.subItems.map((subItem) => (jsxs(StyledMenuItem$1, Object.assign({ onClick: () => handleSubItemClick(item, subItem.key), "data-testid": `submenu-item-${subItem.key}` }, { children: [subItem.icon && (jsx(MenuItemIcon, { src: subItem.icon, alt: subItem.label })), formatMessage({ id: subItem.label })] }), subItem.key))) })))] }, item.key))), languages.length > 0 && (jsxs(Fragment, { children: [jsxs(MenuItemButton, Object.assign({ onClick: handleLangMenuOpen, "aria-haspopup": "true", "aria-expanded": isLangMenuOpen, "data-testid": "language-switcher" }, { children: [jsx(LanguageIcon, { sx: { fontSize: '20px', mr: '4px' } }), jsx(MenuItemText, { children: currentLangLabel }), jsx(DropdownIcon, { sx: {
1246
+ transform: isLangMenuOpen
1247
+ ? 'rotate(180deg)'
1248
+ : 'rotate(0deg)',
1249
+ transition: 'transform 0.2s',
1250
+ } })] })), jsx(StyledMenu$1, Object.assign({ id: "language-menu", anchorEl: langAnchorEl, open: isLangMenuOpen, onClose: handleLangMenuClose, anchorOrigin: {
1251
+ vertical: 'bottom',
1252
+ horizontal: 'left',
1253
+ }, transformOrigin: {
1254
+ vertical: 'top',
1255
+ horizontal: 'left',
1256
+ }, MenuListProps: {
1257
+ 'aria-labelledby': 'language-switcher',
1258
+ } }, { children: languages.map((lang) => (jsx(StyledMenuItem$1, Object.assign({ onClick: () => handleLangSelect(lang.locale, lang.value), selected: lang.locale === currentLocale, "data-testid": `lang-${lang.locale}` }, { children: lang.label }), lang.value))) }))] })), shouldShowCtaButton && (jsx(PurchaseButton, Object.assign({ onClick: handleCtaButtonClick, "data-testid": "header-cta-button" }, { children: formatMessage({ id: ctaText }) })))] })] }) })));
1225
1259
  }
1226
1260
 
1227
1261
  const StyledAppBar$1 = styled(AppBar)(({ theme, ispartnershippagemobileview, scrolled }) => {
@@ -1640,7 +1674,7 @@ function Header$1({ logo, navigationLinks, languages, currentLocale, userToken,
1640
1674
  // Render new desktop layout when enabled and on actual desktop viewport
1641
1675
  // Uses isActuallyDesktop to avoid SSR/prop issues with isMobile detection
1642
1676
  if (useNewDesktopLayout && isActuallyDesktop) {
1643
- return (jsx(DesktopHeaderMenuBar, { logo: logo, logoAlt: "Logo", menuItems: convertedDesktopMenuItems, showCtaButton: showCtaButton, ctaButtonText: ctaButtonText, onCtaClick: onCtaClick, ctaScrollTargetId: ctaScrollTargetId, onScrollToSection: onScrollToSection, onLogoClick: onLogoClick, formatMessage: formatMessage }));
1677
+ return (jsx(DesktopHeaderMenuBar, { logo: logo, logoAlt: "Logo", menuItems: convertedDesktopMenuItems, showCtaButton: showCtaButton, ctaButtonText: ctaButtonText, onCtaClick: onCtaClick, ctaScrollTargetId: ctaScrollTargetId, onScrollToSection: onScrollToSection, onLogoClick: onLogoClick, formatMessage: formatMessage, languages: languages, currentLocale: currentLocale, onLanguageChange: onLanguageChange }));
1644
1678
  }
1645
1679
  return (jsx(StyledAppBar$1, Object.assign({ ispartnershippagemobileview: isPartnershipPageMobileView, scrolled: scrolled }, { children: jsx(ResponsiveB2CLayout, { children: jsx(StyledContainer, Object.assign({ ispartnershippagemobileview: isPartnershipPageMobileView, scrolled: scrolled, maxWidth: "xl" }, { children: jsxs(Toolbar, Object.assign({ disableGutters: true }, { children: [jsx("a", Object.assign({ href: host || '#', onClick: (e) => {
1646
1680
  e === null || e === void 0 ? void 0 : e.preventDefault();
@@ -2057,7 +2091,7 @@ function Footer({ simplifiedLayout = false, introText, addressText, socialLinks,
2057
2091
  }), index === navigationLinks.length - 1 && (jsxs(Fragment, { children: [jsx(ButtonBottomLink, Object.assign({ onClick: onPrivacyPolicyClick }, { children: jsx(Typography, Object.assign({ variant: "body1" }, { children: jsx(AnchorLink, Object.assign({ href: `${host}/${currentLocale}/terms/privacypolicy`, onClick: (e) => e === null || e === void 0 ? void 0 : e.preventDefault() }, { children: formatMessage({ id: 'Privacy Policy' }) })) })) })), jsx(ButtonBottomLink, Object.assign({ onClick: onTermsOfServiceClick }, { children: jsx(Typography, Object.assign({ variant: "body1" }, { children: jsx(AnchorLink, Object.assign({ href: `${host}/${currentLocale}/terms/termsofservice`, onClick: (e) => e === null || e === void 0 ? void 0 : e.preventDefault() }, { children: formatMessage({ id: 'Terms of Service' }) })) })) })), jsx(DivSocial, { children: socialLinks.map((social) => (jsx(ButtonIcon, Object.assign({ onClick: () => onSocialClick === null || onSocialClick === void 0 ? void 0 : onSocialClick(social.platform, social.url), "aria-label": social.ariaLabel || social.platform }, { children: jsx(AnchorLink, Object.assign({ href: social.url, onClick: (e) => e === null || e === void 0 ? void 0 : e.preventDefault() }, { children: jsx("img", { src: social.icon, alt: social.platform, height: isMobile ? '24' : '28', width: isMobile ? '24' : '28', loading: "lazy" }) })) }), social.platform))) })] }))] }, index))) }))] })), isMobile && jsx(StyledDivider, {}), isMobile && (jsx(DivBottom, { children: jsxs(DivLinks, { children: [jsx("div", Object.assign({ onClick: onPrivacyPolicyClick, style: { cursor: 'pointer' } }, { children: jsx(Typography, Object.assign({ variant: "body2" }, { children: jsx(AnchorLink, Object.assign({ href: `${host}/${currentLocale}/terms/privacypolicy`, onClick: (e) => e === null || e === void 0 ? void 0 : e.preventDefault() }, { children: formatMessage({ id: 'Privacy Policy' }) })) })) })), jsx(DivSep, {}), jsx("div", Object.assign({ onClick: onTermsOfServiceClick, style: { cursor: 'pointer' } }, { children: jsx(Typography, Object.assign({ variant: "body2" }, { children: jsx(AnchorLink, Object.assign({ href: `${host}/${currentLocale}/terms/termsofservice`, onClick: (e) => e === null || e === void 0 ? void 0 : e.preventDefault() }, { children: formatMessage({ id: 'Terms of Service' }) })) })) }))] }) }))] }) }));
2058
2092
  }
2059
2093
 
2060
- const StyledDrawer$1 = styled(Drawer)(() => ({
2094
+ const StyledDrawer$1 = styled(Drawer)(({ theme }) => ({
2061
2095
  zIndex: '1300 !important',
2062
2096
  '& .MuiDrawer-root': {
2063
2097
  zIndex: 1300,
@@ -2067,17 +2101,26 @@ const StyledDrawer$1 = styled(Drawer)(() => ({
2067
2101
  boxSizing: 'border-box',
2068
2102
  overflow: 'hidden',
2069
2103
  zIndex: 1300,
2104
+ [theme.breakpoints.up('md')]: {
2105
+ maxWidth: '680px',
2106
+ margin: '0 auto',
2107
+ borderRadius: '16px',
2108
+ },
2070
2109
  },
2071
2110
  '& .MuiBackdrop-root': {
2072
2111
  zIndex: 1299,
2073
2112
  },
2074
2113
  }));
2075
- const DrawerHeader$1 = styled(Box)(() => ({
2114
+ const DrawerHeader$1 = styled(Box)(({ theme }) => ({
2076
2115
  display: 'flex',
2077
2116
  alignItems: 'center',
2078
- justifyContent: 'flex-end',
2079
- padding: '16px',
2080
- minHeight: '56px',
2117
+ justifyContent: 'flex-start',
2118
+ padding: '16px 24px',
2119
+ minHeight: '64px',
2120
+ [theme.breakpoints.down('md')]: {
2121
+ padding: '16px',
2122
+ minHeight: '56px',
2123
+ },
2081
2124
  }));
2082
2125
  const DrawerContent$1 = styled(Box)(() => ({
2083
2126
  flex: 1,
@@ -2156,6 +2199,15 @@ const SecondaryButton = styled(Button$1)(() => ({
2156
2199
  lineHeight: '18px',
2157
2200
  wordSpacing: '-5px',
2158
2201
  }));
2202
+ const BackArrowButton = styled(IconButton)(() => ({
2203
+ padding: 0,
2204
+ width: '32px',
2205
+ height: '32px',
2206
+ color: '#13131B',
2207
+ '& .MuiSvgIcon-root': {
2208
+ fontSize: '24px',
2209
+ },
2210
+ }));
2159
2211
 
2160
2212
  /**
2161
2213
  * RecommendationsDrawer - Mobile drawer for recommendations and forms
@@ -2211,7 +2263,7 @@ function RecommendationsDrawer({ open, onClose, children, headerIcon, title, sub
2211
2263
  },
2212
2264
  }, sx: {
2213
2265
  zIndex: 1300,
2214
- } }, { children: jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', height: '100%' } }, { children: [jsx(DrawerHeader$1, { children: jsx(IconButton, Object.assign({ onClick: handleBackOrClose, sx: { padding: 0 }, "aria-label": showBackButton ? 'back' : 'close' }, { children: showBackButton ? jsx(ArrowBackIcon, {}) : jsx(CloseIcon, {}) })) }), (title || subtitle || headerIcon) && (jsxs(HeaderSection, { children: [headerIcon && (jsx(CategoryIcon, { children: jsx("img", { src: headerIcon, alt: "Category icon", width: 32, height: 32 }) })), title && (jsx(TitleText, Object.assign({ variant: "h5" }, { children: formatMessage({ id: title }) }))), subtitle && (jsx(SubtitleText, Object.assign({ variant: "body2" }, { children: formatMessage({ id: subtitle }) })))] })), jsx(DrawerContent$1, { children: children }), showFooter && (jsx(DrawerFooter, { children: customFooter ? (customFooter) : (jsxs(FooterButtons, { children: [primaryButtonText && (jsx(PrimaryButton, Object.assign({ variant: "contained", fullWidth: true, onClick: onPrimaryAction, disabled: primaryButtonDisabled, sx: {
2266
+ } }, { children: jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', height: '100%' } }, { children: [jsx(DrawerHeader$1, { children: jsx(BackArrowButton, Object.assign({ onClick: handleBackOrClose, "aria-label": showBackButton ? 'back' : 'close' }, { children: showBackButton ? jsx(ArrowBackIcon, {}) : jsx(CloseIcon, {}) })) }), (title || subtitle || headerIcon) && (jsxs(HeaderSection, { children: [headerIcon && (jsx(CategoryIcon, { children: jsx("img", { src: headerIcon, alt: "Category icon", width: 32, height: 32 }) })), title && (jsx(TitleText, Object.assign({ variant: "h5" }, { children: formatMessage({ id: title }) }))), subtitle && (jsx(SubtitleText, Object.assign({ variant: "body2" }, { children: formatMessage({ id: subtitle }) })))] })), jsx(DrawerContent$1, { children: children }), showFooter && (jsx(DrawerFooter, { children: customFooter ? (customFooter) : (jsxs(FooterButtons, { children: [primaryButtonText && (jsx(PrimaryButton, Object.assign({ variant: "contained", fullWidth: true, onClick: onPrimaryAction, disabled: primaryButtonDisabled, sx: {
2215
2267
  backgroundColor: primaryColor,
2216
2268
  '&:hover': {
2217
2269
  backgroundColor: primaryColor,
@@ -2457,13 +2509,16 @@ function ProductSelectionDrawer({ open, onClose, products, onProductSelect, titl
2457
2509
  } }, { children: viewPlansButtonText }))] }, product.id))) }) })] }) })));
2458
2510
  }
2459
2511
 
2460
- const QuestionContainer$1 = styled(Box)(() => ({
2512
+ const QuestionContainer$1 = styled(Box)(({ theme }) => ({
2461
2513
  backgroundColor: '#FFFFFF',
2462
- padding: '12px 16px',
2514
+ padding: '12px 0px',
2463
2515
  display: 'flex',
2464
2516
  flexDirection: 'column',
2465
2517
  gap: '16px',
2466
2518
  width: '100%',
2519
+ [theme.breakpoints.down('md')]: {
2520
+ padding: '8px 12px',
2521
+ },
2467
2522
  }));
2468
2523
  const QuestionHeader = styled(Box)(() => ({
2469
2524
  display: 'flex',
@@ -2877,16 +2932,16 @@ function BillingToggle({ value, onChange, formatMessage = (descriptor) => descri
2877
2932
  ? toggleActiveTextColor
2878
2933
  : toggleInactiveTextColor,
2879
2934
  } }, { children: jsx(ToggleText, { children: formatMessage({
2880
- id: 'Billed monthly',
2881
- defaultMessage: 'Billed monthly',
2935
+ id: 'Billed Monthly',
2936
+ defaultMessage: 'Billed Monthly',
2882
2937
  }) }) })), jsx(ToggleButton, Object.assign({ active: value === 'annually', onClick: () => onChange('annually'), sx: {
2883
2938
  backgroundColor: value === 'annually' ? toggleActiveColor : 'transparent',
2884
2939
  color: value === 'annually'
2885
2940
  ? toggleActiveTextColor
2886
2941
  : toggleInactiveTextColor,
2887
2942
  } }, { children: jsx(ToggleText, { children: formatMessage({
2888
- id: 'Billed annually',
2889
- defaultMessage: 'Billed annually',
2943
+ id: 'Billed Annually',
2944
+ defaultMessage: 'Billed Annually',
2890
2945
  }) }) }))] })));
2891
2946
  }
2892
2947
 
@@ -3443,19 +3498,17 @@ const ButtonContainer = styled(Box)(({ isFixed, desktopRightAligned }) => ({
3443
3498
  padding: '16px',
3444
3499
  boxShadow: isFixed ? '0px 2px 10px 0px rgba(0, 0, 0, 0.12)' : 'none',
3445
3500
  zIndex: 999,
3446
- // Desktop styles for right-aligned button
3447
- '@media (min-width: 900px)': desktopRightAligned
3448
- ? {
3449
- display: 'flex',
3450
- justifyContent: 'flex-end',
3451
- maxWidth: '938px',
3452
- margin: '0 auto',
3453
- padding: '24px 0',
3454
- backgroundColor: 'transparent',
3455
- boxShadow: 'none',
3456
- position: 'relative',
3457
- }
3458
- : {},
3501
+ // Desktop styles for button alignment
3502
+ '@media (min-width: 900px)': {
3503
+ display: 'flex',
3504
+ justifyContent: desktopRightAligned ? 'flex-end' : 'center',
3505
+ maxWidth: '938px',
3506
+ margin: '0 auto',
3507
+ padding: '24px 0',
3508
+ backgroundColor: 'transparent',
3509
+ boxShadow: 'none',
3510
+ position: 'relative',
3511
+ },
3459
3512
  }));
3460
3513
  const StyledButton = styled('button')(({ isDisabled, desktopWidth }) => ({
3461
3514
  width: '100%',
@@ -3487,7 +3540,7 @@ const StyledButton = styled('button')(({ isDisabled, desktopWidth }) => ({
3487
3540
  }));
3488
3541
 
3489
3542
  const CheckoutFormButton = ({ text = 'Next', disabled = false, onClick, fixed = true, type = 'button', sx, loading = false, desktopRightAligned = false, desktopWidth = '180px', }) => {
3490
- return (jsx(ButtonContainer, Object.assign({ isFixed: fixed, desktopRightAligned: desktopRightAligned, sx: sx }, { children: jsx(StyledButton, Object.assign({ type: type, disabled: disabled || loading, isDisabled: disabled || loading, desktopWidth: desktopRightAligned ? desktopWidth : undefined, onClick: onClick }, { children: loading ? 'Processing...' : text })) })));
3543
+ return (jsx(ButtonContainer, Object.assign({ isFixed: fixed, desktopRightAligned: desktopRightAligned, sx: sx }, { children: jsx(StyledButton, Object.assign({ type: type, disabled: disabled || loading, isDisabled: disabled || loading, desktopWidth: desktopWidth, onClick: onClick }, { children: loading ? 'Processing...' : text })) })));
3491
3544
  };
3492
3545
 
3493
3546
  const QuestionContainer = styled(Box)({
@@ -3614,7 +3667,7 @@ const PersonalInformationForm = ({ renderField, fields, consents, onSubmit, form
3614
3667
  color: '#5F5E62',
3615
3668
  fontSize: '12px',
3616
3669
  wordSpacing: '-5px',
3617
- } }, { children: fields.full_name.helperText })))] }), renderField(fields.nric), renderField(fields.date_of_birth), renderField(fields.gender), renderField(fields.salutation), renderField(fields.nationality), renderField(fields.occupation), renderField(fields.industry), renderField(fields.crediting_bank_name), renderField(fields.crediting_bank_account_number), desktopGridLayout ? (jsx(FullWidthField$1, { children: jsxs(CheckboxContainer$1, { children: [jsx(FormControlLabel, { control: jsx(Checkbox, { checked: consents.bank_account_confirmation.checked, onChange: (e) => consents.bank_account_confirmation.onChange(e.target.checked), name: "bank_account_confirmation" }), label: jsx(CheckboxLabel$1, { children: consents.bank_account_confirmation.label ||
3670
+ } }, { children: fields.full_name.helperText })))] }), renderField(fields.nric), renderField(fields.date_of_birth), renderField(fields.gender), renderField(fields.salutation), renderField(fields.nationality), fields.place_of_birth && renderField(fields.place_of_birth), fields.marital_status && renderField(fields.marital_status), fields.race && renderField(fields.race), fields.religion && renderField(fields.religion), fields.annual_income && renderField(fields.annual_income), renderField(fields.occupation), renderField(fields.industry), renderField(fields.crediting_bank_name), renderField(fields.crediting_bank_account_number), desktopGridLayout ? (jsx(FullWidthField$1, { children: jsxs(CheckboxContainer$1, { children: [jsx(FormControlLabel, { control: jsx(Checkbox, { checked: consents.bank_account_confirmation.checked, onChange: (e) => consents.bank_account_confirmation.onChange(e.target.checked), name: "bank_account_confirmation" }), label: jsx(CheckboxLabel$1, { children: consents.bank_account_confirmation.label ||
3618
3671
  defaultBankConfirmationLabel }) }), consents.bank_account_confirmation.error && (jsx(Typography, Object.assign({ sx: {
3619
3672
  color: 'error.main',
3620
3673
  fontSize: '12px',
@@ -3697,8 +3750,10 @@ const SectionTitle$1 = styled(Typography)({
3697
3750
  wordSpacing: '-5px',
3698
3751
  });
3699
3752
 
3700
- const ContactDetailsForm = ({ renderField, fields, mailingFields, mailingAddressSame, onSubmit, formRef, sx, desktopGridLayout = false, }) => {
3753
+ const ContactDetailsForm = ({ renderField, fields, isForChild = false, mailingFields, mailingAddressSame, childContactFields, childContactNotSame, onSubmit, formRef, sx, desktopGridLayout = false, }) => {
3701
3754
  const defaultMailingLabel = 'My mailing address is not the same as residential';
3755
+ const defaultChildContactLabel = 'My child contact details is not the same as residential';
3756
+ const childContactHelperText = 'Tick this box if the child has a different address, phone number, or email';
3702
3757
  const Container = desktopGridLayout ? DesktopFormContainer$2 : FormContainer$2;
3703
3758
  // Helper to render field with or without full width wrapper
3704
3759
  const renderFieldWithLayout = (field, fullWidth = false) => {
@@ -3720,18 +3775,28 @@ const ContactDetailsForm = ({ renderField, fields, mailingFields, mailingAddress
3720
3775
  }
3721
3776
  return content;
3722
3777
  };
3723
- return (jsx(Container, Object.assign({ ref: formRef, component: "form", onSubmit: onSubmit, sx: sx }, { children: desktopGridLayout ? (jsxs(FieldsGridContainer$1, { children: [renderFieldWithHelperText(fields.phone_number, false), renderFieldWithLayout(fields.email_address, false), jsx(FullWidthField, { children: jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }) }), jsx(FullWidthField, { children: jsx(SectionTitle$1, { children: "Residential address" }) }), renderFieldWithHelperText(fields.residential_address_line1, false), renderFieldWithHelperText(fields.residential_address_line2, false), renderField(fields.postal_code), renderField(fields.city), renderField(fields.state), jsx(FullWidthField, { children: jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }) }), (mailingAddressSame === null || mailingAddressSame === void 0 ? void 0 : mailingAddressSame.checked) && mailingFields && (jsxs(Fragment, { children: [jsx(FullWidthField, { children: jsx(SectionTitle$1, { children: "Mailing address" }) }), renderFieldWithHelperText(mailingFields.mailing_address_line1, false), renderFieldWithHelperText(mailingFields.mailing_address_line2, false), renderField(mailingFields.mailing_postal_code), renderField(mailingFields.mailing_city), renderField(mailingFields.mailing_state)] })), mailingAddressSame && (jsx(FullWidthField, { children: jsx(CheckboxContainer, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: mailingAddressSame.checked, onChange: (e) => mailingAddressSame.onChange(e.target.checked), name: "mailing_not_same_as_residential", sx: {
3778
+ return (jsx(Container, Object.assign({ ref: formRef, component: "form", onSubmit: onSubmit, sx: sx }, { children: desktopGridLayout ? (jsxs(FieldsGridContainer$1, { children: [isForChild && (jsx(FullWidthField, { children: jsx(SectionTitle$1, { children: "Policyowner contact details" }) })), renderFieldWithHelperText(fields.phone_number, false), renderFieldWithLayout(fields.email_address, false), ((mailingAddressSame === null || mailingAddressSame === void 0 ? void 0 : mailingAddressSame.checked) && !isForChild) && (jsxs(Fragment, { children: [jsx(FullWidthField, { children: jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }) }), jsx(FullWidthField, { children: jsx(SectionTitle$1, { children: "Residential address" }) })] })), renderFieldWithHelperText(fields.residential_address_line1, false), renderFieldWithHelperText(fields.residential_address_line2, false), fields.country && renderField(fields.country), renderField(fields.postal_code), renderField(fields.city), renderField(fields.state), (mailingAddressSame === null || mailingAddressSame === void 0 ? void 0 : mailingAddressSame.checked) && mailingFields && (jsxs(Fragment, { children: [jsx(FullWidthField, { children: jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }) }), jsx(FullWidthField, { children: jsx(SectionTitle$1, { children: isForChild ? 'Policyowner mailing address' : 'Mailing address' }) }), isForChild && mailingFields.mailing_phone_number && (renderFieldWithHelperText(mailingFields.mailing_phone_number, false)), isForChild && mailingFields.mailing_email_address && (renderFieldWithLayout(mailingFields.mailing_email_address, false)), renderFieldWithHelperText(mailingFields.mailing_address_line1, false), renderFieldWithHelperText(mailingFields.mailing_address_line2, false), mailingFields.mailing_country && renderField(mailingFields.mailing_country), renderField(mailingFields.mailing_postal_code), renderField(mailingFields.mailing_city), renderField(mailingFields.mailing_state)] })), (childContactNotSame === null || childContactNotSame === void 0 ? void 0 : childContactNotSame.checked) && childContactFields && (jsxs(Fragment, { children: [jsx(FullWidthField, { children: jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }) }), jsx(FullWidthField, { children: jsx(SectionTitle$1, { children: "Child's contact details" }) }), renderFieldWithHelperText(childContactFields.child_phone_number, false), renderFieldWithLayout(childContactFields.child_email_address, false), renderFieldWithHelperText(childContactFields.child_address_line1, false), renderFieldWithHelperText(childContactFields.child_address_line2, false), renderField(childContactFields.child_postal_code), childContactFields.child_country && renderField(childContactFields.child_country), renderField(childContactFields.child_city), renderField(childContactFields.child_state)] })), mailingAddressSame && (jsx(FullWidthField, { children: jsx(CheckboxContainer, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: mailingAddressSame.checked, onChange: (e) => mailingAddressSame.onChange(e.target.checked), name: "mailing_not_same_as_residential", sx: {
3724
3779
  color: '#929094',
3725
3780
  '&.Mui-checked': {
3726
3781
  color: '#317abc',
3727
3782
  },
3728
- } }), label: jsx(CheckboxLabel, { children: mailingAddressSame.label || defaultMailingLabel }) }) }) }))] })) : (jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '24px' } }, { children: [jsxs(Box, { children: [renderField(fields.phone_number), fields.phone_number.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3783
+ } }), label: jsx(CheckboxLabel, { children: mailingAddressSame.label || defaultMailingLabel }) }) }) })), childContactNotSame && (jsx(FullWidthField, { children: jsx(CheckboxContainer, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: childContactNotSame.checked, onChange: (e) => childContactNotSame.onChange(e.target.checked), name: "child_contact_not_same", sx: {
3784
+ color: '#929094',
3785
+ '&.Mui-checked': {
3786
+ color: '#317abc',
3787
+ },
3788
+ } }), label: jsxs(Box, { children: [jsx(CheckboxLabel, { children: childContactNotSame.label || defaultChildContactLabel }), jsx(Box, Object.assign({ component: "span", sx: {
3789
+ display: 'block',
3790
+ fontSize: '12px',
3791
+ color: '#5F5E62',
3792
+ mt: 0.5,
3793
+ } }, { children: childContactHelperText }))] }) }) }) }))] })) : (jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '24px' } }, { children: [isForChild && (jsx(SectionTitle$1, { children: "Policyowner contact details" })), jsxs(Box, { children: [renderField(fields.phone_number), fields.phone_number.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3729
3794
  display: 'block',
3730
3795
  mt: 0.5,
3731
3796
  ml: 2,
3732
3797
  color: '#5F5E62',
3733
3798
  fontSize: '12px',
3734
- } }, { children: fields.phone_number.helperText })))] }), renderField(fields.email_address), jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }), jsx(SectionTitle$1, { children: "Residential address" }), jsxs(Box, { children: [renderField(fields.residential_address_line1), fields.residential_address_line1.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3799
+ } }, { children: fields.phone_number.helperText })))] }), renderField(fields.email_address), ((mailingAddressSame === null || mailingAddressSame === void 0 ? void 0 : mailingAddressSame.checked) && !isForChild) && (jsxs(Fragment, { children: [jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }), jsx(SectionTitle$1, { children: "Residential address" })] })), jsxs(Box, { children: [renderField(fields.residential_address_line1), fields.residential_address_line1.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3735
3800
  display: 'block',
3736
3801
  mt: 0.5,
3737
3802
  color: '#5F5E62',
@@ -3741,7 +3806,7 @@ const ContactDetailsForm = ({ renderField, fields, mailingFields, mailingAddress
3741
3806
  mt: 0.5,
3742
3807
  color: '#5F5E62',
3743
3808
  fontSize: '12px',
3744
- } }, { children: fields.residential_address_line2.helperText })))] }), renderField(fields.postal_code), renderField(fields.city), renderField(fields.state), jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }), (mailingAddressSame === null || mailingAddressSame === void 0 ? void 0 : mailingAddressSame.checked) && mailingFields && (jsxs(Fragment, { children: [jsx(SectionTitle$1, { children: "Mailing address" }), jsxs(Box, { children: [renderField(mailingFields.mailing_address_line1), mailingFields.mailing_address_line1.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3809
+ } }, { children: fields.residential_address_line2.helperText })))] }), fields.country && renderField(fields.country), renderField(fields.postal_code), renderField(fields.city), renderField(fields.state), (mailingAddressSame === null || mailingAddressSame === void 0 ? void 0 : mailingAddressSame.checked) && mailingFields && (jsxs(Fragment, { children: [jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }), jsx(SectionTitle$1, { children: isForChild ? 'Policyowner mailing address' : 'Mailing address' }), isForChild && mailingFields.mailing_phone_number && (jsxs(Box, { children: [renderField(mailingFields.mailing_phone_number), mailingFields.mailing_phone_number.helperText && (jsx(Box, Object.assign({ component: "span", sx: { display: 'block', mt: 0.5, ml: 2, color: '#5F5E62', fontSize: '12px' } }, { children: mailingFields.mailing_phone_number.helperText })))] })), isForChild && mailingFields.mailing_email_address && (renderField(mailingFields.mailing_email_address)), jsxs(Box, { children: [renderField(mailingFields.mailing_address_line1), mailingFields.mailing_address_line1.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3745
3810
  display: 'block',
3746
3811
  mt: 0.5,
3747
3812
  color: '#5F5E62',
@@ -3751,12 +3816,22 @@ const ContactDetailsForm = ({ renderField, fields, mailingFields, mailingAddress
3751
3816
  mt: 0.5,
3752
3817
  color: '#5F5E62',
3753
3818
  fontSize: '12px',
3754
- } }, { children: mailingFields.mailing_address_line2.helperText })))] }), renderField(mailingFields.mailing_postal_code), renderField(mailingFields.mailing_city), renderField(mailingFields.mailing_state)] })), mailingAddressSame && (jsx(CheckboxContainer, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: mailingAddressSame.checked, onChange: (e) => mailingAddressSame.onChange(e.target.checked), name: "mailing_not_same_as_residential", sx: {
3819
+ } }, { children: mailingFields.mailing_address_line2.helperText })))] }), mailingFields.mailing_country && renderField(mailingFields.mailing_country), renderField(mailingFields.mailing_postal_code), renderField(mailingFields.mailing_city), renderField(mailingFields.mailing_state)] })), (childContactNotSame === null || childContactNotSame === void 0 ? void 0 : childContactNotSame.checked) && childContactFields && (jsxs(Fragment, { children: [jsx(Divider, { sx: { borderColor: 'rgba(0,0,0,0.1)' } }), jsx(SectionTitle$1, { children: "Child's contact details" }), jsxs(Box, { children: [renderField(childContactFields.child_phone_number), childContactFields.child_phone_number.helperText && (jsx(Box, Object.assign({ component: "span", sx: { display: 'block', mt: 0.5, ml: 2, color: '#5F5E62', fontSize: '12px' } }, { children: childContactFields.child_phone_number.helperText })))] }), renderField(childContactFields.child_email_address), jsxs(Box, { children: [renderField(childContactFields.child_address_line1), childContactFields.child_address_line1.helperText && (jsx(Box, Object.assign({ component: "span", sx: { display: 'block', mt: 0.5, color: '#5F5E62', fontSize: '12px' } }, { children: childContactFields.child_address_line1.helperText })))] }), jsxs(Box, { children: [renderField(childContactFields.child_address_line2), childContactFields.child_address_line2.helperText && (jsx(Box, Object.assign({ component: "span", sx: { display: 'block', mt: 0.5, color: '#5F5E62', fontSize: '12px' } }, { children: childContactFields.child_address_line2.helperText })))] }), renderField(childContactFields.child_postal_code), childContactFields.child_country && renderField(childContactFields.child_country), renderField(childContactFields.child_city), renderField(childContactFields.child_state)] })), mailingAddressSame && (jsx(CheckboxContainer, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: mailingAddressSame.checked, onChange: (e) => mailingAddressSame.onChange(e.target.checked), name: "mailing_not_same_as_residential", sx: {
3820
+ color: '#929094',
3821
+ '&.Mui-checked': {
3822
+ color: '#317abc',
3823
+ },
3824
+ } }), label: jsx(CheckboxLabel, { children: mailingAddressSame.label || defaultMailingLabel }) }) })), childContactNotSame && (jsx(CheckboxContainer, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: childContactNotSame.checked, onChange: (e) => childContactNotSame.onChange(e.target.checked), name: "child_contact_not_same", sx: {
3755
3825
  color: '#929094',
3756
3826
  '&.Mui-checked': {
3757
3827
  color: '#317abc',
3758
3828
  },
3759
- } }), label: jsx(CheckboxLabel, { children: mailingAddressSame.label || defaultMailingLabel }) }) }))] }))) })));
3829
+ } }), label: jsxs(Box, { children: [jsx(CheckboxLabel, { children: childContactNotSame.label || defaultChildContactLabel }), jsx(Box, Object.assign({ component: "span", sx: {
3830
+ display: 'block',
3831
+ fontSize: '12px',
3832
+ color: '#5F5E62',
3833
+ mt: 0.5,
3834
+ } }, { children: childContactHelperText }))] }) }) }))] }))) })));
3760
3835
  };
3761
3836
 
3762
3837
  const FormContainer$1 = styled(Box)({
@@ -3831,28 +3906,30 @@ styled(Box)({
3831
3906
  },
3832
3907
  });
3833
3908
 
3834
- const ChildInformationForm = ({ renderField, fields, onSubmit, formRef, sx, desktopGridLayout = false, }) => {
3909
+ const ChildInformationForm = ({ renderField, fields, consents, onSubmit, formRef, sx, desktopGridLayout = false, }) => {
3835
3910
  const Container = desktopGridLayout ? DesktopFormContainer : FormContainer;
3911
+ const defaultBankConfirmationLabel = "I confirm this bank account is my child's and consent to AmMetLife crediting payouts to it";
3912
+ const defaultMarketingLabel = "I/We consent to AmMetLife Insurance Berhad using my child's personal data for marketing and communication via digital platforms such as email, WhatsApp, and mobile";
3913
+ const renderHelperField = (field) => (jsxs(Box, { children: [renderField(field), field.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3914
+ display: 'block',
3915
+ mt: 0.5,
3916
+ ml: 2,
3917
+ color: '#5F5E62',
3918
+ fontSize: '12px',
3919
+ wordSpacing: '-5px',
3920
+ } }, { children: field.helperText })))] }));
3921
+ const renderConsents = () => {
3922
+ if (!consents)
3923
+ return null;
3924
+ return (jsxs(Fragment, { children: [consents.bank_account_confirmation && (jsxs(Box, Object.assign({ sx: desktopGridLayout ? { gridColumn: '1 / -1' } : undefined }, { children: [jsx(FormControlLabel, { control: jsx(Checkbox, { checked: consents.bank_account_confirmation.checked, onChange: (e) => { var _a; return (_a = consents.bank_account_confirmation) === null || _a === void 0 ? void 0 : _a.onChange(e.target.checked); }, name: "bank_account_confirmation" }), label: jsx(Typography, Object.assign({ sx: { fontSize: '14px', color: '#5f5e62', lineHeight: '18px' } }, { children: consents.bank_account_confirmation.label || defaultBankConfirmationLabel })), sx: { alignItems: 'flex-start', m: 0, '& .MuiCheckbox-root': { pt: '2px' } } }), consents.bank_account_confirmation.error && (jsx(Typography, Object.assign({ sx: { color: 'error.main', fontSize: '12px', mt: 0.5, ml: 4 } }, { children: consents.bank_account_confirmation.error })))] }))), consents.marketing_consent && (jsx(Box, Object.assign({ sx: desktopGridLayout ? { gridColumn: '1 / -1' } : undefined }, { children: jsx(FormControlLabel, { control: jsx(Checkbox, { checked: consents.marketing_consent.checked, onChange: (e) => { var _a; return (_a = consents.marketing_consent) === null || _a === void 0 ? void 0 : _a.onChange(e.target.checked); }, name: "marketing_consent" }), label: jsx(Typography, Object.assign({ sx: { fontSize: '14px', color: '#5f5e62', lineHeight: '18px' } }, { children: consents.marketing_consent.label || defaultMarketingLabel })), sx: { alignItems: 'flex-start', m: 0, '& .MuiCheckbox-root': { pt: '2px' } } }) })))] }));
3925
+ };
3926
+ const renderAdditionalFields = () => (jsxs(Fragment, { children: [fields.place_of_birth && renderField(fields.place_of_birth), fields.marital_status && renderField(fields.marital_status), fields.race && renderField(fields.race), fields.religion && renderField(fields.religion), fields.occupation && renderField(fields.occupation), fields.industry && renderField(fields.industry), fields.crediting_bank_name && renderField(fields.crediting_bank_name), fields.crediting_bank_account_number && renderField(fields.crediting_bank_account_number), fields.annual_income && renderField(fields.annual_income)] }));
3836
3927
  // Desktop layout with 2-column grid
3837
3928
  if (desktopGridLayout) {
3838
- return (jsx(Container, Object.assign({ ref: formRef, component: "form", onSubmit: onSubmit, sx: sx }, { children: jsxs(FieldsGridContainer, { children: [jsxs(Box, { children: [renderField(fields.full_name), fields.full_name.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3839
- display: 'block',
3840
- mt: 0.5,
3841
- ml: 2,
3842
- color: '#5F5E62',
3843
- fontSize: '12px',
3844
- wordSpacing: '-5px',
3845
- } }, { children: fields.full_name.helperText })))] }), fields.nric ? renderField(fields.nric) : renderField(fields.date_of_birth), fields.nric && renderField(fields.date_of_birth), renderField(fields.gender), renderField(fields.nationality)] }) })));
3929
+ return (jsx(Container, Object.assign({ ref: formRef, component: "form", onSubmit: onSubmit, sx: sx }, { children: jsxs(FieldsGridContainer, { children: [renderHelperField(fields.full_name), fields.nric ? renderHelperField(fields.nric) : renderField(fields.date_of_birth), fields.nric && renderField(fields.date_of_birth), renderField(fields.gender), fields.salutation && renderField(fields.salutation), renderField(fields.nationality), renderAdditionalFields(), renderConsents()] }) })));
3846
3930
  }
3847
3931
  // Mobile layout - single column
3848
- return (jsx(Container, Object.assign({ ref: formRef, component: "form", onSubmit: onSubmit, sx: sx }, { children: jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '24px' } }, { children: [jsxs(Box, { children: [renderField(fields.full_name), fields.full_name.helperText && (jsx(Box, Object.assign({ component: "span", sx: {
3849
- display: 'block',
3850
- mt: 0.5,
3851
- ml: 2,
3852
- color: '#5F5E62',
3853
- fontSize: '12px',
3854
- wordSpacing: '-5px',
3855
- } }, { children: fields.full_name.helperText })))] }), fields.nric && renderField(fields.nric), renderField(fields.date_of_birth), renderField(fields.gender), renderField(fields.nationality)] })) })));
3932
+ return (jsx(Container, Object.assign({ ref: formRef, component: "form", onSubmit: onSubmit, sx: sx }, { children: jsxs(Box, Object.assign({ sx: { display: 'flex', flexDirection: 'column', gap: '24px' } }, { children: [renderHelperField(fields.full_name), fields.nric && renderHelperField(fields.nric), renderField(fields.date_of_birth), renderField(fields.gender), fields.salutation && renderField(fields.salutation), renderField(fields.nationality), renderAdditionalFields(), renderConsents()] })) })));
3856
3933
  };
3857
3934
 
3858
3935
  /**