@opexa/portal-components 0.0.278 → 0.0.280
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.
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { createListCollection } from '@ark-ui/react/collection';
|
|
4
|
-
import { parseDate } from '@ark-ui/react/date-picker';
|
|
4
|
+
import { parseDate, useDatePickerContext } from '@ark-ui/react/date-picker';
|
|
5
5
|
import { tz, TZDateMini } from '@date-fns/tz';
|
|
6
6
|
import { endOfDay, format, startOfDay } from 'date-fns';
|
|
7
7
|
import { useReducer, useState } from 'react';
|
|
8
8
|
import { twMerge } from 'tailwind-merge';
|
|
9
|
+
import { useMediaQuery } from 'usehooks-ts';
|
|
9
10
|
import { z } from 'zod';
|
|
10
11
|
import { useBetRecordsQuery } from '../../client/hooks/useBetRecordsQuery.js';
|
|
12
|
+
import { useControllableState } from '../../client/hooks/useControllableState.js';
|
|
13
|
+
import { useDisclosure } from '../../client/hooks/useDisclosure.js';
|
|
11
14
|
import { useInfiniteQueryHelper } from '../../client/hooks/useInfiniteQueryHelper.js';
|
|
12
15
|
import { useLocaleInfo } from '../../client/hooks/useLocaleInfo.js';
|
|
13
16
|
import { GAME_PROVIDER_DATA, GAME_TYPE_DATA, GAME_TYPES, } from '../../constants/index.js';
|
|
@@ -69,7 +72,7 @@ export function BetRecords__client(props) {
|
|
|
69
72
|
}),
|
|
70
73
|
...(state.status && {
|
|
71
74
|
status: {
|
|
72
|
-
|
|
75
|
+
in: state.status === 'SETTLED' ? ['SETTLED'] : ['CANCELLED', 'STARTED'],
|
|
73
76
|
},
|
|
74
77
|
}),
|
|
75
78
|
...(state.timestamp && {
|
|
@@ -84,50 +87,46 @@ export function BetRecords__client(props) {
|
|
|
84
87
|
}),
|
|
85
88
|
},
|
|
86
89
|
});
|
|
90
|
+
const disclosure = useDisclosure({
|
|
91
|
+
onOpenChange(open) {
|
|
92
|
+
if (!open && !state.timestamp)
|
|
93
|
+
setTab('all');
|
|
94
|
+
},
|
|
95
|
+
});
|
|
87
96
|
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 ?? 'all', onValueChange: (details) => {
|
|
88
97
|
firstPage();
|
|
89
98
|
setState({
|
|
90
99
|
type: z.enum(GAME_TYPES).safeParse(details.value).data ?? null,
|
|
91
100
|
provider: null,
|
|
92
101
|
});
|
|
93
|
-
}, className: "w-full overflow-x-auto lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "all", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), gameTypes.map((type) => (_jsxs(SegmentGroup.Item, { value: type.id, children: [_jsx(SegmentGroup.ItemText, { children: type.name }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }, type.id))), _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(
|
|
94
|
-
.
|
|
95
|
-
|
|
102
|
+
}, className: "w-full overflow-x-auto lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "all", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), gameTypes.map((type) => (_jsxs(SegmentGroup.Item, { value: type.id, children: [_jsx(SegmentGroup.ItemText, { children: type.name }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }, type.id))), _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(SegmentGroup.Root, { value: tab, onValueChange: (details) => {
|
|
103
|
+
const value = TabDefinition.parse(details.value);
|
|
104
|
+
if (value === 'today') {
|
|
105
|
+
const now = new Date();
|
|
106
|
+
setState({
|
|
107
|
+
timestamp: {
|
|
108
|
+
start: startOfDay(now),
|
|
109
|
+
end: endOfDay(now),
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
setState({
|
|
115
|
+
timestamp: null,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
96
118
|
firstPage();
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
setTab('all');
|
|
109
|
-
}, selectionMode: "range", closeOnSelect: false, positioning: {
|
|
110
|
-
gutter: 20,
|
|
111
|
-
placement: 'bottom',
|
|
112
|
-
}, children: [_jsxs(SegmentGroup.Root, { value: tab, onValueChange: (details) => {
|
|
113
|
-
const value = TabDefinition.parse(details.value);
|
|
114
|
-
if (value === 'today') {
|
|
115
|
-
const now = new Date();
|
|
116
|
-
setState({
|
|
117
|
-
timestamp: {
|
|
118
|
-
start: startOfDay(now),
|
|
119
|
-
end: endOfDay(now),
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
setState({
|
|
125
|
-
timestamp: null,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
firstPage();
|
|
129
|
-
setTab(value);
|
|
130
|
-
}, className: "w-full lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "all", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "today", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Today" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(DatePicker.Context, { children: (api) => (_jsx(SegmentGroup.Item, { value: "custom", onClick: () => api.setOpen(true), className: "w-full lg:w-auto", children: _jsxs(DatePicker.Control, { children: [_jsx(SegmentGroup.ItemText, { children: "Custom" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }) })) }), _jsx(SegmentGroup.Indicator, {})] }), _jsx(Portal, { children: _jsx(DatePicker.Positioner, { children: _jsx(DatePicker.Content, { children: _jsx(DatePicker.View, { view: "day", children: _jsx(DatePicker.Context, { children: (api) => (_jsxs(_Fragment, { children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx(DatePicker.ViewTrigger, { children: _jsx(DatePicker.RangeText, {}) }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsxs(DatePicker.Table, { children: [_jsx(DatePicker.TableHead, { children: _jsx(DatePicker.TableRow, { children: api.weekDays.map((weekDay, id) => (_jsx(DatePicker.TableHeader, { children: weekDay.short.substring(0, 2) }, id))) }) }), _jsx(DatePicker.TableBody, { children: api.weeks.map((week, id) => (_jsx(DatePicker.TableRow, { children: week.map((day, id) => (_jsx(DatePicker.TableCell, { value: day, children: _jsx(DatePicker.TableCellTrigger, { children: day.day }) }, id))) }, id))) })] })] })) }) }) }) }) })] }), _jsx("div", { className: "hidden grow lg:block" }), _jsxs(Select.Root, { collection: providerCollection, value: state.provider ? [state.provider] : [], onValueChange: (details) => {
|
|
119
|
+
setTab(value);
|
|
120
|
+
}, ids: {
|
|
121
|
+
item(value) {
|
|
122
|
+
return `segment-group:item:${value}`;
|
|
123
|
+
},
|
|
124
|
+
}, className: "w-full lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "all", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "today", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Today" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "custom", onClick: () => disclosure.setOpen(true), className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Custom" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsx(RangeDatePicker, { value: {
|
|
125
|
+
start: state.timestamp?.start,
|
|
126
|
+
end: state.timestamp?.end,
|
|
127
|
+
}, onValueChange: (timestamp) => {
|
|
128
|
+
setState({ timestamp });
|
|
129
|
+
}, open: disclosure.open, onOpenChange: disclosure.setOpen }), _jsx("div", { className: "hidden grow lg:block" }), _jsxs(Select.Root, { collection: providerCollection, value: state.provider ? [state.provider] : [], onValueChange: (details) => {
|
|
131
130
|
const value = z
|
|
132
131
|
.enum((props.gameProviders ?? []))
|
|
133
132
|
.safeParse(details.value.at(0)).data;
|
|
@@ -141,7 +140,7 @@ export function BetRecords__client(props) {
|
|
|
141
140
|
e.stopPropagation();
|
|
142
141
|
}, children: "Clear" }) })) : (_jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })) })) })] }), _jsx(Portal, { children: _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: _jsx(Select.ItemGroup, { children: providerCollection.items.map((provider) => (_jsxs(Select.Item, { item: provider, children: [_jsx(Select.ItemText, { children: provider.name }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, provider.id))) }) }) }) })] }), _jsxs(Select.Root, { collection: statusCollection, value: state.status ? [state.status] : [], onValueChange: (details) => {
|
|
143
142
|
const value = z
|
|
144
|
-
.enum(
|
|
143
|
+
.enum(['SETTLED', 'NOT_SETTLED'])
|
|
145
144
|
.safeParse(details.value.at(0)).data;
|
|
146
145
|
firstPage();
|
|
147
146
|
setState({
|
|
@@ -186,13 +185,8 @@ export function BetRecords__client(props) {
|
|
|
186
185
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
187
186
|
}) }) }) }), _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" }) })] })] }))] }));
|
|
188
187
|
}
|
|
189
|
-
const BET_RECORD_STATUSES = [
|
|
190
|
-
'CANCELLED',
|
|
191
|
-
'SETTLED',
|
|
192
|
-
'STARTED',
|
|
193
|
-
];
|
|
194
188
|
const statusCollection = createListCollection({
|
|
195
|
-
items:
|
|
189
|
+
items: ['SETTLED', 'NOT_SETTLED'],
|
|
196
190
|
itemToValue: (item) => item,
|
|
197
191
|
itemToString: (item) => capitalize(item, {
|
|
198
192
|
delimiter: capitalize.delimiters.UNDERSCORE,
|
|
@@ -200,3 +194,42 @@ const statusCollection = createListCollection({
|
|
|
200
194
|
});
|
|
201
195
|
const TabDefinition = z.enum(['all', 'today', 'custom']);
|
|
202
196
|
const DEVICE_TIMEZONE = Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
197
|
+
function RangeDatePicker(props) {
|
|
198
|
+
const [value, setValue] = useControllableState({
|
|
199
|
+
value: props.value,
|
|
200
|
+
defaultValue: props.defaultValue ?? null,
|
|
201
|
+
onChange: (value) => {
|
|
202
|
+
props.onValueChange?.(value);
|
|
203
|
+
},
|
|
204
|
+
});
|
|
205
|
+
const [open, setOpen] = useControllableState({
|
|
206
|
+
value: props.open,
|
|
207
|
+
defaultValue: props.defaultOpen ?? false,
|
|
208
|
+
onChange: (open) => {
|
|
209
|
+
props.onOpenChange?.(open);
|
|
210
|
+
},
|
|
211
|
+
});
|
|
212
|
+
const desktop = useMediaQuery('(min-width: 1024px)');
|
|
213
|
+
return (_jsx(DatePicker.Root, { lazyMount: true, unmountOnExit: true, value: [value?.start, value?.end]
|
|
214
|
+
.filter(Boolean)
|
|
215
|
+
.map((d) => parseDate(d)), onValueChange: (details) => {
|
|
216
|
+
setValue({
|
|
217
|
+
start: details.value.at(0)?.toDate(DEVICE_TIMEZONE),
|
|
218
|
+
end: details.value.at(1)?.toDate(DEVICE_TIMEZONE),
|
|
219
|
+
});
|
|
220
|
+
}, open: open, onOpenChange: (details) => {
|
|
221
|
+
setOpen(details.open);
|
|
222
|
+
}, selectionMode: "range", closeOnSelect: false, fixedWeeks: true, numOfMonths: desktop ? 2 : 1, positioning: {
|
|
223
|
+
gutter: 16,
|
|
224
|
+
placement: 'bottom',
|
|
225
|
+
}, ids: {
|
|
226
|
+
control: 'segment-group:item:custom',
|
|
227
|
+
}, children: _jsx(Portal, { children: _jsx(DatePicker.Positioner, { children: _jsx(DatePicker.Content, { className: "p-0", children: _jsxs("div", { className: "flex", children: [_jsx(RangeDatePickerCalendar, { monthOffset: 0 }), desktop && _jsx(RangeDatePickerCalendar, { monthOffset: 1 })] }) }) }) }) }));
|
|
228
|
+
}
|
|
229
|
+
function RangeDatePickerCalendar({ monthOffset }) {
|
|
230
|
+
const datePicker = useDatePickerContext();
|
|
231
|
+
const offset = datePicker.getOffset({
|
|
232
|
+
months: monthOffset,
|
|
233
|
+
});
|
|
234
|
+
return (_jsxs(DatePicker.View, { view: "day", className: "border-border-secondary px-6 py-5 lg:first:border-r", children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx("span", { className: "text-text-secondary-700 text-base font-semibold", children: offset.visibleRangeText.start }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsxs(DatePicker.Table, { children: [_jsx(DatePicker.TableHead, { children: _jsx(DatePicker.TableRow, { children: datePicker.weekDays.map((weekDay, id) => (_jsx(DatePicker.TableHeader, { children: weekDay.short.slice(0, 2) }, id))) }) }), _jsx(DatePicker.TableBody, { children: offset.weeks.map((week, id) => (_jsx(DatePicker.TableRow, { children: week.map((day, id) => (_jsx(DatePicker.TableCell, { value: day, visibleRange: offset.visibleRange, children: _jsx(DatePicker.TableCellTrigger, { children: day.day }) }, id))) }, id))) })] })] }));
|
|
235
|
+
}
|
|
@@ -13,7 +13,11 @@ import { Dialog } from '../../ui/Dialog/index.js';
|
|
|
13
13
|
import { Field } from '../../ui/Field/index.js';
|
|
14
14
|
import { Portal } from '../../ui/Portal/index.js';
|
|
15
15
|
const definition = z.object({
|
|
16
|
-
code: z
|
|
16
|
+
code: z
|
|
17
|
+
.string()
|
|
18
|
+
.min(1, 'Code is required')
|
|
19
|
+
.max(10, 'Promo code is too long (max 10 characters)')
|
|
20
|
+
.trim(),
|
|
17
21
|
});
|
|
18
22
|
export function ClaimSpotBonus() {
|
|
19
23
|
const globalStore = useGlobalStore(useShallow((ctx) => ({
|
|
@@ -39,7 +43,7 @@ export function ClaimSpotBonus() {
|
|
|
39
43
|
code: '',
|
|
40
44
|
},
|
|
41
45
|
});
|
|
42
|
-
return (_jsx(Dialog.Root, { open: globalStore.spotBonus.open, onOpenChange: (details) => globalStore.spotBonus.setOpen(details.open), lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { className: "flex items-center lg:items-start", children: _jsxs(Dialog.Content, { className: "mx-auto w-[25rem] max-w-full rounded-xl p-3xl
|
|
46
|
+
return (_jsx(Dialog.Root, { open: globalStore.spotBonus.open, onOpenChange: (details) => globalStore.spotBonus.setOpen(details.open), lazyMount: true, unmountOnExit: true, closeOnEscape: false, closeOnInteractOutside: false, children: _jsxs(Portal, { children: [_jsx(Dialog.Backdrop, {}), _jsx(Dialog.Positioner, { className: "flex items-center lg:items-start", children: _jsxs(Dialog.Content, { className: "mx-auto w-[25rem] max-w-full overflow-y-auto rounded-xl p-3xl", children: [_jsx("div", { className: "overflow-hidden rounded-md", style: {
|
|
43
47
|
background: 'radial-gradient(75.21% 75.21% at 50% 50%, rgba(249, 163, 8, 0.3) 0%, rgba(0, 0, 0, 0) 100%), var(--color-bg-primary-alt)',
|
|
44
48
|
}, children: _jsx(Image, { src: ribbonEnvelope, alt: "", className: "mx-auto h-[12.5rem] w-[80%] object-cover", draggable: false, width: 600, height: 341 }) }), _jsxs("form", { className: "mt-3xl", onSubmit: form.handleSubmit((data) => {
|
|
45
49
|
claimSpotBonusMutation.mutate(data.code);
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { createListCollection } from '@ark-ui/react/collection';
|
|
3
|
-
import { parseDate } from '@ark-ui/react/date-picker';
|
|
3
|
+
import { parseDate, useDatePickerContext } from '@ark-ui/react/date-picker';
|
|
4
4
|
import { endOfDay, startOfDay } from 'date-fns';
|
|
5
5
|
import { useState } from 'react';
|
|
6
|
+
import { useMediaQuery } from 'usehooks-ts';
|
|
6
7
|
import { z } from 'zod';
|
|
7
8
|
import { useControllableState } from '../../client/hooks/useControllableState.js';
|
|
9
|
+
import { useDisclosure } from '../../client/hooks/useDisclosure.js';
|
|
8
10
|
import { CheckIcon } from '../../icons/CheckIcon.js';
|
|
9
11
|
import { ChevronDownIcon } from '../../icons/ChevronDownIcon.js';
|
|
10
12
|
import { ChevronLeftIcon } from '../../icons/ChevronLeftIcon.js';
|
|
@@ -21,7 +23,7 @@ const DEPOSIT_TYPES = [
|
|
|
21
23
|
'MAYA',
|
|
22
24
|
'MANUAL',
|
|
23
25
|
'ONLINE_BANK',
|
|
24
|
-
'QR_PH'
|
|
26
|
+
'QR_PH',
|
|
25
27
|
];
|
|
26
28
|
const DEPOSIT_TYPES_MAP = {
|
|
27
29
|
BANK: 'Bank',
|
|
@@ -165,36 +167,35 @@ export function TableFilters(props) {
|
|
|
165
167
|
handleChange({ transactionType });
|
|
166
168
|
},
|
|
167
169
|
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
if (
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
}, className: "w-full lg:w-fit", children: [_jsxs(SegmentGroup.Item, { value: "all", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "today", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Today" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(DatePicker.Context, { children: (api) => (_jsx(SegmentGroup.Item, { value: "custom", onClick: () => api.setOpen(true), className: "w-full lg:w-auto", children: _jsxs(DatePicker.Control, { children: [_jsx(SegmentGroup.ItemText, { children: "Custom" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }) })) }), _jsx(SegmentGroup.Indicator, {})] }), _jsx(Portal, { children: _jsx(DatePicker.Positioner, { children: _jsx(DatePicker.Content, { children: _jsx(DatePicker.View, { view: "day", children: _jsx(DatePicker.Context, { children: (api) => (_jsxs(_Fragment, { children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx(DatePicker.ViewTrigger, { children: _jsx(DatePicker.RangeText, {}) }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsxs(DatePicker.Table, { children: [_jsx(DatePicker.TableHead, { children: _jsx(DatePicker.TableRow, { children: api.weekDays.map((weekDay, id) => (_jsx(DatePicker.TableHeader, { children: weekDay.short.substring(0, 2) }, id))) }) }), _jsx(DatePicker.TableBody, { children: api.weeks.map((week, id) => (_jsx(DatePicker.TableRow, { children: week.map((day, id) => (_jsx(DatePicker.TableCell, { value: day, children: _jsx(DatePicker.TableCellTrigger, { children: day.day }) }, id))) }, id))) })] })] })) }) }) }) }) })] }), _jsx("div", { className: "hidden grow lg:block" }), props.enabledFilters?.depositType && (_jsxs(Select.Root, { collection: depositTypeCollection, value: depositType ? [depositType] : [], onValueChange: (details) => {
|
|
170
|
+
const disclosure = useDisclosure({
|
|
171
|
+
onOpenChange(open) {
|
|
172
|
+
if (!open && !timestamp)
|
|
173
|
+
setTab('all');
|
|
174
|
+
},
|
|
175
|
+
});
|
|
176
|
+
return (_jsxs("div", { className: "flex flex-col gap-lg lg:flex-row lg:items-center", children: [_jsxs(SegmentGroup.Root, { value: tab, onValueChange: (details) => {
|
|
177
|
+
const value = TabDefinition.parse(details.value);
|
|
178
|
+
if (value === 'today') {
|
|
179
|
+
const now = new Date();
|
|
180
|
+
setTimestamp({
|
|
181
|
+
start: startOfDay(now),
|
|
182
|
+
end: endOfDay(now),
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
setTimestamp(null);
|
|
187
|
+
}
|
|
188
|
+
setTab(value);
|
|
189
|
+
}, className: "w-full lg:w-fit", ids: {
|
|
190
|
+
item(value) {
|
|
191
|
+
return `segment-group:item:${value}`;
|
|
192
|
+
},
|
|
193
|
+
}, children: [_jsxs(SegmentGroup.Item, { value: "all", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "All" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "today", className: "w-full lg:w-auto", children: [_jsx(SegmentGroup.ItemText, { children: "Today" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsxs(SegmentGroup.Item, { value: "custom", className: "w-full lg:w-auto", onClick: () => {
|
|
194
|
+
disclosure.setOpen(true);
|
|
195
|
+
}, children: [_jsx(SegmentGroup.ItemText, { children: "Custom" }), _jsx(SegmentGroup.ItemControl, {}), _jsx(SegmentGroup.ItemHiddenInput, {})] }), _jsx(SegmentGroup.Indicator, {})] }), _jsx(RangeDatePicker, { value: {
|
|
196
|
+
start: timestamp?.start,
|
|
197
|
+
end: timestamp?.end,
|
|
198
|
+
}, onValueChange: setTimestamp, open: disclosure.open, onOpenChange: disclosure.setOpen }), _jsx("div", { className: "hidden grow lg:block" }), props.enabledFilters?.depositType && (_jsxs(Select.Root, { collection: depositTypeCollection, value: depositType ? [depositType] : [], onValueChange: (details) => {
|
|
198
199
|
const value = z
|
|
199
200
|
.enum(DEPOSIT_TYPES)
|
|
200
201
|
.safeParse(details.value.at(0)).data;
|
|
@@ -241,3 +242,42 @@ export function TableFilters(props) {
|
|
|
241
242
|
e.stopPropagation();
|
|
242
243
|
}, children: "Clear" }) })) : (_jsx(Select.Indicator, { asChild: true, children: _jsx(ChevronDownIcon, {}) })) })) })] }), _jsx(Portal, { children: _jsx(Select.Positioner, { children: _jsx(Select.Content, { children: _jsx(Select.ItemGroup, { children: transactionTypeCollection.items.map((item) => (_jsxs(Select.Item, { item: item, children: [_jsx(Select.ItemText, { children: transactionTypeCollection.stringifyItem(item) }), _jsx(Select.ItemIndicator, { asChild: true, children: _jsx(CheckIcon, {}) })] }, item))) }) }) }) })] }))] }));
|
|
243
244
|
}
|
|
245
|
+
function RangeDatePicker(props) {
|
|
246
|
+
const [value, setValue] = useControllableState({
|
|
247
|
+
value: props.value,
|
|
248
|
+
defaultValue: props.defaultValue ?? null,
|
|
249
|
+
onChange: (value) => {
|
|
250
|
+
props.onValueChange?.(value);
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
const [open, setOpen] = useControllableState({
|
|
254
|
+
value: props.open,
|
|
255
|
+
defaultValue: props.defaultOpen ?? false,
|
|
256
|
+
onChange: (open) => {
|
|
257
|
+
props.onOpenChange?.(open);
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
const desktop = useMediaQuery('(min-width: 1024px)');
|
|
261
|
+
return (_jsx(DatePicker.Root, { lazyMount: true, unmountOnExit: true, value: [value?.start, value?.end]
|
|
262
|
+
.filter(Boolean)
|
|
263
|
+
.map((d) => parseDate(d)), onValueChange: (details) => {
|
|
264
|
+
setValue({
|
|
265
|
+
start: details.value.at(0)?.toDate(deviceTimezone),
|
|
266
|
+
end: details.value.at(1)?.toDate(deviceTimezone),
|
|
267
|
+
});
|
|
268
|
+
}, open: open, onOpenChange: (details) => {
|
|
269
|
+
setOpen(details.open);
|
|
270
|
+
}, selectionMode: "range", closeOnSelect: false, fixedWeeks: true, numOfMonths: desktop ? 2 : 1, positioning: {
|
|
271
|
+
gutter: 16,
|
|
272
|
+
placement: 'bottom',
|
|
273
|
+
}, ids: {
|
|
274
|
+
control: 'segment-group:item:custom',
|
|
275
|
+
}, children: _jsx(Portal, { children: _jsx(DatePicker.Positioner, { children: _jsx(DatePicker.Content, { className: "p-0", children: _jsxs("div", { className: "flex", children: [_jsx(RangeDatePickerCalendar, { monthOffset: 0 }), desktop && _jsx(RangeDatePickerCalendar, { monthOffset: 1 })] }) }) }) }) }));
|
|
276
|
+
}
|
|
277
|
+
function RangeDatePickerCalendar({ monthOffset }) {
|
|
278
|
+
const datePicker = useDatePickerContext();
|
|
279
|
+
const offset = datePicker.getOffset({
|
|
280
|
+
months: monthOffset,
|
|
281
|
+
});
|
|
282
|
+
return (_jsxs(DatePicker.View, { view: "day", className: "border-border-secondary px-6 py-5 lg:first:border-r", children: [_jsxs(DatePicker.ViewControl, { children: [_jsx(DatePicker.PrevTrigger, { children: _jsx(ChevronLeftIcon, {}) }), _jsx("span", { className: "text-text-secondary-700 text-base font-semibold", children: offset.visibleRangeText.start }), _jsx(DatePicker.NextTrigger, { children: _jsx(ChevronRightIcon, {}) })] }), _jsxs(DatePicker.Table, { children: [_jsx(DatePicker.TableHead, { children: _jsx(DatePicker.TableRow, { children: datePicker.weekDays.map((weekDay, id) => (_jsx(DatePicker.TableHeader, { children: weekDay.short.slice(0, 2) }, id))) }) }), _jsx(DatePicker.TableBody, { children: offset.weeks.map((week, id) => (_jsx(DatePicker.TableRow, { children: week.map((day, id) => (_jsx(DatePicker.TableCell, { value: day, visibleRange: offset.visibleRange, children: _jsx(DatePicker.TableCellTrigger, { children: day.day }) }, id))) }, id))) })] })] }));
|
|
283
|
+
}
|