@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,329 @@
|
|
|
1
|
+
import { h, r as registerInstance, g as getAssetPath, H as Host, a as getElement } from './index-32e3ae05.js';
|
|
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 = class {
|
|
171
|
+
constructor(hostRef) {
|
|
172
|
+
registerInstance(this, hostRef);
|
|
173
|
+
this.pageSizes = [10, 25, 50];
|
|
174
|
+
this.pagination = null;
|
|
175
|
+
this.stylingAppended = false;
|
|
176
|
+
/*
|
|
177
|
+
* Language of the application.
|
|
178
|
+
*/
|
|
179
|
+
this.language = Localization.defaultLanguage;
|
|
180
|
+
/*
|
|
181
|
+
* Is mobile mode on. Default value `false`.
|
|
182
|
+
*/
|
|
183
|
+
this.mobile = false;
|
|
184
|
+
/*
|
|
185
|
+
* Client styling via inline styles.
|
|
186
|
+
*/
|
|
187
|
+
this.clientStyling = null;
|
|
188
|
+
/*
|
|
189
|
+
* The path to file with styles in `css` format.
|
|
190
|
+
*/
|
|
191
|
+
this.clientStylingUrl = null;
|
|
192
|
+
this.page = 0;
|
|
193
|
+
this.pageSize = this.pageSizes[0];
|
|
194
|
+
this.showMobileFilter = false;
|
|
195
|
+
this.type = '0';
|
|
196
|
+
this.showLoader = true;
|
|
197
|
+
}
|
|
198
|
+
watchMultiple() {
|
|
199
|
+
this.loadTransactions();
|
|
200
|
+
}
|
|
201
|
+
async componentWillLoad() {
|
|
202
|
+
if (this.translationUrl) {
|
|
203
|
+
await Localization.loadCustomTranslations(this.translationUrl);
|
|
204
|
+
}
|
|
205
|
+
this.loadTransactions();
|
|
206
|
+
}
|
|
207
|
+
componentDidRender() {
|
|
208
|
+
this.getComponentHeight();
|
|
209
|
+
if (!this.stylingAppended && this.stylingContainer) {
|
|
210
|
+
if (this.clientStyling) {
|
|
211
|
+
this.setStyles(this.clientStyling);
|
|
212
|
+
}
|
|
213
|
+
if (this.clientStylingUrl) {
|
|
214
|
+
this.setClientStylingByURL();
|
|
215
|
+
}
|
|
216
|
+
this.stylingAppended = true;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
getComponentHeight() {
|
|
220
|
+
var _a;
|
|
221
|
+
if (this.mobile) {
|
|
222
|
+
let height = this.el.getBoundingClientRect().height - ((_a = this.el.shadowRoot.querySelector('.table')) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect().y);
|
|
223
|
+
this.el.style.setProperty('--heightScrollableContainer', height + 'px');
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
setHeightTableProperty() {
|
|
227
|
+
let height = this.getComponentHeight();
|
|
228
|
+
this.el.style.setProperty('--heightScrollableContainer', height + 'px');
|
|
229
|
+
}
|
|
230
|
+
changeTransactionsType(type) {
|
|
231
|
+
this.type = type;
|
|
232
|
+
}
|
|
233
|
+
changePageSize(pageSize) {
|
|
234
|
+
this.pageSize = pageSize;
|
|
235
|
+
}
|
|
236
|
+
prev() {
|
|
237
|
+
var _a;
|
|
238
|
+
if (!((_a = this.pagination) === null || _a === void 0 ? void 0 : _a.previous)) {
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
this.page--;
|
|
242
|
+
}
|
|
243
|
+
next() {
|
|
244
|
+
var _a;
|
|
245
|
+
if (!((_a = this.pagination) === null || _a === void 0 ? void 0 : _a.next)) {
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.page++;
|
|
249
|
+
}
|
|
250
|
+
applyFilters(from, to) {
|
|
251
|
+
this.from = from ? new Date(from).toISOString() : null;
|
|
252
|
+
this.to = to ? new Date(to).toISOString() : null;
|
|
253
|
+
this.loadTransactions();
|
|
254
|
+
}
|
|
255
|
+
showFilter() {
|
|
256
|
+
this.showMobileFilter = !this.showMobileFilter;
|
|
257
|
+
}
|
|
258
|
+
render() {
|
|
259
|
+
var _a;
|
|
260
|
+
const filterSrc = getAssetPath('../assets/filter.svg');
|
|
261
|
+
const warningSrc = getAssetPath('../assets/warning.svg');
|
|
262
|
+
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() }, '>')))));
|
|
263
|
+
}
|
|
264
|
+
async loadTransactions() {
|
|
265
|
+
this.showLoader = true;
|
|
266
|
+
try {
|
|
267
|
+
const url = `${this.endpoint}/v1/player/${this.userId}/transactions/banking?${this.getParams()}`;
|
|
268
|
+
const response = await fetch(url, {
|
|
269
|
+
headers: {
|
|
270
|
+
'X-Sessionid': this.session,
|
|
271
|
+
'Content-Type': 'application/json'
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
if (!response.ok) {
|
|
275
|
+
const err = await response.text();
|
|
276
|
+
throw new Error(err);
|
|
277
|
+
}
|
|
278
|
+
const data = await response.json();
|
|
279
|
+
this.pagination = data.pagination;
|
|
280
|
+
this.transactions = data.transactions;
|
|
281
|
+
}
|
|
282
|
+
catch (ex) {
|
|
283
|
+
console.error(ex);
|
|
284
|
+
}
|
|
285
|
+
finally {
|
|
286
|
+
this.showLoader = false;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
getParams() {
|
|
290
|
+
var _a, _b;
|
|
291
|
+
const now = new Date();
|
|
292
|
+
const offset = (this.page * this.pageSize).toString();
|
|
293
|
+
const startDate = (_a = this.from) !== null && _a !== void 0 ? _a : new Date(now.getFullYear(), now.getMonth(), 1).toISOString();
|
|
294
|
+
const endDate = (_b = this.to) !== null && _b !== void 0 ? _b : new Date(now.getFullYear(), now.getMonth() + 1, 0).toISOString();
|
|
295
|
+
return `offset=${offset}&endDate=${endDate}&startDate=${startDate}&type=${this.type}&limit=${this.pageSize}`;
|
|
296
|
+
}
|
|
297
|
+
setStyles(styles) {
|
|
298
|
+
const cssFile = document.createElement('style');
|
|
299
|
+
cssFile.innerHTML = styles;
|
|
300
|
+
this.stylingContainer.prepend(cssFile);
|
|
301
|
+
}
|
|
302
|
+
async setClientStylingByURL() {
|
|
303
|
+
try {
|
|
304
|
+
const response = await fetch(this.clientStylingUrl);
|
|
305
|
+
if (!response.ok) {
|
|
306
|
+
const err = await response.text();
|
|
307
|
+
throw new Error(err);
|
|
308
|
+
}
|
|
309
|
+
const styles = await response.text();
|
|
310
|
+
this.setStyles(styles);
|
|
311
|
+
}
|
|
312
|
+
catch (ex) {
|
|
313
|
+
console.error(`Failed to load client styles ${this.clientStylingUrl}`, ex);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
static get assetsDirs() { return ["../assets"]; }
|
|
317
|
+
get el() { return getElement(this); }
|
|
318
|
+
static get watchers() { return {
|
|
319
|
+
"page": ["watchMultiple"],
|
|
320
|
+
"type": ["watchMultiple"],
|
|
321
|
+
"session": ["watchMultiple"],
|
|
322
|
+
"userId": ["watchMultiple"],
|
|
323
|
+
"pageSize": ["watchMultiple"],
|
|
324
|
+
"showMobileFilter": ["getComponentHeight"]
|
|
325
|
+
}; }
|
|
326
|
+
};
|
|
327
|
+
TransactionHistoryWidget.style = userTransactionHistoryCss;
|
|
328
|
+
|
|
329
|
+
export { TransactionHistoryWidget as user_transaction_history };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { p as promiseResolve, b as bootstrapLazy } from './index-32e3ae05.js';
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
Stencil Client Patch Browser v2.15.2 | MIT Licensed | https://stenciljs.com
|
|
5
|
+
*/
|
|
6
|
+
const patchBrowser = () => {
|
|
7
|
+
const importMeta = import.meta.url;
|
|
8
|
+
const opts = {};
|
|
9
|
+
if (importMeta !== '') {
|
|
10
|
+
opts.resourcesUrl = new URL('.', importMeta).href;
|
|
11
|
+
}
|
|
12
|
+
return promiseResolve(opts);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
patchBrowser().then(options => {
|
|
16
|
+
return bootstrapLazy([["user-transaction-history",[[1,"user-transaction-history",{"endpoint":[513],"session":[513],"language":[513],"userId":[513,"user-id"],"translationUrl":[513,"translation-url"],"mobile":[516],"clientStyling":[513,"client-styling"],"clientStylingUrl":[513,"client-styling-url"],"page":[32],"pageSize":[32],"showMobileFilter":[32],"to":[32],"from":[32],"type":[32],"transactions":[32],"showLoader":[32]},[[9,"resize","getComponentHeight"]]]]]], options);
|
|
17
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = require('./cjs/index.cjs.js');
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './esm/index.js';
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { sass } from '@stencil/sass';
|
|
2
|
+
export const config = {
|
|
3
|
+
namespace: 'user-transaction-history',
|
|
4
|
+
taskQueue: 'async',
|
|
5
|
+
plugins: [sass()],
|
|
6
|
+
outputTargets: [
|
|
7
|
+
{
|
|
8
|
+
type: 'dist',
|
|
9
|
+
esmLoaderPath: '../loader',
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
type: 'dist-custom-elements',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
type: 'docs-readme',
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'www',
|
|
19
|
+
serviceWorker: null, // disable service workers
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { FunctionalComponent } from '../../stencil-public-runtime';
|
|
2
|
+
export interface FiltersProps {
|
|
3
|
+
language: string;
|
|
4
|
+
from?: string | null;
|
|
5
|
+
to?: string | null;
|
|
6
|
+
applyFilters: (from: string | null, to: string | null) => void;
|
|
7
|
+
}
|
|
8
|
+
export declare const Filters: FunctionalComponent<FiltersProps>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { FunctionalComponent } from '../../stencil-public-runtime';
|
|
2
|
+
interface PagesSizeProps {
|
|
3
|
+
pageSizes: number[];
|
|
4
|
+
changePageSize: (s: number) => void;
|
|
5
|
+
currentPageSize: number;
|
|
6
|
+
language: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const PageSize: FunctionalComponent<PagesSizeProps>;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { FunctionalComponent } from '../../stencil-public-runtime';
|
|
2
|
+
import { Transaction } from '../../models/transactions-response.model';
|
|
3
|
+
export interface ITableComponent {
|
|
4
|
+
source: Transaction[];
|
|
5
|
+
language: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const TableComponent: FunctionalComponent<ITableComponent>;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Transaction } from '../../models/transactions-response.model';
|
|
2
|
+
export declare class TransactionHistoryWidget {
|
|
3
|
+
private pageSizes;
|
|
4
|
+
private pagination;
|
|
5
|
+
private stylingContainer;
|
|
6
|
+
private stylingAppended;
|
|
7
|
+
el: HTMLElement;
|
|
8
|
+
endpoint: string | null;
|
|
9
|
+
session: string;
|
|
10
|
+
language: string;
|
|
11
|
+
userId: string;
|
|
12
|
+
translationUrl: string;
|
|
13
|
+
mobile: boolean;
|
|
14
|
+
clientStyling: string | null;
|
|
15
|
+
clientStylingUrl: string | null;
|
|
16
|
+
page: number;
|
|
17
|
+
pageSize: number;
|
|
18
|
+
showMobileFilter: boolean;
|
|
19
|
+
to: string;
|
|
20
|
+
from: string;
|
|
21
|
+
type: string;
|
|
22
|
+
transactions: Transaction[];
|
|
23
|
+
showLoader: boolean;
|
|
24
|
+
watchMultiple(): void;
|
|
25
|
+
componentWillLoad(): Promise<void>;
|
|
26
|
+
componentDidRender(): void;
|
|
27
|
+
getComponentHeight(): void;
|
|
28
|
+
setHeightTableProperty(): void;
|
|
29
|
+
changeTransactionsType(type: string): void;
|
|
30
|
+
changePageSize(pageSize: number): void;
|
|
31
|
+
prev(): void;
|
|
32
|
+
next(): void;
|
|
33
|
+
applyFilters(from: string | null, to: string | null): void;
|
|
34
|
+
showFilter(): void;
|
|
35
|
+
render(): any;
|
|
36
|
+
private loadTransactions;
|
|
37
|
+
private getParams;
|
|
38
|
+
private setStyles;
|
|
39
|
+
private setClientStylingByURL;
|
|
40
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* tslint:disable */
|
|
3
|
+
/**
|
|
4
|
+
* This is an autogenerated file created by the Stencil compiler.
|
|
5
|
+
* It contains typing information for all components that exist in this project.
|
|
6
|
+
*/
|
|
7
|
+
import { HTMLStencilElement, JSXBase } from "./stencil-public-runtime";
|
|
8
|
+
export namespace Components {
|
|
9
|
+
interface UserTransactionHistory {
|
|
10
|
+
"clientStyling": string | null;
|
|
11
|
+
"clientStylingUrl": string | null;
|
|
12
|
+
"endpoint": string | null;
|
|
13
|
+
"language": string;
|
|
14
|
+
"mobile": boolean;
|
|
15
|
+
"session": string;
|
|
16
|
+
"translationUrl": string;
|
|
17
|
+
"userId": string;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
declare global {
|
|
21
|
+
interface HTMLUserTransactionHistoryElement extends Components.UserTransactionHistory, HTMLStencilElement {
|
|
22
|
+
}
|
|
23
|
+
var HTMLUserTransactionHistoryElement: {
|
|
24
|
+
prototype: HTMLUserTransactionHistoryElement;
|
|
25
|
+
new (): HTMLUserTransactionHistoryElement;
|
|
26
|
+
};
|
|
27
|
+
interface HTMLElementTagNameMap {
|
|
28
|
+
"user-transaction-history": HTMLUserTransactionHistoryElement;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
declare namespace LocalJSX {
|
|
32
|
+
interface UserTransactionHistory {
|
|
33
|
+
"clientStyling"?: string | null;
|
|
34
|
+
"clientStylingUrl"?: string | null;
|
|
35
|
+
"endpoint"?: string | null;
|
|
36
|
+
"language"?: string;
|
|
37
|
+
"mobile"?: boolean;
|
|
38
|
+
"session"?: string;
|
|
39
|
+
"translationUrl"?: string;
|
|
40
|
+
"userId"?: string;
|
|
41
|
+
}
|
|
42
|
+
interface IntrinsicElements {
|
|
43
|
+
"user-transaction-history": UserTransactionHistory;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
export { LocalJSX as JSX };
|
|
47
|
+
declare module "@stencil/core" {
|
|
48
|
+
export namespace JSX {
|
|
49
|
+
interface IntrinsicElements {
|
|
50
|
+
"user-transaction-history": LocalJSX.UserTransactionHistory & JSXBase.HTMLAttributes<HTMLUserTransactionHistoryElement>;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@vaadin/date-picker/theme/lumo/vaadin-date-picker.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './components';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface Transaction {
|
|
2
|
+
completed: string;
|
|
3
|
+
created: string;
|
|
4
|
+
creditPayItemType: string;
|
|
5
|
+
creditVendorName: string;
|
|
6
|
+
currency: string;
|
|
7
|
+
debitPayItemType: string;
|
|
8
|
+
debitVendorName: string;
|
|
9
|
+
externalReference: string;
|
|
10
|
+
productType: string;
|
|
11
|
+
realAmount: number;
|
|
12
|
+
status: string;
|
|
13
|
+
transId: number;
|
|
14
|
+
type: number;
|
|
15
|
+
}
|
|
16
|
+
export interface Pagination {
|
|
17
|
+
next: string | null;
|
|
18
|
+
previous: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface TransactionResponse {
|
|
21
|
+
pagination: Pagination;
|
|
22
|
+
transactions: Transaction[];
|
|
23
|
+
}
|