@opexa/portal-components 0.0.741 → 0.0.743

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.
Files changed (113) hide show
  1. package/dist/components/Account/Account.lazy.js +15 -15
  2. package/dist/components/Banner/Banner.client.d.ts +12 -0
  3. package/dist/components/Banner/Banner.client.js +49 -0
  4. package/dist/components/DigitainLauncher/Loading.d.ts +1 -0
  5. package/dist/components/DigitainLauncher/Loading.js +5 -0
  6. package/dist/components/Disclaimer/DisclaimerV2.js +15 -15
  7. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +184 -0
  8. package/dist/components/Jackpots/JackpotsCarouselNext/JackpotsCarouselStageItem.js +12 -9
  9. package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +184 -0
  10. package/dist/components/Jackpots/JackpotsListNext/JackpotMultiStageDesktop.js +13 -14
  11. package/dist/components/Jackpots/JackpotsListNext/JackpotMultiStageMobile.js +13 -12
  12. package/dist/components/KYC/BasicInformation.d.ts +1 -0
  13. package/dist/components/KYC/BasicInformation.js +101 -0
  14. package/dist/components/KYC/IdentityVerification.d.ts +1 -0
  15. package/dist/components/KYC/IdentityVerification.js +120 -0
  16. package/dist/components/KYC/Indicator.d.ts +1 -0
  17. package/dist/components/KYC/Indicator.js +8 -0
  18. package/dist/components/KYC/KYC.lazy.d.ts +6 -0
  19. package/dist/components/KYC/KYC.lazy.js +45 -0
  20. package/dist/components/KYC/KYCContext.d.ts +6 -0
  21. package/dist/components/KYC/KYCContext.js +2 -0
  22. package/dist/components/KYC/KYCDefault/BasicInformation.d.ts +1 -0
  23. package/dist/components/KYC/KYCDefault/BasicInformation.js +101 -0
  24. package/dist/components/KYC/KYCDefault/IdentityVerification.js +15 -15
  25. package/dist/components/KYC/KYCDefault/PersonalInformation.js +15 -15
  26. package/dist/components/KYC/KYCReminder.lazy.js +45 -17
  27. package/dist/components/KYC/KYCVerificationStatus.d.ts +1 -0
  28. package/dist/components/KYC/KYCVerificationStatus.js +10 -0
  29. package/dist/components/KYC/KYCVerificationStatus.lazy.d.ts +1 -0
  30. package/dist/components/KYC/KYCVerificationStatus.lazy.js +36 -0
  31. package/dist/components/KYC/PersonalInformation.d.ts +1 -0
  32. package/dist/components/KYC/PersonalInformation.js +122 -0
  33. package/dist/components/KYC/useKYC.d.ts +25 -0
  34. package/dist/components/KYC/useKYC.js +38 -0
  35. package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +1 -0
  36. package/dist/components/PortalProvider/AndroidOnlyComponents.js +12 -0
  37. package/dist/components/PortalProvider/CXDTokenObserver.d.ts +1 -0
  38. package/dist/components/PortalProvider/CXDTokenObserver.js +30 -0
  39. package/dist/components/PortalProvider/LinkGoogleAccountObserver.d.ts +1 -0
  40. package/dist/components/PortalProvider/LinkGoogleAccountObserver.js +29 -0
  41. package/dist/components/Quests/JourneyQuest.js +15 -14
  42. package/dist/components/SessionWatcher/SessionWatcher.d.ts +1 -0
  43. package/dist/components/SessionWatcher/SessionWatcher.js +20 -0
  44. package/dist/components/SessionWatcher/index.d.ts +1 -0
  45. package/dist/components/SessionWatcher/index.js +1 -0
  46. package/dist/components/SignIn/utils.d.ts +8 -0
  47. package/dist/components/SignIn/utils.js +26 -0
  48. package/dist/components/TopProgress/TopProgressBar.js +4 -0
  49. package/dist/components/TopProgress/index.d.ts +1 -0
  50. package/dist/components/TopProgress/index.js +1 -0
  51. package/dist/constants/Branches.d.ts +2 -0
  52. package/dist/constants/Branches.js +42 -0
  53. package/dist/constants/EnvVar.d.ts +1 -1
  54. package/dist/images/responsible-gaming-yellow.png +0 -0
  55. package/dist/services/queries.d.ts +1 -1
  56. package/dist/services/queries.js +2 -0
  57. package/dist/third-parties/FacebookPixel/FacebookPixel.d.ts +4 -0
  58. package/dist/third-parties/FacebookPixel/FacebookPixel.js +4 -0
  59. package/dist/third-parties/FacebookPixel/api.d.ts +0 -0
  60. package/dist/third-parties/FacebookPixel/api.js +1 -0
  61. package/dist/third-parties/FacebookPixel/index.d.ts +1 -0
  62. package/dist/third-parties/FacebookPixel/index.js +1 -0
  63. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.d.ts +4 -0
  64. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.js +4 -0
  65. package/dist/third-parties/GoogleRecaptcha/api.d.ts +0 -0
  66. package/dist/third-parties/GoogleRecaptcha/api.js +1 -0
  67. package/dist/third-parties/GoogleRecaptcha/index.d.ts +1 -0
  68. package/dist/third-parties/GoogleRecaptcha/index.js +1 -0
  69. package/dist/third-parties/index.d.ts +2 -0
  70. package/dist/third-parties/index.js +2 -0
  71. package/dist/types/index.d.ts +2 -0
  72. package/dist/ui/AlertDialog/AlertDialog.d.ts +121 -121
  73. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +11 -11
  74. package/dist/ui/Badge/Badge.d.ts +12 -12
  75. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  76. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  77. package/dist/ui/Carousel/Carousel.d.ts +72 -72
  78. package/dist/ui/Carousel/carousel.recipe.d.ts +8 -8
  79. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  80. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  81. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  82. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  83. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  84. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  85. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  86. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  87. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  88. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  89. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  90. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  91. package/dist/ui/Field/Field.d.ts +21 -21
  92. package/dist/ui/Field/field.recipe.d.ts +3 -3
  93. package/dist/ui/Menu/Menu.d.ts +90 -90
  94. package/dist/ui/Menu/menu.recipe.d.ts +5 -5
  95. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  96. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  97. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  98. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  99. package/dist/ui/PinInput/PinInput.d.ts +12 -12
  100. package/dist/ui/PinInput/pinInput.recipe.d.ts +3 -3
  101. package/dist/ui/Progress/Progress.d.ts +27 -27
  102. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  103. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  104. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  105. package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
  106. package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
  107. package/dist/ui/Select/Select.d.ts +45 -45
  108. package/dist/ui/Select/select.recipe.d.ts +3 -3
  109. package/dist/ui/Table/Table.d.ts +21 -21
  110. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  111. package/dist/ui/Table/table.recipe.d.ts +3 -3
  112. package/package.json +1 -1
  113. package/dist/tsconfig.build.tsbuildinfo +0 -1
@@ -13,7 +13,7 @@ import { User01Icon } from '../../../icons/User01Icon.js';
13
13
  import firstPlace from '../../../images/first-place.png';
14
14
  import leaderboard from '../../../images/leaderboard.png';
15
15
  import { formatNumber } from '../../../utils/formatNumber.js';
16
- import { mask } from '../../../utils/mask.js';
16
+ import { mask, maskFirstLast } from '../../../utils/mask.js';
17
17
  import { parseDecimal } from '../../../utils/parseDecimal.js';
18
18
  import styles from '../Jackpots.module.css';
19
19
  import { useJackpotsListItemContext } from './JackpotsListContext.js';
@@ -48,25 +48,24 @@ export function JackpotMultiStageDesktop({ animate = true, customJackpotChestIma
48
48
  };
49
49
  };
50
50
  const chestImages = getChestImages(jackpot.stage ?? 1);
51
- const target = parseFloat(jackpot.stages?.[jackpot.stage - 1]?.targetTurnover ?? '0');
52
- const total = parseFloat(jackpot.totalTurnover ?? '0');
53
- const currStageProgressPercentage = getPercentage(total, target);
54
- const totalTurnover = jackpot.totalTurnover;
55
- const overallTurnover = parseDecimal(jackpot.totalTurnover, 0) /
56
- (jackpot.stages?.reduce((acc, stage) => acc + parseFloat(stage.targetTurnover ?? '0'), 0) ?? 0);
57
- const overallPercentage = getPercentage(totalTurnover, overallTurnover);
58
- console.log(jackpot.stages, 'jackpot.stages');
59
- console.log(jackpot.stage, 'jackpot.stage');
51
+ const parsed = parseInt(jackpot.currentStageProgressPercentage?.toString() ?? '0');
52
+ const currStageProgressPercentage = Number.isNaN(parsed)
53
+ ? 0
54
+ : parsed > 100
55
+ ? 100
56
+ : parsed;
57
+ const overallPercentage = parseInt(jackpot.overallProgressPercentage ?? '0');
58
+ const isCompleted = overallPercentage >= 100;
60
59
  const ProfileIcon = () => jackpotProfileShape === 'oval' ? (_jsxs("div", { className: "relative flex h-18 w-18 items-center justify-center rounded-full bg-bg-tertiary", children: [_jsx(User01Icon, { className: "size-9 text-text-quarterary-500" }), _jsx("div", { className: twMerge('absolute right-0 bottom-safe-area-inset-bottom flex h-6 w-6 items-center justify-center rounded-full border-[1.5px] border-bg-primary bg-yellow-400 font-bold text-brand-950 text-xs', className?.latestPayoutRankRoot), children: "1st" })] })) : (_jsxs("div", { className: "relative grid h-18 w-18", children: [_jsx(StarIcon, { className: "col-start-1 row-start-1 h-full w-full" }), _jsx(User01Icon, { className: "z-10 col-start-1 row-start-1 size-9 place-self-center text-text-quarterary-500" }), _jsx("div", { className: twMerge('-right-0 absolute bottom-safe-area-inset-bottom z-20 flex h-7 w-7 items-center justify-center rounded-full border-[1.5px] border-bg-primary bg-yellow-400 text-center font-bold text-brand-950 text-xs', className?.latestPayoutRankRoot), children: "1st" })] }));
61
60
  const PayoutBadge = () => (_jsxs("div", { className: twMerge('flex h-fit w-fit items-center gap-1 rounded-sm border border-utility-brand-200 bg-utility-brand-50 px-2 py-0.5 font-medium text-utility-brand-700 text-xs', className?.latestPayoutBadgeRoot), children: [_jsx(Trophy01Icon, { className: twMerge('size-3.5 text-utility-brand-600', className?.latestPayoutBadgeIcon) }), "Winner"] }));
62
- const ProgressBar = () => (_jsxs("div", { className: "mt-3 lg:mt-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "font-semibold text-sm text-text-primary-900", children: ["Stage ", jackpot.stage, " Progress"] }), currStageProgressPercentage, "%"] }), _jsx(Progress.Root, { className: "h-2 w-full rounded-full bg-bg-primary lg:h-4", max: 100, value: currStageProgressPercentage, children: _jsx(Progress.Track, { className: twMerge('h-full overflow-hidden rounded-full bg-bg-primary', className?.progressBarTrack), children: _jsx(Progress.Range, { className: "relative h-full overflow-hidden rounded-full bg-brand-500 pl-1.5", children: _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }) }) }) })] }));
61
+ const ProgressBar = () => (_jsxs("div", { className: "mt-3 lg:mt-4", children: [_jsxs("div", { className: "flex items-center justify-between", children: [_jsxs("div", { className: "font-semibold text-sm text-text-primary-900", children: ["Stage ", isCompleted ? (jackpot.stage ?? 1) - 1 : jackpot.stage, ' ', "Progress"] }), isCompleted ? 100 : currStageProgressPercentage, "%"] }), _jsx(Progress.Root, { className: "h-2 w-full rounded-full bg-bg-primary lg:h-4", max: 100, value: isCompleted ? 100 : currStageProgressPercentage, children: _jsx(Progress.Track, { className: twMerge('h-full overflow-hidden rounded-full bg-bg-primary', className?.progressBarTrack), children: _jsx(Progress.Range, { className: "relative h-full overflow-hidden rounded-full bg-brand-500 pl-1.5", children: _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }) }) }) })] }));
63
62
  const OverallProgressBar = () => {
64
63
  return (_jsxs("div", { className: "mt-3 lg:mt-4", children: [_jsxs("div", { className: "mb-[0.3125rem] flex items-center justify-between font-semibold text-sm text-text-primary-900", children: [_jsx("p", { children: "Overall Progress" }), overallPercentage, "%"] }), _jsx(Progress.Root, { className: "h-2 w-full rounded-full bg-bg-primary lg:h-4", max: 100, value: overallPercentage, children: _jsx(Progress.Track, { className: twMerge('h-full overflow-hidden rounded-full bg-bg-primary', className?.progressBarTrack), children: _jsx(Progress.Range, { className: "relative h-full overflow-hidden rounded-full bg-brand-500 pl-1.5", children: _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }) }) }) })] }));
65
64
  };
66
65
  const RecentPayoutsTable = () => (_jsx("div", { className: twMerge('max-h-[17rem] overflow-y-scroll', styles.scrollArea), children: _jsx("div", { className: "overflow-hidden rounded-xl border-gray-200", children: _jsxs("table", { className: "w-full", children: [_jsx("thead", { children: _jsx("tr", { className: twMerge('h-8 whitespace-nowrap bg-bg-secondary text-left font-medium text-text-tertiary-600 text-xs', className?.recentPayoutsTableHeadRow), children: ['Stage', 'Player', 'Turnover Target', 'Prize', 'Timestamp'].map((header) => (_jsx("th", { className: "px-4", children: header }, header))) }) }), _jsx("tbody", { children: jackpot.stages
67
66
  ? jackpot.stages.map((j, i) => (_jsxs("tr", { className: twMerge('whitespace-nowrap bg-bg-primary text-left text-sm text-text-secondary-700', className?.recentPayoutsTableBodyRow), children: [_jsx("td", { className: twMerge('h-12 border-border-secondary border-t-2 px-4', className?.recentPayoutsTableBodyData), children: i + 1 }), _jsx("td", { className: twMerge('h-12 border-border-secondary border-t-2 px-4', className?.recentPayoutsTableBodyData), children: j.member?.name
68
- ? mask(j.member.name, {
69
- totalCharsCount: 6,
67
+ ? maskFirstLast(j.member.name, {
68
+ firstCharsCount: 3,
70
69
  })
71
70
  : '-' }), _jsx("td", { className: twMerge('h-12 border-border-secondary border-t-2 px-4', className?.recentPayoutsTableBodyData), children: formatNumber(j.targetTurnover, {
72
71
  currency: localeInfo.currency.code,
@@ -84,7 +83,7 @@ export function JackpotMultiStageDesktop({ animate = true, customJackpotChestIma
84
83
  return null;
85
84
  }
86
85
  return (_jsxs("div", { ref: rootRef, className: twMerge('rounded-2xl border border-border-primary bg-bg-tertiary', className?.itemRoot), children: [_jsxs("div", { style: props.style, className: twMerge('relative flex shrink-0 rounded-2xl p-3 text-center lg:gap-4 lg:p-5', window.location.href.includes('blucky') &&
87
- styles['animate-multi-stage-gradient-blucky']), children: [_jsxs("div", { className: "relative z-1 flex flex-1 flex-col", children: [_jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsxs("div", { className: "flex w-full flex-col", children: [_jsxs("div", { className: "relative flex w-full justify-between", children: [_jsxs("div", { children: [_jsxs("div", { className: "flex gap-2.5", children: [_jsxs("div", { className: twMerge('flex w-fit items-center gap-1 rounded-full border border-[#3F100B] bg-[#CDA95B] px-2 py-0.5 font-medium text-[#1D0201] text-xs', className?.jackpotBadgeRoot), children: [_jsx(Flag05Icon, { className: "size-3.5 text-[inherit]" }), "Stage ", jackpot.stage] }), overallPercentage < 100 ? (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-blue-200 bg-utility-blue-50 px-2 py-0.5 font-medium text-utility-blue-700 text-xs", children: [_jsx(ArrowNarrowUpRightIcon, { className: "size-3.5 text-utility-blue-500" }), "In Progress"] })) : (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-success-200 bg-utility-success-50 px-2 py-0.5 font-medium text-utility-success-700 text-xs", children: [_jsx(CheckCircleBrokenIcon, { className: "size-3.5 text-utility-success-500" }), "Completed"] }))] }), _jsx("div", { className: "mt-1 text-left font-semibold text-lg text-text-primary-900 lg:mt-5 lg:text-2xl", children: jackpot.name }), _jsx("div", { className: twMerge('mt-1.5 w-fit rounded-md bg-bg-primary px-2 py-1 font-bold text-2xl text-brand-400 lg:mt-2 lg:text-4xl', className?.jackpotAmountRoot), children: formatNumber(jackpotAmount, {
86
+ styles['animate-multi-stage-gradient-blucky']), children: [_jsxs("div", { className: "relative z-1 flex flex-1 flex-col", children: [_jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsxs("div", { className: "flex w-full flex-col", children: [_jsxs("div", { className: "relative flex w-full justify-between", children: [_jsxs("div", { children: [_jsxs("div", { className: "flex gap-2.5", children: [_jsxs("div", { className: twMerge('flex w-fit items-center gap-1 rounded-full border border-[#3F100B] bg-[#CDA95B] px-2 py-0.5 font-medium text-[#1D0201] text-xs', className?.jackpotBadgeRoot), children: [_jsx(Flag05Icon, { className: "size-3.5 text-[inherit]" }), "Stage", ' ', isCompleted ? (jackpot.stage ?? 1) - 1 : jackpot.stage] }), !isCompleted ? (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-blue-200 bg-utility-blue-50 px-2 py-0.5 font-medium text-utility-blue-700 text-xs", children: [_jsx(ArrowNarrowUpRightIcon, { className: "size-3.5 text-utility-blue-500" }), "In Progress"] })) : (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-success-200 bg-utility-success-50 px-2 py-0.5 font-medium text-utility-success-700 text-xs", children: [_jsx(CheckCircleBrokenIcon, { className: "size-3.5 text-utility-success-500" }), "Completed"] }))] }), _jsx("div", { className: "mt-1 text-left font-semibold text-lg text-text-primary-900 lg:mt-5 lg:text-2xl", children: jackpot.name }), _jsx("div", { className: twMerge('mt-1.5 w-fit rounded-md bg-bg-primary px-2 py-1 font-bold text-2xl text-brand-400 lg:mt-2 lg:text-4xl', className?.jackpotAmountRoot), children: formatNumber(jackpotAmount, {
88
87
  currency: localeInfo.currency.code,
89
88
  minDecimalPlaces: 2,
90
89
  maxDecimalPlaces: 2,
@@ -17,7 +17,7 @@ import firstPlace from '../../../images/first-place.png';
17
17
  import leaderboard from '../../../images/leaderboard.png';
18
18
  import { Button } from '../../../ui/Button/index.js';
19
19
  import { formatNumber } from '../../../utils/formatNumber.js';
20
- import { mask } from '../../../utils/mask.js';
20
+ import { mask, maskFirstLast } from '../../../utils/mask.js';
21
21
  import { parseDecimal } from '../../../utils/parseDecimal.js';
22
22
  import styles from '../Jackpots.module.css';
23
23
  import { useJackpotsListItemContext } from './JackpotsListContext.js';
@@ -72,16 +72,17 @@ export function JackpotMultiStageMobile({ animate = true, customJackpotChestImag
72
72
  return () => clearTimeout(timeout);
73
73
  }
74
74
  }, [minLimitTooltipOpen]);
75
- const target = parseFloat(jackpot.stages?.[jackpot.stage - 1]?.targetTurnover ?? '0');
76
- const total = parseFloat(jackpot.totalTurnover ?? '0');
77
- const currStageProgressPercentage = getPercentage(total, target);
78
- const totalTurnover = jackpot.totalTurnover;
79
- const overallTurnover = parseDecimal(jackpot.totalTurnover, 0) /
80
- (jackpot.stages?.reduce((acc, stage) => acc + parseFloat(stage.targetTurnover ?? '0'), 0) ?? 0);
81
- const overallPercentage = getPercentage(totalTurnover, overallTurnover);
75
+ const parsed = parseInt(jackpot.currentStageProgressPercentage?.toString() ?? '0');
76
+ const currStageProgressPercentage = Number.isNaN(parsed)
77
+ ? 0
78
+ : parsed > 100
79
+ ? 100
80
+ : parsed;
81
+ const overallPercentage = parseInt(jackpot.overallProgressPercentage ?? '0');
82
+ const isCompleted = overallPercentage >= 100;
82
83
  const ProfileIcon = () => jackpotProfileShape === 'oval' ? (_jsxs("div", { className: "relative flex h-18 w-18 items-center justify-center rounded-full bg-bg-tertiary", children: [_jsx(User01Icon, { className: "size-9 text-text-quarterary-500" }), _jsx("div", { className: twMerge('absolute right-0 bottom-safe-area-inset-bottom flex h-6 w-6 items-center justify-center rounded-full border-[1.5px] border-bg-primary bg-yellow-400 font-bold text-brand-950 text-xs', className?.latestPayoutRankRoot), children: "1st" })] })) : (_jsxs("div", { className: "relative grid h-18 w-18", children: [_jsx(StarIcon, { className: "col-start-1 row-start-1 h-full w-full" }), _jsx(User01Icon, { className: "z-10 col-start-1 row-start-1 size-9 place-self-center text-text-quarterary-500" }), _jsx("div", { className: twMerge('-right-0 absolute bottom-safe-area-inset-bottom z-20 flex h-7 w-7 items-center justify-center rounded-full border-[1.5px] border-bg-primary bg-yellow-400 text-center font-bold text-brand-950 text-xs', className?.latestPayoutRankRoot), children: "1st" })] }));
83
84
  const PayoutBadge = () => (_jsxs("div", { className: twMerge('flex h-fit w-fit items-center gap-1 rounded-sm border border-utility-brand-200 bg-utility-brand-50 px-2 py-0.5 font-medium text-utility-brand-700 text-xs', className?.latestPayoutBadgeRoot), children: [_jsx(Trophy01Icon, { className: twMerge('size-3.5 text-utility-brand-600', className?.latestPayoutBadgeIcon) }), "Winner"] }));
84
- const ProgressBar = () => (_jsxs("div", { className: "flex w-full flex-col items-center justify-between", children: [_jsxs("div", { className: "mb-[5px] flex w-full items-center justify-between", children: [_jsxs("div", { className: "font-semibold text-text-primary-900 text-xs", children: ["Stage ", jackpot.stage, " Progress"] }), currStageProgressPercentage, "%"] }), _jsx(Progress.Root, { className: "h-2 w-full rounded-full bg-bg-primary", max: 100, value: currStageProgressPercentage, "aria-valuemax": 100, "aria-label": "Stage progress", children: _jsx(Progress.Track, { className: twMerge('h-full overflow-hidden rounded-full bg-bg-primary', className?.progressBarTrack), children: _jsx(Progress.Range, { className: "relative h-full overflow-hidden rounded-full bg-brand-500 pl-1.5", children: _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }) }) }) })] }));
85
+ const ProgressBar = () => (_jsxs("div", { className: "flex w-full flex-col items-center justify-between", children: [_jsxs("div", { className: "mb-[5px] flex w-full items-center justify-between", children: [_jsxs("div", { className: "font-semibold text-text-primary-900 text-xs", children: ["Stage ", isCompleted ? (jackpot.stage ?? 1) - 1 : jackpot.stage, ' '] }), isCompleted ? 100 : currStageProgressPercentage, "%"] }), _jsx(Progress.Root, { className: "h-2 w-full rounded-full bg-bg-primary", max: 100, value: isCompleted ? 100 : currStageProgressPercentage, "aria-valuemax": 100, "aria-label": "Stage progress", children: _jsx(Progress.Track, { className: twMerge('h-full overflow-hidden rounded-full bg-bg-primary', className?.progressBarTrack), children: _jsx(Progress.Range, { className: "relative h-full overflow-hidden rounded-full bg-brand-500 pl-1.5", children: _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }) }) }) })] }));
85
86
  const OverallProgressBar = () => {
86
87
  return (_jsxs("div", { className: twMerge('mt-3 mb-[1rem] px-[0.75rem] lg:mt-4', className?.jackpotOverallProgressBarRoot), children: [_jsxs("div", { className: "mb-[5px] flex items-center justify-between font-semibold text-text-primary-900 text-xs", children: [_jsx("p", { children: "Overall Progress" }), overallPercentage, "%"] }), _jsx(Progress.Root, { className: "h-2 w-full rounded-full bg-bg-primary lg:h-4", max: 100, value: overallPercentage, children: _jsx(Progress.Track, { className: twMerge('h-full overflow-hidden rounded-full bg-bg-primary', className?.progressBarTrack), children: _jsx(Progress.Range, { className: "relative h-full overflow-hidden rounded-full bg-brand-500 pl-1.5", children: _jsx("div", { className: "pointer-events-none absolute inset-0 flex items-center justify-start pl-1.5", "aria-hidden": "true", children: arrowImages }) }) }) })] }));
87
88
  };
@@ -106,7 +107,7 @@ export function JackpotMultiStageMobile({ animate = true, customJackpotChestImag
106
107
  return null;
107
108
  }
108
109
  return (_jsxs("div", { ref: rootRef, className: twMerge('rounded-2xl border border-border-primary bg-bg-primary', className?.itemRoot), children: [_jsxs("div", { style: props.style, className: twMerge('relative flex shrink-0 rounded-2xl bg-bg-tertiary p-3 text-center lg:gap-4 lg:p-5', window.location.href.includes('blucky') &&
109
- styles['animate-multi-stage-gradient-blucky']), children: [_jsxs("div", { className: "relative z-1 flex flex-1 flex-col", children: [_jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsx("div", { className: "flex w-full flex-col", children: _jsxs("div", { className: "relative flex w-full items-center justify-between", children: [_jsxs("div", { className: "w-full", children: [_jsxs("div", { className: "flex gap-2.5", children: [_jsxs("div", { className: twMerge('flex w-fit items-center gap-1 rounded-full border border-[#3F100B] bg-[#CDA95B] px-2 py-0.5 font-medium text-[#1D0201] text-xs', className?.jackpotBadgeRoot), children: [_jsx(Flag05Icon, { className: "size-3.5 text-[inherit]" }), "Stage ", jackpot.stage] }), overallPercentage < 100 ? (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-blue-200 bg-utility-blue-50 px-2 py-0.5 font-medium text-utility-blue-700 text-xs", children: [_jsx(ArrowNarrowUpRightIcon, { className: "size-3.5 text-utility-blue-500" }), "In Progress"] })) : (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-success-200 bg-utility-success-50 px-2 py-0.5 font-medium text-utility-success-700 text-xs", children: [_jsx(CheckCircleBrokenIcon, { className: "size-3.5 text-utility-success-500" }), "Completed"] }))] }), _jsx("div", { className: "mt-1 text-left font-medium text-lg text-text-primary-900 lg:mt-5 lg:text-2xl", children: jackpot.name }), _jsx("div", { className: twMerge('mt-1.5 w-fit rounded-md bg-bg-primary px-2 py-1 font-bold text-2xl text-brand-400 lg:mt-2 lg:text-4xl', className?.jackpotAmountRoot), children: formatNumber(jackpotAmount, {
110
+ styles['animate-multi-stage-gradient-blucky']), children: [_jsxs("div", { className: "relative z-1 flex flex-1 flex-col", children: [_jsx("div", { className: "flex h-full flex-col justify-between", children: _jsx("div", { className: "flex w-full justify-between", children: _jsx("div", { className: "flex w-full flex-col", children: _jsxs("div", { className: "relative flex w-full items-center justify-between", children: [_jsxs("div", { className: "w-full", children: [_jsxs("div", { className: "flex gap-2.5", children: [_jsxs("div", { className: twMerge('flex w-fit items-center gap-1 rounded-full border border-[#3F100B] bg-[#CDA95B] px-2 py-0.5 font-medium text-[#1D0201] text-xs', className?.jackpotBadgeRoot), children: [_jsx(Flag05Icon, { className: "size-3.5 text-[inherit]" }), "Stage", ' ', isCompleted ? (jackpot.stage ?? 1) - 1 : jackpot.stage] }), !isCompleted ? (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-blue-200 bg-utility-blue-50 px-2 py-0.5 font-medium text-utility-blue-700 text-xs", children: [_jsx(ArrowNarrowUpRightIcon, { className: "size-3.5 text-utility-blue-500" }), "In Progress"] })) : (_jsxs("div", { className: "flex w-fit items-center gap-1 rounded-full border border-utility-success-200 bg-utility-success-50 px-2 py-0.5 font-medium text-utility-success-700 text-xs", children: [_jsx(CheckCircleBrokenIcon, { className: "size-3.5 text-utility-success-500" }), "Completed"] }))] }), _jsx("div", { className: "mt-1 text-left font-medium text-lg text-text-primary-900 lg:mt-5 lg:text-2xl", children: jackpot.name }), _jsx("div", { className: twMerge('mt-1.5 w-fit rounded-md bg-bg-primary px-2 py-1 font-bold text-2xl text-brand-400 lg:mt-2 lg:text-4xl', className?.jackpotAmountRoot), children: formatNumber(jackpotAmount, {
110
111
  currency: localeInfo.currency.code,
111
112
  minDecimalPlaces: 2,
112
113
  maxDecimalPlaces: 2,
@@ -114,8 +115,8 @@ export function JackpotMultiStageMobile({ animate = true, customJackpotChestImag
114
115
  currency: localeInfo.currency.code,
115
116
  minDecimalPlaces: 2,
116
117
  maxDecimalPlaces: 2,
117
- })] })] }), _jsx(ProgressBar, {})] }), chestImages?.image && (_jsx("div", { className: twMerge('right-0 bottom-[-60] z-1 block min-w-34.5 lg:absolute', chestImages?.style?.wrapper), children: _jsx(Image, { width: 100, height: 100, src: chestImages?.image, alt: "chest", className: twMerge('size-full h-34.5 w-34.5 p-2 lg:h-37.5 lg:w-37.5', chestImages?.style?.image) }) }))] }) }) }) }), _jsx("div", { className: twMerge('relative mt-4 flex w-full gap-4 rounded-lg bg-bg-primary p-4', className?.latestPayoutRoot), children: topJackpotPayout?.amount ? (_jsxs(_Fragment, { children: [_jsx(ProfileIcon, {}), _jsxs("div", { className: "flex flex-col gap-1 text-left", children: [_jsx(PayoutBadge, {}), _jsx("div", { className: "font-semibold", children: mask(topJackpotPayout.member.name, {
118
- totalCharsCount: 6,
118
+ })] })] }), _jsx(ProgressBar, {})] }), chestImages?.image && (_jsx("div", { className: twMerge('right-0 bottom-[-60] z-1 block min-w-34.5 lg:absolute', chestImages?.style?.wrapper), children: _jsx(Image, { width: 100, height: 100, src: chestImages?.image, alt: "chest", className: twMerge('size-full h-34.5 w-34.5 p-2 lg:h-37.5 lg:w-37.5', chestImages?.style?.image) }) }))] }) }) }) }), _jsx("div", { className: twMerge('relative mt-4 flex w-full gap-4 rounded-lg bg-bg-primary p-4', className?.latestPayoutRoot), children: topJackpotPayout?.amount ? (_jsxs(_Fragment, { children: [_jsx(ProfileIcon, {}), _jsxs("div", { className: "flex flex-col gap-1 text-left", children: [_jsx(PayoutBadge, {}), _jsx("div", { className: "font-semibold", children: maskFirstLast(topJackpotPayout.member.name, {
119
+ firstCharsCount: 3,
119
120
  }) }), _jsx("div", { className: twMerge('text-2xl text-brand-400', className?.latestPayoutAmount), children: formatNumber(topJackpotPayout.amount, {
120
121
  currency: localeInfo.currency.code,
121
122
  minDecimalPlaces: 2,
@@ -0,0 +1 @@
1
+ export declare function BasicInformation(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { zodResolver } from '@hookform/resolvers/zod';
3
+ import { differenceInYears, format, isSameDay, isValid, parse } from 'date-fns';
4
+ import { isNil, omitBy, size } from 'lodash-es';
5
+ import { useEffect } from 'react';
6
+ import { useForm } from 'react-hook-form';
7
+ import invariant from 'tiny-invariant';
8
+ import { z } from 'zod';
9
+ import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
10
+ import { useUpdateAccountMutation } from '../../client/hooks/useUpdateAccountMutation.js';
11
+ import { toaster } from '../../client/utils/toaster.js';
12
+ import { Button } from '../../ui/Button/index.js';
13
+ import { Dialog } from '../../ui/Dialog/index.js';
14
+ import { Field } from '../../ui/Field/index.js';
15
+ import { useKYCContext } from './KYCContext.js';
16
+ const definition = z.object({
17
+ realName: z
18
+ .string()
19
+ .min(3, 'Name must be 3 or more characters')
20
+ .max(50, 'Name must not be more than 50 characters')
21
+ .regex(/^[a-z0-9 ]+$/gi, 'Name must not contain special characters')
22
+ .trim(),
23
+ birthDay: z
24
+ .string()
25
+ .min(1, 'Date of birth is required')
26
+ .superRefine((value, ctx) => {
27
+ const dob = parse(value, 'yyyy-MM-dd', new Date());
28
+ if (!isValid(dob)) {
29
+ return ctx.addIssue({
30
+ code: z.ZodIssueCode.invalid_date,
31
+ });
32
+ }
33
+ const now = new Date();
34
+ const age = differenceInYears(now, dob);
35
+ if (age < 21) {
36
+ return ctx.addIssue({
37
+ code: z.ZodIssueCode.custom,
38
+ message: 'You must be at least 21 years old',
39
+ });
40
+ }
41
+ }),
42
+ branchCode: z.string().min(4).max(10).optional().or(z.literal('')),
43
+ });
44
+ export function BasicInformation() {
45
+ const kyc = useKYCContext();
46
+ const form = useForm({
47
+ resolver: zodResolver(definition),
48
+ mode: 'all',
49
+ defaultValues: {
50
+ birthDay: '',
51
+ branchCode: '',
52
+ realName: '',
53
+ },
54
+ });
55
+ const accountQuery = useAccountQuery();
56
+ const account = accountQuery.data;
57
+ const stepCompleted = account != null && account.realName != null && account.birthDay != null;
58
+ useEffect(() => {
59
+ if (stepCompleted)
60
+ kyc.setStep(2);
61
+ }, [stepCompleted, kyc]);
62
+ useEffect(() => {
63
+ if (account) {
64
+ form.reset({
65
+ realName: account.realName ?? '',
66
+ birthDay: account.birthDay
67
+ ? format(account.birthDay, 'yyyy-MM-dd')
68
+ : '',
69
+ });
70
+ }
71
+ }, [account, form]);
72
+ const updateAccountMutation = useUpdateAccountMutation({
73
+ onError(error) {
74
+ toaster.error({
75
+ title: 'Error',
76
+ description: error.message,
77
+ });
78
+ },
79
+ onSuccess() {
80
+ kyc.setStep(2);
81
+ toaster.success({
82
+ title: 'Success',
83
+ description: 'Basic information has been set successfully.',
84
+ });
85
+ },
86
+ });
87
+ return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Basic Information" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Enter your basic details for identification and communication." }), _jsxs("form", { className: "mt-3", onSubmit: form.handleSubmit((data) => {
88
+ invariant(account);
89
+ const input = omitBy({
90
+ realName: account.realName === data.realName ? undefined : data.realName,
91
+ birthDay: account.birthDay && isSameDay(data.birthDay, account.birthDay)
92
+ ? undefined
93
+ : format(data.birthDay, 'yyyy-MM-dd'),
94
+ }, isNil);
95
+ if (size(input) === 0)
96
+ return kyc.setStep(2);
97
+ updateAccountMutation.mutate(input);
98
+ }), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.realName, readOnly: !!accountQuery.data?.realName, children: [_jsx(Field.Label, { children: "Real Name" }), _jsx(Field.Input, { placeholder: "Enter your real name", ...form.register('realName') }), _jsx(Field.ErrorText, { children: form.formState.errors.realName?.message })] }), _jsxs(Field.Root, { className: "mt-3", invalid: !!form.formState.errors.branchCode, readOnly: !!accountQuery.data?.birthDay, children: [_jsx(Field.Label, { children: "Date of Birth" }), _jsx(Field.Input, { type: "date", ...form.register('birthDay') }), _jsx(Field.ErrorText, { children: form.formState.errors.birthDay?.message })] }), _jsx(Button, { type: "submit", className: "mt-8", disabled: accountQuery.isLoading ||
99
+ updateAccountMutation.isPending ||
100
+ stepCompleted, children: "Continue" })] })] }));
101
+ }
@@ -0,0 +1 @@
1
+ export declare function IdentityVerification(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,120 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { zodResolver } from '@hookform/resolvers/zod';
4
+ import { useEffect } from 'react';
5
+ import { Controller, useForm } from 'react-hook-form';
6
+ import { z } from 'zod';
7
+ import { useShallow } from 'zustand/shallow';
8
+ import { useCreateMemberVerificationMutation } from '../../client/hooks/useCreateMemberVerificationMutation.js';
9
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
10
+ import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
11
+ import { useUpdateMemberVerificationMutation } from '../../client/hooks/useUpdateMemberVerificationMutation.js';
12
+ import { toaster } from '../../client/utils/toaster.js';
13
+ import { Button } from '../../ui/Button/index.js';
14
+ import { Dialog } from '../../ui/Dialog/index.js';
15
+ import { Field } from '../../ui/Field/index.js';
16
+ import { getQueryClient } from '../../utils/getQueryClient.js';
17
+ import { getMemberVerificationQueryKey } from '../../utils/queryKeys.js';
18
+ import { IdFrontImageField } from '../shared/IdFrontImageField/index.js';
19
+ import { SelfieImageField } from '../shared/SelfieImageField/index.js';
20
+ import { useKYCContext } from './KYCContext.js';
21
+ const formSchema = z.object({
22
+ selfieImage: z.string().min(1, 'Selfie image is required.'),
23
+ idFrontImage: z.string().min(1, 'Front image of ID is required.'),
24
+ });
25
+ export function IdentityVerification() {
26
+ const kyc = useKYCContext();
27
+ const { mutate: createMemberVerification, isPending: createPending } = useCreateMemberVerificationMutation({
28
+ onSuccess: () => {
29
+ toaster.success({
30
+ title: 'ID Front Image & Selfie Image uploaded successfully',
31
+ });
32
+ },
33
+ onError: (error) => {
34
+ toaster.error({
35
+ title: 'Failed to upload ID Front Image & Selfie Image',
36
+ description: error.message,
37
+ });
38
+ },
39
+ });
40
+ const { mutate: updateMemberVerification, isPending: updatePending } = useUpdateMemberVerificationMutation({
41
+ onSuccess: () => {
42
+ const queryClient = getQueryClient();
43
+ toaster.success({
44
+ title: 'ID Front Image & Selfie Image updated successfully',
45
+ });
46
+ queryClient.setQueryData(getMemberVerificationQueryKey(), (prev) => {
47
+ if (!prev)
48
+ return prev;
49
+ return {
50
+ ...prev,
51
+ status: 'CREATED',
52
+ };
53
+ });
54
+ },
55
+ onError: (error) => {
56
+ toaster.error({
57
+ title: 'Failed to upload ID Front Image & Selfie Image',
58
+ description: error.message,
59
+ });
60
+ },
61
+ });
62
+ const memberVerification = useMemberVerificationQuery();
63
+ const memberId = memberVerification.data?.id;
64
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
65
+ kyc: ctx.kyc,
66
+ })));
67
+ const form = useForm({
68
+ resolver: zodResolver(formSchema),
69
+ defaultValues: {
70
+ idFrontImage: '',
71
+ selfieImage: '',
72
+ },
73
+ });
74
+ function onSubmit(values) {
75
+ if (!memberId) {
76
+ createMemberVerification({
77
+ selfieImage: values.selfieImage,
78
+ idFrontImage: values.idFrontImage,
79
+ address: '',
80
+ nationality: '',
81
+ natureOfWork: '',
82
+ permanentAddress: '',
83
+ placeOfBirth: '',
84
+ sourceOfIncome: '',
85
+ });
86
+ kyc.setStep(3);
87
+ }
88
+ else {
89
+ updateMemberVerification({
90
+ id: memberId,
91
+ data: {
92
+ selfieImage: values.selfieImage,
93
+ idFrontImage: values.idFrontImage,
94
+ },
95
+ });
96
+ kyc.setStep(3);
97
+ }
98
+ }
99
+ useEffect(() => {
100
+ if (kyc.selfieImageId)
101
+ form.setValue('selfieImage', kyc.selfieImageId);
102
+ if (kyc.idFrontImageId)
103
+ form.setValue('idFrontImage', kyc.idFrontImageId);
104
+ }, [form, kyc.idFrontImageId, kyc.selfieImageId]);
105
+ return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Verify your identity" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Verify your details to confirm your identity and secure your access." }), _jsxs("div", { className: "mt-7 rounded-xl border border-border-primary bg-bg-primary p-lg text-text-placeholder text-xs leading-tight", children: [_jsx("h3", { className: "font-semibold", children: "Instructions" }), _jsxs("ol", { className: "mt-2 list-inside list-decimal", children: [_jsx("li", { children: "Upload a full photo of your ID." }), _jsx("li", { children: "Please ensure that all details in the uploaded image are legible." }), _jsx("li", { children: "Please ensure that the ID uploaded is within the validity period." })] })] }), _jsxs("form", { className: "mt-xl", onSubmit: form.handleSubmit(onSubmit), children: [_jsx(Controller, { control: form.control, name: "idFrontImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, children: [_jsx(Field.Label, { children: "Front of your ID" }), _jsx(IdFrontImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
106
+ form.setValue('idFrontImage', '');
107
+ form.setError('idFrontImage', {
108
+ type: 'validate',
109
+ message: error.message,
110
+ });
111
+ } }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Controller, { control: form.control, name: "selfieImage", render: (o) => (_jsxs(Field.Root, { invalid: o.fieldState.invalid, className: "mt-3", children: [_jsx(Field.Label, { children: "Selfie holding your ID" }), _jsx(SelfieImageField, { value: o.field.value, onChange: o.field.onChange, onError: (error) => {
112
+ form.setValue('selfieImage', '');
113
+ form.setError('selfieImage', {
114
+ type: 'validate',
115
+ message: error.message,
116
+ });
117
+ } }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-6", disabled: createPending || updatePending, children: "Continue" }), _jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", type: "button", onClick: () => {
118
+ globalStore.kyc.setOpen(false);
119
+ }, children: "Skip for now" })] })] }));
120
+ }
@@ -0,0 +1 @@
1
+ export declare function Indicator(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,8 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { noop } from 'lodash-es';
3
+ import { Progress } from '../../ui/Progress/index.js';
4
+ import { useKYCContext } from './KYCContext.js';
5
+ export function Indicator() {
6
+ const kyc = useKYCContext();
7
+ return (_jsxs("div", { className: "flex items-center justify-center gap-1.5 py-3", children: [_jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step > 1 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) }), _jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step > 2 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) }), _jsx(Progress.Root, { className: "w-10 shrink-0", value: kyc.step === 3 ? 100 : 0, onValueChange: noop, children: _jsx(Progress.Track, { className: "bg-bg-primary-hover", children: _jsx(Progress.Range, {}) }) })] }));
8
+ }
@@ -0,0 +1,6 @@
1
+ import type { ImageProps } from 'next/image';
2
+ import { type KYCReminderProps } from './KYCReminder.lazy';
3
+ export interface KYCProps extends KYCReminderProps {
4
+ logo: ImageProps['src'];
5
+ }
6
+ export declare function KYC(props: KYCProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,45 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import Image from 'next/image';
3
+ import { useEffect } from 'react';
4
+ import { useShallow } from 'zustand/shallow';
5
+ import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
6
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
+ import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
8
+ import { XIcon } from '../../icons/XIcon.js';
9
+ import { Dialog } from '../../ui/Dialog/index.js';
10
+ import { Portal } from '../../ui/Portal/index.js';
11
+ import { BasicInformation } from './BasicInformation.js';
12
+ import { IdentityVerification } from './IdentityVerification.js';
13
+ import { Indicator } from './Indicator.js';
14
+ import { KYCContext } from './KYCContext.js';
15
+ import { KYCReminder } from './KYCReminder.lazy.js';
16
+ import { PersonalInformation } from './PersonalInformation.js';
17
+ import { useKYC } from './useKYC.js';
18
+ export function KYC(props) {
19
+ const globalStore = useGlobalStore(useShallow((ctx) => ({ kyc: ctx.kyc })));
20
+ const kyc = useKYC();
21
+ const { data: account } = useAccountQuery();
22
+ const { data: verification } = useMemberVerificationQuery();
23
+ const isBasicInfoCompleted = account?.realName !== null && account?.birthDay !== null;
24
+ const isUploadCompleted = Boolean(verification?.idFrontImage) && Boolean(verification?.selfieImage);
25
+ const isVerified = Boolean(verification?.status === 'VERIFIED') ||
26
+ Boolean(verification?.status === 'PENDING') ||
27
+ Boolean(verification?.status === 'APPROVED');
28
+ const isRejected = Boolean(verification?.status === 'REJECTED');
29
+ const hasMissingData = !isBasicInfoCompleted || !isUploadCompleted || !isVerified;
30
+ const steps = !isBasicInfoCompleted
31
+ ? 1
32
+ : !isUploadCompleted
33
+ ? 2
34
+ : isRejected
35
+ ? 2
36
+ : 3;
37
+ useEffect(() => {
38
+ if (steps) {
39
+ kyc.setStep(steps);
40
+ }
41
+ }, [steps, kyc]);
42
+ return (_jsxs(_Fragment, { children: [_jsx(KYCContext, { value: kyc, children: _jsx(Dialog.Root, { open: globalStore.kyc.open && hasMissingData, onOpenChange: (details) => {
43
+ globalStore.kyc.setOpen(details.open);
44
+ }, lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsx(Dialog.Content, { className: "mx-auto min-h-full w-full overflow-y-auto bg-bg-primary-alt lg:min-h-auto lg:w-fit", children: _jsxs("div", { className: "flex h-dvh w-full flex-col overflow-y-auto p-3xl sm:h-fit sm:overflow-auto lg:w-[400px]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx(Image, { src: props.logo, alt: "", width: 200, height: 100, className: "mx-auto mb-5 block h-7.5 w-auto", draggable: false }), _jsx(Indicator, {}), kyc.step === 1 && _jsx(BasicInformation, {}), kyc.step === 2 && _jsx(IdentityVerification, {}), kyc.step === 3 && _jsx(PersonalInformation, {})] }) }) })] }) }) }), _jsx(KYCReminder, { ...props })] }));
45
+ }
@@ -0,0 +1,6 @@
1
+ import type { UseKYCReturn } from './useKYC';
2
+ export declare const KYCContext: (props: {
3
+ value: UseKYCReturn;
4
+ } & {
5
+ children?: import("react").ReactNode | undefined;
6
+ }) => React.ReactNode, useKYCContext: () => UseKYCReturn;
@@ -0,0 +1,2 @@
1
+ import { createContext } from '../../client/utils/createContext.js';
2
+ export const [KYCContext, useKYCContext] = createContext();
@@ -0,0 +1 @@
1
+ export declare function BasicInformation(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,101 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { zodResolver } from '@hookform/resolvers/zod';
3
+ import { differenceInYears, format, isSameDay, isValid, parse } from 'date-fns';
4
+ import { isNil, omitBy, size } from 'lodash-es';
5
+ import { useEffect } from 'react';
6
+ import { useForm } from 'react-hook-form';
7
+ import invariant from 'tiny-invariant';
8
+ import { z } from 'zod';
9
+ import { useAccountQuery } from '../../../client/hooks/useAccountQuery.js';
10
+ import { useUpdateAccountMutation } from '../../../client/hooks/useUpdateAccountMutation.js';
11
+ import { toaster } from '../../../client/utils/toaster.js';
12
+ import { Button } from '../../../ui/Button/index.js';
13
+ import { Dialog } from '../../../ui/Dialog/index.js';
14
+ import { Field } from '../../../ui/Field/index.js';
15
+ import { useKYCDefaultContext } from './KYCDefaultContext.js';
16
+ const definition = z.object({
17
+ realName: z
18
+ .string()
19
+ .min(3, 'Name must be 3 or more characters')
20
+ .max(50, 'Name must not be more than 50 characters')
21
+ .regex(/^[a-z0-9 ]+$/gi, 'Name must not contain special characters')
22
+ .trim(),
23
+ birthDay: z
24
+ .string()
25
+ .min(1, 'Date of birth is required')
26
+ .superRefine((value, ctx) => {
27
+ const dob = parse(value, 'yyyy-MM-dd', new Date());
28
+ if (!isValid(dob)) {
29
+ return ctx.addIssue({
30
+ code: z.ZodIssueCode.invalid_date,
31
+ });
32
+ }
33
+ const now = new Date();
34
+ const age = differenceInYears(now, dob);
35
+ if (age < 21) {
36
+ return ctx.addIssue({
37
+ code: z.ZodIssueCode.custom,
38
+ message: 'You must be at least 21 years old',
39
+ });
40
+ }
41
+ }),
42
+ branchCode: z.string().min(4).max(10).optional().or(z.literal('')),
43
+ });
44
+ export function BasicInformation() {
45
+ const kyc = useKYCDefaultContext();
46
+ const form = useForm({
47
+ resolver: zodResolver(definition),
48
+ mode: 'all',
49
+ defaultValues: {
50
+ birthDay: '',
51
+ branchCode: '',
52
+ realName: '',
53
+ },
54
+ });
55
+ const accountQuery = useAccountQuery();
56
+ const account = accountQuery.data;
57
+ const stepCompleted = account != null && account.realName != null && account.birthDay != null;
58
+ useEffect(() => {
59
+ if (stepCompleted)
60
+ kyc.setStep(2);
61
+ }, [stepCompleted, kyc]);
62
+ useEffect(() => {
63
+ if (account) {
64
+ form.reset({
65
+ realName: account.realName ?? '',
66
+ birthDay: account.birthDay
67
+ ? format(account.birthDay, 'yyyy-MM-dd')
68
+ : '',
69
+ });
70
+ }
71
+ }, [account, form]);
72
+ const updateAccountMutation = useUpdateAccountMutation({
73
+ onError(error) {
74
+ toaster.error({
75
+ title: 'Error',
76
+ description: error.message,
77
+ });
78
+ },
79
+ onSuccess() {
80
+ kyc.setStep(2);
81
+ toaster.success({
82
+ title: 'Success',
83
+ description: 'Basic information has been set successfully.',
84
+ });
85
+ },
86
+ });
87
+ return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center font-semibold text-lg", children: "Basic Information" }), _jsx(Dialog.Description, { className: "mt-xs text-center text-sm text-text-secondary-700", children: "Enter your basic details for identification and communication." }), _jsxs("form", { className: "mt-3", onSubmit: form.handleSubmit((data) => {
88
+ invariant(account);
89
+ const input = omitBy({
90
+ realName: account.realName === data.realName ? undefined : data.realName,
91
+ birthDay: account.birthDay && isSameDay(data.birthDay, account.birthDay)
92
+ ? undefined
93
+ : format(data.birthDay, 'yyyy-MM-dd'),
94
+ }, isNil);
95
+ if (size(input) === 0)
96
+ return kyc.setStep(2);
97
+ updateAccountMutation.mutate(input);
98
+ }), children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.realName, readOnly: !!accountQuery.data?.realName, children: [_jsx(Field.Label, { children: "Real Name" }), _jsx(Field.Input, { placeholder: "Enter your real name", ...form.register('realName') }), _jsx(Field.ErrorText, { children: form.formState.errors.realName?.message })] }), _jsxs(Field.Root, { className: "mt-3", invalid: !!form.formState.errors.branchCode, readOnly: !!accountQuery.data?.birthDay, children: [_jsx(Field.Label, { children: "Date of Birth" }), _jsx(Field.Input, { type: "date", ...form.register('birthDay') }), _jsx(Field.ErrorText, { children: form.formState.errors.birthDay?.message })] }), _jsx(Button, { type: "submit", className: "mt-8", disabled: accountQuery.isLoading ||
99
+ updateAccountMutation.isPending ||
100
+ stepCompleted, children: "Continue" })] })] }));
101
+ }
@@ -36,20 +36,6 @@ export function IdentityVerification() {
36
36
  localStorage.clear();
37
37
  sessionStorage.clear();
38
38
  router.replace('/');
39
- if (Capacitor.isNativePlatform()) {
40
- const session = await getQueryClient().fetchQuery({
41
- queryKey: getSessionQueryKey(),
42
- queryFn: async () => getSession(),
43
- });
44
- invariant(session.status === 'authenticated');
45
- await unregisterFCMDevice({
46
- type: ['IOS', 'ANDROID'],
47
- }, {
48
- headers: {
49
- Authorization: `Bearer ${session.token}`,
50
- },
51
- });
52
- }
53
39
  },
54
40
  });
55
41
  const { mutate: createMemberVerification, isPending: createPending } = useCreateMemberVerificationMutation({
@@ -155,7 +141,21 @@ export function IdentityVerification() {
155
141
  } }), _jsx(Field.ErrorText, { children: o.fieldState.error?.message })] })) }), _jsx(Button, { type: "submit", className: "mt-6", disabled: createPending || updatePending, children: "Continue" }), kyc.isSkippable && (_jsx(Button, { variant: "outline", colorScheme: "gray", className: "mt-lg", type: "button", onClick: () => {
156
142
  globalStore.kyc.setOpen(false);
157
143
  globalStore.kycReminder.setOpen(true);
158
- }, children: "Skip for now" })), _jsx(Button, { className: "bg-transparent text-text-brand-primary-600", onClick: () => {
144
+ }, children: "Skip for now" })), _jsx(Button, { className: "bg-transparent text-text-brand-primary-600", onClick: async () => {
145
+ if (Capacitor.isNativePlatform()) {
146
+ const session = await getQueryClient().fetchQuery({
147
+ queryKey: getSessionQueryKey(),
148
+ queryFn: async () => getSession(),
149
+ });
150
+ invariant(session.status === 'authenticated');
151
+ await unregisterFCMDevice({
152
+ type: ['IOS', 'ANDROID'],
153
+ }, {
154
+ headers: {
155
+ Authorization: `Bearer ${session.token}`,
156
+ },
157
+ });
158
+ }
159
159
  signOutMutation.mutate();
160
160
  router.push('/');
161
161
  }, children: "Log Out" })] })] }));