@everymatrix/user-transaction-history 1.13.11
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/index-206e75cb.js +1416 -0
- package/dist/cjs/index.cjs.js +2 -0
- package/dist/cjs/loader.cjs.js +21 -0
- package/dist/cjs/user-transaction-history.cjs.entry.js +333 -0
- package/dist/cjs/user-transaction-history.cjs.js +19 -0
- package/dist/collection/assets/filter.svg +4 -0
- package/dist/collection/assets/warning.svg +4 -0
- package/dist/collection/collection-manifest.json +12 -0
- package/dist/collection/components/internal/filters.js +22 -0
- package/dist/collection/components/internal/loader.js +14 -0
- package/dist/collection/components/internal/page-size.js +7 -0
- package/dist/collection/components/internal/table.js +31 -0
- package/dist/collection/components/internal/transaction.js +14 -0
- package/dist/collection/components/user-transaction-history/user-transaction-history.css +406 -0
- package/dist/collection/components/user-transaction-history/user-transaction-history.js +357 -0
- package/dist/collection/contracts/translation.js +1 -0
- package/dist/collection/global/app.js +1 -0
- package/dist/collection/index.js +1 -0
- package/dist/collection/models/transactions-response.model.js +1 -0
- package/dist/collection/utils/currency.utils.js +18 -0
- package/dist/collection/utils/date.util.js +8 -0
- package/dist/collection/utils/locale.util.js +55 -0
- package/dist/components/index.d.ts +26 -0
- package/dist/components/index.js +1 -0
- package/dist/components/user-transaction-history.d.ts +11 -0
- package/dist/components/user-transaction-history.js +364 -0
- package/dist/esm/index-32e3ae05.js +1388 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/loader.js +17 -0
- package/dist/esm/polyfills/core-js.js +11 -0
- package/dist/esm/polyfills/css-shim.js +1 -0
- package/dist/esm/polyfills/dom.js +79 -0
- package/dist/esm/polyfills/es5-html-element.js +1 -0
- package/dist/esm/polyfills/index.js +34 -0
- package/dist/esm/polyfills/system.js +6 -0
- package/dist/esm/user-transaction-history.entry.js +329 -0
- package/dist/esm/user-transaction-history.js +17 -0
- package/dist/index.cjs.js +1 -0
- package/dist/index.js +1 -0
- package/dist/stencil.config.js +22 -0
- package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/user-transaction-history/.stencil/packages/user-transaction-history/stencil.config.d.ts +2 -0
- package/dist/types/components/internal/filters.d.ts +8 -0
- package/dist/types/components/internal/loader.d.ts +2 -0
- package/dist/types/components/internal/page-size.d.ts +9 -0
- package/dist/types/components/internal/table.d.ts +7 -0
- package/dist/types/components/internal/transaction.d.ts +3 -0
- package/dist/types/components/user-transaction-history/user-transaction-history.d.ts +40 -0
- package/dist/types/components.d.ts +53 -0
- package/dist/types/contracts/translation.d.ts +2 -0
- package/dist/types/global/app.d.ts +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/models/transactions-response.model.d.ts +23 -0
- package/dist/types/stencil-public-runtime.d.ts +1565 -0
- package/dist/types/utils/currency.utils.d.ts +4 -0
- package/dist/types/utils/date.util.d.ts +4 -0
- package/dist/types/utils/locale.util.d.ts +28 -0
- package/dist/user-transaction-history/index.esm.js +0 -0
- package/dist/user-transaction-history/p-10b5b959.js +1 -0
- package/dist/user-transaction-history/p-8e086032.entry.js +1 -0
- package/dist/user-transaction-history/user-transaction-history.esm.js +1 -0
- package/loader/cdn.js +3 -0
- package/loader/index.cjs.js +3 -0
- package/loader/index.d.ts +12 -0
- package/loader/index.es2017.js +3 -0
- package/loader/index.js +4 -0
- package/loader/package.json +10 -0
- package/package.json +19 -0
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
import { h, proxyCustomElement, HTMLElement, getAssetPath, Host } from '@stencil/core/internal/client';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_TRANSLATIONS = {
|
|
4
|
+
"en": {
|
|
5
|
+
"deposit": "Deposit",
|
|
6
|
+
"withdrawals": "Withdrawals",
|
|
7
|
+
"show": "Show",
|
|
8
|
+
"from": "From",
|
|
9
|
+
"to": "To",
|
|
10
|
+
"filter": "Filter",
|
|
11
|
+
"transactionId": "Transaction ID",
|
|
12
|
+
"date": "Date",
|
|
13
|
+
"amount": "Amount",
|
|
14
|
+
"productType": "Product Type",
|
|
15
|
+
"status": "Status",
|
|
16
|
+
"noData": "There are no account activities"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
class Localization {
|
|
20
|
+
constructor() { }
|
|
21
|
+
static async loadCustomTranslations(translationUrl) {
|
|
22
|
+
try {
|
|
23
|
+
const response = await fetch(translationUrl, {
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
if (!response.ok) {
|
|
29
|
+
const err = await response.text();
|
|
30
|
+
throw new Error(err);
|
|
31
|
+
}
|
|
32
|
+
const translations = await response.json();
|
|
33
|
+
Localization.updateTranslations(translations);
|
|
34
|
+
}
|
|
35
|
+
catch (ex) {
|
|
36
|
+
console.error(`Failed to load translations ${translationUrl}. ${ex.message}`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
static translate(key, locale) {
|
|
40
|
+
var _a, _b;
|
|
41
|
+
const avaliableLocales = Localization.getAvaliableLanguages(locale);
|
|
42
|
+
return ((_b = (_a = Localization.customTranslation) === null || _a === void 0 ? void 0 : _a[avaliableLocales.customLanguage]) === null || _b === void 0 ? void 0 : _b[key]) || Localization.defaultTranslation[avaliableLocales.predefinedLanguage][key];
|
|
43
|
+
}
|
|
44
|
+
static getAvaliableLanguages(locale) {
|
|
45
|
+
var _a;
|
|
46
|
+
const customLanguage = ((_a = Localization.customLanguages) === null || _a === void 0 ? void 0 : _a.includes(locale)) ? locale : Localization.defaultLanguage;
|
|
47
|
+
const predefinedLanguage = Localization.supportedLanguages.includes(locale) ? locale : Localization.defaultLanguage;
|
|
48
|
+
return { predefinedLanguage, customLanguage };
|
|
49
|
+
}
|
|
50
|
+
static updateTranslations(translations) {
|
|
51
|
+
Localization.customLanguages = Array.from(new Set([...Localization.supportedLanguages, ...Object.keys(translations).map(k => k.toLowerCase())]));
|
|
52
|
+
Localization.customTranslation = translations;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
Localization.defaultLanguage = 'en';
|
|
56
|
+
Localization.supportedLanguages = ['en'];
|
|
57
|
+
Localization.defaultTranslation = DEFAULT_TRANSLATIONS;
|
|
58
|
+
|
|
59
|
+
const Loader = () => (h("div", { class: "loader" },
|
|
60
|
+
h("div", null),
|
|
61
|
+
h("div", null),
|
|
62
|
+
h("div", null),
|
|
63
|
+
h("div", null),
|
|
64
|
+
h("div", null),
|
|
65
|
+
h("div", null),
|
|
66
|
+
h("div", null),
|
|
67
|
+
h("div", null),
|
|
68
|
+
h("div", null),
|
|
69
|
+
h("div", null),
|
|
70
|
+
h("div", null),
|
|
71
|
+
h("div", null)));
|
|
72
|
+
|
|
73
|
+
class DateTransformer {
|
|
74
|
+
constructor() { }
|
|
75
|
+
static dateToFormatedString(date) {
|
|
76
|
+
const dateStr = date.toLocaleDateString('en-gb');
|
|
77
|
+
const timeStr = date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
|
|
78
|
+
return `${dateStr}, ${timeStr}`;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
class CurrencyFormatter {
|
|
83
|
+
constructor() { }
|
|
84
|
+
static format(currency, value) {
|
|
85
|
+
let result = `${value} ${currency}`;
|
|
86
|
+
try {
|
|
87
|
+
const formatter = new Intl.NumberFormat('en-US', {
|
|
88
|
+
style: 'currency',
|
|
89
|
+
currency: currency,
|
|
90
|
+
});
|
|
91
|
+
result = formatter.format(value);
|
|
92
|
+
}
|
|
93
|
+
catch (_a) {
|
|
94
|
+
// If we here formatter do not support that currency.
|
|
95
|
+
// Just ignore that and use the currency name instead of it symbol.
|
|
96
|
+
}
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const TransactionComponent = (transaction) => (h("div", { class: "data-transaction" },
|
|
102
|
+
h("p", null, transaction.productType),
|
|
103
|
+
h("p", { class: "text-style text-style-status" },
|
|
104
|
+
h("span", { class: transaction.status.toLowerCase() }, transaction.status)),
|
|
105
|
+
h("p", { class: "date" },
|
|
106
|
+
transaction.transId,
|
|
107
|
+
" | ",
|
|
108
|
+
DateTransformer.dateToFormatedString(new Date(transaction.created))),
|
|
109
|
+
h("p", { class: "text-style" },
|
|
110
|
+
CurrencyFormatter.format(transaction.currency, transaction.realAmount),
|
|
111
|
+
" ")));
|
|
112
|
+
|
|
113
|
+
const PageSize = (props) => {
|
|
114
|
+
return (h("div", { class: "page-size" },
|
|
115
|
+
h("span", null, Localization.translate('show', props.language)),
|
|
116
|
+
props.pageSizes.map(pageSize => (h("button", { class: props.currentPageSize === pageSize ? 'active' : '', onClick: () => props.changePageSize(pageSize) }, pageSize)))));
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const Filters = ({ from, to, applyFilters, language }) => {
|
|
120
|
+
let fromPicker;
|
|
121
|
+
let toPicker;
|
|
122
|
+
const fromChange = () => {
|
|
123
|
+
from = fromPicker.value;
|
|
124
|
+
};
|
|
125
|
+
const toChange = () => {
|
|
126
|
+
to = toPicker.value;
|
|
127
|
+
};
|
|
128
|
+
return (h("div", { class: "period" },
|
|
129
|
+
h("div", { class: "period-content" },
|
|
130
|
+
h("div", { class: "date-input" },
|
|
131
|
+
h("vaadin-date-picker", { value: from, ref: el => (fromPicker = el), label: Localization.translate('from', language), onChange: fromChange })),
|
|
132
|
+
h("span", null,
|
|
133
|
+
h("svg", { width: "24px", viewBox: "0 0 24 24", xmlns: "http://www.w3.org/2000/svg" },
|
|
134
|
+
h("path", { d: "m21 11.75c0-.414-.336-.75-.75-.75h-16.5c-.414 0-.75.336-.75.75s.336.75.75.75h16.5c.414 0 .75-.336.75-.75z", "fill-rule": "nonzero", fill: '#5d687b' }))),
|
|
135
|
+
h("div", { class: "date-input" },
|
|
136
|
+
h("vaadin-date-picker", { value: to, ref: el => (toPicker = el), label: Localization.translate('to', language), onChange: toChange })),
|
|
137
|
+
h("button", { class: "filter-btn", onClick: () => applyFilters(from, to) }, Localization.translate('filter', language)))));
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
const TableComponent = ({ source, language }) => {
|
|
141
|
+
const columns = [
|
|
142
|
+
{ name: Localization.translate('transactionId', language) },
|
|
143
|
+
{
|
|
144
|
+
name: Localization.translate('date', language),
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: Localization.translate('amount', language),
|
|
148
|
+
},
|
|
149
|
+
{ name: Localization.translate('productType', language) },
|
|
150
|
+
{
|
|
151
|
+
name: Localization.translate('status', language),
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
return (h("table", null,
|
|
155
|
+
h("thead", null,
|
|
156
|
+
h("tr", null, columns.map(column => h("th", null, column.name)))),
|
|
157
|
+
h("tbody", null, source.map(transaction => h("tr", null,
|
|
158
|
+
h("td", null, transaction.transId),
|
|
159
|
+
h("td", null, DateTransformer.dateToFormatedString(new Date(transaction.created))),
|
|
160
|
+
h("td", null,
|
|
161
|
+
CurrencyFormatter.format(transaction.currency, transaction.realAmount),
|
|
162
|
+
" "),
|
|
163
|
+
h("td", null, transaction.productType),
|
|
164
|
+
h("td", null,
|
|
165
|
+
h("span", { class: transaction.status.toLowerCase() }, transaction.status)))))));
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
const userTransactionHistoryCss = ":host{--activeButtonBackground:#7ec51e;--activeButtonFont:#002149;--hoverBackground:#ffffff;--background:#e4e6e8;--success:#7ac345;--heightScrollableContainer:400px;--borderColor:#d3d3d3;--borderColorButton:#c4c4c4;--textColor:#002554;--textColorHover:#7ac345;--errorColor:#c23b21;--loaderColor:#7ac345;--headerTableBackground:#cdcdcd;--borderTable:#dedede;--shadowBorderTable:#f1f1f1;--backgroundTable:#ffffff;font-family:Roboto, Arial, sans-serif;font-size:14px;color:var(--textColor);display:block;background-color:var(--background)}:host .wrapper{height:100%;padding:1rem}:host .types{display:flex;width:100%;gap:5px}:host .transaction-type{background:inherit;font-weight:600;padding:0.6rem 1.6rem;border:1px solid #6c757d;cursor:pointer}:host .transaction-type:hover{color:var(--activeButtonBackground);border-color:var(--activeButtonBackground);background:var(--hoverBackground)}:host .clicked{background-color:var(--activeButtonBackground);border-color:var(--activeButtonBackground)}:host .types-mobile{justify-content:center;margin-bottom:15px}:host .types-desktop{justify-content:flex-end;margin-bottom:3rem}:host .page-size{display:flex;width:100%;justify-content:flex-end;align-items:center}:host .page-size button{background:transparent;border:none;cursor:pointer;margin:0.4rem;width:2rem;height:2rem}:host .page-size button:hover{color:var(--textColorHover)}:host .page-size button.active{background:var(--activeButtonBackground);color:var(--textColor);font-weight:600;border-radius:0.4rem}:host .period{display:flex;width:100%;align-items:flex-end;justify-content:center;gap:10px;background:#f0f0f0;border-bottom:2px solid #e9e9e9;padding:1.6rem 0 0;margin-bottom:4rem}@media (max-width: 801px){:host .period{margin-bottom:0;flex-direction:column;align-items:stretch;width:auto;padding:1.4rem 2.8rem;box-shadow:0 4px 5px 0 rgba(90, 90, 90, 0.24)}}:host .period .range{color:var(--errorColor)}:host .period .filter-btn{height:40px;background:transparent;border:0.1rem solid var(--borderColorButton);min-width:12rem;max-width:17rem;cursor:pointer}@media (max-width: 801px){:host .period .filter-btn{max-width:none;min-width:none;margin-top:1rem}}:host .period .filter-btn:hover{border:none;background:var(--hoverBackground)}:host .period .duet-date__input{padding:7px 60px 7px 7px}:host .period+button{padding:9px 15px}:host .period-content{display:flex;flex-direction:row;width:100%;justify-content:center;align-items:flex-end;margin:0 auto 1.6rem}@media (max-width: 801px){:host .period-content{flex-direction:column;align-items:stretch}}:host .period-content span{height:40px;display:flex;align-items:center;justify-content:center}@media (max-width: 801px){:host .period-content span{display:none}}:host .period-content .filter-btn{margin-left:60px}@media (max-width: 801px){:host .period-content .filter-btn{margin-left:0}}:host .period-content .date-input{padding:0 4px}@media (max-width: 801px){:host .period-content .date-input{width:auto}:host .period-content .date-input:first-child{margin-bottom:0.5rem}}:host .period-content .date-input label{display:inline-block;margin-bottom:0.9rem}:host .period-content .date-input input{border:0.1rem solid var(--borderColor);box-sizing:border-box;border-radius:0.2rem}:host .pagination{display:flex;width:100%;justify-content:center;margin-top:1.5rem}:host .pagination button{cursor:pointer;border:none;background-color:var(--activeButtonBackground);color:#fff;opacity:0.5;padding:7px 12px}:host .pagination button:hover{opacity:1}:host .pagination button:focus{opacity:1}:host button.active{color:var(--activeButtonFont);background-color:var(--activeButtonBackground)}.mobile-filter-button{display:flex;justify-content:center;align-items:center;width:100%;height:2.8rem;background:inherit;border:1px solid var(--borderColorButton)}.mobile-filter-button img{height:50%;margin-right:0.5rem}.noData{display:flex;align-items:center;box-shadow:0 0.4rem 0.4rem rgba(0, 0, 0, 0.25);padding:1.1rem;border-radius:0.6rem}.noData span{margin-left:0.5rem}.table{height:var(--heightScrollableContainer);overflow-y:auto}.table .mobile-table{height:100%}.data-transaction{border-bottom:1px solid var(--borderColor);background-color:var(--hoverBackground);padding:0 20px;display:grid;grid-template-columns:repeat(2, 1fr)}.data-transaction .text-style-status{font-weight:600}.data-transaction .text-style-status .success{color:var(--success)}.data-transaction .text-style-status .error{color:var(--errorColor)}.data-transaction .text-style{text-align:end}.data-transaction .date{font-size:12px;display:flex;align-items:center}.loader{display:inline-block;position:absolute;width:80px;height:80px;top:calc(50% - 40px);left:calc(50% - 40px);z-index:999}.loader::before{content:\"\";position:fixed;top:0;bottom:0;left:0;right:0;background-color:rgba(255, 255, 255, 0.6)}.loader div{position:absolute;width:6px;height:6px;background:var(--loaderColor);border-radius:50%;animation:loader 1.2s linear infinite}.loader div:nth-child(1){animation-delay:0s;top:37px;left:66px}.loader div:nth-child(2){animation-delay:-0.1s;top:22px;left:62px}.loader div:nth-child(3){animation-delay:-0.2s;top:11px;left:52px}.loader div:nth-child(4){animation-delay:-0.3s;top:7px;left:37px}.loader div:nth-child(5){animation-delay:-0.4s;top:11px;left:22px}.loader div:nth-child(6){animation-delay:-0.5s;top:22px;left:11px}.loader div:nth-child(7){animation-delay:-0.6s;top:37px;left:7px}.loader div:nth-child(8){animation-delay:-0.7s;top:52px;left:11px}.loader div:nth-child(9){animation-delay:-0.8s;top:62px;left:22px}.loader div:nth-child(10){animation-delay:-0.9s;top:66px;left:37px}.loader div:nth-child(11){animation-delay:-1s;top:62px;left:52px}.loader div:nth-child(12){animation-delay:-1.1s;top:52px;left:62px}@keyframes loader{0%,20%,80%,100%{transform:scale(1)}50%{transform:scale(1.5)}}.table thead th{position:sticky;top:0}table{border-collapse:collapse;width:100%}table th{padding:14px 24px;text-align:left;font-weight:600;color:var(--textColor);background:var(--headerTableBackground)}table td{padding:1rem 1.7rem;box-shadow:0 -1px 0 0 var(--shadowBorderTable) inset;border-bottom:0.1rem solid var(--borderTable);text-align:left;color:var(--textColor)}table tbody{background:var(--backgroundTable)}table .success{color:var(--success)}table .error{color:var(--errorColor)}vaadin-date-picker{min-width:320px}@media (max-width: 1261px){vaadin-date-picker{width:auto;min-width:auto}}@media (max-width: 801px){vaadin-date-picker{width:100%}}";
|
|
169
|
+
|
|
170
|
+
const TransactionHistoryWidget = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
|
171
|
+
constructor() {
|
|
172
|
+
super();
|
|
173
|
+
this.__registerHost();
|
|
174
|
+
this.__attachShadow();
|
|
175
|
+
this.pageSizes = [10, 25, 50];
|
|
176
|
+
this.pagination = null;
|
|
177
|
+
this.stylingAppended = false;
|
|
178
|
+
/*
|
|
179
|
+
* Language of the application.
|
|
180
|
+
*/
|
|
181
|
+
this.language = Localization.defaultLanguage;
|
|
182
|
+
/*
|
|
183
|
+
* Is mobile mode on. Default value `false`.
|
|
184
|
+
*/
|
|
185
|
+
this.mobile = false;
|
|
186
|
+
/*
|
|
187
|
+
* Client styling via inline styles.
|
|
188
|
+
*/
|
|
189
|
+
this.clientStyling = null;
|
|
190
|
+
/*
|
|
191
|
+
* The path to file with styles in `css` format.
|
|
192
|
+
*/
|
|
193
|
+
this.clientStylingUrl = null;
|
|
194
|
+
this.page = 0;
|
|
195
|
+
this.pageSize = this.pageSizes[0];
|
|
196
|
+
this.showMobileFilter = false;
|
|
197
|
+
this.type = '0';
|
|
198
|
+
this.showLoader = true;
|
|
199
|
+
}
|
|
200
|
+
watchMultiple() {
|
|
201
|
+
this.loadTransactions();
|
|
202
|
+
}
|
|
203
|
+
async componentWillLoad() {
|
|
204
|
+
if (this.translationUrl) {
|
|
205
|
+
await Localization.loadCustomTranslations(this.translationUrl);
|
|
206
|
+
}
|
|
207
|
+
this.loadTransactions();
|
|
208
|
+
}
|
|
209
|
+
componentDidRender() {
|
|
210
|
+
this.getComponentHeight();
|
|
211
|
+
if (!this.stylingAppended && this.stylingContainer) {
|
|
212
|
+
if (this.clientStyling) {
|
|
213
|
+
this.setStyles(this.clientStyling);
|
|
214
|
+
}
|
|
215
|
+
if (this.clientStylingUrl) {
|
|
216
|
+
this.setClientStylingByURL();
|
|
217
|
+
}
|
|
218
|
+
this.stylingAppended = true;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
getComponentHeight() {
|
|
222
|
+
var _a;
|
|
223
|
+
if (this.mobile) {
|
|
224
|
+
let height = this.el.getBoundingClientRect().height - ((_a = this.el.shadowRoot.querySelector('.table')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().y);
|
|
225
|
+
this.el.style.setProperty('--heightScrollableContainer', height + 'px');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
setHeightTableProperty() {
|
|
229
|
+
let height = this.getComponentHeight();
|
|
230
|
+
this.el.style.setProperty('--heightScrollableContainer', height + 'px');
|
|
231
|
+
}
|
|
232
|
+
changeTransactionsType(type) {
|
|
233
|
+
this.type = type;
|
|
234
|
+
}
|
|
235
|
+
changePageSize(pageSize) {
|
|
236
|
+
this.pageSize = pageSize;
|
|
237
|
+
}
|
|
238
|
+
prev() {
|
|
239
|
+
var _a;
|
|
240
|
+
if (!((_a = this.pagination) === null || _a === void 0 ? void 0 : _a.previous)) {
|
|
241
|
+
return;
|
|
242
|
+
}
|
|
243
|
+
this.page--;
|
|
244
|
+
}
|
|
245
|
+
next() {
|
|
246
|
+
var _a;
|
|
247
|
+
if (!((_a = this.pagination) === null || _a === void 0 ? void 0 : _a.next)) {
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
this.page++;
|
|
251
|
+
}
|
|
252
|
+
applyFilters(from, to) {
|
|
253
|
+
this.from = from ? new Date(from).toISOString() : null;
|
|
254
|
+
this.to = to ? new Date(to).toISOString() : null;
|
|
255
|
+
this.loadTransactions();
|
|
256
|
+
}
|
|
257
|
+
showFilter() {
|
|
258
|
+
this.showMobileFilter = !this.showMobileFilter;
|
|
259
|
+
}
|
|
260
|
+
render() {
|
|
261
|
+
var _a;
|
|
262
|
+
const filterSrc = getAssetPath('../assets/filter.svg');
|
|
263
|
+
const warningSrc = getAssetPath('../assets/warning.svg');
|
|
264
|
+
return (h(Host, null, this.showLoader ? h(Loader, null) : '', h("div", { class: "wrapper", ref: el => (this.stylingContainer = el) }, h("div", { class: { 'types types-mobile': this.mobile, 'types types-desktop': !this.mobile } }, h("button", { class: 'transaction-type' + ' ' + (this.type === '0' ? 'clicked' : ''), onClick: () => this.changeTransactionsType('0') }, Localization.translate('deposit', this.language)), h("button", { class: 'transaction-type' + ' ' + (this.type === '1' ? 'clicked' : ''), onClick: () => this.changeTransactionsType('1') }, Localization.translate('withdrawals', this.language))), !this.mobile ? h(PageSize, { language: this.language, pageSizes: this.pageSizes, currentPageSize: this.pageSize, changePageSize: s => this.changePageSize(s) }) : '', this.mobile ? (h("button", { class: "mobile-filter-button", onClick: () => this.showFilter() }, h("img", { src: filterSrc, alt: "Filter" }), Localization.translate('filter', this.language))) : (''), !this.mobile || (this.showMobileFilter && this.mobile) ? h(Filters, { language: this.language, applyFilters: (from, to) => this.applyFilters(from, to) }) : '', ((_a = this.transactions) === null || _a === void 0 ? void 0 : _a.length) > 0 ? (h("div", { class: "table" }, this.mobile ? (h("div", { class: "mobile-table" }, this.transactions.map(transaction => (h(TransactionComponent, Object.assign({}, transaction)))))) : (h(TableComponent, { source: this.transactions, language: this.language })))) : (h("div", { class: "noData" }, h("img", { src: warningSrc, alt: "Warning" }), h("span", null, Localization.translate('noData', this.language)))), h("div", { class: "pagination" }, h("button", { onClick: () => this.prev() }, '<'), h("button", { onClick: () => this.next() }, '>')))));
|
|
265
|
+
}
|
|
266
|
+
async loadTransactions() {
|
|
267
|
+
this.showLoader = true;
|
|
268
|
+
try {
|
|
269
|
+
const url = `${this.endpoint}/v1/player/${this.userId}/transactions/banking?${this.getParams()}`;
|
|
270
|
+
const response = await fetch(url, {
|
|
271
|
+
headers: {
|
|
272
|
+
'X-Sessionid': this.session,
|
|
273
|
+
'Content-Type': 'application/json'
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
if (!response.ok) {
|
|
277
|
+
const err = await response.text();
|
|
278
|
+
throw new Error(err);
|
|
279
|
+
}
|
|
280
|
+
const data = await response.json();
|
|
281
|
+
this.pagination = data.pagination;
|
|
282
|
+
this.transactions = data.transactions;
|
|
283
|
+
}
|
|
284
|
+
catch (ex) {
|
|
285
|
+
console.error(ex);
|
|
286
|
+
}
|
|
287
|
+
finally {
|
|
288
|
+
this.showLoader = false;
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
getParams() {
|
|
292
|
+
var _a, _b;
|
|
293
|
+
const now = new Date();
|
|
294
|
+
const offset = (this.page * this.pageSize).toString();
|
|
295
|
+
const startDate = (_a = this.from) !== null && _a !== void 0 ? _a : new Date(now.getFullYear(), now.getMonth(), 1).toISOString();
|
|
296
|
+
const endDate = (_b = this.to) !== null && _b !== void 0 ? _b : new Date(now.getFullYear(), now.getMonth() + 1, 0).toISOString();
|
|
297
|
+
return `offset=${offset}&endDate=${endDate}&startDate=${startDate}&type=${this.type}&limit=${this.pageSize}`;
|
|
298
|
+
}
|
|
299
|
+
setStyles(styles) {
|
|
300
|
+
const cssFile = document.createElement('style');
|
|
301
|
+
cssFile.innerHTML = styles;
|
|
302
|
+
this.stylingContainer.prepend(cssFile);
|
|
303
|
+
}
|
|
304
|
+
async setClientStylingByURL() {
|
|
305
|
+
try {
|
|
306
|
+
const response = await fetch(this.clientStylingUrl);
|
|
307
|
+
if (!response.ok) {
|
|
308
|
+
const err = await response.text();
|
|
309
|
+
throw new Error(err);
|
|
310
|
+
}
|
|
311
|
+
const styles = await response.text();
|
|
312
|
+
this.setStyles(styles);
|
|
313
|
+
}
|
|
314
|
+
catch (ex) {
|
|
315
|
+
console.error(`Failed to load client styles ${this.clientStylingUrl}`, ex);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
static get assetsDirs() { return ["../assets"]; }
|
|
319
|
+
get el() { return this; }
|
|
320
|
+
static get watchers() { return {
|
|
321
|
+
"page": ["watchMultiple"],
|
|
322
|
+
"type": ["watchMultiple"],
|
|
323
|
+
"session": ["watchMultiple"],
|
|
324
|
+
"userId": ["watchMultiple"],
|
|
325
|
+
"pageSize": ["watchMultiple"],
|
|
326
|
+
"showMobileFilter": ["getComponentHeight"]
|
|
327
|
+
}; }
|
|
328
|
+
static get style() { return userTransactionHistoryCss; }
|
|
329
|
+
}, [1, "user-transaction-history", {
|
|
330
|
+
"endpoint": [513],
|
|
331
|
+
"session": [513],
|
|
332
|
+
"language": [513],
|
|
333
|
+
"userId": [513, "user-id"],
|
|
334
|
+
"translationUrl": [513, "translation-url"],
|
|
335
|
+
"mobile": [516],
|
|
336
|
+
"clientStyling": [513, "client-styling"],
|
|
337
|
+
"clientStylingUrl": [513, "client-styling-url"],
|
|
338
|
+
"page": [32],
|
|
339
|
+
"pageSize": [32],
|
|
340
|
+
"showMobileFilter": [32],
|
|
341
|
+
"to": [32],
|
|
342
|
+
"from": [32],
|
|
343
|
+
"type": [32],
|
|
344
|
+
"transactions": [32],
|
|
345
|
+
"showLoader": [32]
|
|
346
|
+
}, [[9, "resize", "getComponentHeight"]]]);
|
|
347
|
+
function defineCustomElement$1() {
|
|
348
|
+
if (typeof customElements === "undefined") {
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const components = ["user-transaction-history"];
|
|
352
|
+
components.forEach(tagName => { switch (tagName) {
|
|
353
|
+
case "user-transaction-history":
|
|
354
|
+
if (!customElements.get(tagName)) {
|
|
355
|
+
customElements.define(tagName, TransactionHistoryWidget);
|
|
356
|
+
}
|
|
357
|
+
break;
|
|
358
|
+
} });
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const UserTransactionHistory = TransactionHistoryWidget;
|
|
362
|
+
const defineCustomElement = defineCustomElement$1;
|
|
363
|
+
|
|
364
|
+
export { UserTransactionHistory, defineCustomElement };
|