@opexa/portal-components 0.0.46 → 0.0.48
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Account/Account.js +7 -2
- package/dist/components/BetRecords/BetRecords.js +5 -16
- package/dist/components/Messages/Messages.d.ts +14 -1
- package/dist/components/Messages/Messages.js +11 -4
- package/dist/components/TransactionRecords/DepositRecordsTable.js +5 -17
- package/dist/components/TransactionRecords/TransactionRecords.js +1 -1
- package/dist/components/TransactionRecords/TransactionRecordsTable.js +5 -17
- package/dist/components/TransactionRecords/WithdrawalRecordsTable.js +5 -17
- package/dist/styles/theme.css +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/ui/SegmentGroup/SegmentGroup.d.ts +18 -18
- package/dist/ui/SegmentGroup/segmentGroup.recipe.d.ts +3 -3
- package/dist/ui/SegmentGroup/segmentGroup.recipe.js +1 -1
- package/dist/ui/Table/Table.d.ts +21 -21
- package/dist/ui/Table/table.recipe.d.ts +3 -3
- package/dist/ui/Table/table.recipe.js +1 -1
- package/dist/ui/Tabs/Tabs.d.ts +15 -15
- package/dist/ui/Tabs/tabs.recipe.d.ts +3 -3
- package/dist/ui/Tabs/tabs.recipe.js +1 -1
- package/package.json +1 -1
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { Portal } from '@ark-ui/react';
|
|
4
4
|
import Image from 'next/image';
|
|
5
5
|
import Link from 'next/link';
|
|
6
|
+
import { twMerge } from 'tailwind-merge';
|
|
6
7
|
import { useShallow } from 'zustand/shallow';
|
|
7
8
|
import { useAccountQuery, useGlobalStore, useLocaleInfo, useSignOutMutation, useUnreadMessagesCountQuery, useWalletQuery, } from '../../client/hooks/index.js';
|
|
8
9
|
import { AlertCircleIcon, ChevronRightIcon, CoinsStacked02Icon, CoinsSwap02Icon, Gift01Icon, Logout01Icon, Settings02Icon, XIcon, } from '../../icons/index.js';
|
|
@@ -20,10 +21,14 @@ export function Account(props) {
|
|
|
20
21
|
const betRecordsUrl = props.betRecordsUrl ?? '/bet-records';
|
|
21
22
|
const transactionsUrl = props.transactionsUrl ?? '/transactions';
|
|
22
23
|
const accountSettingsUrl = props.accountSettingsUrl ?? '/account';
|
|
24
|
+
const [mobileOffsetTop, desktopOffsetTop] = Array.isArray(props.offsetTop)
|
|
25
|
+
? props.offsetTop
|
|
26
|
+
: [props.offsetTop ?? '0px', props.offsetTop ?? '0px'];
|
|
23
27
|
return (_jsxs(_Fragment, { children: [_jsxs(Drawer.Root, { open: globalStore.account__mobile.open, onOpenChange: (details) => {
|
|
24
28
|
globalStore.account__mobile.setOpen(details.open);
|
|
25
|
-
}, lazyMount: true, unmountOnExit: true, children: [_jsx(Drawer.Trigger, { asChild: true, className: "lg:hidden", children: props.children ?? (_jsx(IconButton, { size: "sm", colorScheme: "gray", children: globalStore.account__mobile.open ? (_jsx(XIcon, {})) : (_jsx(Image, { src: avatarPlaceholder, alt: "", width: 100, height: 100, className: "size-10" })) })) }), _jsx(Portal, { children: _jsx(Drawer.Positioner, { children: _jsxs(Drawer.Content, { className:
|
|
26
|
-
['--top']:
|
|
29
|
+
}, lazyMount: true, unmountOnExit: true, children: [_jsx(Drawer.Trigger, { asChild: true, className: "lg:hidden", children: props.children ?? (_jsx(IconButton, { size: "sm", colorScheme: "gray", children: globalStore.account__mobile.open ? (_jsx(XIcon, {})) : (_jsx(Image, { src: avatarPlaceholder, alt: "", width: 100, height: 100, className: "size-10" })) })) }), _jsx(Portal, { children: _jsx(Drawer.Positioner, { children: _jsxs(Drawer.Content, { className: twMerge('relative', 'flex', 'flex-col', 'top-[var(--offset-top-mobile)]', 'h-[calc(100%-var(--offset-top-mobile))]', 'w-full', 'px-xl', 'py-6', 'lg:top-[var(--offset-top-desktop)]', 'lg:h-[calc(100%-var(--offset-top-desktop))]'), style: {
|
|
30
|
+
['--offset-top-mobile']: mobileOffsetTop,
|
|
31
|
+
['--offset-top-desktop']: desktopOffsetTop,
|
|
27
32
|
}, children: [_jsx(Profile, {}), _jsx(Wallet, {}), _jsx(Links, { rewardsUrl: rewardsUrl, betRecordsUrl: betRecordsUrl, transactionsUrl: transactionsUrl, accountSettingsUrl: accountSettingsUrl })] }) }) })] }), _jsxs(Popover.Root, { open: globalStore.account.open, onOpenChange: (details) => {
|
|
28
33
|
globalStore.account.setOpen(details.open);
|
|
29
34
|
}, lazyMount: true, unmountOnExit: true, positioning: {
|
|
@@ -29,7 +29,7 @@ export function BetRecords(props) {
|
|
|
29
29
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
30
30
|
}),
|
|
31
31
|
});
|
|
32
|
-
const { page,
|
|
32
|
+
const { page, hasNextPage, hasPrevPage, next, prev, rows, totalPages, loading, firstPage, } = useInfiniteQueryHelper(useBetRecordsQuery, {
|
|
33
33
|
filter: {
|
|
34
34
|
...(state.type && {
|
|
35
35
|
game__type: {
|
|
@@ -58,7 +58,7 @@ export function BetRecords(props) {
|
|
|
58
58
|
}),
|
|
59
59
|
},
|
|
60
60
|
});
|
|
61
|
-
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "text-
|
|
61
|
+
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "text-sm font-semibold leading-tight lg:text-lg", children: "Bet Records" }), _jsx("p", { className: "text-text-tertiary-600 mt-xs text-sm leading-tight", children: "Review your betting history" }), _jsx("div", { className: "mt-lg lg:mt-2xl", children: _jsxs(SegmentGroup.Root, { value: state.type, onValueChange: (details) => {
|
|
62
62
|
firstPage();
|
|
63
63
|
setState({
|
|
64
64
|
type: z
|
|
@@ -67,7 +67,7 @@ export function BetRecords(props) {
|
|
|
67
67
|
});
|
|
68
68
|
}, children: [props.gameTypes.map((type) => (_jsxs(SegmentGroup.Item, { value: type, children: [_jsx(SegmentGroup.ItemText, { children: capitalize(type, {
|
|
69
69
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
70
|
-
}) }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }, type))), _jsx(SegmentGroup.Indicator, {})] }) }), _jsx("h3", { className: "text-text-secondary-700 mt-3xl text-sm font-semibold", children: "Table" }), _jsxs("div", { className: "mt-xl flex flex-col gap-lg lg:flex-row lg:items-center", children: [_jsxs(DatePicker.Root, { lazyMount: true, unmountOnExit: true, value: [state.timestamp?.start, state.timestamp?.end]
|
|
70
|
+
}) }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }, type))), _jsx(SegmentGroup.Indicator, {})] }) }), _jsx("div", { className: "border-border-secondary mt-2xl hidden border-t lg:block" }), _jsx("h3", { className: "text-text-secondary-700 mt-3xl text-sm font-semibold", children: "Table" }), _jsxs("div", { className: "mt-xl flex flex-col gap-lg lg:flex-row lg:items-center", children: [_jsxs(DatePicker.Root, { lazyMount: true, unmountOnExit: true, value: [state.timestamp?.start, state.timestamp?.end]
|
|
71
71
|
.filter(Boolean)
|
|
72
72
|
.map((d) => parseDate(d)), onValueChange: (details) => {
|
|
73
73
|
firstPage();
|
|
@@ -134,7 +134,7 @@ export function BetRecords(props) {
|
|
|
134
134
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
135
135
|
}) }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, status))) }) }) }) })] })] }), rows.length <= 0 && (_jsx(Empty, { icon: loading ? SpinnerIcon : File02Icon, title: loading ? 'Just a moment' : 'No data', message: loading
|
|
136
136
|
? 'Fetching latest bet records...'
|
|
137
|
-
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-
|
|
137
|
+
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-xl', 'border-y', 'border-border-secondary', 'relative', 'left-1/2', 'right-1/2', '-mx-[50dvw]', 'w-dvw', 'lg:mt-3xl', 'lg:-mx-0', 'lg:-ml-0', 'lg:left-0', 'lg:right-0', 'lg:w-full', 'lg:rounded-xl', 'lg:border-x'), children: [_jsx("div", { className: "border-border-secondary scrollbar-thumb:bg-bg-quaternary scrollbar-track:bg-transparent scrollbar:h-2 scrollbar-thumb:rounded-full overflow-hidden overflow-x-auto rounded-none border-b lg:rounded-t-xl", children: _jsxs(Table.Root, { className: "border-0", children: [_jsx(Table.Header, { children: _jsxs(Table.Row, { children: [_jsx(Table.Heading, { children: "Bet Time" }), _jsx(Table.Heading, { children: "Settlement Time" }), _jsx(Table.Heading, { children: "Bet Content" }), _jsx(Table.Heading, { children: "Odds" }), _jsx(Table.Heading, { children: "Bet Amount" }), _jsx(Table.Heading, { children: "Valid Bet" }), _jsx(Table.Heading, { children: "Settled Amount" }), _jsx(Table.Heading, { children: "Jackpot Contribution" }), _jsx(Table.Heading, { children: "Jackpot Payout" }), _jsx(Table.Heading, { children: "Bet Status" }), _jsx(Table.Heading, { children: "Game Name" }), _jsx(Table.Heading, { children: "Vendor Round ID" })] }) }), _jsx(Table.Body, { children: rows.map((data) => (_jsxs(Table.Row, { children: [_jsxs(Table.Cell, { className: "!py-1", children: [_jsx("div", { className: "leading-tight", children: format(data.dateTimeCreated, 'MM/dd/yyyy', {
|
|
138
138
|
in: tz(localeInfo.timezone),
|
|
139
139
|
}) }), _jsx("div", { className: "text-text-tertiary-600 leading-tight", children: format(data.dateTimeCreated, 'hh:mm a', {
|
|
140
140
|
in: tz(localeInfo.timezone),
|
|
@@ -163,24 +163,13 @@ export function BetRecords(props) {
|
|
|
163
163
|
? 'blue'
|
|
164
164
|
: 'danger', children: _jsx(Badge.Label, { children: capitalize(data.status, {
|
|
165
165
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
166
|
-
}) }) }) }), _jsx(Table.Cell, { className: "!py-1", children: data.game.name }), _jsx(Table.Cell, { className: "!py-1", children: data.vendorRoundId })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center gap-lg px-4 py-3", children: [_jsxs("p", { className: "text-text-secondary-700
|
|
167
|
-
const n = parseInt(details.value[0]);
|
|
168
|
-
const v = isNaN(n) ? 10 : n;
|
|
169
|
-
setPageSize(v);
|
|
170
|
-
}, collection: pageSizeCollection, lazyMount: true, className: "hidden lg:block", positioning: {
|
|
171
|
-
sameWidth: true,
|
|
172
|
-
}, children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) }), _jsx(Portal, { children: _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: pageSizeCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: pageSizeCollection.stringifyItem(item) }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item))) }) }) })] }) }), _jsxs("div", { className: "contents lg:flex", children: [_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-1 lg:order-none lg:rounded-r-none lg:border-r-0", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-3 lg:order-none lg:rounded-l-none", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] })] }))] }));
|
|
166
|
+
}) }) }) }), _jsx(Table.Cell, { className: "!py-1", children: data.game.name }), _jsx(Table.Cell, { className: "!py-1", children: data.vendorRoundId })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center justify-between gap-lg px-4 py-3", children: [_jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsxs("p", { className: "text-text-secondary-700 text-sm font-medium", children: ["Page ", page, " of ", totalPages] }), _jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] }))] }));
|
|
173
167
|
}
|
|
174
168
|
const BET_RECORD_STATUSES = [
|
|
175
169
|
'CANCELLED',
|
|
176
170
|
'SETTLED',
|
|
177
171
|
'STARTED',
|
|
178
172
|
];
|
|
179
|
-
const pageSizeCollection = createListCollection({
|
|
180
|
-
items: useInfiniteQueryHelper.config.pageSizes,
|
|
181
|
-
itemToValue: (item) => item.toString(),
|
|
182
|
-
itemToString: (item) => `${item} items per page`,
|
|
183
|
-
});
|
|
184
173
|
const statusCollection = createListCollection({
|
|
185
174
|
items: BET_RECORD_STATUSES,
|
|
186
175
|
itemToValue: (item) => item,
|
|
@@ -1 +1,14 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface MessagesProps {
|
|
2
|
+
children?: React.ReactNode;
|
|
3
|
+
/**
|
|
4
|
+
* @default '0px'
|
|
5
|
+
* @example
|
|
6
|
+
* ```tsx
|
|
7
|
+
* offsetTop="1em"
|
|
8
|
+
* offsetTop="1rem"
|
|
9
|
+
* offsetTop="16px"
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
offsetTop?: string | [mobile: string, desktop: string];
|
|
13
|
+
}
|
|
14
|
+
export declare function Messages(props: MessagesProps): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Portal } from '@ark-ui/react';
|
|
4
|
+
import { twMerge } from 'tailwind-merge';
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
import { useShallow } from 'zustand/shallow';
|
|
6
7
|
import { useGlobalStore, useMessagesQuery, useUnreadMessagesCountQuery, } from '../../client/hooks/index.js';
|
|
@@ -10,7 +11,7 @@ import { InfiniteScroll } from '../InfiniteScroll.js';
|
|
|
10
11
|
import { MessageItem } from './MessageItem.js';
|
|
11
12
|
import { MessagePopup } from './MessagePopup.js';
|
|
12
13
|
const TABS = ['ALL', 'UNREAD'];
|
|
13
|
-
export function Messages() {
|
|
14
|
+
export function Messages(props) {
|
|
14
15
|
const globalStore = useGlobalStore(useShallow((ctx) => ({ messages: ctx.messages })));
|
|
15
16
|
const unreadMessagesCountQuery = useUnreadMessagesCountQuery({}, { refetchInterval: 5000 });
|
|
16
17
|
const unreadMessagesCount = unreadMessagesCountQuery.data ?? 0;
|
|
@@ -25,7 +26,13 @@ export function Messages() {
|
|
|
25
26
|
}),
|
|
26
27
|
}, { refetchInterval: 5000 });
|
|
27
28
|
const messages = messagesQuery.data?.pages.flatMap((page) => page.edges.map((e) => e.node)) ?? [];
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
const [mobileOffsetTop, desktopOffsetTop] = Array.isArray(props.offsetTop)
|
|
30
|
+
? props.offsetTop
|
|
31
|
+
: [props.offsetTop ?? '0px', props.offsetTop ?? '0px'];
|
|
32
|
+
return (_jsxs(_Fragment, { children: [_jsxs(Drawer.Root, { open: globalStore.messages.open, onOpenChange: ({ open }) => globalStore.messages.setOpen(open), lazyMount: true, unmountOnExit: true, children: [_jsx(Drawer.Trigger, { asChild: true, children: props.children ?? (_jsxs(IconButton, { size: "sm", colorScheme: "gray", className: "relative", children: [!!unreadMessagesCount && (_jsx("div", { className: "bg-brand-500 leading-4.5 text-button-primary-fg absolute -right-1.5 -top-1.5 rounded-full border px-1.5 text-2xs font-semibold", children: unreadMessagesCount })), _jsx(Bell01Icon, {})] })) }), _jsx(Portal, { children: _jsx(Drawer.Positioner, { children: _jsx(Drawer.Content, { className: twMerge('flex', 'flex-col', 'border-border-secondary', 'top-[var(--offset-top-mobile)]', 'h-[calc(100%-var(--offset-top-mobile))]', 'lg:border-l', 'lg:top-[var(--offset-top-desktop)]', 'lg:h-[calc(100%-var(--offset-top-desktop))]'), style: {
|
|
33
|
+
['--offset-top-mobile']: mobileOffsetTop,
|
|
34
|
+
['--offset-top-desktop']: desktopOffsetTop,
|
|
35
|
+
}, children: _jsxs("div", { className: "flex flex-col space-y-6", children: [_jsxs("div", { className: "flex items-end justify-between px-4 pt-6", children: [_jsx("p", { className: "text-text-primary-brand text-xl font-semibold", children: "Notifications" }), _jsx(Drawer.CloseTrigger, { className: "p-2", children: _jsx(XIcon, {}) })] }), _jsxs(Tabs.Root, { value: globalStore.messages.tab, onValueChange: (details) => globalStore.messages.setTab(z.enum(TABS).parse(details.value)), lazyMount: true, unmountOnExit: true, children: [_jsx("div", { className: "mb-4 w-full px-4", children: _jsxs(Tabs.List, { className: "border-border-secondary w-full border", children: [_jsx(Tabs.Trigger, { value: "ALL", className: "flex-1/5 ui-selected:text-text-primary-brand text-text-tertiary-600", children: "All" }), _jsxs(Tabs.Trigger, { value: "UNREAD", className: "flex-1/5 ui-selected:text-text-primary-brand text-text-tertiary-600 flex items-center justify-center space-x-2", children: [_jsx("div", { children: "Unread" }), !!unreadMessagesCount && (_jsx("div", { className: "border-border-primary bg-bg-secondary rounded-full border px-2 py-0.5", children: unreadMessagesCount }))] }), _jsx(Tabs.Indicator, { className: "bg-bg-active" })] }) }), _jsx("div", { className: "border-border-secondary w-full border-t" }), TABS.map((tab) => (_jsxs(Tabs.Content, { value: tab, className: "scrollbar:w-2 scrollbar-track:bg-bg-primary-alt scrollbar-track:rounded-full scrollbar-thumb:bg-bg-quaternary scrollbar-thumb:rounded-full max-h-[calc(100vh-197px)] overflow-y-auto p-xl", style: { scrollbarGutter: 'stable' }, children: [messages.length > 0 && (_jsx("div", { className: "flex flex-col space-y-4", children: messages.map((message) => (_jsx(MessageItem, { message: message }, message.id))) })), _jsx(InfiniteScroll, { loader: _jsx(SpinnerIcon, { className: "mx-auto size-5" }), hasMore: !!messagesQuery.hasNextPage, loadMore: async () => {
|
|
36
|
+
await messagesQuery.fetchNextPage();
|
|
37
|
+
}, className: "mt-4" })] }, tab)))] })] }) }) }) })] }), _jsx(MessagePopup, {})] }));
|
|
31
38
|
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { createListCollection, Portal } from '@ark-ui/react';
|
|
3
2
|
import { tz, TZDateMini } from '@date-fns/tz';
|
|
4
3
|
import {} from '@opexa/portal-sdk-core';
|
|
5
4
|
import { endOfDay, format, startOfDay } from 'date-fns';
|
|
6
5
|
import { useState } from 'react';
|
|
7
6
|
import { twMerge } from 'tailwind-merge';
|
|
8
7
|
import { useDepositRecordsQuery, useInfiniteQueryHelper, useLocaleInfo, } from '../../client/hooks/index.js';
|
|
9
|
-
import {
|
|
10
|
-
import { Badge, IconButton,
|
|
8
|
+
import { ChevronLeftIcon, ChevronRightIcon, File02Icon, SpinnerIcon, } from '../../icons/index.js';
|
|
9
|
+
import { Badge, IconButton, Table } from '../../ui/index.js';
|
|
11
10
|
import { capitalize, formatNumber } from '../../utils/index.js';
|
|
12
11
|
import { Empty } from '../Empty.js';
|
|
13
12
|
import { TableFilters } from './TableFilters.js';
|
|
@@ -15,7 +14,7 @@ export function DepositRecordsTable() {
|
|
|
15
14
|
const [timestamp, setTimestamp] = useState();
|
|
16
15
|
const [depositStatus, setDepositStatus] = useState();
|
|
17
16
|
const localeInfo = useLocaleInfo();
|
|
18
|
-
const { page,
|
|
17
|
+
const { page, hasNextPage, hasPrevPage, next, prev, rows, totalPages, loading, firstPage, } = useInfiniteQueryHelper(useDepositRecordsQuery, {
|
|
19
18
|
filter: {
|
|
20
19
|
...(depositStatus && {
|
|
21
20
|
status: {
|
|
@@ -45,7 +44,7 @@ export function DepositRecordsTable() {
|
|
|
45
44
|
setDepositStatus(value.depositStatus);
|
|
46
45
|
} }), rows.length <= 0 && (_jsx(Empty, { icon: loading ? SpinnerIcon : File02Icon, title: loading ? 'Just a moment' : 'No data', message: loading
|
|
47
46
|
? 'Fetching latest deposit records...'
|
|
48
|
-
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-
|
|
47
|
+
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-xl', 'border-y', 'border-border-secondary', 'relative', 'left-1/2', 'right-1/2', '-mx-[50dvw]', 'w-dvw', 'lg:mt-3xl', 'lg:-mx-0', 'lg:-ml-0', 'lg:left-0', 'lg:right-0', 'lg:w-full', 'lg:rounded-xl', 'lg:border-x'), children: [_jsx("div", { className: "border-border-secondary scrollbar-thumb:bg-bg-quaternary scrollbar-track:bg-transparent scrollbar:h-2 scrollbar-thumb:rounded-full overflow-hidden overflow-x-auto rounded-none border-b lg:rounded-t-xl", children: _jsxs(Table.Root, { className: "border-0", children: [_jsx(Table.Header, { children: _jsxs(Table.Row, { children: [_jsx(Table.Heading, { children: "Deposit No." }), _jsx(Table.Heading, { children: "Reference" }), _jsx(Table.Heading, { children: "Deposit Method" }), _jsx(Table.Heading, { children: "Applied Amount" }), _jsx(Table.Heading, { children: "Recieved Amount" }), _jsx(Table.Heading, { children: "Transaction Fee" }), _jsx(Table.Heading, { children: "Deposit Time" }), _jsx(Table.Heading, { children: "Recieved Time" }), _jsx(Table.Heading, { children: "Status" })] }) }), _jsx(Table.Body, { children: rows.map((data) => (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { className: "!py-1", children: data.depositNumber }), _jsx(Table.Cell, { className: "!py-1", children: data.reference }), _jsx(Table.Cell, { className: "!py-1", children: capitalize(data.type, {
|
|
49
48
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
50
49
|
}) }), _jsx(Table.Cell, { className: "!py-1", children: formatNumber(data.amount, {
|
|
51
50
|
currency: localeInfo.currency.code,
|
|
@@ -73,16 +72,5 @@ export function DepositRecordsTable() {
|
|
|
73
72
|
? 'warning'
|
|
74
73
|
: 'success', children: _jsx(Badge.Label, { children: capitalize(data.status, {
|
|
75
74
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
76
|
-
}) }) }) })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center gap-lg px-4 py-3", children: [_jsxs("p", { className: "text-text-secondary-700
|
|
77
|
-
const n = parseInt(details.value[0]);
|
|
78
|
-
const v = isNaN(n) ? 10 : n;
|
|
79
|
-
setPageSize(v);
|
|
80
|
-
}, collection: pageSizeCollection, lazyMount: true, className: "hidden lg:block", positioning: {
|
|
81
|
-
sameWidth: true,
|
|
82
|
-
}, children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) }), _jsx(Portal, { children: _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: pageSizeCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: pageSizeCollection.stringifyItem(item) }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item))) }) }) })] }) }), _jsxs("div", { className: "contents lg:flex", children: [_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-1 lg:order-none lg:rounded-r-none lg:border-r-0", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-3 lg:order-none lg:rounded-l-none", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] })] }))] }));
|
|
75
|
+
}) }) }) })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center justify-between gap-lg px-4 py-3", children: [_jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsxs("p", { className: "text-text-secondary-700 text-sm font-medium", children: ["Page ", page, " of ", totalPages] }), _jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] }))] }));
|
|
83
76
|
}
|
|
84
|
-
const pageSizeCollection = createListCollection({
|
|
85
|
-
items: useInfiniteQueryHelper.config.pageSizes,
|
|
86
|
-
itemToValue: (item) => item.toString(),
|
|
87
|
-
itemToString: (item) => `${item} items per page`,
|
|
88
|
-
});
|
|
@@ -5,5 +5,5 @@ import { DepositRecordsTable } from './DepositRecordsTable.js';
|
|
|
5
5
|
import { TransactionRecordsTable } from './TransactionRecordsTable.js';
|
|
6
6
|
import { WithdrawalRecordsTable } from './WithdrawalRecordsTable.js';
|
|
7
7
|
export function TransactionRecords(props) {
|
|
8
|
-
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "text-
|
|
8
|
+
return (_jsxs("div", { className: props.className, children: [_jsx("h2", { className: "text-sm font-semibold leading-tight lg:text-lg", children: "Transactions" }), _jsx("p", { className: "text-text-tertiary-600 mt-xs text-sm leading-tight", children: "View your transaction records" }), _jsxs(Tabs.Root, { className: "mt-lg lg:mt-2xl", defaultValue: "transactions", lazyMount: true, unmountOnExit: true, children: [_jsxs(Tabs.List, { children: [_jsx(Tabs.Trigger, { value: "transactions", children: "Transactions" }), _jsx(Tabs.Trigger, { value: "deposits", children: "Deposits" }), _jsx(Tabs.Trigger, { value: "withdrawals", children: "Withdrawals" }), _jsx(Tabs.Indicator, {})] }), _jsx("div", { className: "border-border-secondary mt-2xl hidden border-t lg:block" }), _jsx("h3", { className: "text-text-secondary-700 mt-3xl text-sm font-semibold", children: "Table" }), _jsx(Tabs.Content, { value: "transactions", className: "mt-xl", children: _jsx(TransactionRecordsTable, {}) }), _jsx(Tabs.Content, { value: "deposits", className: "mt-xl", children: _jsx(DepositRecordsTable, {}) }), _jsx(Tabs.Content, { value: "withdrawals", className: "mt-xl", children: _jsx(WithdrawalRecordsTable, {}) })] })] }));
|
|
9
9
|
}
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { createListCollection, Portal } from '@ark-ui/react';
|
|
3
2
|
import { tz, TZDateMini } from '@date-fns/tz';
|
|
4
3
|
import { endOfDay, format, startOfDay } from 'date-fns';
|
|
5
4
|
import { useState } from 'react';
|
|
6
5
|
import { twMerge } from 'tailwind-merge';
|
|
7
6
|
import { useInfiniteQueryHelper, useLocaleInfo, useTransactionRecordsQuery, } from '../../client/hooks/index.js';
|
|
8
|
-
import {
|
|
9
|
-
import { IconButton,
|
|
7
|
+
import { ChevronLeftIcon, ChevronRightIcon, File02Icon, SpinnerIcon, } from '../../icons/index.js';
|
|
8
|
+
import { IconButton, Table } from '../../ui/index.js';
|
|
10
9
|
import { capitalize, formatNumber } from '../../utils/index.js';
|
|
11
10
|
import { Empty } from '../Empty.js';
|
|
12
11
|
import { TableFilters } from './TableFilters.js';
|
|
13
12
|
export function TransactionRecordsTable() {
|
|
14
13
|
const [timestamp, setTimestamp] = useState();
|
|
15
14
|
const localeInfo = useLocaleInfo();
|
|
16
|
-
const { page,
|
|
15
|
+
const { page, hasNextPage, hasPrevPage, next, prev, rows, totalPages, loading, firstPage, } = useInfiniteQueryHelper(useTransactionRecordsQuery, {
|
|
17
16
|
filter: {
|
|
18
17
|
...(timestamp && {
|
|
19
18
|
dateTimeCreated: {
|
|
@@ -36,7 +35,7 @@ export function TransactionRecordsTable() {
|
|
|
36
35
|
transactionType: true,
|
|
37
36
|
} }), rows.length <= 0 && (_jsx(Empty, { icon: loading ? SpinnerIcon : File02Icon, title: loading ? 'Just a moment' : 'No data', message: loading
|
|
38
37
|
? 'Fetching latest transaction records...'
|
|
39
|
-
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-
|
|
38
|
+
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-xl', 'border-y', 'border-border-secondary', 'relative', 'left-1/2', 'right-1/2', '-mx-[50dvw]', 'w-dvw', 'lg:mt-3xl', 'lg:-mx-0', 'lg:-ml-0', 'lg:left-0', 'lg:right-0', 'lg:w-full', 'lg:rounded-xl', 'lg:border-x'), children: [_jsx("div", { className: "border-border-secondary scrollbar-thumb:bg-bg-quaternary scrollbar-track:bg-transparent scrollbar:h-2 scrollbar-thumb:rounded-full overflow-hidden overflow-x-auto rounded-none border-b lg:rounded-t-xl", children: _jsxs(Table.Root, { className: "border-0", children: [_jsx(Table.Header, { children: _jsxs(Table.Row, { children: [_jsx(Table.Heading, { children: "Transaction Type" }), _jsx(Table.Heading, { children: "Transaction Time" }), _jsx(Table.Heading, { children: "Amount" }), _jsx(Table.Heading, { children: "Current Balance" }), _jsx(Table.Heading, { children: "Reference Number" }), _jsx(Table.Heading, { children: "Content" })] }) }), _jsx(Table.Body, { children: rows.map((data) => (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { className: "!py-1", children: capitalize(data.type, {
|
|
40
39
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
41
40
|
}) }), _jsxs(Table.Cell, { className: "!py-1", children: [_jsx("div", { className: "leading-tight", children: format(data.dateTimeCreated, 'MM/dd/yyyy', {
|
|
42
41
|
in: tz(localeInfo.timezone),
|
|
@@ -48,16 +47,5 @@ export function TransactionRecordsTable() {
|
|
|
48
47
|
}) }), _jsx(Table.Cell, { className: "!py-1", children: formatNumber(data.currentBalance, {
|
|
49
48
|
currency: localeInfo.currency.code,
|
|
50
49
|
minDecimalPlaces: 2,
|
|
51
|
-
}) }), _jsx(Table.Cell, { className: "!py-1", children: data.referenceNumber }), _jsx(Table.Cell, { className: "!py-1", children: data.content || '/' })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center gap-lg px-4 py-3", children: [_jsxs("p", { className: "text-text-secondary-700
|
|
52
|
-
const n = parseInt(details.value[0]);
|
|
53
|
-
const v = isNaN(n) ? 10 : n;
|
|
54
|
-
setPageSize(v);
|
|
55
|
-
}, collection: pageSizeCollection, lazyMount: true, className: "hidden lg:block", positioning: {
|
|
56
|
-
sameWidth: true,
|
|
57
|
-
}, children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) }), _jsx(Portal, { children: _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: pageSizeCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: pageSizeCollection.stringifyItem(item) }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item))) }) }) })] }) }), _jsxs("div", { className: "contents lg:flex", children: [_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-1 lg:order-none lg:rounded-r-none lg:border-r-0", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-3 lg:order-none lg:rounded-l-none", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] })] }))] }));
|
|
50
|
+
}) }), _jsx(Table.Cell, { className: "!py-1", children: data.referenceNumber }), _jsx(Table.Cell, { className: "!py-1", children: data.content || '/' })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center justify-between gap-lg px-4 py-3", children: [_jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsxs("p", { className: "text-text-secondary-700 text-sm font-medium", children: ["Page ", page, " of ", totalPages] }), _jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] }))] }));
|
|
58
51
|
}
|
|
59
|
-
const pageSizeCollection = createListCollection({
|
|
60
|
-
items: useInfiniteQueryHelper.config.pageSizes,
|
|
61
|
-
itemToValue: (item) => item.toString(),
|
|
62
|
-
itemToString: (item) => `${item} items per page`,
|
|
63
|
-
});
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { createListCollection, Portal } from '@ark-ui/react';
|
|
3
2
|
import { tz, TZDateMini } from '@date-fns/tz';
|
|
4
3
|
import { endOfDay, format, startOfDay } from 'date-fns';
|
|
5
4
|
import { useState } from 'react';
|
|
6
5
|
import { twMerge } from 'tailwind-merge';
|
|
7
6
|
import { useInfiniteQueryHelper, useLocaleInfo, useWithdrawalRecordsQuery, } from '../../client/hooks/index.js';
|
|
8
|
-
import {
|
|
9
|
-
import { Badge, IconButton,
|
|
7
|
+
import { ChevronLeftIcon, ChevronRightIcon, File02Icon, SpinnerIcon, } from '../../icons/index.js';
|
|
8
|
+
import { Badge, IconButton, Table } from '../../ui/index.js';
|
|
10
9
|
import { capitalize, formatNumber } from '../../utils/index.js';
|
|
11
10
|
import { Empty } from '../Empty.js';
|
|
12
11
|
import { TableFilters } from './TableFilters.js';
|
|
@@ -14,7 +13,7 @@ export function WithdrawalRecordsTable() {
|
|
|
14
13
|
const [timestamp, setTimestamp] = useState();
|
|
15
14
|
const [withdrawalStatus, setWithdrawalStatus] = useState();
|
|
16
15
|
const localeInfo = useLocaleInfo();
|
|
17
|
-
const { page,
|
|
16
|
+
const { page, hasNextPage, hasPrevPage, next, prev, rows, totalPages, loading, firstPage, } = useInfiniteQueryHelper(useWithdrawalRecordsQuery, {
|
|
18
17
|
filter: {
|
|
19
18
|
...(withdrawalStatus && {
|
|
20
19
|
status: {
|
|
@@ -44,7 +43,7 @@ export function WithdrawalRecordsTable() {
|
|
|
44
43
|
setWithdrawalStatus(value.withdrawalStatus);
|
|
45
44
|
} }), rows.length <= 0 && (_jsx(Empty, { icon: loading ? SpinnerIcon : File02Icon, title: loading ? 'Just a moment' : 'No data', message: loading
|
|
46
45
|
? 'Fetching latest withdrawal records...'
|
|
47
|
-
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-
|
|
46
|
+
: 'No data is currently available.', className: "mt-5xl" })), rows.length >= 1 && (_jsxs("div", { className: twMerge('mt-xl', 'border-y', 'border-border-secondary', 'relative', 'left-1/2', 'right-1/2', '-mx-[50dvw]', 'w-dvw', 'lg:mt-3xl', 'lg:-mx-0', 'lg:-ml-0', 'lg:left-0', 'lg:right-0', 'lg:w-full', 'lg:rounded-xl', 'lg:border-x'), children: [_jsx("div", { className: "border-border-secondary scrollbar-thumb:bg-bg-quaternary scrollbar-track:bg-transparent scrollbar:h-2 scrollbar-thumb:rounded-full overflow-hidden overflow-x-auto rounded-none border-b lg:rounded-t-xl", children: _jsxs(Table.Root, { className: "border-0", children: [_jsx(Table.Header, { children: _jsxs(Table.Row, { children: [_jsx(Table.Heading, { children: "Withdrawal No." }), _jsx(Table.Heading, { children: "Reference" }), _jsx(Table.Heading, { children: "Withdrawal Method" }), _jsx(Table.Heading, { children: "Mobile Number" }), _jsx(Table.Heading, { children: "Withdrawal Amount" }), _jsx(Table.Heading, { children: "Net Amount" }), _jsx(Table.Heading, { children: "Transaction Fee" }), _jsx(Table.Heading, { children: "Bank Name" }), _jsx(Table.Heading, { children: "Withdrawal Time" }), _jsx(Table.Heading, { children: "Status" })] }) }), _jsx(Table.Body, { children: rows.map((data) => (_jsxs(Table.Row, { children: [_jsx(Table.Cell, { className: "!py-1", children: data.withdrawalNumber }), _jsx(Table.Cell, { className: "!py-1", children: data.reference }), _jsx(Table.Cell, { className: "!py-1", children: capitalize(data.type, {
|
|
48
47
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
49
48
|
}) }), _jsx(Table.Cell, { className: "!py-1", children: data.recipientMobileNumber }), _jsx(Table.Cell, { className: "!py-1", children: formatNumber(data.amount, {
|
|
50
49
|
currency: localeInfo.currency.code,
|
|
@@ -67,16 +66,5 @@ export function WithdrawalRecordsTable() {
|
|
|
67
66
|
? 'warning'
|
|
68
67
|
: 'success', children: _jsx(Badge.Label, { children: capitalize(data.status, {
|
|
69
68
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
70
|
-
}) }) }) })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center gap-lg px-4 py-3", children: [_jsxs("p", { className: "text-text-secondary-700
|
|
71
|
-
const n = parseInt(details.value[0]);
|
|
72
|
-
const v = isNaN(n) ? 10 : n;
|
|
73
|
-
setPageSize(v);
|
|
74
|
-
}, collection: pageSizeCollection, lazyMount: true, className: "hidden lg:block", positioning: {
|
|
75
|
-
sameWidth: true,
|
|
76
|
-
}, children: _jsxs(Select.Trigger, { children: [_jsx(Select.ValueText, {}), _jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) }), _jsx(Portal, { children: _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: pageSizeCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: pageSizeCollection.stringifyItem(item) }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item))) }) }) })] }) }), _jsxs("div", { className: "contents lg:flex", children: [_jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-1 lg:order-none lg:rounded-r-none lg:border-r-0", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsx(IconButton, { size: "sm", variant: "outline", colorScheme: "gray", className: "order-3 lg:order-none lg:rounded-l-none", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] })] }))] }));
|
|
69
|
+
}) }) }) })] }, data.id))) })] }) }), _jsxs("div", { className: "flex items-center justify-between gap-lg px-4 py-3", children: [_jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasPrevPage || loading, onClick: () => prev(), children: _jsx(ChevronLeftIcon, { className: "size-5" }) }), _jsxs("p", { className: "text-text-secondary-700 text-sm font-medium", children: ["Page ", page, " of ", totalPages] }), _jsx(IconButton, { size: "xs", variant: "outline", colorScheme: "gray", disabled: !hasNextPage || loading, onClick: () => next(), children: _jsx(ChevronRightIcon, { className: "size-5" }) })] })] }))] }));
|
|
77
70
|
}
|
|
78
|
-
const pageSizeCollection = createListCollection({
|
|
79
|
-
items: useInfiniteQueryHelper.config.pageSizes,
|
|
80
|
-
itemToValue: (item) => item.toString(),
|
|
81
|
-
itemToString: (item) => `${item} items per page`,
|
|
82
|
-
});
|
package/dist/styles/theme.css
CHANGED
|
@@ -211,6 +211,7 @@
|
|
|
211
211
|
--color-bg-brand-secondary: #ca8504;
|
|
212
212
|
--color-bg-brand-secondary-alt: #22262f;
|
|
213
213
|
--color-bg-secondary: #13161b;
|
|
214
|
+
--color-bg-secondary-alt: #0c0e12;
|
|
214
215
|
--color-bg-tertiary: #22262f;
|
|
215
216
|
--color-bg-quaternary: #373a41;
|
|
216
217
|
--color-bg-active: #22262f;
|