@opexa/portal-components 0.0.153 → 0.0.155

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 (70) hide show
  1. package/dist/components/AccountVerification/AccountVerification.js +1 -5
  2. package/dist/components/DepositWithdrawal/Withdrawal/Withdrawal.js +8 -1
  3. package/dist/components/KYC/AutoOpen.d.ts +1 -0
  4. package/dist/components/KYC/AutoOpen.js +25 -0
  5. package/dist/components/KYC/BasicInformation.js +6 -4
  6. package/dist/components/KYC/FileUpload.js +29 -3
  7. package/dist/components/KYC/KYC.js +2 -1
  8. package/dist/components/KYC/KYC.lazy.js +3 -26
  9. package/dist/components/KYC/useKYC.d.ts +1 -0
  10. package/dist/components/KYC/useKYC.js +8 -0
  11. package/dist/components/Messages/Message.js +8 -10
  12. package/dist/components/Messages/MessageContext.d.ts +1 -1
  13. package/dist/components/Messages/MessageContext.js +1 -1
  14. package/dist/components/Messages/MessagePopup.d.ts +1 -1
  15. package/dist/components/Messages/MessagePopup.js +7 -11
  16. package/dist/components/Messages/MessagesPopup.js +10 -2
  17. package/dist/components/Quests/CountdownTimer.d.ts +15 -0
  18. package/dist/components/Quests/CountdownTimer.js +33 -0
  19. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.d.ts +4 -0
  20. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuest.js +78 -0
  21. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.d.ts +8 -0
  22. package/dist/components/Quests/DailyCheckInQuest/DailyCheckInQuestModal.js +9 -0
  23. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.d.ts +4 -0
  24. package/dist/components/Quests/OnboardingQuest/OnboardingQuest.js +4 -0
  25. package/dist/components/Quests/WageringQuest/WageringQuest.d.ts +4 -0
  26. package/dist/components/Quests/WageringQuest/WageringQuest.js +20 -0
  27. package/dist/components/Quests/WageringQuest/WageringQuestModal.d.ts +9 -0
  28. package/dist/components/Quests/WageringQuest/WageringQuestModal.js +9 -0
  29. package/dist/components/SignUp/SignUpForm.js +0 -4
  30. package/dist/ui/AlertDialog/AlertDialog.d.ts +88 -88
  31. package/dist/ui/AlertDialog/alertDialog.recipe.d.ts +8 -8
  32. package/dist/ui/Badge/Badge.d.ts +12 -12
  33. package/dist/ui/Badge/badge.anatomy.d.ts +1 -1
  34. package/dist/ui/Badge/badge.recipe.d.ts +3 -3
  35. package/dist/ui/Carousel/Carousel.d.ts +45 -45
  36. package/dist/ui/Carousel/carousel.recipe.d.ts +5 -5
  37. package/dist/ui/Checkbox/Checkbox.d.ts +23 -23
  38. package/dist/ui/Checkbox/checkbox.recipe.d.ts +3 -3
  39. package/dist/ui/Clipboard/Clipboard.d.ts +18 -18
  40. package/dist/ui/Clipboard/clipboard.recipe.d.ts +3 -3
  41. package/dist/ui/Combobox/Combobox.d.ts +42 -42
  42. package/dist/ui/Combobox/combobox.recipe.d.ts +3 -3
  43. package/dist/ui/DatePicker/DatePicker.d.ts +72 -72
  44. package/dist/ui/DatePicker/datePicker.recipe.d.ts +3 -3
  45. package/dist/ui/Dialog/Dialog.d.ts +88 -88
  46. package/dist/ui/Dialog/dialog.recipe.d.ts +8 -8
  47. package/dist/ui/Drawer/Drawer.d.ts +33 -33
  48. package/dist/ui/Drawer/drawer.recipe.d.ts +3 -3
  49. package/dist/ui/Menu/Menu.d.ts +90 -90
  50. package/dist/ui/Menu/menu.recipe.d.ts +5 -5
  51. package/dist/ui/PasswordInput/PasswordInput.d.ts +18 -18
  52. package/dist/ui/PasswordInput/passwordInput.recipe.d.ts +3 -3
  53. package/dist/ui/Progress/Progress.d.ts +27 -27
  54. package/dist/ui/Progress/progress.recipe.d.ts +3 -3
  55. package/dist/ui/QrCode/QrCode.d.ts +25 -25
  56. package/dist/ui/QrCode/qrCode.recipe.d.ts +5 -5
  57. package/dist/ui/Select/Select.d.ts +45 -45
  58. package/dist/ui/Select/select.recipe.d.ts +3 -3
  59. package/dist/ui/Table/Table.d.ts +21 -21
  60. package/dist/ui/Table/table.anatomy.d.ts +1 -1
  61. package/dist/ui/Table/table.recipe.d.ts +3 -3
  62. package/dist/ui/Tabs/Tabs.d.ts +15 -15
  63. package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
  64. package/dist/ui/Tooltip/Tooltip.d.ts +30 -30
  65. package/dist/ui/Tooltip/tooltip.recipe.d.ts +5 -5
  66. package/dist/utils/dataUrlToBlob.d.ts +1 -0
  67. package/dist/utils/dataUrlToBlob.js +11 -0
  68. package/dist/utils/resizeImageSize.d.ts +2 -0
  69. package/dist/utils/resizeImageSize.js +11 -0
  70. package/package.json +1 -1
@@ -6,7 +6,6 @@ import { useShallow } from 'zustand/shallow';
6
6
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
7
  import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
8
8
  import { useProfileCompletionQuery } from '../../client/hooks/useProfileCompletionQuery.js';
9
- import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
10
9
  import { AlertCircleIcon } from '../../icons/AlertCircleIcon.js';
11
10
  import { CheckVerified02Icon } from '../../icons/CheckVerified02Icon.js';
12
11
  import { CreditCard02Icon } from '../../icons/CreditCard02Icon.js';
@@ -20,8 +19,6 @@ export function AccountVerification(props) {
20
19
  const globalStore = useGlobalStore(useShallow((ctx) => ({
21
20
  kyc: ctx.kyc,
22
21
  })));
23
- const sessionQuery = useSessionQuery();
24
- const session = sessionQuery.data;
25
22
  const profileCompletionQuery = useProfileCompletionQuery();
26
23
  const profileCompletion = profileCompletionQuery.data;
27
24
  const verificationQuery = useMemberVerificationQuery();
@@ -33,8 +30,7 @@ export function AccountVerification(props) {
33
30
  verification?.status === 'UNVERIFIED';
34
31
  return (_jsxs("div", { className: props.className, children: [_jsxs("div", { className: "flex items-start gap-8", children: [_jsxs("div", { className: "grow", children: [_jsx("h2", { className: "text-text-secondary-700 text-sm font-semibold", children: "Verify your identity" }), _jsx("p", { className: "text-text-tertiary-600 text-sm", children: "Complete personal verification to unlock all features and enhance account security." })] }), _jsx(ark.svg, { asChild: true, className: twMerge('size-6', profileCompletion?.accountVerification
35
32
  ? 'text-text-success-primary'
36
- : 'text-text-warning-primary'), children: profileCompletion?.accountVerification ? (_jsx(CheckVerified02Icon, {})) : (_jsx(AlertCircleIcon, {})) })] }), _jsxs("div", { className: "shadow-xs border-border-secondary bg-bg-primary-alt mt-5 rounded-xl border", children: [_jsx("div", { className: "px-4 py-5", children: _jsxs("ul", { className: "space-y-lg", children: [_jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(FileCheck02Icon, {}), "Basic Information"] }), _jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(Globe05Icon, {}), "Proof of address"] }), _jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(CreditCard02Icon, {}), "Government ID"] }), _jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(FaceIdIcon, {}), "Facial Verification"] })] }) }), _jsx("div", { className: "border-border-secondary flex justify-end border-t px-4 py-3 lg:py-xl", children: ((verification && verification.status !== 'PENDING') ||
37
- session?.status === 'authenticated') && (_jsx(Button, { size: "sm", className: "w-full lg:w-fit", onClick: () => globalStore.kyc.setOpen(true), children: "Verify Now" })) })] }), success && _jsx(VerificationSuccess, {}), pending && _jsx(VerificationInProgress, {}), failed && _jsx(VerificationFailed, {}), empty && _jsx(VerificationNotSubmitted, {})] }));
33
+ : 'text-text-warning-primary'), children: profileCompletion?.accountVerification ? (_jsx(CheckVerified02Icon, {})) : (_jsx(AlertCircleIcon, {})) })] }), _jsxs("div", { className: "shadow-xs border-border-secondary bg-bg-primary-alt mt-5 rounded-xl border", children: [_jsx("div", { className: "px-4 py-5", children: _jsxs("ul", { className: "space-y-lg", children: [_jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(FileCheck02Icon, {}), "Basic Information"] }), _jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(Globe05Icon, {}), "Proof of address"] }), _jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(CreditCard02Icon, {}), "Government ID"] }), _jsxs("li", { className: "text-text-secondary-700 icon:size-6 icon:text-text-nav-item-button-icon flex items-center gap-lg", children: [_jsx(FaceIdIcon, {}), "Facial Verification"] })] }) }), _jsx("div", { className: "border-border-secondary flex justify-end border-t px-4 py-3 lg:py-xl", children: (!verification || verification?.status === 'REJECTED') && (_jsx(Button, { size: "sm", className: "w-full lg:w-fit", onClick: () => globalStore.kyc.setOpen(true), children: "Verify Now" })) })] }), success && _jsx(VerificationSuccess, {}), pending && _jsx(VerificationInProgress, {}), failed && _jsx(VerificationFailed, {}), empty && _jsx(VerificationNotSubmitted, {})] }));
38
34
  }
39
35
  function VerificationNotSubmitted() {
40
36
  return (_jsxs("div", { className: "shadow-xs border-border-primary bg-bg-primary-alt mt-6 flex flex-col gap-2 rounded-xl border p-xl lg:flex-row", children: [_jsx("div", { className: "border-text-warning-primary/10 flex size-[2.1875rem] items-center justify-center rounded-full border-2", children: _jsx("div", { className: "border-text-warning-primary/30 flex size-[1.666625rem] items-center justify-center rounded-full border-2", children: _jsx(AlertCircleIcon, { className: "text-text-warning-primary size-5" }) }) }), _jsx("p", { className: "text-text-tertiary-600 max-w-[800px] text-sm", children: "To serve you better and unlock all features, please provide valid identification documents. This helps protect your account and makes recovery easier if ever needed." })] }));
@@ -84,7 +84,14 @@ export function Withdrawal() {
84
84
  return (_jsxs(_Fragment, { children: [_jsx(PaymentMethods, { value: paymentMethod, onChange: setPaymentMethod, options: enabledPaymentMethods }), paymentMethod === 'GCASH' && _jsx(GCashWithdrawal, {}), paymentMethod === 'MAYA' && _jsx(MayaWithdrawal, {}), paymentMethod === 'MAYA_APP' && _jsx(MayaAppWithdrawal, {}), paymentMethod === 'INSTAPAY' && _jsx(InstapayWithdrawal, {})] }));
85
85
  }
86
86
  function AccountVerificationRequired() {
87
- return (_jsxs("div", { className: "pt-xl", children: [_jsx("div", { className: "bg-bg-warning-secondary mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, { className: "text-text-featured-icon-light-warning size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold", children: "Personal Verification" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: "To withdraw funds, you must first verify your identity. Complete personal verification to ensure your account\u2019s security." }), _jsx(Button, { className: "mt-3xl", children: "Verify Now" })] }));
87
+ const globalStore = useGlobalStore(useShallow((ctx) => ({
88
+ kyc: ctx.kyc,
89
+ depositWithdrawal: ctx.depositWithdrawal,
90
+ })));
91
+ return (_jsxs("div", { className: "pt-xl", children: [_jsx("div", { className: "bg-bg-warning-secondary mx-auto flex size-12 items-center justify-center rounded-full", children: _jsx(AlertCircleIcon, { className: "text-text-featured-icon-light-warning size-6" }) }), _jsx("h2", { className: "mt-lg text-center text-lg font-semibold", children: "Personal Verification" }), _jsx("p", { className: "text-text-tertiary-600 mx-auto mt-xs max-w-[25rem] text-center text-sm", children: "To withdraw funds, you must first verify your identity. Complete personal verification to ensure your account\u2019s security." }), _jsx(Button, { className: "mt-3xl", onClick: () => {
92
+ globalStore.kyc.setOpen(true);
93
+ globalStore.depositWithdrawal.setOpen(false);
94
+ }, children: "Verify Now" })] }));
88
95
  }
89
96
  function InsufficientBalance() {
90
97
  const setTab = useGlobalStore(useShallow((ctx) => ctx.depositWithdrawal.setTab));
@@ -0,0 +1 @@
1
+ export declare function AutoOpen(): null;
@@ -0,0 +1,25 @@
1
+ import { useEffect } from 'react';
2
+ import { useShallow } from 'zustand/shallow';
3
+ import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
4
+ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
5
+ import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
6
+ import { useSessionQuery } from '../../client/hooks/useSessionQuery.js';
7
+ export function AutoOpen() {
8
+ const kycStore = useGlobalStore(useShallow((ctx) => ctx.kyc));
9
+ const { data: session } = useSessionQuery();
10
+ const { data: account } = useAccountQuery();
11
+ const { data: verification } = useMemberVerificationQuery();
12
+ const shouldOpen = !account?.realName ||
13
+ !account?.birthDay ||
14
+ !verification ||
15
+ verification.status === 'REJECTED';
16
+ useEffect(() => {
17
+ if (session?.status == 'authenticated' &&
18
+ !kycStore['~touched'] &&
19
+ shouldOpen) {
20
+ kycStore.setOpen(true);
21
+ return;
22
+ }
23
+ }, [kycStore, session?.status, shouldOpen]);
24
+ return null;
25
+ }
@@ -5,11 +5,11 @@ import { isNil, omitBy, size } from 'lodash-es';
5
5
  import { useEffect } from 'react';
6
6
  import { useForm } from 'react-hook-form';
7
7
  import invariant from 'tiny-invariant';
8
+ import { useInterval } from 'usehooks-ts';
8
9
  import { z } from 'zod';
9
10
  import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
10
11
  import { useUpdateAccountMutation } from '../../client/hooks/useUpdateAccountMutation.js';
11
12
  import { toaster } from '../../client/utils/toaster.js';
12
- import { SpinnerIcon } from '../../icons/SpinnerIcon.js';
13
13
  import { Button } from '../../ui/Button/index.js';
14
14
  import { Dialog } from '../../ui/Dialog/index.js';
15
15
  import { Field } from '../../ui/Field/index.js';
@@ -55,6 +55,8 @@ export function BasicInformation() {
55
55
  });
56
56
  const accountQuery = useAccountQuery();
57
57
  const account = accountQuery.data;
58
+ const completed = account != null && account.realName != null && account.birthDay != null;
59
+ useInterval(() => kyc.setStep(2), completed ? 1000 : null);
58
60
  const updateAccountMutation = useUpdateAccountMutation({
59
61
  onError(error) {
60
62
  toaster.error({
@@ -80,8 +82,6 @@ export function BasicInformation() {
80
82
  });
81
83
  }
82
84
  }, [account, form, kyc]);
83
- if (accountQuery.isLoading)
84
- return _jsx(SpinnerIcon, {});
85
85
  return (_jsxs("div", { children: [_jsx(Dialog.Title, { className: "text-center text-lg font-semibold", children: "Basic Information" }), _jsx(Dialog.Description, { className: "text-text-secondary-700 mt-xs text-center text-sm", children: "Enter your basic details for identification and communication." }), _jsxs("form", { className: "mt-3", onSubmit: form.handleSubmit((data) => {
86
86
  invariant(account);
87
87
  const input = omitBy({
@@ -93,5 +93,7 @@ export function BasicInformation() {
93
93
  if (size(input) === 0)
94
94
  return kyc.setStep(2);
95
95
  updateAccountMutation.mutate(input);
96
- }), 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: updateAccountMutation.isPending, children: "Continue" })] })] }));
96
+ }), 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 ||
97
+ updateAccountMutation.isPending ||
98
+ completed, children: completed ? (_jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", viewBox: "0 0 24 24", className: "size-5", children: [_jsx("path", { fill: "currentColor", d: "M12,1A11,11,0,1,0,23,12,11,11,0,0,0,12,1Zm0,19a8,8,0,1,1,8-8A8,8,0,0,1,12,20Z", opacity: ".25" }), _jsx("path", { fill: "currentColor", d: "M10.14,1.16a11,11,0,0,0-9,8.92A1.59,1.59,0,0,0,2.46,12,1.52,1.52,0,0,0,4.11,10.7a8,8,0,0,1,6.66-6.61A1.42,1.42,0,0,0,12,2.69h0A1.57,1.57,0,0,0,10.14,1.16Z", children: _jsx("animateTransform", { attributeName: "transform", dur: "0.75s", repeatCount: "indefinite", type: "rotate", values: "0 12 12;360 12 12" }) })] })) : ('Continue') })] })] }));
97
99
  }
@@ -1,17 +1,43 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import Image from 'next/image';
4
+ import { useEffect, useState } from 'react';
4
5
  import { twMerge } from 'tailwind-merge';
5
- import { useFileQuery } from '../../client/hooks/useFileQuery.js';
6
+ import invariant from 'tiny-invariant';
6
7
  import { useUploadImageFileMutation } from '../../client/hooks/useUploadImageFileMutation.js';
8
+ import { getSession } from '../../client/services/getSession.js';
7
9
  import { UploadCloud02Icon } from '../../icons/UploadCloud02Icon.js';
10
+ import { getFile } from '../../services/file.js';
8
11
  import { Button } from '../../ui/Button/index.js';
12
+ import { createPoll } from '../../utils/createPoll.js';
9
13
  import { useKYCContext } from './KYCContext.js';
10
14
  import { validateFile } from './utils.js';
11
15
  function FileUpload({ value, name, hasDescription, onChange, captureObject, }) {
12
16
  const kyc = useKYCContext();
13
17
  const { mutate, isPending } = useUploadImageFileMutation();
14
- const { data: uploadedImage, isSuccess: uploadedImageReady } = useFileQuery(value);
18
+ const [uploadedImageUrl, setUploadedImageUrl] = useState(null);
19
+ async function pollImage(id) {
20
+ if (!id)
21
+ return;
22
+ const poll = createPoll(async () => {
23
+ const session = await getSession();
24
+ invariant(session.status === 'authenticated');
25
+ const file = await getFile(id, {
26
+ headers: {
27
+ Authorization: `Bearer ${session.token}`,
28
+ },
29
+ });
30
+ return file ?? null;
31
+ }, { until: (r) => !!r, interval: 1000, maxAttempt: 5 });
32
+ const image = await poll();
33
+ if (!image) {
34
+ console.error('Image not found or failed to load');
35
+ }
36
+ setUploadedImageUrl(image?.url ?? null);
37
+ }
38
+ useEffect(() => {
39
+ pollImage(value);
40
+ }, [value]);
15
41
  if (isPending) {
16
42
  return (_jsx("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: _jsx("div", { className: "flex items-center justify-center", children: _jsx("span", { className: "text-text-secondary-700", children: "Uploading..." }) }) }));
17
43
  }
@@ -38,6 +64,6 @@ function FileUpload({ value, name, hasDescription, onChange, captureObject, }) {
38
64
  fileInput.click();
39
65
  }
40
66
  }
41
- return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: [uploadedImageReady ? (_jsxs("div", { className: "border-border-primary bg-bg-primary min-h-[9.25rem]", children: [_jsx(Image, { src: uploadedImage?.url ?? '', alt: "Uploaded", className: "w-full object-contain", width: 350, height: 350, draggable: false }), _jsx(Button, { size: "xs", variant: "outline", className: twMerge('mx-auto mt-4 w-fit', value && 'hidden'), type: "button", onClick: handleUploadClick, children: "Reupload" })] })) : hasDescription ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsxs("p", { className: "text-text-tertiary-600 text-center text-sm", children: [_jsx("span", { className: "text-button-secondary-fg cursor-pointer font-semibold", onClick: handleUploadClick, children: "Click to upload" }), ' ', "or drag and drop", _jsx("br", {}), "PNG, JPG or JPEG (max. 10mb)", _jsx("br", {}), "or"] })] })) : null, _jsx("input", { type: "file", id: `file-upload-${name}`, name: name, onChange: handleFileChange, accept: "image/png, image/jpg, image/jpeg", className: "hidden" }), _jsx(Button, { size: "xs", variant: "outline", className: "mx-auto w-fit", onClick: () => kyc.setCapturing(captureObject), disabled: isPending, type: "button", children: value ? 'Retake Photo' : 'Take a Photo' })] }));
67
+ return (_jsxs("div", { className: "border-border-primary bg-bg-primary flex min-h-[11.25rem] flex-col justify-center gap-lg rounded-xl border px-3xl py-xl", children: [uploadedImageUrl ? (_jsxs("div", { className: "border-border-primary bg-bg-primary min-h-[9.25rem]", children: [_jsx(Image, { src: uploadedImageUrl, alt: "Uploaded", className: "w-full object-contain", width: 350, height: 350, draggable: false }), _jsx(Button, { size: "xs", variant: "outline", className: twMerge('mx-auto mt-4 w-fit', value && 'hidden'), type: "button", onClick: handleUploadClick, children: "Reupload" })] })) : hasDescription ? (_jsxs(_Fragment, { children: [_jsx("div", { className: "border-border-primary shadow-xs mx-auto flex size-8 items-center justify-center rounded-sm border", children: _jsx(UploadCloud02Icon, { className: "text-text-quinary size-4" }) }), _jsxs("p", { className: "text-text-tertiary-600 text-center text-sm", children: [_jsx("span", { className: "text-button-secondary-fg cursor-pointer font-semibold", onClick: handleUploadClick, children: "Click to upload" }), ' ', "or drag and drop", _jsx("br", {}), "PNG, JPG or JPEG (max. 10mb)", _jsx("br", {}), "or"] })] })) : null, _jsx("input", { type: "file", id: `file-upload-${name}`, name: name, onChange: handleFileChange, accept: "image/png, image/jpg, image/jpeg", className: "hidden" }), _jsx(Button, { size: "xs", variant: "outline", className: "mx-auto w-fit", onClick: () => kyc.setCapturing(captureObject), disabled: isPending, type: "button", children: value ? 'Retake Photo' : 'Take a Photo' })] }));
42
68
  }
43
69
  export default FileUpload;
@@ -4,11 +4,12 @@ import dynamic from 'next/dynamic';
4
4
  import Script from 'next/script';
5
5
  import { useShallow } from 'zustand/shallow';
6
6
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
+ import { AutoOpen } from './AutoOpen.js';
7
8
  const Component = dynamic(() => import('./KYC.lazy.js').then((m) => m.KYC), {
8
9
  ssr: false,
9
10
  loading: () => null,
10
11
  });
11
12
  export function KYC(props) {
12
13
  const touched = useGlobalStore(useShallow((ctx) => ctx.kyc['~touched']));
13
- return (_jsxs(_Fragment, { children: [touched && _jsx(Component, { ...props }), _jsx(Script, { src: "https://docs.opencv.org/4.7.0/opencv.js", async: true }), _jsx(Script, { src: "https://cdn.jsdelivr.net/gh/ColonelParrot/jscanify@master/src/jscanify.min.js", strategy: "afterInteractive" })] }));
14
+ return (_jsxs(_Fragment, { children: [touched && _jsx(Component, { ...props }), _jsx(AutoOpen, {}), _jsx(Script, { src: "https://docs.opencv.org/4.7.0/opencv.js", async: true }), _jsx(Script, { src: "https://cdn.jsdelivr.net/gh/ColonelParrot/jscanify@master/src/jscanify.min.js", strategy: "afterInteractive" })] }));
14
15
  }
@@ -1,14 +1,11 @@
1
- 'use client';
2
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
2
  import Image from 'next/image';
4
- import { useEffect } from 'react';
5
3
  import { useShallow } from 'zustand/shallow';
6
- import { useAccountQuery } from '../../client/hooks/useAccountQuery.js';
7
4
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
8
- import { useMemberVerificationQuery } from '../../client/hooks/useMemberVerificationQuery.js';
9
5
  import { XIcon } from '../../icons/XIcon.js';
10
6
  import { Dialog } from '../../ui/Dialog/index.js';
11
7
  import { Portal } from '../../ui/Portal/index.js';
8
+ import { BasicInformation } from './BasicInformation.js';
12
9
  import { CaptureIdDocument } from './CaptureIdDocument.js';
13
10
  import { CaptureSelfie } from './CaptureSelfie.js';
14
11
  import { IdentityVerification } from './IdentityVerification.js';
@@ -17,31 +14,11 @@ import { KYCContext } from './KYCContext.js';
17
14
  import { PersonalInformation } from './PersonalInformation.js';
18
15
  import { useKYC } from './useKYC.js';
19
16
  export function KYC(props) {
20
- const kyc = useKYC();
21
- const accountQuery = useAccountQuery();
22
- const memberVerification = useMemberVerificationQuery();
23
- const isBasicInfoVerified = Boolean(accountQuery.data?.realName) &&
24
- Boolean(accountQuery.data?.birthDay);
25
- const isMemberUploaded = Boolean(memberVerification.data?.idFrontImage) &&
26
- Boolean(memberVerification.data?.selfieImage);
27
- const memberStatus = memberVerification.data?.status;
28
- //check steps
29
- useEffect(() => {
30
- if (memberStatus === 'REJECTED') {
31
- kyc.setStep(2);
32
- }
33
- else if (isBasicInfoVerified && isMemberUploaded) {
34
- kyc.setStep(3);
35
- }
36
- }, [isBasicInfoVerified, isMemberUploaded, memberStatus, kyc]);
37
17
  const globalStore = useGlobalStore(useShallow((ctx) => ({
38
18
  kyc: ctx.kyc,
39
19
  })));
20
+ const kyc = useKYC();
40
21
  return (_jsx(KYCContext, { value: kyc, children: _jsx(Dialog.Root, { open: globalStore.kyc.open, onOpenChange: (details) => {
41
22
  globalStore.kyc.setOpen(details.open);
42
- }, lazyMount: true, unmountOnExit: true, onExitComplete: () => {
43
- kyc.setStep(2);
44
- kyc.setDone(false);
45
- kyc.setCapturing(null);
46
- }, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsxs(Dialog.Content, { className: "bg-bg-primary-alt lg:min-h-auto mx-auto min-h-full w-full lg:w-fit", children: [kyc.capturing === 'SELFIE' && _jsx(CaptureSelfie, {}), kyc.capturing === 'ID_DOCUMENT' && _jsx(CaptureIdDocument, {}), !kyc.capturing && (_jsxs("div", { className: "w-full p-3xl 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 === 2 && _jsx(IdentityVerification, {}), kyc.step === 3 && _jsx(PersonalInformation, {})] }))] }) })] }) }) }));
23
+ }, lazyMount: true, unmountOnExit: true, onExitComplete: kyc.reset, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { children: _jsxs(Dialog.Content, { className: "bg-bg-primary-alt lg:min-h-auto mx-auto min-h-full w-full lg:w-fit", children: [kyc.capturing === 'SELFIE' && _jsx(CaptureSelfie, {}), kyc.capturing === 'ID_DOCUMENT' && _jsx(CaptureIdDocument, {}), !kyc.capturing && (_jsxs("div", { className: "w-full p-3xl 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, {})] }))] }) })] }) }) }));
47
24
  }
@@ -21,6 +21,7 @@ export interface UseKYCReturn {
21
21
  setFrontImageId: (id: string | null) => void;
22
22
  selfieImageId: string | null;
23
23
  setSelfieImageId: (id: string | null) => void;
24
+ reset: () => void;
24
25
  }
25
26
  export declare function useKYC(): UseKYCReturn;
26
27
  export {};
@@ -17,6 +17,13 @@ export function useKYC() {
17
17
  subscriber(detail);
18
18
  });
19
19
  };
20
+ const reset = () => {
21
+ setStep(1);
22
+ setDone(false);
23
+ setCapturing(null);
24
+ setFrontImageId(null);
25
+ setSelfieImageId(null);
26
+ };
20
27
  return {
21
28
  step,
22
29
  setStep,
@@ -30,5 +37,6 @@ export function useKYC() {
30
37
  setSelfieImageId,
31
38
  subscribe,
32
39
  triggerEvent,
40
+ reset,
33
41
  };
34
42
  }
@@ -7,12 +7,8 @@ import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
7
  import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
8
8
  import { useMarkMessageAsReadMutation } from '../../client/hooks/useMarkMessageAsReadMutation.js';
9
9
  import { useMessageContext } from './MessageContext.js';
10
- import { MessageIcon } from './MessageIcon.js';
11
- import { useMessagesPropsContext } from './MessagesContext.js';
12
- import { normalizeActionUrl } from './utils.js';
10
+ import { getMessageIcon } from './utils.js';
13
11
  export function Message() {
14
- const messagesProps = useMessagesPropsContext();
15
- const transactionsPageUrl = messagesProps.transactionsPageUrl ?? '/transactions';
16
12
  const message = useMessageContext();
17
13
  const localeInfo = useLocaleInfo();
18
14
  const globalStore = useGlobalStore(useShallow((ctx) => ({
@@ -20,6 +16,7 @@ export function Message() {
20
16
  messages: ctx.messages,
21
17
  })));
22
18
  const markMessageAsReadMutation = useMarkMessageAsReadMutation();
19
+ const Icon = getMessageIcon(message.icon);
23
20
  const handleViewMessage = async () => {
24
21
  globalStore.message.setData(message);
25
22
  globalStore.message.setOpen(true);
@@ -27,11 +24,12 @@ export function Message() {
27
24
  if (!message.markedAsRead)
28
25
  markMessageAsReadMutation.mutate(message.id);
29
26
  };
27
+ const handleActionClick = (e) => {
28
+ e.stopPropagation();
29
+ globalStore.messages.setOpen(false);
30
+ globalStore.messages.setTab('ALL');
31
+ };
30
32
  return (_jsxs("div", { role: "button", tabIndex: 0, className: "border-border-secondary rounded-xs bg-bg-secondary flex h-auto flex-shrink-0 cursor-pointer flex-col border px-3.5 py-2.5", onClick: handleViewMessage, "aria-pressed": "false", children: [_jsxs("div", { className: "flex items-center space-x-2", children: [_jsx("p", { className: "text-text-tertiary-600 text-xs font-normal", children: format(new Date(message.dateTimeCreated), 'M/d/yyyy - h:mma', {
31
33
  in: tz(localeInfo.timezone),
32
- }) }), !message.markedAsRead && (_jsx("div", { className: "bg-utility-success-500 h-2.5 w-2.5 rounded-full" }))] }), _jsxs("div", { className: "flex items-center space-x-2", children: [_jsx(MessageIcon, { type: message.icon, className: "text-brand-400 size-5" }), _jsx("p", { className: "text-text-primary-brand text-sm font-semibold", children: message.title })] }), message.content && (_jsx("p", { className: "mt-2 line-clamp-3 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: message.content } })), message.actions.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center justify-end gap-2", children: message.actions.map((action, index) => (_jsx(Link, { className: "border-button-secondary-border text-button-secondary-fg rounded-md border px-3 py-2 text-sm", href: normalizeActionUrl(transactionsPageUrl, action.url), onClick: (e) => {
33
- e.stopPropagation();
34
- globalStore.messages.setOpen(false);
35
- globalStore.messages.setTab('ALL');
36
- }, children: action.name }, index))) }))] }));
34
+ }) }), !message.markedAsRead && (_jsx("div", { className: "bg-utility-success-500 h-2.5 w-2.5 rounded-full" }))] }), _jsxs("div", { className: "mb-2 flex items-center space-x-2", children: [_jsx(Icon, { className: "text-brand-400" }), _jsx("p", { className: "text-text-primary-brand text-sm font-semibold", children: message.title })] }), _jsx("p", { className: "line-clamp-3 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: message.content } }), message.actions.length > 0 && (_jsx("div", { className: "mt-2 flex flex-wrap items-center justify-end gap-2", children: message.actions.map((action, index) => (_jsx(Link, { className: "border-button-secondary-border text-button-secondary-fg rounded-md border px-3 py-2 text-sm", href: action.url, onClick: handleActionClick, children: action.name }, index))) }))] }));
37
35
  }
@@ -1,5 +1,5 @@
1
1
  import type { Message } from '../../types';
2
- export declare const MessageProvider: (props: {
2
+ export declare const MessageContext: (props: {
3
3
  value: Message;
4
4
  } & {
5
5
  children?: import("react").ReactNode | undefined;
@@ -1,2 +1,2 @@
1
1
  import { createContext } from '../../client/utils/createContext.js';
2
- export const [MessageProvider, useMessageContext] = createContext();
2
+ export const [MessageContext, useMessageContext] = createContext();
@@ -1 +1 @@
1
- export declare function MessagePopup(): import("react/jsx-runtime").JSX.Element;
1
+ export declare const MessagePopup: () => import("react/jsx-runtime").JSX.Element;
@@ -1,24 +1,20 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import Image from 'next/image';
4
3
  import Link from 'next/link';
5
4
  import { useShallow } from 'zustand/shallow';
6
5
  import { useGlobalStore } from '../../client/hooks/useGlobalStore.js';
7
6
  import { XIcon } from '../../icons/XIcon.js';
8
7
  import { Dialog } from '../../ui/Dialog/index.js';
9
8
  import { Portal } from '../../ui/Portal/index.js';
10
- import { MessageIcon } from './MessageIcon.js';
11
- import { useMessagesPropsContext } from './MessagesContext.js';
12
- import { normalizeActionUrl } from './utils.js';
13
- export function MessagePopup() {
14
- const messagesProps = useMessagesPropsContext();
15
- const transactionsPageUrl = messagesProps.transactionsPageUrl ?? '/transactions';
9
+ import { getMessageIcon } from './utils.js';
10
+ export const MessagePopup = () => {
16
11
  const globalStore = useGlobalStore(useShallow((ctx) => ({ message: ctx.message })));
12
+ const Icon = getMessageIcon(globalStore.message.data?.icon ?? 'MESSAGE');
17
13
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: globalStore.message.open, onOpenChange: ({ open }) => {
18
14
  globalStore.message.setOpen(open);
19
- }, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl px-xl pb-0 pt-5 shadow-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "pb-6", children: [_jsx("div", { className: "bg-bg-brand-secondary mx-auto w-fit rounded-full p-3", children: _jsx(MessageIcon, { type: globalStore.message.data?.icon ?? 'INFO', className: "text-text-brand size-6" }) }), _jsx("p", { className: "text-text-primary-brand mt-lg text-center text-lg font-semibold leading-tight", children: globalStore.message.data?.title }), globalStore.message.data?.content && (_jsx("div", { className: "text-shadow-text-secondary-700 mt-xs text-center text-sm font-normal leading-tight", dangerouslySetInnerHTML: {
20
- __html: globalStore.message.data.content,
21
- } })), globalStore.message.data?.image && (_jsx(Image, { src: globalStore.message.data.image, alt: "", width: 400, height: 400, loading: "lazy", unoptimized: true, className: "mt-5 h-auto w-full" }))] }), globalStore.message.data?.actions.length ? (_jsx("div", { className: "flex flex-col space-y-2 px-4 pb-8 pt-6 text-center", children: globalStore.message.data.actions.map((action, index) => (_jsx(Link, { className: "bg-button-primary-bg rounded-xs text-button-primary-fg w-full px-4 py-2.5 text-base font-semibold", href: normalizeActionUrl(transactionsPageUrl, action.url), onClick: () => {
15
+ }, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl px-xl pb-0 pt-5 shadow-xl", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "pb-6", children: [_jsx("div", { className: "bg-bg-brand-secondary mx-auto w-fit rounded-full p-3", children: _jsx(Icon, { className: "text-text-brand", height: "24", width: "24" }) }), _jsx("p", { className: "text-text-primary-brand mt-lg text-center text-lg font-semibold leading-tight", children: globalStore.message.data?.title }), _jsx("div", { className: "text-shadow-text-secondary-700 mt-xs text-center text-sm font-normal leading-tight", dangerouslySetInnerHTML: {
16
+ __html: globalStore.message.data?.content ?? '',
17
+ } })] }), globalStore.message.data?.actions.length ? (_jsx("div", { className: "flex flex-col space-y-2 px-4 pb-8 pt-6 text-center", children: globalStore.message.data.actions.map((action, index) => (_jsx(Link, { className: "bg-button-primary-bg rounded-xs text-button-primary-fg w-full px-4 py-2.5 text-base font-semibold", href: action.url, onClick: () => {
22
18
  globalStore.message.setOpen(false);
23
19
  }, children: action.name }, index))) })) : null] }) })] }) }));
24
- }
20
+ };
@@ -22,8 +22,11 @@ export function MessagesPopup() {
22
22
  const messagesProps = useMessagesPropsContext();
23
23
  const transactionsPageUrl = messagesProps.transactionsPageUrl ?? '/transactions';
24
24
  const globalStore = useGlobalStore(useShallow((ctx) => ({
25
+ kyc: ctx.kyc,
25
26
  message: ctx.message,
26
27
  messages: ctx.messages,
28
+ gameLaunch: ctx.gameLaunch,
29
+ depositWithdrawal: ctx.depositWithdrawal,
27
30
  })));
28
31
  const markMessageAsReadMutation = useMarkMessageAsReadMutation();
29
32
  const [paused, setPaused] = useState(false);
@@ -53,7 +56,12 @@ export function MessagesPopup() {
53
56
  },
54
57
  },
55
58
  }, {
56
- enabled: !globalStore.messages.open && !globalStore.message.open && !paused,
59
+ enabled: globalStore.gameLaunch.details.status === 'WAITING' &&
60
+ !globalStore.depositWithdrawal.open &&
61
+ !globalStore.messages.open &&
62
+ !globalStore.message.open &&
63
+ !globalStore.kyc.open &&
64
+ !paused,
57
65
  refetchInterval: disclosure.open ? undefined : 10_000,
58
66
  });
59
67
  const messages = messagesQuery.data?.pages.flatMap((page) => page.edges.map((edge) => edge.node)) ?? [];
@@ -65,7 +73,7 @@ export function MessagesPopup() {
65
73
  }, [disclosure, messages.length, paused]);
66
74
  return (_jsx(Dialog.Root, { open: disclosure.open, onOpenChange: (details) => {
67
75
  disclosure.setOpen(details.open);
68
- }, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl p-3xl lg:min-w-[25rem] lg:max-w-[25rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Carousel.Root, { page: page, onPageChange: (details) => {
76
+ }, lazyMount: true, unmountOnExit: true, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+3)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+4)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto min-w-[21.438rem] max-w-[21.438rem] rounded-xl p-3xl lg:min-w-[25rem] lg:max-w-[25rem]", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs(Carousel.Root, { page: page, onPageChange: (details) => {
69
77
  setPage(details.page);
70
78
  const message = messages.at(details.page - 1);
71
79
  if (!message)
@@ -0,0 +1,15 @@
1
+ import { type ReactNode } from 'react';
2
+ type TimeLeft = {
3
+ days: number;
4
+ hours: number;
5
+ minutes: number;
6
+ seconds: number;
7
+ };
8
+ interface CountdownTimerProps {
9
+ startDateTime?: string;
10
+ endDateTime?: string;
11
+ renderAction: (timeLeft: TimeLeft) => ReactNode;
12
+ onEnd?: () => void;
13
+ }
14
+ export default function CountdownTimer({ startDateTime, endDateTime, renderAction, onEnd, }: CountdownTimerProps): import("react/jsx-runtime").JSX.Element;
15
+ export {};
@@ -0,0 +1,33 @@
1
+ 'use client';
2
+ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
3
+ import { differenceInSeconds, parseISO } from 'date-fns';
4
+ import { useCallback, useEffect, useState } from 'react';
5
+ export default function CountdownTimer({ startDateTime, endDateTime, renderAction, onEnd, }) {
6
+ const calculateTimeLeft = useCallback(() => {
7
+ const start = startDateTime ? parseISO(startDateTime) : new Date();
8
+ const end = endDateTime ? parseISO(endDateTime) : new Date();
9
+ const totalSeconds = Math.max(differenceInSeconds(end, start), 0);
10
+ const days = Math.floor(totalSeconds / (60 * 60 * 24));
11
+ const hours = Math.floor((totalSeconds % (60 * 60 * 24)) / (60 * 60));
12
+ const minutes = Math.floor((totalSeconds % (60 * 60)) / 60);
13
+ const seconds = totalSeconds % 60;
14
+ return { days, hours, minutes, seconds };
15
+ }, [startDateTime, endDateTime]);
16
+ const [timeLeft, setTimeLeft] = useState(calculateTimeLeft);
17
+ useEffect(() => {
18
+ const interval = setInterval(() => {
19
+ const newTimeLeft = calculateTimeLeft();
20
+ setTimeLeft(newTimeLeft);
21
+ const isZero = newTimeLeft.days === 0 &&
22
+ newTimeLeft.hours === 0 &&
23
+ newTimeLeft.minutes === 0 &&
24
+ newTimeLeft.seconds === 0;
25
+ if (isZero) {
26
+ clearInterval(interval);
27
+ onEnd?.();
28
+ }
29
+ }, 1000);
30
+ return () => clearInterval(interval);
31
+ }, [calculateTimeLeft, onEnd]);
32
+ return _jsx(_Fragment, { children: renderAction(timeLeft) });
33
+ }
@@ -0,0 +1,4 @@
1
+ import type { Quest } from '../../../types';
2
+ export declare function DailyCheckInQuest({ quest }: {
3
+ quest: Quest;
4
+ }): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,78 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { addDays, isEqual, startOfDay } from 'date-fns';
4
+ import { useState } from 'react';
5
+ import { twMerge } from 'tailwind-merge';
6
+ import { useCheckInDailyCheckInQuestMutation } from '../../../client/hooks/useCheckInDailyCheckInQuestMutation.js';
7
+ import { toaster } from '../../../client/utils/toaster.js';
8
+ import { CalendarIcon } from '../../../icons/CalendarIcon.js';
9
+ import { CheckIcon } from '../../../icons/CheckIcon.js';
10
+ import { ClockStopWatchIcon } from '../../../icons/ClockStopWatchIcon.js';
11
+ import { InfoCircleIcon } from '../../../icons/InfoCircleIcon.js';
12
+ import { Badge } from '../../../ui/Badge/index.js';
13
+ import { Button } from '../../../ui/Button/index.js';
14
+ import { getQueryClient } from '../../../utils/getQueryClient.js';
15
+ import { getAvailableQuestsQueryKey } from '../../../utils/queryKeys.js';
16
+ import CountdownTimer from '../CountdownTimer.js';
17
+ import { DailyCheckInQuestModal } from './DailyCheckInQuestModal.js';
18
+ export function DailyCheckInQuest({ quest }) {
19
+ const queryClient = getQueryClient();
20
+ const [showRules, setShowRules] = useState(false);
21
+ const [isExpired, setIsExpired] = useState(false);
22
+ const { name, description, status, lastCheckInDate, progressPercentage, checkInStreak, thirdDayBonusAmount, sixthDayBonusAmount, seventhDayBonusAmount, endDateTime, id, } = quest;
23
+ const today = startOfDay(new Date());
24
+ const hasCheckedInToday = lastCheckInDate
25
+ ? isEqual(today, startOfDay(new Date(lastCheckInDate)))
26
+ : false;
27
+ const checkedInRewards = {
28
+ 3: thirdDayBonusAmount,
29
+ 6: sixthDayBonusAmount,
30
+ 7: seventhDayBonusAmount,
31
+ };
32
+ const dailyCheckedInData = Array.from({ length: 7 }, (_, i) => {
33
+ const day = i + 1;
34
+ return {
35
+ day,
36
+ reward: checkedInRewards[day] ?? 0,
37
+ };
38
+ });
39
+ const { mutate } = useCheckInDailyCheckInQuestMutation({
40
+ onSuccess() {
41
+ toaster.success({
42
+ title: 'Check-in successful 🎉',
43
+ description: 'You’ve successfully checked in for today! Keep it up to maintain your streak!',
44
+ });
45
+ queryClient.invalidateQueries({
46
+ queryKey: getAvailableQuestsQueryKey(),
47
+ });
48
+ },
49
+ onError(e) {
50
+ toaster.error({
51
+ title: 'Check-in successful 🎉',
52
+ description: e.message ?? 'Check-In Failed',
53
+ });
54
+ },
55
+ });
56
+ const handleCheckIn = async () => mutate(id);
57
+ return (_jsxs(_Fragment, { children: [_jsx(DailyCheckInQuestModal, { modalState: {
58
+ isOpen: showRules,
59
+ setIsOpen: setShowRules,
60
+ } }), _jsxs("div", { className: "border-border-primary bg-bg-tertiary flex h-full w-full flex-col space-y-6 rounded-2xl border px-4 pb-6 pt-5", children: [_jsxs("div", { className: "flex flex-col space-y-2", children: [_jsxs("div", { className: "flex max-h-7.5 items-start justify-between", children: [_jsx(CountdownTimer, { endDateTime: endDateTime, renderAction: (timeLeft) => (_jsxs(Badge.Root, { size: "lg", colorScheme: "brand", round: false, children: [_jsx(Badge.Icon, { children: _jsx(ClockStopWatchIcon, {}) }), _jsxs(Badge.Label, { children: [timeLeft.days, "d:", timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => setIsExpired(true) }), _jsx("div", { role: "button", className: "bg-bg-primary border-border-secondary flex size-9 cursor-pointer items-center justify-center rounded-md border", onClick: () => setShowRules((prev) => !prev), children: _jsx(InfoCircleIcon, { className: "text-text-disabled size-5" }) })] }), _jsx("p", { className: "text-xl font-semibold", children: name }), _jsx("p", { className: "text-text-secondary-700 text-wrap text-sm font-normal", dangerouslySetInnerHTML: { __html: description } })] }), _jsxs("div", { className: "flex w-full flex-col space-y-2", children: [_jsx("div", { className: "grid grid-cols-7", children: dailyCheckedInData.map((item) => {
61
+ const reward = item.reward ? `+₱${item.reward}` : '-';
62
+ return (_jsx("div", { className: twMerge('flex items-center justify-center', item.day <= (checkInStreak || 0)
63
+ ? 'text-brand-400'
64
+ : 'text-text-secondary-700'), children: _jsx("p", { children: reward }) }, item.day));
65
+ }) }), _jsx("div", { className: "bg-bg-primary h-2 w-full overflow-hidden rounded-full", children: _jsx("div", { className: "bg-utility-brand-600 h-full rounded-full transition-all duration-300", style: { width: `${progressPercentage}%` } }) }), _jsx("div", { className: "grid grid-cols-7", children: dailyCheckedInData.map((item) => (_jsx("div", { className: "flex items-center justify-center", children: _jsx(CalendarWithDayNumber, { day: item.day, currentCheckedInDays: checkInStreak || 0 }, item.day) }, item.day))) })] }), _jsx(Button, { onClick: handleCheckIn, className: "disabled:bg-bg-primary disabled:text-text-disabled", disabled: isExpired ||
66
+ status === 'COMPLETED' ||
67
+ status === 'FAILED' ||
68
+ hasCheckedInToday, children: hasCheckedInToday && status === 'IN_PROGRESS' ? (_jsx(CountdownTimer, { endDateTime: startOfDay(addDays(new Date(), 1)).toISOString(), renderAction: (timeLeft) => (_jsxs("div", { className: "flex items-center space-x-0.5", children: [_jsx(CheckIcon, {}), _jsxs("p", { children: [timeLeft.hours, "h:", timeLeft.minutes, "m:", timeLeft.seconds, "s"] })] })), onEnd: () => {
69
+ queryClient.invalidateQueries({
70
+ queryKey: getAvailableQuestsQueryKey(),
71
+ });
72
+ } })) : ('Check-In') })] })] }));
73
+ }
74
+ function CalendarWithDayNumber({ day, currentCheckedInDays, }) {
75
+ return (_jsxs("div", { className: twMerge('group relative h-fit w-fit', day <= currentCheckedInDays
76
+ ? 'text-brand-400'
77
+ : 'text-text-secondary-700'), children: [_jsx(CalendarIcon, {}), _jsx("div", { className: "absolute inset-0 mt-1 flex items-center justify-center text-2xs lg:mt-[2px]", children: _jsx("p", { className: "text-center", children: day }) })] }));
78
+ }
@@ -0,0 +1,8 @@
1
+ interface Props {
2
+ modalState: {
3
+ isOpen: boolean;
4
+ setIsOpen: (isOpen: boolean) => void;
5
+ };
6
+ }
7
+ export declare function DailyCheckInQuestModal(props: Props): import("react/jsx-runtime").JSX.Element;
8
+ export {};
@@ -0,0 +1,9 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { XIcon } from '../../../icons/XIcon.js';
4
+ import { Button } from '../../../ui/Button/index.js';
5
+ import { Dialog } from '../../../ui/Dialog/index.js';
6
+ import { Portal } from '../../../ui/Portal/index.js';
7
+ export function DailyCheckInQuestModal(props) {
8
+ return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: props.modalState.isOpen, onOpenChange: ({ open }) => props.modalState.setIsOpen(open), closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, { className: "!z-[calc(var(--z-dialog)+1)]" }), _jsx(Dialog.Positioner, { className: "!z-[calc(var(--z-dialog)+2)] flex items-center justify-center", children: _jsxs(Dialog.Content, { className: "min-h-auto mx-auto max-w-[343px] rounded-xl px-4 pb-0 pt-5", children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "flex flex-col space-y-5", children: [_jsx("p", { className: "text-text-primary-900 text-lg font-semibold", children: "Daily Check-In Rules" }), _jsxs("ul", { className: "text-text-tertiary-600 group list-disc text-wrap pl-4 text-sm font-normal", children: [_jsx("li", { children: "Earn rewards just for checking in each day!" }), _jsx("li", { children: "Stay consistent to unlock special rewards on the 3rd, 5th, and 7th day." }), _jsx("li", { children: "Missing a day will reset your streak, starting again from Day 1." }), _jsx("li", { children: "Each check-in unlocks the next one on the following day." }), _jsx("li", { children: "Successfully check in for 7 consecutive days to complete the quest and reset the cycle." })] })] }), _jsx("div", { className: "pb-4 pt-6", children: _jsx(Button, { onClick: () => props.modalState.setIsOpen(false), children: "Ok" }) })] }) })] }) }));
9
+ }
@@ -0,0 +1,4 @@
1
+ import type { Quest } from '../../../types';
2
+ export declare function OnboardingQuest(props: {
3
+ quest: Quest;
4
+ }): null;
@@ -0,0 +1,4 @@
1
+ export function OnboardingQuest(props) {
2
+ console.log('OnboardingQuest not implemented', props.quest);
3
+ return null;
4
+ }
@@ -0,0 +1,4 @@
1
+ import type { Quest } from '../../../types';
2
+ export declare function WageringQuest({ quest }: {
3
+ quest: Quest;
4
+ }): import("react/jsx-runtime").JSX.Element;