@opexa/portal-components 0.0.1079 → 0.0.1081

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.
@@ -132,6 +132,13 @@ function Rules(props) {
132
132
  return false;
133
133
  return milestones.every((milestone) => milestone.isCompleted);
134
134
  }, [milestones]);
135
+ const isExpired = useMemo(() => {
136
+ if (!quest?.daysToClear || !quest?.dateTimeCreated)
137
+ return false;
138
+ const targetDateTime = new Date(quest.dateTimeCreated);
139
+ targetDateTime.setDate(targetDateTime.getDate() + Number(quest.daysToClear));
140
+ return new Date() > targetDateTime;
141
+ }, [quest?.dateTimeCreated, quest?.daysToClear]);
135
142
  const sessionQuery = useSessionQuery();
136
143
  const session = sessionQuery.data;
137
144
  return (_jsx(Dialog.Root, { lazyMount: true, unmountOnExit: true, open: open, onOpenChange: (details) => setOpen(details.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 p-4", children: _jsxs(Dialog.Content, { className: twMerge('mx-auto max-h-[80vh] min-h-auto min-w-[21.438rem] max-w-[400px] overflow-y-auto rounded-xl px-4 py-10 md:scrollbar:h-2 md:scrollbar:w-2 md:scrollbar-thumb:rounded-full md:scrollbar-thumb:bg-bg-quaternary md:scrollbar-track:bg-transparent', props.className?.root), children: [_jsx(Dialog.CloseTrigger, { children: _jsx(XIcon, {}) }), _jsxs("div", { className: "group flex flex-col space-y-5 text-sm text-text-quarterary-brand", children: [_jsx("h2", { className: twMerge('font-semibold text-lg text-text-primary-900', props.className?.title), children: quest?.name || 'Quest' }), _jsx("div", { className: "relative", children: _jsx("div", { className: "max-h-[30vh] overflow-y-auto", children: quest?.description ? (_jsx(Prose, { dangerouslySetInnerHTML: {
@@ -162,19 +169,20 @@ function Rules(props) {
162
169
  globalStore.depositWithdrawal.setOpen(true);
163
170
  globalStore.depositWithdrawal.setTab('DEPOSIT');
164
171
  }
165
- }, "aria-label": `Complete ${milestone.label}`, disabled: milestoneType === 'ACCOUNT_VERIFICATION' &&
166
- verificationStatus === 'PENDING', children: [milestoneType === 'ACCOUNT_VERIFICATION' ? (_jsx(FileCheck02Icon, { className: "size-5" })) : (_jsx(CoinsHandIcon, { className: "size-5" })), milestoneType === 'FIRST_DEPOSIT'
172
+ }, "aria-label": `Complete ${milestone.label}`, disabled: isExpired ||
173
+ (milestoneType === 'ACCOUNT_VERIFICATION' &&
174
+ verificationStatus === 'PENDING'), children: [milestoneType === 'ACCOUNT_VERIFICATION' ? (_jsx(FileCheck02Icon, { className: "size-5" })) : (_jsx(CoinsHandIcon, { className: "size-5" })), milestoneType === 'FIRST_DEPOSIT'
167
175
  ? 'Deposit'
168
176
  : 'Verify Account'] })), !milestone.isCompleted &&
169
- milestoneType === 'LINK_FACEBOOK_ACCOUNT' && (_jsxs(_Fragment, { children: [milestone.bonus && (_jsxs("p", { className: "text-[#94969C] text-sm", children: ["Link your Facebook Account and get Php", ' ', milestone.bonus, " Bonus"] })), _jsx(FacebookSignInTrigger, { text: "Link Facebook Account", className: "!mt-0 flex h-10 w-full items-center justify-center gap-md rounded-md bg-button-primary-bg px-3 font-semibold text-button-primary-fg text-sm shadow-xs disabled:opacity-60 disabled:shadow-none aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:shadow-none" })] })), !milestone.isCompleted &&
170
- milestoneType === 'LINK_GOOGLE_ACCOUNT' && (_jsxs(_Fragment, { children: [milestone.bonus && (_jsxs("p", { className: "text-[#94969C] text-sm", children: ["Link your Google Account and get Php", ' ', milestone.bonus, " Bonus"] })), _jsx(GoogleSignInButton, { text: "Link Google Account", className: "flex h-10 w-full items-center justify-center gap-md rounded-md bg-button-primary-bg px-3 font-semibold text-button-primary-fg text-sm shadow-xs disabled:opacity-60 disabled:shadow-none aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:shadow-none" })] })), !milestone.isCompleted &&
177
+ milestoneType === 'LINK_FACEBOOK_ACCOUNT' && (_jsxs(_Fragment, { children: [milestone.bonus && (_jsxs("p", { className: "text-[#94969C] text-sm", children: ["Link your Facebook Account and get Php", ' ', milestone.bonus, " Bonus"] })), _jsx(FacebookSignInTrigger, { text: "Link Facebook Account", className: "!mt-0 flex h-10 w-full items-center justify-center gap-md rounded-md bg-button-primary-bg px-3 font-semibold text-button-primary-fg text-sm shadow-xs disabled:opacity-60 disabled:shadow-none aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:shadow-none", disabled: isExpired })] })), !milestone.isCompleted &&
178
+ milestoneType === 'LINK_GOOGLE_ACCOUNT' && (_jsxs(_Fragment, { children: [milestone.bonus && (_jsxs("p", { className: "text-[#94969C] text-sm", children: ["Link your Google Account and get Php", ' ', milestone.bonus, " Bonus"] })), _jsx(GoogleSignInButton, { text: "Link Google Account", className: "flex h-10 w-full items-center justify-center gap-md rounded-md bg-button-primary-bg px-3 font-semibold text-button-primary-fg text-sm shadow-xs disabled:opacity-60 disabled:shadow-none aria-disabled:cursor-not-allowed aria-disabled:opacity-60 aria-disabled:shadow-none", disabled: isExpired })] })), !milestone.isCompleted &&
171
179
  milestoneType === 'CUSTOM_LINK' &&
172
180
  (() => {
173
181
  const baseUrl = process.env.NEXT_PUBLIC_ENVIRONMENT === 'development'
174
182
  ? 'https://api.trigger.development.opexa.io'
175
183
  : 'https://api.trigger.opexa.io';
176
184
  const linkUrl = `${baseUrl}/v1/quests/${quest?.id}/milestones/${milestone.id}/link?token=${session?.token}`;
177
- return (_jsx(Button, { size: "sm", "aria-label": `Complete ${milestone.label}`, asChild: true, children: _jsxs(Link, { href: linkUrl, target: "_blank", rel: "noopener noreferrer", children: ["Click Here", _jsx(Link01Icon, { className: "size-5" })] }) }));
185
+ return (_jsx(Button, { size: "sm", "aria-label": `Complete ${milestone.label}`, asChild: !isExpired, disabled: isExpired, children: isExpired ? (_jsx("span", { children: "Quest Expired" })) : (_jsxs(Link, { href: linkUrl, target: "_blank", rel: "noopener noreferrer", children: ["Click Here", _jsx(Link01Icon, { className: "size-5" })] })) }));
178
186
  })()] }, milestone.key));
179
187
  }), quest?.bonus && (_jsx("div", { className: "flex h-full items-end", children: allMilestonesCompleted ? (_jsx(Button, { size: "sm", onClick: () => setOpen(false), "aria-label": "Close", className: "w-full", children: "Close" })) : (_jsx("div", { className: twMerge('w-full rounded-md border border-bg-primary-hover bg-button-secondary-bg px-3.5 py-2.5 text-center text-white', props.className?.uncompleteButton), children: _jsxs("p", { children: ["Complete target to", ' ', _jsxs("span", { className: "text-brand-400", children: ["\u20B1", quest?.bonus] }), ' ', "bonus!"] }) })) }))] })] }) })] }) }));
180
188
  }
@@ -1,14 +1,16 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- import { endOfDay } from 'date-fns';
2
+ import { useMemo } from 'react';
3
3
  import { useRemainingTime } from '../../client/hooks/useRemainingTime.js';
4
4
  import { ClockStopWatchIcon } from '../../icons/ClockStopWatchIcon.js';
5
5
  import { Badge } from '../../ui/Badge/index.js';
6
6
  import { useQuestContext } from './QuestsContext.js';
7
7
  export function RemainingTime({ endOfDay: useEndOfDay = false, className, }) {
8
8
  const quest = useQuestContext();
9
- const targetDateTime = useEndOfDay
10
- ? endOfDay(new Date(quest.endDateTime)).toISOString()
11
- : quest.endDateTime;
9
+ const targetDateTime = useMemo(() => {
10
+ const date = new Date(quest.dateTimeCreated);
11
+ date.setDate(date.getDate() + Number(quest.daysToClear ?? 0));
12
+ return date;
13
+ }, [quest.dateTimeCreated, quest.daysToClear]);
12
14
  const remainingTime = useRemainingTime(targetDateTime);
13
15
  if (quest.status === 'COMPLETED') {
14
16
  return (_jsx(Badge.Root, { size: "lg", colorScheme: "success", round: false, className: className?.completedBadgeRoot, children: _jsx(Badge.Label, { className: className?.completedBadgeLabel, children: "Completed" }) }));
@@ -1,4 +1,5 @@
1
- interface FacebookSignInTriggerProps {
1
+ import type { ComponentPropsWithRef } from 'react';
2
+ interface FacebookSignInTriggerProps extends ComponentPropsWithRef<'button'> {
2
3
  text?: string;
3
4
  className?: string;
4
5
  }
@@ -46,6 +46,6 @@ export const FacebookSignInTrigger = (props) => {
46
46
  description: 'Failed to sign in with Facebook. Please try again.',
47
47
  });
48
48
  }, render: ({ onClick }) => {
49
- return (_jsxs(Button, { variant: "outline", id: "fb-btn", onClick: onClick, colorScheme: "gray", className: `mt-lg border-border-primary bg-bg-primary text-text-secondary-700 ${props.className}`, children: [_jsx(FacebookIcon, { className: "size-6" }), props.text ?? 'Continue with Facebook'] }));
49
+ return (_jsxs(Button, { variant: "outline", id: "fb-btn", onClick: onClick, colorScheme: "gray", disabled: props.disabled, className: `mt-lg border-border-primary bg-bg-primary text-text-secondary-700 ${props.className}`, children: [_jsx(FacebookIcon, { className: "size-6" }), props.text ?? 'Continue with Facebook'] }));
50
50
  } }));
51
51
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opexa/portal-components",
3
- "version": "0.0.1079",
3
+ "version": "0.0.1081",
4
4
  "exports": {
5
5
  "./ui/*": {
6
6
  "types": "./dist/ui/*/index.d.ts",