@opexa/portal-components 0.0.835 → 0.0.837

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 (148) hide show
  1. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/QRPHDepositContext.d.ts +2 -2
  2. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit/useQRPHDeposit.d.ts +1 -1
  3. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/QRPHDepositContext.d.ts +2 -2
  4. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__legacy/useQRPHDeposit.d.ts +1 -1
  5. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.d.ts +1 -0
  6. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Confirmed.js +11 -0
  7. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.d.ts +1 -0
  8. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Failed.js +11 -0
  9. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.d.ts +1 -0
  10. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/Form.js +126 -0
  11. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.d.ts +1 -0
  12. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/GeneratingQrCode.js +10 -0
  13. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.d.ts +1 -0
  14. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDeposit.js +12 -0
  15. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.d.ts +17 -0
  16. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QRPHDepositContext.js +2 -0
  17. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.d.ts +1 -0
  18. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/QrCodeGenerated.js +41 -0
  19. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.d.ts +13 -0
  20. package/dist/components/DepositWithdrawal/Deposit/QRPHDeposit__next/useQRPHDeposit.js +91 -0
  21. package/dist/components/DepositWithdrawal/Withdrawal/InstapayWithdrawal/InstapayWithdrawal.js +30 -6
  22. package/dist/services/graphqlRequest.js +31 -0
  23. package/dist/services/httpRequest.js +33 -0
  24. package/dist/ui/AlertDialog/AlertDialog.d.ts +187 -187
  25. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +17 -17
  26. package/dist/ui/Avatar/Avatar.d.ts +9 -9
  27. package/dist/ui/Avatar/avatar.recipe.d.ts +3 -3
  28. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  29. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  30. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  31. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  32. package/dist/ui/Collapsible/Collapsible.d.ts +20 -20
  33. package/dist/ui/Collapsible/collapsible.recipe.d.ts +5 -5
  34. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  35. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  36. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  37. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  38. package/dist/ui/Dialog/Dialog.d.ts +33 -33
  39. package/dist/ui/Dialog/dialog.recipe.d.ts +3 -3
  40. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  41. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  42. package/dist/ui/Menu/Menu.d.ts +144 -144
  43. package/dist/ui/Menu/menu.recipe.d.ts +8 -8
  44. package/dist/ui/NumberInput/NumberInput.d.ts +24 -24
  45. package/dist/ui/NumberInput/numberInput.recipe.d.ts +3 -3
  46. package/dist/ui/Popover/Popover.d.ts +154 -154
  47. package/dist/ui/Popover/popover.recipe.d.ts +14 -14
  48. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  49. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  50. package/dist/ui/Select/Select.d.ts +45 -45
  51. package/dist/ui/Select/select.recipe.d.ts +3 -3
  52. package/dist/ui/Table/Table.d.ts +21 -21
  53. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  54. package/dist/ui/Table/table.recipe.d.ts +3 -3
  55. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  56. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  57. package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
  58. package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
  59. package/package.json +1 -1
  60. package/dist/assets/providers/alize.png +0 -0
  61. package/dist/assets/providers/bigtime-gaming.png +0 -0
  62. package/dist/assets/providers/bng.png +0 -0
  63. package/dist/assets/providers/boongo.png +0 -0
  64. package/dist/assets/providers/btg.png +0 -0
  65. package/dist/assets/providers/cq9.png +0 -0
  66. package/dist/assets/providers/darwin.png +0 -0
  67. package/dist/assets/providers/digitain.png +0 -0
  68. package/dist/assets/providers/evolution.png +0 -0
  69. package/dist/assets/providers/fantasma-games.png +0 -0
  70. package/dist/assets/providers/fc.png +0 -0
  71. package/dist/assets/providers/fp.png +0 -0
  72. package/dist/assets/providers/habanero.png +0 -0
  73. package/dist/assets/providers/hacksaw.png +0 -0
  74. package/dist/assets/providers/jdb.png +0 -0
  75. package/dist/assets/providers/jili.png +0 -0
  76. package/dist/assets/providers/leap.png +0 -0
  77. package/dist/assets/providers/live-22-metaverse.png +0 -0
  78. package/dist/assets/providers/netent.png +0 -0
  79. package/dist/assets/providers/no-limit.png +0 -0
  80. package/dist/assets/providers/pg.png +0 -0
  81. package/dist/assets/providers/pgsoft.png +0 -0
  82. package/dist/assets/providers/pragmatic-play.png +0 -0
  83. package/dist/assets/providers/realtime-gaming.png +0 -0
  84. package/dist/assets/providers/redtiger.png +0 -0
  85. package/dist/assets/providers/rtg.png +0 -0
  86. package/dist/assets/providers/sagaming.png +0 -0
  87. package/dist/components/Banner/Banner.client.d.ts +0 -12
  88. package/dist/components/Banner/Banner.client.js +0 -49
  89. package/dist/components/DepositWithdrawal/AiOPaymentMethods.d.ts +0 -11
  90. package/dist/components/DepositWithdrawal/AiOPaymentMethods.js +0 -55
  91. package/dist/components/DigitainLauncher/Loading.d.ts +0 -1
  92. package/dist/components/DigitainLauncher/Loading.js +0 -5
  93. package/dist/components/Jackpots/JackpotsCarousel/JackpotsCarouselItem.module.css +0 -184
  94. package/dist/components/Jackpots/JackpotsList/JackpotsListItem.module.css +0 -184
  95. package/dist/components/KYC/BasicInformation.d.ts +0 -1
  96. package/dist/components/KYC/BasicInformation.js +0 -101
  97. package/dist/components/KYC/IdentityVerification.d.ts +0 -1
  98. package/dist/components/KYC/IdentityVerification.js +0 -120
  99. package/dist/components/KYC/Indicator.d.ts +0 -1
  100. package/dist/components/KYC/Indicator.js +0 -8
  101. package/dist/components/KYC/KYC.lazy.d.ts +0 -6
  102. package/dist/components/KYC/KYC.lazy.js +0 -45
  103. package/dist/components/KYC/KYCContext.d.ts +0 -6
  104. package/dist/components/KYC/KYCContext.js +0 -2
  105. package/dist/components/KYC/KYCDefault/BasicInformation.d.ts +0 -1
  106. package/dist/components/KYC/KYCDefault/BasicInformation.js +0 -101
  107. package/dist/components/KYC/KYCVerificationStatus.d.ts +0 -1
  108. package/dist/components/KYC/KYCVerificationStatus.js +0 -10
  109. package/dist/components/KYC/KYCVerificationStatus.lazy.d.ts +0 -1
  110. package/dist/components/KYC/KYCVerificationStatus.lazy.js +0 -36
  111. package/dist/components/KYC/PersonalInformation.d.ts +0 -1
  112. package/dist/components/KYC/PersonalInformation.js +0 -122
  113. package/dist/components/KYC/useKYC.d.ts +0 -25
  114. package/dist/components/KYC/useKYC.js +0 -38
  115. package/dist/components/KYCNotRequired/KYCNotRequired.d.ts +0 -0
  116. package/dist/components/KYCNotRequired/KYCNotRequired.js +0 -1
  117. package/dist/components/PortalProvider/AndroidOnlyComponents.d.ts +0 -1
  118. package/dist/components/PortalProvider/AndroidOnlyComponents.js +0 -12
  119. package/dist/components/PortalProvider/CXDTokenObserver.d.ts +0 -1
  120. package/dist/components/PortalProvider/CXDTokenObserver.js +0 -30
  121. package/dist/components/PortalProvider/LinkGoogleAccountObserver.d.ts +0 -1
  122. package/dist/components/PortalProvider/LinkGoogleAccountObserver.js +0 -29
  123. package/dist/components/Quests/MultiWageringQuest.d.ts +0 -1
  124. package/dist/components/Quests/MultiWageringQuest.js +0 -111
  125. package/dist/components/SessionWatcher/SessionWatcher.d.ts +0 -1
  126. package/dist/components/SessionWatcher/SessionWatcher.js +0 -20
  127. package/dist/components/SessionWatcher/index.d.ts +0 -1
  128. package/dist/components/SessionWatcher/index.js +0 -1
  129. package/dist/components/SignIn/utils.d.ts +0 -8
  130. package/dist/components/SignIn/utils.js +0 -26
  131. package/dist/constants/Branches.d.ts +0 -2
  132. package/dist/constants/Branches.js +0 -42
  133. package/dist/images/game-providers/ALPHACHINKO.png +0 -0
  134. package/dist/images/responsible-gaming-yellow.png +0 -0
  135. package/dist/third-parties/FacebookPixel/FacebookPixel.d.ts +0 -4
  136. package/dist/third-parties/FacebookPixel/FacebookPixel.js +0 -4
  137. package/dist/third-parties/FacebookPixel/api.d.ts +0 -0
  138. package/dist/third-parties/FacebookPixel/api.js +0 -1
  139. package/dist/third-parties/FacebookPixel/index.d.ts +0 -1
  140. package/dist/third-parties/FacebookPixel/index.js +0 -1
  141. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.d.ts +0 -4
  142. package/dist/third-parties/GoogleRecaptcha/GoogleRecaptcha.js +0 -4
  143. package/dist/third-parties/GoogleRecaptcha/api.d.ts +0 -0
  144. package/dist/third-parties/GoogleRecaptcha/api.js +0 -1
  145. package/dist/third-parties/GoogleRecaptcha/index.d.ts +0 -1
  146. package/dist/third-parties/GoogleRecaptcha/index.js +0 -1
  147. package/dist/third-parties/index.d.ts +0 -2
  148. package/dist/third-parties/index.js +0 -2
@@ -1,6 +1,6 @@
1
1
  export declare const QRPHDepositContext: (props: {
2
2
  value: {
3
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
3
+ status: "confirmed" | "failed" | "idle" | "generating-qr-code" | "qr-code-generated";
4
4
  deposit: import("../../../../types").Deposit | null;
5
5
  generateQRCode: (input: import("./useQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
6
6
  regenerateQRCode: () => Promise<void>;
@@ -9,7 +9,7 @@ export declare const QRPHDepositContext: (props: {
9
9
  } & {
10
10
  children?: import("react").ReactNode | undefined;
11
11
  }) => React.ReactNode, useQRPHDepositContext: () => {
12
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
12
+ status: "confirmed" | "failed" | "idle" | "generating-qr-code" | "qr-code-generated";
13
13
  deposit: import("../../../../types").Deposit | null;
14
14
  generateQRCode: (input: import("./useQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
15
15
  regenerateQRCode: () => Promise<void>;
@@ -5,7 +5,7 @@ export interface GenerateQRCodeInput {
5
5
  promo?: string | null;
6
6
  }
7
7
  export declare function useQRPHDeposit(): {
8
- status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
8
+ status: "confirmed" | "failed" | "idle" | "generating-qr-code" | "qr-code-generated";
9
9
  deposit: Deposit | null;
10
10
  generateQRCode: (input: GenerateQRCodeInput) => Promise<void>;
11
11
  regenerateQRCode: () => Promise<void>;
@@ -1,7 +1,7 @@
1
1
  export declare const QRPHDepositContext: (props: {
2
2
  value: {
3
3
  view: "form" | "qrCode";
4
- status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
4
+ status: "failed" | "waiting" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
5
5
  verify: () => void;
6
6
  reset: () => void;
7
7
  deposit: import("../../../../types").Deposit | null;
@@ -14,7 +14,7 @@ export declare const QRPHDepositContext: (props: {
14
14
  children?: import("react").ReactNode | undefined;
15
15
  }) => React.ReactNode, useQRPHDepositContext: () => {
16
16
  view: "form" | "qrCode";
17
- status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
17
+ status: "failed" | "waiting" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
18
18
  verify: () => void;
19
19
  reset: () => void;
20
20
  deposit: import("../../../../types").Deposit | null;
@@ -2,7 +2,7 @@ import type { Deposit } from '../../../../types';
2
2
  export type UseQRPHDepositReturn = ReturnType<typeof useQRPHDeposit>;
3
3
  export declare function useQRPHDeposit(): {
4
4
  view: "form" | "qrCode";
5
- status: "waiting" | "processing" | "failed" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
5
+ status: "failed" | "waiting" | "processing" | "verification-waiting" | "verification-processing" | "verification-failed" | "verification-success";
6
6
  verify: () => void;
7
7
  reset: () => void;
8
8
  deposit: Deposit | null;
@@ -0,0 +1 @@
1
+ export declare function Confirmed(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { CheckCircleIcon } from '../../../../icons/CheckCircleIcon.js';
3
+ import { XIcon } from '../../../../icons/XIcon.js';
4
+ import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
5
+ import { Button } from '../../../../ui/Button/index.js';
6
+ import { Portal } from '../../../../ui/Portal/index.js';
7
+ import { useQRPHDepositContext } from './QRPHDepositContext.js';
8
+ export function Confirmed() {
9
+ const context = useQRPHDepositContext();
10
+ return (_jsx(AlertDialog.Root, { open: context.status === 'confirmed', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)]", children: _jsxs(AlertDialog.Content, { children: [_jsx("button", { type: "button", className: "absolute top-4 right-4 icon:size-6 p-md text-text-quinary disabled:cursor-not-allowed disabled:opacity-50", onClick: context.reset, children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-success-secondary", children: _jsx(CheckCircleIcon, { className: "size-6 text-text-featured-icon-light-success" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Your deposit was successful!" }), _jsx(AlertDialog.Description, { className: "mt-xl px-3", children: "The funds have been added to your account." }), _jsx(Button, { className: "mt-4xl w-full", onClick: context.reset, children: "Ok" })] }) })] }) }));
11
+ }
@@ -0,0 +1 @@
1
+ export declare function Failed(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
3
+ import { XIcon } from '../../../../icons/XIcon.js';
4
+ import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
5
+ import { Button } from '../../../../ui/Button/index.js';
6
+ import { Portal } from '../../../../ui/Portal/index.js';
7
+ import { useQRPHDepositContext } from './QRPHDepositContext.js';
8
+ export function Failed() {
9
+ const context = useQRPHDepositContext();
10
+ return (_jsx(AlertDialog.Root, { open: context.status === 'failed', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)]", children: _jsxs(AlertDialog.Content, { children: [_jsx("button", { type: "button", className: "absolute top-4 right-4 icon:size-6 p-md text-text-quinary disabled:cursor-not-allowed disabled:opacity-50", onClick: context.reset, children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-error-secondary", children: _jsx(AlertCircleIcon, { className: "size-6 text-text-featured-icon-light-error" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Your deposit failed or was cancelled." }), _jsx(AlertDialog.Description, { className: "mt-xl px-3", children: "Your deposit was not completed or has been cancelled. You can try again by generating a\u00A0new\u00A0QR code." }), _jsx(Button, { className: "mt-4xl w-full", variant: "outline", onClick: context.regenerateQRCode, children: "Generate New QR Code" })] }) })] }) }));
11
+ }
@@ -0,0 +1 @@
1
+ export declare function Form(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,126 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { zodResolver } from '@hookform/resolvers/zod';
3
+ import Link from 'next/link';
4
+ import { useEffect } from 'react';
5
+ import { Controller, useForm } from 'react-hook-form';
6
+ import { useBoolean } from 'usehooks-ts';
7
+ import { z } from 'zod';
8
+ import { useShallow } from 'zustand/shallow';
9
+ import { useAvailablePromosQuery } from '../../../../client/hooks/useAvailablePromosQuery.js';
10
+ import { useDepositsCountQuery } from '../../../../client/hooks/useDepositsCountQuery.js';
11
+ import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
12
+ import { usePaymentSettingsQuery } from '../../../../client/hooks/usePaymentSettingsQuery.js';
13
+ import { QrCode02Icon } from '../../../../icons/QrCode02Icon.js';
14
+ import { XIcon } from '../../../../icons/XIcon.js';
15
+ import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
16
+ import { Button } from '../../../../ui/Button/index.js';
17
+ import { Field } from '../../../../ui/Field/index.js';
18
+ import { Portal } from '../../../../ui/Portal/index.js';
19
+ import { parseDecimal } from '../../../../utils/parseDecimal.js';
20
+ import { AmountChoices } from '../../AmountChoices.js';
21
+ import { useDepositWithdrawalPropsContext } from '../../DepositWithdrawalContext.js';
22
+ import { AvailablePromos } from '../AvailablePromos.js';
23
+ import { useQRPHDepositContext } from './QRPHDepositContext.js';
24
+ export function Form() {
25
+ const depositWithdrawalProps = useDepositWithdrawalPropsContext();
26
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
27
+ depositWithdrawal: ctx.depositWithdrawal,
28
+ })));
29
+ const context = useQRPHDepositContext();
30
+ const depositsCountQuery = useDepositsCountQuery();
31
+ const depositsCount = depositsCountQuery.data ?? 0;
32
+ const paymentSettingsQuery = usePaymentSettingsQuery();
33
+ const paymentSettings = paymentSettingsQuery.data;
34
+ const gatewaySettings = paymentSettings?.qrphDepositGatewaySettings;
35
+ const maximumAmount = parseDecimal(gatewaySettings?.maximumAmount, 0);
36
+ const minimumAmount = depositsCount <= 0
37
+ ? parseDecimal(paymentSettingsQuery.data?.minimumFirstDepositAmount, 0)
38
+ : parseDecimal(gatewaySettings?.minimumAmount, 0);
39
+ const promosQuery = useAvailablePromosQuery();
40
+ const promos = promosQuery.data ?? [];
41
+ const definition = z
42
+ .object({
43
+ amount: z.string().superRefine((val, ctx) => {
44
+ const n = parseDecimal(val, 0);
45
+ if (val.includes('.')) {
46
+ ctx.addIssue({
47
+ code: z.ZodIssueCode.custom,
48
+ message: 'Amount must be a whole number',
49
+ });
50
+ return;
51
+ }
52
+ if (n < minimumAmount) {
53
+ ctx.addIssue({
54
+ type: 'number',
55
+ code: z.ZodIssueCode.too_small,
56
+ inclusive: true,
57
+ minimum: minimumAmount,
58
+ message: `Minimum amount is ${minimumAmount.toLocaleString()}`,
59
+ });
60
+ }
61
+ if (n > maximumAmount) {
62
+ ctx.addIssue({
63
+ type: 'number',
64
+ code: z.ZodIssueCode.too_big,
65
+ inclusive: true,
66
+ maximum: maximumAmount,
67
+ message: `Maximum amount is ${maximumAmount.toLocaleString()}`,
68
+ });
69
+ }
70
+ }),
71
+ promo: z.string().optional().nullable(),
72
+ })
73
+ .superRefine((value, ctx) => {
74
+ const promo = promos.find((o) => o.id === value.promo);
75
+ const promoMinAmount = parseDecimal(promo?.minimumDepositAmount, 0);
76
+ const promoMaxAmount = parseDecimal(promo?.maximumDepositAmount, 0);
77
+ const amount = parseDecimal(value.amount, 0);
78
+ if (promo && amount < promoMinAmount) {
79
+ ctx.addIssue({
80
+ path: ['amount'],
81
+ code: z.ZodIssueCode.custom,
82
+ message: `Minimum amount for this promo is ${promoMinAmount.toLocaleString()}`,
83
+ });
84
+ }
85
+ if (promo && amount > promoMaxAmount) {
86
+ ctx.addIssue({
87
+ path: ['amount'],
88
+ code: z.ZodIssueCode.custom,
89
+ message: `Maximum amount for this promo is ${promoMaxAmount}`,
90
+ });
91
+ }
92
+ });
93
+ const form = useForm({
94
+ mode: 'all',
95
+ resolver: zodResolver(definition),
96
+ defaultValues: {
97
+ amount: '0',
98
+ promo: globalStore.depositWithdrawal.promo ?? null,
99
+ },
100
+ });
101
+ useEffect(() => {
102
+ if (minimumAmount) {
103
+ form.reset({
104
+ amount: minimumAmount.toString(),
105
+ promo: form.getValues('promo') ?? null,
106
+ });
107
+ }
108
+ }, [form, minimumAmount]);
109
+ const confirm = useBoolean();
110
+ return (_jsxs("form", { onSubmit: (e) => {
111
+ e.preventDefault();
112
+ confirm.setTrue();
113
+ }, noValidate: true, children: [_jsxs(Field.Root, { invalid: !!form.formState.errors.amount, className: "mt-3xl", children: [_jsx(Field.Label, { children: "Enter the amount you want to deposit" }), _jsx(Field.Input, { type: "number", ...form.register('amount') }), _jsx(Field.ErrorText, { children: form.formState.errors.amount?.message })] }), _jsx(AmountChoices, { value: parseDecimal(form.watch('amount'), 0), onChange: (value) => {
114
+ form.setValue('amount', value.toString(), {
115
+ shouldTouch: true,
116
+ shouldDirty: true,
117
+ shouldValidate: true,
118
+ });
119
+ }, min: minimumAmount, max: maximumAmount, className: "mt-lg" }), _jsx(Controller, { control: form.control, name: "promo", render: (o) => (_jsx(AvailablePromos, { value: o.field.value, onChange: (value) => {
120
+ o.field.onChange(value);
121
+ globalStore.depositWithdrawal.setPromo(null);
122
+ }, className: "mt-3xl" })) }), _jsx(Button, { type: "submit", className: "mt-3xl", children: "Deposit" }), depositWithdrawalProps.hasPrivacyPolicyAndTermsOfUse && (_jsxs("p", { className: "mt-lg text-text-tertiary-600 text-xs", children: ["By depositing, you agree to our", ' ', _jsx(Link, { href: depositWithdrawalProps.termsOfUseUrl ?? '/terms-of-use', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Terms of Use" }), ' ', "and", ' ', _jsx(Link, { href: depositWithdrawalProps.privacyPolicyUrl ?? '/privacy-policy', onClick: () => globalStore.depositWithdrawal.setOpen(false), className: "text-text-warning-primary-600 underline underline-offset-2", children: "Privacy Policy" }), "."] })), _jsx(AlertDialog.Root, { open: confirm.value, lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary", children: _jsx(QrCode02Icon, { className: "size-6 text-text-featured-icon-light-brand" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Generate Single Use QR Code" }), _jsx(AlertDialog.Description, { className: "mt-xs px-2", children: "To proceed with your QRPH deposit, please generate a QR code first." }), _jsx(Button, { className: "mt-4xl", variant: "outline", colorScheme: "gray", onClick: form.handleSubmit(async (data) => {
123
+ confirm.setFalse();
124
+ await context.generateQRCode(data);
125
+ }), children: "Generate QR code" })] }) })] }) })] }));
126
+ }
@@ -0,0 +1 @@
1
+ export declare function GeneratingQrCode(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,10 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Spinner02Icon } from '../../../../icons/Spinner02Icon.js';
3
+ import { XIcon } from '../../../../icons/XIcon.js';
4
+ import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
5
+ import { Portal } from '../../../../ui/Portal/index.js';
6
+ import { useQRPHDepositContext } from './QRPHDepositContext.js';
7
+ export function GeneratingQrCode() {
8
+ const context = useQRPHDepositContext();
9
+ return (_jsx(AlertDialog.Root, { open: context.status === 'generating-qr-code', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { disabled: true, children: _jsx(XIcon, {}) }), _jsx(Spinner02Icon, { className: "mx-auto size-12 text-text-featured-icon-light-brand" }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "Generating Single Use QR Code" }), _jsxs(AlertDialog.Description, { className: "mt-xs px-3", children: [_jsx("span", { className: "block", children: "Please hold tight as we verify the account details and amount. Once verified, a QRPH code will be displayed for you to scan and complete the transaction." }), _jsxs("span", { className: "mt-3 block", children: ["Please wait ", _jsx("span", { className: "font-bold", children: "60" }), " seconds..."] })] })] }) })] }) }));
10
+ }
@@ -0,0 +1 @@
1
+ export declare function QRPHDeposit(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,12 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Confirmed } from './Confirmed.js';
3
+ import { Failed } from './Failed.js';
4
+ import { Form } from './Form.js';
5
+ import { GeneratingQrCode } from './GeneratingQrCode.js';
6
+ import { QRPHDepositContext } from './QRPHDepositContext.js';
7
+ import { QrCodeGenerated } from './QrCodeGenerated.js';
8
+ import { useQRPHDeposit } from './useQRPHDeposit.js';
9
+ export function QRPHDeposit() {
10
+ const context = useQRPHDeposit();
11
+ return (_jsxs(QRPHDepositContext, { value: context, children: [_jsx(Form, {}), _jsx(GeneratingQrCode, {}), _jsx(QrCodeGenerated, {}), _jsx(Failed, {}), _jsx(Confirmed, {})] }));
12
+ }
@@ -0,0 +1,17 @@
1
+ export declare const QRPHDepositContext: (props: {
2
+ value: {
3
+ status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
4
+ deposit: import("../../../../types").Deposit | null;
5
+ generateQRCode: (input: import("./useQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
6
+ regenerateQRCode: () => Promise<void>;
7
+ reset: () => void;
8
+ };
9
+ } & {
10
+ children?: import("react").ReactNode | undefined;
11
+ }) => React.ReactNode, useQRPHDepositContext: () => {
12
+ status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
13
+ deposit: import("../../../../types").Deposit | null;
14
+ generateQRCode: (input: import("./useQRPHDeposit").GenerateQRCodeInput) => Promise<void>;
15
+ regenerateQRCode: () => Promise<void>;
16
+ reset: () => void;
17
+ };
@@ -0,0 +1,2 @@
1
+ import { createContext } from '../../../../client/utils/createContext.js';
2
+ export const [QRPHDepositContext, useQRPHDepositContext] = createContext();
@@ -0,0 +1 @@
1
+ export declare function QrCodeGenerated(): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,41 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import Image from 'next/image';
3
+ import { useBoolean } from 'usehooks-ts';
4
+ import { AlertCircleIcon } from '../../../../icons/AlertCircleIcon.js';
5
+ import { ArrowCircleDownIcon } from '../../../../icons/ArrowCircleDownIcon.js';
6
+ import { QrCode02Icon } from '../../../../icons/QrCode02Icon.js';
7
+ import { XIcon } from '../../../../icons/XIcon.js';
8
+ import qrphIcon from '../../../../images/qrph-icon.png';
9
+ import { AlertDialog } from '../../../../ui/AlertDialog/index.js';
10
+ import { Button } from '../../../../ui/Button/index.js';
11
+ import { Portal } from '../../../../ui/Portal/index.js';
12
+ import { QrCode } from '../../../../ui/QrCode/index.js';
13
+ import { useQRPHDepositContext } from './QRPHDepositContext.js';
14
+ export function QrCodeGenerated() {
15
+ const context = useQRPHDepositContext();
16
+ const confirm = useBoolean(false);
17
+ return (_jsx(AlertDialog.Root, { open: context.status === 'qr-code-generated', lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+2)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+3)]", children: _jsxs(AlertDialog.Content, { children: [_jsx("button", { type: "button", className: "absolute top-4 right-4 icon:size-6 p-md text-text-quinary disabled:cursor-not-allowed disabled:opacity-50", onClick: () => {
18
+ if (!confirm.value) {
19
+ confirm.setTrue();
20
+ return;
21
+ }
22
+ confirm.setFalse();
23
+ }, children: _jsx(XIcon, {}) }), !confirm.value ? (_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary", children: _jsx(QrCode02Icon, { className: "size-6 text-text-featured-icon-light-brand" }) })) : (_jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-error-secondary", children: _jsx(AlertCircleIcon, { className: "size-6 text-text-featured-icon-light-error" }) })), _jsx(AlertDialog.Title, { className: "mt-xl", dangerouslySetInnerHTML: {
24
+ __html: confirm.value
25
+ ? 'Are you sure you want to close this&nbsp;window?'
26
+ : 'Single Use QR Code',
27
+ } }), _jsx(AlertDialog.Description, { className: "mt-xs px-3", children: confirm.value
28
+ ? 'Closing this window will cancel your current deposit. Do you want to continue?'
29
+ : 'Scan the QR code below with your banking app, or upload it to complete your deposit.' }), !confirm.value && (_jsx("div", { className: "mx-auto mt-xl w-[14.125rem] rounded-xl bg-bg-primary-alt p-6", children: _jsxs(QrCode.Root, { value: context.deposit?.qrCode ?? '', encoding: {
30
+ ecc: 'H',
31
+ boostEcc: true,
32
+ }, children: [_jsxs("div", { className: "relative", children: [_jsx(QrCode.Frame, { className: "mx-auto size-[10rem] rounded-[0.25rem] border border-border-primary bg-white", children: _jsx(QrCode.Pattern, {}) }), _jsx(QrCode.Overlay, { className: "bg-white p-0.5", children: _jsx(Image, { src: qrphIcon, alt: "", className: "size-8", width: 40, height: 40 }) })] }), _jsxs(QrCode.DownloadTrigger, { type: "button", fileName: `QRPH-${Date.now()}.jpg`, mimeType: "image/jpeg", className: "mx-auto mt-5 flex w-fit items-center gap-1 font-semibold text-button-tertiary-fg", children: [_jsx(ArrowCircleDownIcon, { className: "size-5" }), "Download QR Code"] })] }) })), confirm.value && (_jsxs("div", { className: "mt-4xl flex gap-lg", children: [_jsx(Button, { variant: "outline", onClick: confirm.setFalse, children: "Go back" }), _jsx(Button, { onClick: () => {
33
+ context.reset();
34
+ setTimeout(() => {
35
+ confirm.setFalse();
36
+ }, 2);
37
+ }, children: "Continue" })] })), !confirm.value && _jsx(Instruction, {})] }) })] }) }));
38
+ }
39
+ function Instruction() {
40
+ return (_jsxs(AlertDialog.Root, { lazyMount: true, closeOnEscape: false, closeOnInteractOutside: false, children: [_jsxs("p", { className: "mt-lg text-center text-text-tertiary-600 text-xs", children: ["Need help using the QR Code?", ' ', _jsx(AlertDialog.Trigger, { className: "text-text-brand", children: "See instructions" })] }), _jsxs(Portal, { children: [_jsx(AlertDialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(AlertDialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)]", children: _jsxs(AlertDialog.Content, { children: [_jsx(AlertDialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsx("div", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-bg-brand-secondary", children: _jsx(QrCode02Icon, { className: "size-6 text-text-featured-icon-light-brand" }) }), _jsx(AlertDialog.Title, { className: "mt-xl", children: "How to Use the QR Code for Payment" }), _jsx(AlertDialog.Description, { className: "mt-xl px-3", children: "Follow these simple steps to complete your\u00A0transaction:" }), _jsx("div", { className: "mt-4 text-sm text-text-tertiary-600", children: _jsxs("ol", { className: "list-decimal pl-4", children: [_jsx("li", { className: "marker:font-mono marker:text-sm", children: "Open your preferred banking or EMI mobile app and select 'Transfer Money' or 'Pay via QR.'" }), _jsx("li", { className: "marker:font-mono marker:text-sm", children: "Scan or upload the generated QR Ph code. If prompted by the app, enter the amount to be sent." }), _jsx("li", { className: "marker:font-mono marker:text-sm", children: "Proceed with the transfer or payment." })] }) })] }) })] })] }));
41
+ }
@@ -0,0 +1,13 @@
1
+ import type { Deposit } from '../../../../types';
2
+ export type UseQRPHDepositReturn = ReturnType<typeof useQRPHDeposit>;
3
+ export interface GenerateQRCodeInput {
4
+ amount: string;
5
+ promo?: string | null;
6
+ }
7
+ export declare function useQRPHDeposit(): {
8
+ status: "idle" | "confirmed" | "failed" | "generating-qr-code" | "qr-code-generated";
9
+ deposit: Deposit | null;
10
+ generateQRCode: (input: GenerateQRCodeInput) => Promise<void>;
11
+ regenerateQRCode: () => Promise<void>;
12
+ reset: () => void;
13
+ };
@@ -0,0 +1,91 @@
1
+ import { useEffect, useRef, useState } from 'react';
2
+ import invariant from 'tiny-invariant';
3
+ import { useShallow } from 'zustand/shallow';
4
+ import { useCreateQRPHDepositMutation } from '../../../../client/hooks/useCreateQRPHDepositMutation.js';
5
+ import { useDepositQuery } from '../../../../client/hooks/useDepositQuery.js';
6
+ import { useGlobalStore } from '../../../../client/hooks/useGlobalStore.js';
7
+ import { useMemberVerificationQuery } from '../../../../client/hooks/useMemberVerificationQuery.js';
8
+ export function useQRPHDeposit() {
9
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
10
+ kycVerificationStatus: ctx.kycVerificationStatus,
11
+ })));
12
+ const inputRef = useRef(null);
13
+ const [deposit, setDeposit] = useState(null);
14
+ const [status, setStatus] = useState('idle');
15
+ const verificationQuery = useMemberVerificationQuery();
16
+ const verificationStatus = verificationQuery.data?.status ?? 'UNVERIFIED';
17
+ const mutation = useCreateQRPHDepositMutation({
18
+ onMutate() {
19
+ setStatus('generating-qr-code');
20
+ },
21
+ onSuccess(data) {
22
+ invariant(data.qrCode);
23
+ setStatus('qr-code-generated');
24
+ setDeposit(data);
25
+ },
26
+ onError() {
27
+ setStatus('failed');
28
+ },
29
+ });
30
+ const query = useDepositQuery(deposit?.id, {
31
+ enabled: !!deposit && status === 'qr-code-generated',
32
+ refetchInterval: (ctx) => {
33
+ if (ctx.state.data?.status === 'APPROVED' ||
34
+ ctx.state.data?.status === 'CONFIRMED' ||
35
+ ctx.state.data?.status === 'CANCELLED' ||
36
+ ctx.state.data?.status === 'REJECTED' ||
37
+ ctx.state.data?.status === 'FAILED') {
38
+ return false;
39
+ }
40
+ return 2000;
41
+ },
42
+ });
43
+ useEffect(() => {
44
+ if (query.data?.status === 'APPROVED' ||
45
+ query.data?.status === 'CONFIRMED') {
46
+ setStatus('confirmed');
47
+ return;
48
+ }
49
+ if (query.data?.status === 'CANCELLED' ||
50
+ query.data?.status === 'REJECTED' ||
51
+ query.data?.status === 'FAILED') {
52
+ setStatus('failed');
53
+ return;
54
+ }
55
+ }, [query.data?.status]);
56
+ const generateQRCode = async (input) => {
57
+ if (verificationStatus === 'PENDING' ||
58
+ verificationStatus === 'UNVERIFIED' ||
59
+ verificationStatus === 'REJECTED' ||
60
+ verificationStatus === 'CREATED') {
61
+ globalStore.kycVerificationStatus.setOpen(true);
62
+ return;
63
+ }
64
+ inputRef.current = input;
65
+ mutation.mutate({
66
+ amount: input.amount,
67
+ promo: input.promo ?? undefined,
68
+ });
69
+ };
70
+ const regenerateQRCode = async () => {
71
+ invariant(inputRef.current);
72
+ mutation.reset();
73
+ await new Promise((resolve) => setTimeout(resolve, 1));
74
+ mutation.mutate({
75
+ amount: inputRef.current.amount,
76
+ promo: inputRef.current.promo ?? undefined,
77
+ });
78
+ };
79
+ const reset = () => {
80
+ setStatus('idle');
81
+ setDeposit(null);
82
+ inputRef.current = null;
83
+ };
84
+ return {
85
+ status,
86
+ deposit,
87
+ generateQRCode,
88
+ regenerateQRCode,
89
+ reset,
90
+ };
91
+ }
@@ -32,6 +32,17 @@ import { explainError } from '../../utils.js';
32
32
  import { ActiveTurnoverRequirement } from '../ActiveTurnoverRequirement.js';
33
33
  import { RequireFirstDeposit } from '../RequireFirstDeposit.js';
34
34
  import { TransactionPasswordNotSet } from '../TransactionPasswordNotSet.js';
35
+ const sortBanksWithPriority = (banks) => {
36
+ const priorityBankCodes = ['BNKGCH', 'BNKMYA'];
37
+ const priorityBanks = banks.filter((bank) => priorityBankCodes.includes(bank.code));
38
+ const otherBanks = banks.filter((bank) => !priorityBankCodes.includes(bank.code));
39
+ const sortedPriorityBanks = priorityBanks.sort((a, b) => {
40
+ const aIndex = priorityBankCodes.indexOf(a.code);
41
+ const bIndex = priorityBankCodes.indexOf(b.code);
42
+ return aIndex - bIndex;
43
+ });
44
+ return [...sortedPriorityBanks, ...otherBanks];
45
+ };
35
46
  export function InstapayWithdrawal() {
36
47
  const depositWithdrawalProps = useDepositWithdrawalPropsContext();
37
48
  const globalStore = useGlobalStore(useShallow((ctx) => ({
@@ -123,9 +134,11 @@ export function InstapayWithdrawal() {
123
134
  }, [form, minimumAmount]);
124
135
  useEffect(() => {
125
136
  if (instapayBankList?.length) {
137
+ const sortedBanks = sortBanksWithPriority(instapayBankList);
138
+ const defaultBank = sortedBanks[0];
126
139
  form.reset({
127
140
  amount: form.getValues('amount'),
128
- bankCode: instapayBankList[0].code,
141
+ bankCode: defaultBank.code,
129
142
  password: '',
130
143
  accountNumber: '',
131
144
  });
@@ -144,11 +157,22 @@ export function InstapayWithdrawal() {
144
157
  bankCode: data.bankCode,
145
158
  });
146
159
  });
147
- const bankCollection = useMemo(() => createListCollection({
148
- items: instapayBankList ?? [],
149
- itemToValue: (item) => item.code,
150
- itemToString: (item) => item.name,
151
- }), [instapayBankList]);
160
+ const bankCollection = useMemo(() => {
161
+ const emptyItems = [];
162
+ if (!instapayBankList?.length) {
163
+ return createListCollection({
164
+ items: emptyItems,
165
+ itemToValue: (item) => item.code,
166
+ itemToString: (item) => item.name,
167
+ });
168
+ }
169
+ const sortedBanks = sortBanksWithPriority(instapayBankList);
170
+ return createListCollection({
171
+ items: sortedBanks,
172
+ itemToValue: (item) => item.code,
173
+ itemToString: (item) => item.name,
174
+ });
175
+ }, [instapayBankList]);
152
176
  return (_jsxs("form", { onSubmit: handleSubmit, noValidate: true, autoComplete: "off", id: "hook-form", children: [_jsx(Controller, { control: form.control, name: "bankCode", render: (o) => (_jsxs(Field.Root, { invalid: !!form.formState.errors.bankCode, children: [_jsxs(Select.Root, { collection: bankCollection, positioning: {
153
177
  sameWidth: true,
154
178
  }, value: o.field.value ? [o.field.value] : [], onValueChange: (details) => {
@@ -1,3 +1,4 @@
1
+ import { Capacitor } from '@capacitor/core';
1
2
  import { ENVIRONMENT, PLATFORM_CODE, PLATFORM_ID, SITE_ID } from '../constants/index.js';
2
3
  export async function graphqlRequest(url, query, variables, options) {
3
4
  const headers = new Headers();
@@ -11,6 +12,21 @@ export async function graphqlRequest(url, query, variables, options) {
11
12
  new Headers(options?.headers).forEach((value, key) => {
12
13
  headers.set(key, value);
13
14
  });
15
+ const domain = typeof window === 'undefined'
16
+ ? null
17
+ : !Capacitor.isNativePlatform()
18
+ ? null
19
+ : Capacitor.getPlatform() === 'ios'
20
+ ? `ios/${PLATFORM_CODE}`.toLowerCase()
21
+ : Capacitor.getPlatform() === 'android'
22
+ ? `android/${PLATFORM_CODE}`.toLowerCase()
23
+ : null;
24
+ if (domain) {
25
+ headers.set('Domain', domain);
26
+ }
27
+ else {
28
+ headers.delete('Domain');
29
+ }
14
30
  const info = getOperationInfo(query);
15
31
  const url_ = new URL(url);
16
32
  if (info) {
@@ -109,6 +125,21 @@ export async function graphqlUpload(url, query, variables, options) {
109
125
  headers.set('Platform-Code', PLATFORM_CODE);
110
126
  headers.set('Environment', ENVIRONMENT);
111
127
  headers.delete('Content-Type');
128
+ const domain = typeof window === 'undefined'
129
+ ? null
130
+ : !Capacitor.isNativePlatform()
131
+ ? null
132
+ : Capacitor.getPlatform() === 'ios'
133
+ ? `ios/${PLATFORM_CODE}`.toLowerCase()
134
+ : Capacitor.getPlatform() === 'android'
135
+ ? `android/${PLATFORM_CODE}`.toLowerCase()
136
+ : null;
137
+ if (domain) {
138
+ headers.set('Domain', domain);
139
+ }
140
+ else {
141
+ headers.delete('Domain');
142
+ }
112
143
  const body = createUploadBody(query, variables);
113
144
  const info = getOperationInfo(query);
114
145
  const url_ = new URL(url);
@@ -1,3 +1,4 @@
1
+ import { Capacitor } from '@capacitor/core';
1
2
  import { z } from 'zod';
2
3
  import { ENVIRONMENT, PLATFORM_CODE, PLATFORM_ID, SITE_ID } from '../constants/index.js';
3
4
  export async function httpRequest(url, opts = {}) {
@@ -10,6 +11,22 @@ export async function httpRequest(url, opts = {}) {
10
11
  new Headers(opts.headers).forEach((value, key) => {
11
12
  headers.set(key, value);
12
13
  });
14
+ /* 👌🏻 Override domain set outside */
15
+ const domain = typeof window === 'undefined'
16
+ ? null
17
+ : !Capacitor.isNativePlatform()
18
+ ? null
19
+ : Capacitor.getPlatform() === 'ios'
20
+ ? `ios/${PLATFORM_CODE}`.toLowerCase()
21
+ : Capacitor.getPlatform() === 'android'
22
+ ? `android/${PLATFORM_CODE}`.toLowerCase()
23
+ : null;
24
+ if (domain) {
25
+ headers.set('Domain', domain);
26
+ }
27
+ else {
28
+ headers.delete('Domain');
29
+ }
13
30
  const res = await fetch(url, {
14
31
  ...opts,
15
32
  headers,
@@ -43,6 +60,22 @@ httpRequest.json = async (url, opts = {}) => {
43
60
  new Headers(opts.headers).forEach((value, key) => {
44
61
  headers.set(key, value);
45
62
  });
63
+ /* 👌🏻 Override domain set outside */
64
+ const domain = typeof window === 'undefined'
65
+ ? null
66
+ : !Capacitor.isNativePlatform()
67
+ ? null
68
+ : Capacitor.getPlatform() === 'ios'
69
+ ? `ios/${PLATFORM_CODE}`.toLowerCase()
70
+ : Capacitor.getPlatform() === 'android'
71
+ ? `android/${PLATFORM_CODE}`.toLowerCase()
72
+ : null;
73
+ if (domain) {
74
+ headers.set('Domain', domain);
75
+ }
76
+ else {
77
+ headers.delete('Domain');
78
+ }
46
79
  const response = await fetch(url, {
47
80
  ...opts,
48
81
  headers,