@everymatrix/pam-statement-history 0.0.1
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/cjs/app-globals-3a1e7e63.js +5 -0
- package/dist/cjs/index-fb94c0e0.js +1297 -0
- package/dist/cjs/index.cjs.js +10 -0
- package/dist/cjs/loader.cjs.js +15 -0
- package/dist/cjs/pam-statement-history-b224d6b2.js +12493 -0
- package/dist/cjs/pam-statement-history.cjs.entry.js +10 -0
- package/dist/cjs/pam-statement-history.cjs.js +25 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/pam-statement-history/index.js +1 -0
- package/dist/collection/components/pam-statement-history/pam-statement-history.css +427 -0
- package/dist/collection/components/pam-statement-history/pam-statement-history.js +702 -0
- package/dist/collection/i18n.js +31 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/utils/locale.utils.js +136 -0
- package/dist/collection/utils/utils.js +3 -0
- package/dist/esm/app-globals-0f993ce5.js +3 -0
- package/dist/esm/index-02b4ec70.js +1270 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/loader.js +11 -0
- package/dist/esm/pam-statement-history-dc238928.js +12491 -0
- package/dist/esm/pam-statement-history.entry.js +2 -0
- package/dist/esm/pam-statement-history.js +20 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/pam-statement-history/app-globals-0f993ce5.js +1 -0
- package/dist/pam-statement-history/index-02b4ec70.js +2 -0
- package/dist/pam-statement-history/index.esm.js +1 -0
- package/dist/pam-statement-history/pam-statement-history-dc238928.js +6657 -0
- package/dist/pam-statement-history/pam-statement-history.entry.js +1 -0
- package/dist/pam-statement-history/pam-statement-history.esm.js +1 -0
- package/dist/stencil.config.dev.js +19 -0
- package/dist/stencil.config.js +19 -0
- package/dist/storybook/main.js +43 -0
- package/dist/storybook/preview.js +9 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/packages/stencil/pam-statement-history/stencil.config.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/packages/stencil/pam-statement-history/stencil.config.dev.d.ts +2 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/packages/stencil/pam-statement-history/storybook/main.d.ts +3 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/packages/stencil/pam-statement-history/storybook/preview.d.ts +70 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/tools/plugins/index.d.ts +4 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/tools/plugins/lazy-load-chunk-plugin.d.ts +12 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
- package/dist/types/builds/emfe-widgets/widgets-monorepo/packages/stencil/pam-statement-history/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
- package/dist/types/components/pam-statement-history/index.d.ts +1 -0
- package/dist/types/components/pam-statement-history/pam-statement-history.d.ts +78 -0
- package/dist/types/components.d.ts +63 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/stencil-public-runtime.d.ts +1674 -0
- package/dist/types/typings.d.ts +1 -0
- package/dist/types/utils/locale.utils.d.ts +9 -0
- package/dist/types/utils/utils.d.ts +1 -0
- package/loader/cdn.js +1 -0
- package/loader/index.cjs.js +1 -0
- package/loader/index.d.ts +24 -0
- package/loader/index.es2017.js +1 -0
- package/loader/index.js +2 -0
- package/loader/package.json +11 -0
- package/package.json +27 -0
|
@@ -0,0 +1,702 @@
|
|
|
1
|
+
import { h, Fragment } from "@stencil/core";
|
|
2
|
+
import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
|
|
3
|
+
import { translate, getTranslations, TABS, FILTERS, DAYS, TRANSACTION_TYPES } from "../../utils/locale.utils";
|
|
4
|
+
import "../../../../../../../libs/vaadin-facade/index";
|
|
5
|
+
import { format, subMonths, startOfDay, endOfDay, parse } from "date-fns";
|
|
6
|
+
export class PamStatementHistory {
|
|
7
|
+
constructor() {
|
|
8
|
+
this.calendarMaxDate = '';
|
|
9
|
+
this.fetchToken = 0;
|
|
10
|
+
this.fetchData = async () => {
|
|
11
|
+
if (!this.playerid || !this.session || !this.endpoint) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
this.fetchToken++;
|
|
15
|
+
const currentToken = this.fetchToken;
|
|
16
|
+
this.isLoading = true;
|
|
17
|
+
this.errorMessage = null;
|
|
18
|
+
const { startDate, endDate } = this.getDateRange();
|
|
19
|
+
const headers = { 'X-SessionId': this.session };
|
|
20
|
+
const baseEndpoint = this.endpoint.replace(/\/$/, '');
|
|
21
|
+
const offset = (this.currentPage * this.itemsPerPage).toString();
|
|
22
|
+
const limit = this.itemsPerPage.toString();
|
|
23
|
+
try {
|
|
24
|
+
const fetchPromises = [];
|
|
25
|
+
let hasBankingNext = false;
|
|
26
|
+
let hasWageringNext = false;
|
|
27
|
+
if (['All', 'Payments'].includes(this.activeTab)) {
|
|
28
|
+
const bankingUrl = new URL(`${baseEndpoint}/v1/player/${this.playerid}/transactions/banking`, window.location.origin);
|
|
29
|
+
bankingUrl.searchParams.append('limit', limit);
|
|
30
|
+
bankingUrl.searchParams.append('offset', offset);
|
|
31
|
+
bankingUrl.searchParams.append('startDate', format(new Date(startDate), 'yyyy-MM-dd'));
|
|
32
|
+
bankingUrl.searchParams.append('endDate', format(new Date(endDate), 'yyyy-MM-dd'));
|
|
33
|
+
fetchPromises.push(fetch(bankingUrl.href, { method: 'GET', headers })
|
|
34
|
+
.then(res => res.ok ? res.json() : null)
|
|
35
|
+
.then(data => {
|
|
36
|
+
var _a;
|
|
37
|
+
hasBankingNext = !!((_a = data === null || data === void 0 ? void 0 : data.pagination) === null || _a === void 0 ? void 0 : _a.next);
|
|
38
|
+
return this.normalizeBankingData(data);
|
|
39
|
+
}));
|
|
40
|
+
}
|
|
41
|
+
if (['All', 'Casino', 'Sports', 'Bonus'].includes(this.activeTab)) {
|
|
42
|
+
const wageringUrl = new URL(`${baseEndpoint}/v1/player/${this.playerid}/transactions/wagering`, window.location.origin);
|
|
43
|
+
wageringUrl.searchParams.append('type', this.activeTab === 'All' ? 'All' : this.activeTab);
|
|
44
|
+
wageringUrl.searchParams.append('limit', limit);
|
|
45
|
+
wageringUrl.searchParams.append('offset', offset);
|
|
46
|
+
wageringUrl.searchParams.append('startDate', startDate);
|
|
47
|
+
wageringUrl.searchParams.append('endDate', endDate);
|
|
48
|
+
fetchPromises.push(fetch(wageringUrl.href, { method: 'GET', headers })
|
|
49
|
+
.then(res => res.ok ? res.json() : null)
|
|
50
|
+
.then(data => {
|
|
51
|
+
var _a;
|
|
52
|
+
hasWageringNext = !!((_a = data === null || data === void 0 ? void 0 : data.pagination) === null || _a === void 0 ? void 0 : _a.next);
|
|
53
|
+
return this.normalizeWageringData(data);
|
|
54
|
+
}));
|
|
55
|
+
}
|
|
56
|
+
const results = await Promise.all(fetchPromises);
|
|
57
|
+
if (this.fetchToken !== currentToken) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
const combined = results.flat().filter(Boolean);
|
|
61
|
+
combined.sort((a, b) => b.timestamp - a.timestamp);
|
|
62
|
+
this.transactions = combined;
|
|
63
|
+
this.hasNextPage = hasBankingNext || hasWageringNext;
|
|
64
|
+
this.isLoading = false;
|
|
65
|
+
window.postMessage({ type: 'ScrollToTop' }, window.location.href);
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
if (this.fetchToken !== currentToken) {
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
this.errorMessage = this.translate('errorLoading');
|
|
72
|
+
this.isLoading = false;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
this.scrollToTop = () => {
|
|
76
|
+
if (this.statementContainer) {
|
|
77
|
+
setTimeout(() => {
|
|
78
|
+
this.statementContainer.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
|
79
|
+
}, 50);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
this.goToPrevPage = () => {
|
|
83
|
+
if (this.currentPage > 0) {
|
|
84
|
+
this.currentPage--;
|
|
85
|
+
this.fetchData();
|
|
86
|
+
this.scrollToTop();
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
this.goToNextPage = () => {
|
|
90
|
+
if (this.hasNextPage) {
|
|
91
|
+
this.currentPage++;
|
|
92
|
+
this.fetchData();
|
|
93
|
+
this.scrollToTop();
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
this.formatDate = (dateParts) => {
|
|
97
|
+
if (!dateParts)
|
|
98
|
+
return '';
|
|
99
|
+
return format(new Date(dateParts.year, dateParts.month, dateParts.day), this.dateformat);
|
|
100
|
+
};
|
|
101
|
+
this.parseDate = (inputValue) => {
|
|
102
|
+
const separator = inputValue.includes('/') ? '/' : '-';
|
|
103
|
+
const parts = inputValue.split(separator);
|
|
104
|
+
let day = parts[0], month = parts[1], year = parts[2];
|
|
105
|
+
if (parts[0].length === 4) {
|
|
106
|
+
year = parts[0];
|
|
107
|
+
month = parts[1];
|
|
108
|
+
day = parts[2];
|
|
109
|
+
}
|
|
110
|
+
return { year: parseInt(year), month: parseInt(month) - 1, day: parseInt(day) };
|
|
111
|
+
};
|
|
112
|
+
this.handleStartDateChange = (event) => {
|
|
113
|
+
const input = event.target;
|
|
114
|
+
if (input.value)
|
|
115
|
+
this.customStartDate = input.value;
|
|
116
|
+
};
|
|
117
|
+
this.handleEndDateChange = (event) => {
|
|
118
|
+
const input = event.target;
|
|
119
|
+
if (input.value)
|
|
120
|
+
this.customEndDate = input.value;
|
|
121
|
+
};
|
|
122
|
+
this.mbSource = undefined;
|
|
123
|
+
this.clientStyling = undefined;
|
|
124
|
+
this.clientStylingUrl = undefined;
|
|
125
|
+
this.session = '';
|
|
126
|
+
this.playerid = '';
|
|
127
|
+
this.endpoint = '';
|
|
128
|
+
this.statementenabled = '';
|
|
129
|
+
this.postMessage = false;
|
|
130
|
+
this.language = '';
|
|
131
|
+
this.quickFiltersActive = false;
|
|
132
|
+
this.clientStylingUrlContent = '';
|
|
133
|
+
this.dateformat = 'dd-MM-yyyy';
|
|
134
|
+
this.translationUrl = '';
|
|
135
|
+
this.activeTab = 'All';
|
|
136
|
+
this.activeFilter = '1D';
|
|
137
|
+
this.transactions = [];
|
|
138
|
+
this.isLoading = false;
|
|
139
|
+
this.errorMessage = null;
|
|
140
|
+
this.customStartDate = '';
|
|
141
|
+
this.customEndDate = '';
|
|
142
|
+
this.currentPage = 0;
|
|
143
|
+
this.hasNextPage = false;
|
|
144
|
+
this.itemsPerPage = 10;
|
|
145
|
+
this.copiedId = null;
|
|
146
|
+
this.isStatementEnabled = true;
|
|
147
|
+
}
|
|
148
|
+
translate(key) {
|
|
149
|
+
const translatedValue = translate(key, this.language);
|
|
150
|
+
if (!translatedValue && key) {
|
|
151
|
+
return key.charAt(0).toUpperCase() + key.slice(1);
|
|
152
|
+
}
|
|
153
|
+
return translatedValue ? translatedValue : key;
|
|
154
|
+
}
|
|
155
|
+
formatCurrencyAmount(value) {
|
|
156
|
+
if (value === null || value === undefined || isNaN(value))
|
|
157
|
+
return '0.00';
|
|
158
|
+
return value.toFixed(2);
|
|
159
|
+
}
|
|
160
|
+
isDateRangeExceeded() {
|
|
161
|
+
if (!this.customStartDate || !this.customEndDate)
|
|
162
|
+
return false;
|
|
163
|
+
const start = new Date(this.customStartDate).getTime();
|
|
164
|
+
const end = new Date(this.customEndDate).getTime();
|
|
165
|
+
const diffInMs = Math.abs(end - start);
|
|
166
|
+
const diffInDays = Math.ceil(diffInMs / (1000 * 60 * 60 * 24));
|
|
167
|
+
return diffInDays > 180;
|
|
168
|
+
}
|
|
169
|
+
async componentWillLoad() {
|
|
170
|
+
if (this.translationUrl) {
|
|
171
|
+
await getTranslations(this.translationUrl).catch(err => {
|
|
172
|
+
console.error('Failed to load translations', err);
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
const currentDate = new Date();
|
|
176
|
+
this.calendarMaxDate = format(currentDate, 'yyyy-MM-dd');
|
|
177
|
+
this.customEndDate = format(currentDate, 'yyyy-MM-dd');
|
|
178
|
+
this.customStartDate = format(subMonths(currentDate, 1), 'yyyy-MM-dd');
|
|
179
|
+
}
|
|
180
|
+
handleStatementEnabledChange(newValue) {
|
|
181
|
+
if (newValue === 'false') {
|
|
182
|
+
window.location.replace('/account/profile-info');
|
|
183
|
+
}
|
|
184
|
+
else if (newValue === 'true') {
|
|
185
|
+
this.isStatementEnabled = false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
handleTabChange() {
|
|
189
|
+
this.resetPaginationAndFetch();
|
|
190
|
+
}
|
|
191
|
+
handleFilterChange(newValue) {
|
|
192
|
+
if (newValue !== 'Custom') {
|
|
193
|
+
this.resetPaginationAndFetch();
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
handleClientStylingChange(newValue, oldValue) {
|
|
197
|
+
if (newValue !== oldValue) {
|
|
198
|
+
setClientStyling(this.statementContainer, this.clientStyling);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
handleClientStylingUrlChange(newValue, oldValue) {
|
|
202
|
+
if (newValue !== oldValue) {
|
|
203
|
+
setClientStylingURL(this.statementContainer, this.clientStylingUrl);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
handleMbSourceChange(newValue, oldValue) {
|
|
207
|
+
if (newValue !== oldValue) {
|
|
208
|
+
setStreamStyling(this.statementContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
handleAuthDataChange() {
|
|
212
|
+
if (this.endpoint && this.playerid && this.session) {
|
|
213
|
+
this.fetchData();
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
componentDidLoad() {
|
|
217
|
+
if (this.statementenabled === 'false') {
|
|
218
|
+
window.location.replace('/account/profile-info');
|
|
219
|
+
}
|
|
220
|
+
else if (this.statementenabled === 'true') {
|
|
221
|
+
this.isStatementEnabled = false;
|
|
222
|
+
}
|
|
223
|
+
if (this.statementContainer) {
|
|
224
|
+
if (this.mbSource) {
|
|
225
|
+
setStreamStyling(this.statementContainer, `${this.mbSource}.Style`, this.stylingSubscription);
|
|
226
|
+
}
|
|
227
|
+
if (this.clientStyling) {
|
|
228
|
+
setClientStyling(this.statementContainer, this.clientStyling);
|
|
229
|
+
}
|
|
230
|
+
if (this.clientStylingUrl) {
|
|
231
|
+
setClientStylingURL(this.statementContainer, this.clientStylingUrl);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
disconnectedCallback() {
|
|
236
|
+
if (this.stylingSubscription) {
|
|
237
|
+
this.stylingSubscription.unsubscribe();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
resetPaginationAndFetch() {
|
|
241
|
+
this.currentPage = 0;
|
|
242
|
+
this.hasNextPage = false;
|
|
243
|
+
this.fetchData();
|
|
244
|
+
}
|
|
245
|
+
formatDateForUI(dateString) {
|
|
246
|
+
if (!dateString)
|
|
247
|
+
return '';
|
|
248
|
+
const date = new Date(dateString);
|
|
249
|
+
const dayName = this.translate(DAYS[date.getDay()].toLowerCase());
|
|
250
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
251
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
252
|
+
const hours = String(date.getHours()).padStart(2, '0');
|
|
253
|
+
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
254
|
+
return `${dayName} ${day}/${month} - ${hours}:${minutes}`;
|
|
255
|
+
}
|
|
256
|
+
formattedToIso(dateString, dayEnd) {
|
|
257
|
+
const parsed = parse(dateString, 'yyyy-MM-dd', new Date());
|
|
258
|
+
const timed = dayEnd ? endOfDay(parsed) : startOfDay(parsed);
|
|
259
|
+
return format(timed, "yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
|
|
260
|
+
}
|
|
261
|
+
getDateRange() {
|
|
262
|
+
if (this.activeFilter === 'Custom') {
|
|
263
|
+
return {
|
|
264
|
+
startDate: this.formattedToIso(this.customStartDate, false),
|
|
265
|
+
endDate: this.formattedToIso(this.customEndDate, true)
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
const end = new Date();
|
|
269
|
+
const start = new Date();
|
|
270
|
+
switch (this.activeFilter) {
|
|
271
|
+
case '1D':
|
|
272
|
+
start.setDate(start.getDate() - 1);
|
|
273
|
+
break;
|
|
274
|
+
case '1W':
|
|
275
|
+
start.setDate(start.getDate() - 7);
|
|
276
|
+
break;
|
|
277
|
+
case '1M':
|
|
278
|
+
start.setMonth(start.getMonth() - 1);
|
|
279
|
+
break;
|
|
280
|
+
case '3M':
|
|
281
|
+
start.setMonth(start.getMonth() - 3);
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
return { startDate: start.toISOString(), endDate: end.toISOString() };
|
|
285
|
+
}
|
|
286
|
+
parseAmount(val) {
|
|
287
|
+
if (val === null || val === undefined)
|
|
288
|
+
return 0;
|
|
289
|
+
if (typeof val === 'object' && val.parsedValue !== undefined) {
|
|
290
|
+
return Number(val.parsedValue) || 0;
|
|
291
|
+
}
|
|
292
|
+
return Number(val) || 0;
|
|
293
|
+
}
|
|
294
|
+
normalizeBankingData(data) {
|
|
295
|
+
if (!data || !data.transactions)
|
|
296
|
+
return [];
|
|
297
|
+
return data.transactions.map((transaction) => {
|
|
298
|
+
var _a;
|
|
299
|
+
const isWithdraw = transaction.type === TRANSACTION_TYPES.WITHDRAWAL ||
|
|
300
|
+
transaction.type === TRANSACTION_TYPES.SYSTEM_DEBIT;
|
|
301
|
+
const amountVal = (_a = transaction.realAmount) !== null && _a !== void 0 ? _a : transaction.creditAmount;
|
|
302
|
+
let safeId = transaction.transIdStr;
|
|
303
|
+
if (!safeId && transaction.transId) {
|
|
304
|
+
safeId = typeof transaction.transId === 'object' ? (transaction.transId.source || transaction.transId.parsedValue) : transaction.transId;
|
|
305
|
+
}
|
|
306
|
+
const categoryKey = isWithdraw ? 'withdrawal' : 'deposit';
|
|
307
|
+
const statusKey = transaction.status ? String(transaction.status).toLowerCase() : '';
|
|
308
|
+
return {
|
|
309
|
+
id: safeId ? (String(safeId).startsWith('#') ? String(safeId) : `#${safeId}`) : this.translate('na'),
|
|
310
|
+
category: this.translate(categoryKey),
|
|
311
|
+
status: statusKey ? this.translate(statusKey) : null,
|
|
312
|
+
statusClass: statusKey,
|
|
313
|
+
amount: Math.abs(this.parseAmount(amountVal)),
|
|
314
|
+
currency: transaction.currencyCode || transaction.currency || '',
|
|
315
|
+
balance: null,
|
|
316
|
+
date: this.formatDateForUI(transaction.created),
|
|
317
|
+
isPositive: !isWithdraw,
|
|
318
|
+
timestamp: new Date(transaction.created).getTime()
|
|
319
|
+
};
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
normalizeWageringData(data) {
|
|
323
|
+
if (!data || !data.transactions)
|
|
324
|
+
return [];
|
|
325
|
+
return data.transactions.map((transaction) => {
|
|
326
|
+
var _a, _b;
|
|
327
|
+
const isCredit = transaction.transName === 'Credit' || transaction.transType === '2';
|
|
328
|
+
let categoryName = this.translate('casino');
|
|
329
|
+
if ((_a = transaction.gameModel) === null || _a === void 0 ? void 0 : _a.name) {
|
|
330
|
+
categoryName = `${this.translate('casino')} / ${transaction.gameModel.name}`;
|
|
331
|
+
}
|
|
332
|
+
else if (transaction.gameId) {
|
|
333
|
+
categoryName = `${this.translate('casino')} / ${transaction.gameId}`;
|
|
334
|
+
}
|
|
335
|
+
const statusKey = isCredit ? 'won' : (transaction.transName === 'Debit' || transaction.transType === '1' ? 'placed' : String(transaction.transName).toLowerCase());
|
|
336
|
+
const amountVal = (_b = transaction.realAmount) !== null && _b !== void 0 ? _b : transaction.totalAmount;
|
|
337
|
+
return {
|
|
338
|
+
id: transaction.transId,
|
|
339
|
+
category: categoryName,
|
|
340
|
+
status: this.translate(statusKey),
|
|
341
|
+
statusClass: isCredit ? 'won' : 'placed',
|
|
342
|
+
amount: Math.abs(this.parseAmount(amountVal)),
|
|
343
|
+
currency: transaction.currencyCode || transaction.currency || '',
|
|
344
|
+
balance: this.parseAmount(transaction.balance),
|
|
345
|
+
date: this.formatDateForUI(transaction.ins),
|
|
346
|
+
isPositive: isCredit,
|
|
347
|
+
timestamp: new Date(transaction.ins).getTime()
|
|
348
|
+
};
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
execCommandCopy(text) {
|
|
352
|
+
const textArea = document.createElement('textarea');
|
|
353
|
+
textArea.value = text;
|
|
354
|
+
Object.assign(textArea.style, { position: 'fixed', opacity: '0' });
|
|
355
|
+
document.body.appendChild(textArea);
|
|
356
|
+
textArea.select();
|
|
357
|
+
document.execCommand('copy');
|
|
358
|
+
document.body.removeChild(textArea);
|
|
359
|
+
}
|
|
360
|
+
async copyToClipboard(text) {
|
|
361
|
+
try {
|
|
362
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
363
|
+
await navigator.clipboard.writeText(text);
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
this.execCommandCopy(text);
|
|
367
|
+
}
|
|
368
|
+
this.copiedId = text;
|
|
369
|
+
setTimeout(() => {
|
|
370
|
+
if (this.copiedId === text)
|
|
371
|
+
this.copiedId = null;
|
|
372
|
+
}, 2000);
|
|
373
|
+
}
|
|
374
|
+
catch (err) {
|
|
375
|
+
try {
|
|
376
|
+
this.execCommandCopy(text);
|
|
377
|
+
this.copiedId = text;
|
|
378
|
+
setTimeout(() => {
|
|
379
|
+
if (this.copiedId === text)
|
|
380
|
+
this.copiedId = null;
|
|
381
|
+
}, 2000);
|
|
382
|
+
}
|
|
383
|
+
catch (fallbackErr) {
|
|
384
|
+
console.error(this.translate('failedToCopyText'), fallbackErr);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
setDateFormat(dom) {
|
|
389
|
+
if (dom && !dom.__i18nConfigured) {
|
|
390
|
+
dom.i18n = Object.assign(Object.assign({}, dom.i18n), { formatDate: this.formatDate, parseDate: this.parseDate });
|
|
391
|
+
dom.__i18nConfigured = true;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
isSubmitEnabled() {
|
|
395
|
+
if (!this.customStartDate || !this.customEndDate)
|
|
396
|
+
return false;
|
|
397
|
+
const start = new Date(this.customStartDate).getTime();
|
|
398
|
+
const end = new Date(this.customEndDate).getTime();
|
|
399
|
+
if (start > end)
|
|
400
|
+
return false;
|
|
401
|
+
return Math.ceil(Math.abs(end - start) / (1000 * 60 * 60 * 24)) <= 180;
|
|
402
|
+
}
|
|
403
|
+
render() {
|
|
404
|
+
if (this.isStatementEnabled) {
|
|
405
|
+
return (h("div", { class: "verify-access-loading" }, h("div", { class: "loading-text" }, this.translate('loading'))));
|
|
406
|
+
}
|
|
407
|
+
return (h("div", { ref: (el) => (this.statementContainer = el), class: "statement-wrapper" }, h("div", { class: "header" }, h("h2", null, this.translate('transactionHistory'))), h("div", { class: "tabs-container desktop-tabs" }, TABS.map(tab => (h("button", { class: `tab-btn ${this.activeTab === tab ? 'active' : ''}`, onClick: () => this.activeTab = tab }, this.translate(tab.toLowerCase()))))), h("div", { class: "mobile-tabs-select" }, h("select", Object.assign({ onChange: (e) => this.activeTab = e.target.value }, { value: this.activeTab }), TABS.map(tab => h("option", { value: tab }, this.translate(tab.toLowerCase()))))), h("div", { class: "card-container" }, h("div", { class: "filters-container" }, FILTERS.map(filter => (h("button", { class: `filter-btn ${this.activeFilter === filter ? 'active' : ''}`, onClick: () => this.activeFilter = filter }, this.translate(filter.toLowerCase()))))), this.activeFilter === 'Custom' && (h("div", { class: "custom-date-wrapper" }, h("div", { class: "calendar-container" }, h("div", { class: "calendar-field" }, h("label", null, this.translate('from')), h("vaadin-date-picker", { value: this.customStartDate, max: this.calendarMaxDate, onChange: this.handleStartDateChange, ref: (el) => this.setDateFormat(el), class: "VaadinDatePicker" })), h("div", { class: "calendar-field" }, h("label", null, this.translate('to')), h("vaadin-date-picker", { value: this.customEndDate, min: this.customStartDate, max: this.calendarMaxDate, onChange: this.handleEndDateChange, ref: (el) => this.setDateFormat(el), class: "VaadinDatePicker" }))), h("button", { class: "apply-date-btn", disabled: !this.isSubmitEnabled() || this.isLoading, onClick: () => this.resetPaginationAndFetch() }, this.translate('apply')), this.isDateRangeExceeded() && (h("div", { class: "date-limit-warning" }, this.translate('maxRange'))))), h("div", { class: "transactions-list" }, this.isLoading && (h("div", { class: "empty-state" }, this.translate('loading'))), !this.isLoading && this.errorMessage && (h("div", { class: "empty-state error" }, this.errorMessage)), !this.isLoading && !this.errorMessage && this.transactions.length === 0 && (h("div", { class: "empty-state" }, this.translate('noData'))), !this.isLoading && !this.errorMessage && this.transactions.length > 0 && (this.transactions.map(transaction => (h("div", { class: "transaction-item" }, h("div", { class: "row top-row" }, h("div", { class: "category-group" }, h("span", { class: "category" }, transaction.category), transaction.status && h("span", { class: `status-badge ${transaction.statusClass}` }, transaction.status)), h("span", { class: `amount ${transaction.isPositive ? 'positive' : 'negative'}` }, transaction.isPositive ? '+' : '-', " ", transaction.currency, " ", this.formatCurrencyAmount(transaction.amount))), h("div", { class: "row middle-row" }, h("span", { class: "transaction-id" }, transaction.id.startsWith('#') ? transaction.id : `#${transaction.id}`), h("div", { class: "copy-action-wrapper", onClick: () => this.copyToClipboard(transaction.id) }, h("svg", { class: "copy-icon", viewBox: "0 0 24 24", width: "25", height: "25" }, h("rect", { x: "9", y: "9", width: "10", height: "10", rx: "1", ry: "1" }), h("rect", { x: "5", y: "5", width: "10", height: "10", rx: "1", ry: "1" })), this.copiedId === transaction.id && h("span", { class: "copied-tooltip" }, this.translate('copied')))), h("div", { class: "row bottom-row" }, h("span", { class: "date" }, transaction.date), h("span", { class: "balance" }, transaction.balance !== null && transaction.balance !== undefined && !isNaN(transaction.balance) && (h(Fragment, null, this.translate('balance'), " ", h("strong", null, transaction.currency, " ", this.formatCurrencyAmount(transaction.balance))))))))))), !this.isLoading && this.transactions.length > 0 && (this.currentPage > 0 || this.hasNextPage) && (h("div", { class: "pagination-container" }, h("button", { class: "pagination-btn prev-btn", disabled: this.currentPage === 0, onClick: this.goToPrevPage }, this.translate('prev')), h("span", { class: "page-indicator" }, this.translate('page'), " ", this.currentPage + 1), h("button", { class: "pagination-btn next-btn", disabled: !this.hasNextPage, onClick: this.goToNextPage }, this.translate('next')))))));
|
|
408
|
+
}
|
|
409
|
+
static get is() { return "pam-statement-history"; }
|
|
410
|
+
static get encapsulation() { return "shadow"; }
|
|
411
|
+
static get originalStyleUrls() {
|
|
412
|
+
return {
|
|
413
|
+
"$": ["pam-statement-history.scss"]
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
static get styleUrls() {
|
|
417
|
+
return {
|
|
418
|
+
"$": ["pam-statement-history.css"]
|
|
419
|
+
};
|
|
420
|
+
}
|
|
421
|
+
static get properties() {
|
|
422
|
+
return {
|
|
423
|
+
"mbSource": {
|
|
424
|
+
"type": "string",
|
|
425
|
+
"mutable": false,
|
|
426
|
+
"complexType": {
|
|
427
|
+
"original": "string",
|
|
428
|
+
"resolved": "string",
|
|
429
|
+
"references": {}
|
|
430
|
+
},
|
|
431
|
+
"required": true,
|
|
432
|
+
"optional": false,
|
|
433
|
+
"docs": {
|
|
434
|
+
"tags": [],
|
|
435
|
+
"text": ""
|
|
436
|
+
},
|
|
437
|
+
"attribute": "mb-source",
|
|
438
|
+
"reflect": true
|
|
439
|
+
},
|
|
440
|
+
"clientStyling": {
|
|
441
|
+
"type": "string",
|
|
442
|
+
"mutable": false,
|
|
443
|
+
"complexType": {
|
|
444
|
+
"original": "string",
|
|
445
|
+
"resolved": "string",
|
|
446
|
+
"references": {}
|
|
447
|
+
},
|
|
448
|
+
"required": true,
|
|
449
|
+
"optional": false,
|
|
450
|
+
"docs": {
|
|
451
|
+
"tags": [],
|
|
452
|
+
"text": ""
|
|
453
|
+
},
|
|
454
|
+
"attribute": "client-styling",
|
|
455
|
+
"reflect": true
|
|
456
|
+
},
|
|
457
|
+
"clientStylingUrl": {
|
|
458
|
+
"type": "string",
|
|
459
|
+
"mutable": false,
|
|
460
|
+
"complexType": {
|
|
461
|
+
"original": "string",
|
|
462
|
+
"resolved": "string",
|
|
463
|
+
"references": {}
|
|
464
|
+
},
|
|
465
|
+
"required": true,
|
|
466
|
+
"optional": false,
|
|
467
|
+
"docs": {
|
|
468
|
+
"tags": [],
|
|
469
|
+
"text": ""
|
|
470
|
+
},
|
|
471
|
+
"attribute": "client-styling-url",
|
|
472
|
+
"reflect": true
|
|
473
|
+
},
|
|
474
|
+
"session": {
|
|
475
|
+
"type": "string",
|
|
476
|
+
"mutable": false,
|
|
477
|
+
"complexType": {
|
|
478
|
+
"original": "string",
|
|
479
|
+
"resolved": "string",
|
|
480
|
+
"references": {}
|
|
481
|
+
},
|
|
482
|
+
"required": false,
|
|
483
|
+
"optional": false,
|
|
484
|
+
"docs": {
|
|
485
|
+
"tags": [],
|
|
486
|
+
"text": ""
|
|
487
|
+
},
|
|
488
|
+
"attribute": "session",
|
|
489
|
+
"reflect": false,
|
|
490
|
+
"defaultValue": "''"
|
|
491
|
+
},
|
|
492
|
+
"playerid": {
|
|
493
|
+
"type": "string",
|
|
494
|
+
"mutable": false,
|
|
495
|
+
"complexType": {
|
|
496
|
+
"original": "string",
|
|
497
|
+
"resolved": "string",
|
|
498
|
+
"references": {}
|
|
499
|
+
},
|
|
500
|
+
"required": false,
|
|
501
|
+
"optional": false,
|
|
502
|
+
"docs": {
|
|
503
|
+
"tags": [],
|
|
504
|
+
"text": ""
|
|
505
|
+
},
|
|
506
|
+
"attribute": "playerid",
|
|
507
|
+
"reflect": false,
|
|
508
|
+
"defaultValue": "''"
|
|
509
|
+
},
|
|
510
|
+
"endpoint": {
|
|
511
|
+
"type": "string",
|
|
512
|
+
"mutable": false,
|
|
513
|
+
"complexType": {
|
|
514
|
+
"original": "string",
|
|
515
|
+
"resolved": "string",
|
|
516
|
+
"references": {}
|
|
517
|
+
},
|
|
518
|
+
"required": false,
|
|
519
|
+
"optional": false,
|
|
520
|
+
"docs": {
|
|
521
|
+
"tags": [],
|
|
522
|
+
"text": ""
|
|
523
|
+
},
|
|
524
|
+
"attribute": "endpoint",
|
|
525
|
+
"reflect": false,
|
|
526
|
+
"defaultValue": "''"
|
|
527
|
+
},
|
|
528
|
+
"statementenabled": {
|
|
529
|
+
"type": "string",
|
|
530
|
+
"mutable": false,
|
|
531
|
+
"complexType": {
|
|
532
|
+
"original": "string",
|
|
533
|
+
"resolved": "string",
|
|
534
|
+
"references": {}
|
|
535
|
+
},
|
|
536
|
+
"required": false,
|
|
537
|
+
"optional": false,
|
|
538
|
+
"docs": {
|
|
539
|
+
"tags": [],
|
|
540
|
+
"text": ""
|
|
541
|
+
},
|
|
542
|
+
"attribute": "statementenabled",
|
|
543
|
+
"reflect": false,
|
|
544
|
+
"defaultValue": "''"
|
|
545
|
+
},
|
|
546
|
+
"postMessage": {
|
|
547
|
+
"type": "boolean",
|
|
548
|
+
"mutable": false,
|
|
549
|
+
"complexType": {
|
|
550
|
+
"original": "boolean",
|
|
551
|
+
"resolved": "boolean",
|
|
552
|
+
"references": {}
|
|
553
|
+
},
|
|
554
|
+
"required": false,
|
|
555
|
+
"optional": false,
|
|
556
|
+
"docs": {
|
|
557
|
+
"tags": [],
|
|
558
|
+
"text": ""
|
|
559
|
+
},
|
|
560
|
+
"attribute": "post-message",
|
|
561
|
+
"reflect": true,
|
|
562
|
+
"defaultValue": "false"
|
|
563
|
+
},
|
|
564
|
+
"language": {
|
|
565
|
+
"type": "string",
|
|
566
|
+
"mutable": false,
|
|
567
|
+
"complexType": {
|
|
568
|
+
"original": "string",
|
|
569
|
+
"resolved": "string",
|
|
570
|
+
"references": {}
|
|
571
|
+
},
|
|
572
|
+
"required": false,
|
|
573
|
+
"optional": false,
|
|
574
|
+
"docs": {
|
|
575
|
+
"tags": [],
|
|
576
|
+
"text": ""
|
|
577
|
+
},
|
|
578
|
+
"attribute": "language",
|
|
579
|
+
"reflect": false,
|
|
580
|
+
"defaultValue": "''"
|
|
581
|
+
},
|
|
582
|
+
"quickFiltersActive": {
|
|
583
|
+
"type": "boolean",
|
|
584
|
+
"mutable": false,
|
|
585
|
+
"complexType": {
|
|
586
|
+
"original": "boolean",
|
|
587
|
+
"resolved": "boolean",
|
|
588
|
+
"references": {}
|
|
589
|
+
},
|
|
590
|
+
"required": false,
|
|
591
|
+
"optional": false,
|
|
592
|
+
"docs": {
|
|
593
|
+
"tags": [],
|
|
594
|
+
"text": ""
|
|
595
|
+
},
|
|
596
|
+
"attribute": "quick-filters-active",
|
|
597
|
+
"reflect": true,
|
|
598
|
+
"defaultValue": "false"
|
|
599
|
+
},
|
|
600
|
+
"clientStylingUrlContent": {
|
|
601
|
+
"type": "string",
|
|
602
|
+
"mutable": false,
|
|
603
|
+
"complexType": {
|
|
604
|
+
"original": "string",
|
|
605
|
+
"resolved": "string",
|
|
606
|
+
"references": {}
|
|
607
|
+
},
|
|
608
|
+
"required": false,
|
|
609
|
+
"optional": false,
|
|
610
|
+
"docs": {
|
|
611
|
+
"tags": [],
|
|
612
|
+
"text": ""
|
|
613
|
+
},
|
|
614
|
+
"attribute": "client-styling-url-content",
|
|
615
|
+
"reflect": true,
|
|
616
|
+
"defaultValue": "''"
|
|
617
|
+
},
|
|
618
|
+
"dateformat": {
|
|
619
|
+
"type": "string",
|
|
620
|
+
"mutable": false,
|
|
621
|
+
"complexType": {
|
|
622
|
+
"original": "string",
|
|
623
|
+
"resolved": "string",
|
|
624
|
+
"references": {}
|
|
625
|
+
},
|
|
626
|
+
"required": false,
|
|
627
|
+
"optional": false,
|
|
628
|
+
"docs": {
|
|
629
|
+
"tags": [],
|
|
630
|
+
"text": ""
|
|
631
|
+
},
|
|
632
|
+
"attribute": "dateformat",
|
|
633
|
+
"reflect": false,
|
|
634
|
+
"defaultValue": "'dd-MM-yyyy'"
|
|
635
|
+
},
|
|
636
|
+
"translationUrl": {
|
|
637
|
+
"type": "string",
|
|
638
|
+
"mutable": false,
|
|
639
|
+
"complexType": {
|
|
640
|
+
"original": "string",
|
|
641
|
+
"resolved": "string",
|
|
642
|
+
"references": {}
|
|
643
|
+
},
|
|
644
|
+
"required": false,
|
|
645
|
+
"optional": false,
|
|
646
|
+
"docs": {
|
|
647
|
+
"tags": [],
|
|
648
|
+
"text": ""
|
|
649
|
+
},
|
|
650
|
+
"attribute": "translation-url",
|
|
651
|
+
"reflect": true,
|
|
652
|
+
"defaultValue": "''"
|
|
653
|
+
}
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
static get states() {
|
|
657
|
+
return {
|
|
658
|
+
"activeTab": {},
|
|
659
|
+
"activeFilter": {},
|
|
660
|
+
"transactions": {},
|
|
661
|
+
"isLoading": {},
|
|
662
|
+
"errorMessage": {},
|
|
663
|
+
"customStartDate": {},
|
|
664
|
+
"customEndDate": {},
|
|
665
|
+
"currentPage": {},
|
|
666
|
+
"hasNextPage": {},
|
|
667
|
+
"itemsPerPage": {},
|
|
668
|
+
"copiedId": {},
|
|
669
|
+
"isStatementEnabled": {}
|
|
670
|
+
};
|
|
671
|
+
}
|
|
672
|
+
static get watchers() {
|
|
673
|
+
return [{
|
|
674
|
+
"propName": "statementenabled",
|
|
675
|
+
"methodName": "handleStatementEnabledChange"
|
|
676
|
+
}, {
|
|
677
|
+
"propName": "activeTab",
|
|
678
|
+
"methodName": "handleTabChange"
|
|
679
|
+
}, {
|
|
680
|
+
"propName": "activeFilter",
|
|
681
|
+
"methodName": "handleFilterChange"
|
|
682
|
+
}, {
|
|
683
|
+
"propName": "clientStyling",
|
|
684
|
+
"methodName": "handleClientStylingChange"
|
|
685
|
+
}, {
|
|
686
|
+
"propName": "clientStylingUrl",
|
|
687
|
+
"methodName": "handleClientStylingUrlChange"
|
|
688
|
+
}, {
|
|
689
|
+
"propName": "mbSource",
|
|
690
|
+
"methodName": "handleMbSourceChange"
|
|
691
|
+
}, {
|
|
692
|
+
"propName": "session",
|
|
693
|
+
"methodName": "handleAuthDataChange"
|
|
694
|
+
}, {
|
|
695
|
+
"propName": "playerid",
|
|
696
|
+
"methodName": "handleAuthDataChange"
|
|
697
|
+
}, {
|
|
698
|
+
"propName": "endpoint",
|
|
699
|
+
"methodName": "handleAuthDataChange"
|
|
700
|
+
}];
|
|
701
|
+
}
|
|
702
|
+
}
|