@everymatrix/pam-player-documents 0.11.2

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.
Files changed (56) hide show
  1. package/dist/cjs/app-globals-3a1e7e63.js +5 -0
  2. package/dist/cjs/index-84b76e65.js +1227 -0
  3. package/dist/cjs/index.cjs.js +10 -0
  4. package/dist/cjs/loader.cjs.js +15 -0
  5. package/dist/cjs/pam-player-documents-bc881ad5.js +416 -0
  6. package/dist/cjs/pam-player-documents.cjs.js +25 -0
  7. package/dist/cjs/pam-player-documents_2.cjs.entry.js +203 -0
  8. package/dist/collection/collection-manifest.json +19 -0
  9. package/dist/collection/components/pam-player-documents/index.js +1 -0
  10. package/dist/collection/components/pam-player-documents/pam-player-documents.css +249 -0
  11. package/dist/collection/components/pam-player-documents/pam-player-documents.js +428 -0
  12. package/dist/collection/index.js +1 -0
  13. package/dist/collection/utils/locale.utils.js +129 -0
  14. package/dist/collection/utils/utils.js +12 -0
  15. package/dist/esm/app-globals-0f993ce5.js +3 -0
  16. package/dist/esm/index-3f96eae4.js +1200 -0
  17. package/dist/esm/index.js +2 -0
  18. package/dist/esm/loader.js +11 -0
  19. package/dist/esm/pam-player-documents-7540c613.js +414 -0
  20. package/dist/esm/pam-player-documents.js +20 -0
  21. package/dist/esm/pam-player-documents_2.entry.js +198 -0
  22. package/dist/index.cjs.js +1 -0
  23. package/dist/index.js +1 -0
  24. package/dist/pam-player-documents/app-globals-0f993ce5.js +1 -0
  25. package/dist/pam-player-documents/index-3f96eae4.js +2 -0
  26. package/dist/pam-player-documents/index.esm.js +1 -0
  27. package/dist/pam-player-documents/pam-player-documents-7540c613.js +1 -0
  28. package/dist/pam-player-documents/pam-player-documents.esm.js +1 -0
  29. package/dist/pam-player-documents/pam-player-documents_2.entry.js +1 -0
  30. package/dist/stencil.config.dev.js +17 -0
  31. package/dist/stencil.config.js +19 -0
  32. package/dist/storybook/main.js +47 -0
  33. package/dist/storybook/preview.js +9 -0
  34. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/libs/common/src/storybook/storybook-utils.d.ts +39 -0
  35. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/packages/stencil/pam-player-documents/stencil.config.d.ts +2 -0
  36. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/packages/stencil/pam-player-documents/stencil.config.dev.d.ts +2 -0
  37. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/packages/stencil/pam-player-documents/storybook/main.d.ts +3 -0
  38. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/packages/stencil/pam-player-documents/storybook/preview.d.ts +70 -0
  39. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/tools/plugins/index.d.ts +3 -0
  40. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/tools/plugins/stencil-clean-deps-plugin.d.ts +5 -0
  41. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/tools/plugins/vite-chunk-plugin.d.ts +6 -0
  42. package/dist/types/Users/adrian.pripon/Documents/Work/widgets-monorepo/packages/stencil/pam-player-documents/.stencil/tools/plugins/vite-clean-deps-plugin.d.ts +4 -0
  43. package/dist/types/components/pam-player-documents/index.d.ts +1 -0
  44. package/dist/types/components/pam-player-documents/pam-player-documents.d.ts +46 -0
  45. package/dist/types/components.d.ts +57 -0
  46. package/dist/types/index.d.ts +1 -0
  47. package/dist/types/stencil-public-runtime.d.ts +1674 -0
  48. package/dist/types/utils/locale.utils.d.ts +23 -0
  49. package/dist/types/utils/utils.d.ts +7 -0
  50. package/loader/cdn.js +1 -0
  51. package/loader/index.cjs.js +1 -0
  52. package/loader/index.d.ts +24 -0
  53. package/loader/index.es2017.js +1 -0
  54. package/loader/index.js +2 -0
  55. package/loader/package.json +11 -0
  56. package/package.json +26 -0
@@ -0,0 +1,428 @@
1
+ import { setClientStyling, setClientStylingURL, setStreamStyling } from "../../../../../../../../libs/common/src/styling/index";
2
+ import { h } from "@stencil/core";
3
+ import { translate } from "../../utils/locale.utils";
4
+ import { isMobile } from "../../utils/utils";
5
+ import "../../../../../ui-skeleton/dist/types/index";
6
+ export class PamPlayerDocuments {
7
+ constructor() {
8
+ this.dataRef = {};
9
+ this.fieldsState = {};
10
+ this.sendLoadedMessage = () => {
11
+ window.postMessage({ type: 'DOCUMENTS_LOADED' });
12
+ };
13
+ this.sendValidMessage = () => {
14
+ window.postMessage({ type: 'DOCUMENTS_VALIDITY', data: this.isSubmitButtonAvailable });
15
+ };
16
+ this.sendSuccessNotification = () => {
17
+ window.postMessage({ type: 'WidgetNotification', data: { type: 'success', message: translate('successMessage', this.lang) } }, window.location.href);
18
+ };
19
+ this.sendErrorNotification = (errorKey) => {
20
+ window.postMessage({ type: 'WidgetNotification', data: { type: 'error', message: translate(errorKey, this.lang) } }, window.location.href);
21
+ };
22
+ this.sendData = () => {
23
+ window.postMessage({ type: 'DOCUMENTS_UPDATE_DATA', data: this.data }, window.location.href);
24
+ };
25
+ this.messageHandler = (message) => {
26
+ var _a;
27
+ switch ((_a = message.data) === null || _a === void 0 ? void 0 : _a.type) {
28
+ case 'DOCUMENTS_DATA':
29
+ this.data = message.data.data;
30
+ this.resetState();
31
+ this.isSkeletonLoading = false;
32
+ break;
33
+ case 'DOCUMENTS_SEND_DATA':
34
+ this.sendData();
35
+ break;
36
+ }
37
+ };
38
+ this.getData = () => {
39
+ const url = new URL(`/api/v1/players/${this.userId}/player-identifiable-information/documents/`, this.endpoint);
40
+ const headers = new Headers();
41
+ headers.append('X-SessionID', this.session);
42
+ const options = {
43
+ method: 'GET',
44
+ headers: headers
45
+ };
46
+ return new Promise((resolve) => {
47
+ fetch(url.href, options)
48
+ .then(res => {
49
+ if (res.ok) {
50
+ return res.json();
51
+ }
52
+ this.sendErrorNotification('errorMessageFetch');
53
+ })
54
+ .then(res => {
55
+ this.data = res;
56
+ resolve();
57
+ });
58
+ });
59
+ };
60
+ this.buildFieldState = (isValid, initialValue, rule) => Object.assign({ 'isValid': isValid, 'initialValue': initialValue, 'rule': rule });
61
+ this.resetState = () => {
62
+ this.initData();
63
+ this.initEditableFieldsState();
64
+ this.invalidFields = 0;
65
+ this.isSubmitButtonAvailable = false;
66
+ };
67
+ this.updateState = (sectionKey) => (e) => {
68
+ this.dataRef[sectionKey].documentNumber = e.target.value;
69
+ const fieldState = this.fieldsState[sectionKey]['data'].documentNumber;
70
+ const value = e.target.value;
71
+ const passedRuleCheck = fieldState.rule(value);
72
+ if (passedRuleCheck && !fieldState.isValid) {
73
+ fieldState.isValid = true;
74
+ this.invalidFields -= 1;
75
+ }
76
+ else if (!passedRuleCheck && fieldState.isValid) {
77
+ fieldState.isValid = false;
78
+ this.invalidFields += 1;
79
+ }
80
+ this.fieldsState[sectionKey]['hasChanged'] = value !== fieldState.initialValue;
81
+ const previous = this.isSubmitButtonAvailable;
82
+ this.updateSubmitButtonStatus();
83
+ if (this.isStandAlone !== 'true' && this.isSubmitButtonAvailable !== previous) {
84
+ this.sendValidMessage();
85
+ }
86
+ };
87
+ this.updateData = (e) => {
88
+ if (e)
89
+ e.preventDefault();
90
+ const promises = [];
91
+ for (const documentType of Object.keys(this.fieldsState)) {
92
+ if (!this.fieldsState[documentType]['hasChanged'])
93
+ continue;
94
+ const document = this.dataRef[documentType];
95
+ const url = new URL(`/api/v1/players/${this.userId}/player-identifiable-information/documents/${document['documentId']}/`, this.endpoint);
96
+ const headers = new Headers();
97
+ headers.append('X-SessionId', this.session);
98
+ headers.append('Content-Type', 'application/json-patch+json');
99
+ const reqParams = {
100
+ method: 'PUT',
101
+ headers,
102
+ body: JSON.stringify(document)
103
+ };
104
+ promises.push(fetch(url, reqParams));
105
+ }
106
+ Promise.all(promises)
107
+ .then(resArr => {
108
+ if (resArr.some(res => !res.ok)) {
109
+ return this.sendErrorNotification('errorMessageUpdate');
110
+ }
111
+ this.sendSuccessNotification();
112
+ this.getData().then(() => this.resetState());
113
+ });
114
+ };
115
+ this.updateSubmitButtonStatus = () => {
116
+ this.isSubmitButtonAvailable = this.invalidFields === 0 && Object.values(this.fieldsState).some(v => v.hasChanged);
117
+ };
118
+ this.editableField = (sectionKey, fieldKey, labelTranslationKey, errorTranslationKey) => {
119
+ const fieldState = this.fieldsState[sectionKey]['data'][fieldKey];
120
+ const value = this.dataRef[sectionKey];
121
+ if (fieldState) {
122
+ return (h("div", { class: `Field ${fieldState.isValid ? '' : 'Invalid'}` }, h("label", null, translate(labelTranslationKey, this.lang)), h("input", { type: "text", value: value[fieldKey], onKeyUp: this.updateState(sectionKey) }), !fieldState.isValid &&
123
+ h("p", { class: "Error" }, translate(errorTranslationKey, this.lang))));
124
+ }
125
+ else {
126
+ return null;
127
+ }
128
+ };
129
+ this.staticField = (sectionKey, fieldKey, labelTranslationKey) => {
130
+ const value = this.dataRef[sectionKey];
131
+ if (value && value[fieldKey]) {
132
+ return (h("div", { class: "Field Disabled" }, h("label", null, translate(labelTranslationKey, this.lang)), h("input", { type: "text", value: value[fieldKey], readonly: true })));
133
+ }
134
+ else {
135
+ return null;
136
+ }
137
+ };
138
+ this.toggleScreen = () => {
139
+ window.postMessage({ type: 'PlayerAccountMenuActive', isMobile: this.isMobile }, window.location.href);
140
+ };
141
+ this.userId = undefined;
142
+ this.session = undefined;
143
+ this.endpoint = undefined;
144
+ this.lang = 'en';
145
+ this.mbSource = undefined;
146
+ this.clientStyling = undefined;
147
+ this.clientStylingUrl = undefined;
148
+ this.translationUrl = undefined;
149
+ this.isEditable = 'false';
150
+ this.isStandAlone = 'true';
151
+ this.limitStylingAppends = false;
152
+ this.isSkeletonLoading = true;
153
+ this.isSubmitButtonAvailable = false;
154
+ this.invalidFields = 0;
155
+ this.isMobile = isMobile(window.navigator.userAgent);
156
+ }
157
+ handleStylingChange(newValue, oldValue) {
158
+ if (newValue !== oldValue)
159
+ setClientStyling(this.stylingContainer, this.clientStyling);
160
+ }
161
+ handleStylingUrlChange(newValue, oldValue) {
162
+ if (newValue !== oldValue)
163
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
164
+ }
165
+ async componentWillLoad() {
166
+ if (this.isStandAlone !== 'true') {
167
+ return;
168
+ }
169
+ await this.getData()
170
+ .then(() => {
171
+ this.initData();
172
+ this.initEditableFieldsState();
173
+ })
174
+ .finally(() => this.isSkeletonLoading = false);
175
+ }
176
+ componentDidLoad() {
177
+ if (this.stylingContainer) {
178
+ if (window.emMessageBuss != undefined) {
179
+ setStreamStyling(this.stylingContainer, `${this.mbSource}.Style`, this.stylingSubscription);
180
+ }
181
+ else {
182
+ if (this.clientStyling)
183
+ setClientStyling(this.stylingContainer, this.clientStyling);
184
+ if (this.clientStylingUrl)
185
+ setClientStylingURL(this.stylingContainer, this.clientStylingUrl);
186
+ }
187
+ }
188
+ if (this.isStandAlone !== 'true') {
189
+ window.addEventListener('message', this.messageHandler, false);
190
+ this.sendLoadedMessage();
191
+ }
192
+ }
193
+ disconnectedCallback() {
194
+ this.stylingSubscription && this.stylingSubscription.unsubscribe();
195
+ if (this.isStandAlone !== 'true')
196
+ window.removeEventListener('message', this.messageHandler, false);
197
+ }
198
+ initData() {
199
+ for (const document of this.data.documents) {
200
+ this.dataRef[document.documentType] = document;
201
+ }
202
+ }
203
+ initEditableFieldsState() {
204
+ for (const [documentType, document] of Object.entries(this.dataRef)) {
205
+ this.fieldsState[documentType] = {};
206
+ this.fieldsState[documentType]['data'] = {};
207
+ this.fieldsState[documentType]['data']['documentNumber'] = this.buildFieldState(true, document.documentNumber, (val) => val && /^(?=.*[a-zA-Z0-9])[a-zA-Z0-9\s]+$/.test(val) && val.length <= 50);
208
+ this.fieldsState[documentType]['hasChanged'] = false;
209
+ }
210
+ }
211
+ render() {
212
+ return (h("div", { key: '7abe1ef66b345689e5b12f56c8c563f21bf31862', ref: el => this.stylingContainer = el }, this.isSkeletonLoading
213
+ ? h("form", { class: "PlayerDocumentsWrapper skeleton" }, h("div", { class: "ReturnButton" }, h("ui-skeleton", { structure: "title", width: "auto", height: "30px" })), h("div", { class: "Section" }, h("section", { class: "SectionContent" }, h("div", { class: "Field" }, h("ui-skeleton", { structure: "text", width: "auto", "margin-bottom": "10px", height: "10px" }), h("ui-skeleton", { structure: "title", width: "100%", height: "40px" })), h("div", { class: "Field" }, h("ui-skeleton", { structure: "text", width: "auto", "margin-bottom": "10px", height: "10px" }), h("ui-skeleton", { structure: "title", width: "100%", height: "40px" })))), h("section", { class: "ButtonsArea" }, h("div", { class: "SaveButton" }, h("ui-skeleton", { structure: "rectangle", width: "auto", height: "40px" }))))
214
+ : h("form", { class: `PlayerDocumentsWrapper ${this.isMobile ? 'Mobile' : ''}` }, h("div", { class: "ReturnButton", onClick: this.toggleScreen }, h("svg", { xmlns: "http://www.w3.org/2000/svg", width: "15", height: "15", viewBox: "0 0 15 15" }, h("g", { transform: "translate(-20 -158)" }, h("g", { transform: "translate(20 158)" }, h("path", { class: "aaa", d: "M7.5,0,6.136,1.364,11.3,6.526H0V8.474H11.3L6.136,13.636,7.5,15,15,7.5Z", transform: "translate(15 15) rotate(180)" })))), h("h2", null, translate('title', this.lang))), h("h2", { class: "HeaderText" }, translate('title', this.lang)), h("div", { class: "Section" }, h("section", { class: "SectionContent" }, Object.keys(this.dataRef).map(documentType => {
215
+ return (h("div", { class: "CompoundField" }, this.staticField(documentType, 'documentType', 'documentType'), this.isEditable === 'true'
216
+ ? this.editableField(documentType, 'documentNumber', 'documentNumber', 'documentNumberError')
217
+ : this.staticField(documentType, 'documentNumber', 'documentNumber')));
218
+ }))), this.isStandAlone === 'true' &&
219
+ h("section", { class: "ButtonsArea" }, h("button", { class: `SaveButton ${this.isSubmitButtonAvailable ? '' : 'Disabled'}`, onClick: this.updateData }, translate('saveButton'))))));
220
+ }
221
+ static get is() { return "pam-player-documents"; }
222
+ static get encapsulation() { return "shadow"; }
223
+ static get originalStyleUrls() {
224
+ return {
225
+ "$": ["pam-player-documents.scss"]
226
+ };
227
+ }
228
+ static get styleUrls() {
229
+ return {
230
+ "$": ["pam-player-documents.css"]
231
+ };
232
+ }
233
+ static get properties() {
234
+ return {
235
+ "userId": {
236
+ "type": "string",
237
+ "mutable": false,
238
+ "complexType": {
239
+ "original": "string",
240
+ "resolved": "string",
241
+ "references": {}
242
+ },
243
+ "required": false,
244
+ "optional": false,
245
+ "docs": {
246
+ "tags": [],
247
+ "text": ""
248
+ },
249
+ "attribute": "user-id",
250
+ "reflect": true
251
+ },
252
+ "session": {
253
+ "type": "string",
254
+ "mutable": false,
255
+ "complexType": {
256
+ "original": "string",
257
+ "resolved": "string",
258
+ "references": {}
259
+ },
260
+ "required": false,
261
+ "optional": false,
262
+ "docs": {
263
+ "tags": [],
264
+ "text": ""
265
+ },
266
+ "attribute": "session",
267
+ "reflect": true
268
+ },
269
+ "endpoint": {
270
+ "type": "string",
271
+ "mutable": false,
272
+ "complexType": {
273
+ "original": "string",
274
+ "resolved": "string",
275
+ "references": {}
276
+ },
277
+ "required": false,
278
+ "optional": false,
279
+ "docs": {
280
+ "tags": [],
281
+ "text": ""
282
+ },
283
+ "attribute": "endpoint",
284
+ "reflect": true
285
+ },
286
+ "lang": {
287
+ "type": "string",
288
+ "mutable": false,
289
+ "complexType": {
290
+ "original": "string",
291
+ "resolved": "string",
292
+ "references": {}
293
+ },
294
+ "required": false,
295
+ "optional": false,
296
+ "docs": {
297
+ "tags": [],
298
+ "text": ""
299
+ },
300
+ "attribute": "lang",
301
+ "reflect": true,
302
+ "defaultValue": "'en'"
303
+ },
304
+ "mbSource": {
305
+ "type": "string",
306
+ "mutable": false,
307
+ "complexType": {
308
+ "original": "string",
309
+ "resolved": "string",
310
+ "references": {}
311
+ },
312
+ "required": false,
313
+ "optional": false,
314
+ "docs": {
315
+ "tags": [],
316
+ "text": ""
317
+ },
318
+ "attribute": "mb-source",
319
+ "reflect": true
320
+ },
321
+ "clientStyling": {
322
+ "type": "string",
323
+ "mutable": false,
324
+ "complexType": {
325
+ "original": "string",
326
+ "resolved": "string",
327
+ "references": {}
328
+ },
329
+ "required": false,
330
+ "optional": false,
331
+ "docs": {
332
+ "tags": [],
333
+ "text": ""
334
+ },
335
+ "attribute": "client-styling",
336
+ "reflect": true
337
+ },
338
+ "clientStylingUrl": {
339
+ "type": "string",
340
+ "mutable": false,
341
+ "complexType": {
342
+ "original": "string",
343
+ "resolved": "string",
344
+ "references": {}
345
+ },
346
+ "required": false,
347
+ "optional": false,
348
+ "docs": {
349
+ "tags": [],
350
+ "text": ""
351
+ },
352
+ "attribute": "client-styling-url",
353
+ "reflect": true
354
+ },
355
+ "translationUrl": {
356
+ "type": "string",
357
+ "mutable": false,
358
+ "complexType": {
359
+ "original": "string",
360
+ "resolved": "string",
361
+ "references": {}
362
+ },
363
+ "required": false,
364
+ "optional": false,
365
+ "docs": {
366
+ "tags": [],
367
+ "text": ""
368
+ },
369
+ "attribute": "translation-url",
370
+ "reflect": true
371
+ },
372
+ "isEditable": {
373
+ "type": "string",
374
+ "mutable": false,
375
+ "complexType": {
376
+ "original": "string",
377
+ "resolved": "string",
378
+ "references": {}
379
+ },
380
+ "required": false,
381
+ "optional": false,
382
+ "docs": {
383
+ "tags": [],
384
+ "text": ""
385
+ },
386
+ "attribute": "is-editable",
387
+ "reflect": true,
388
+ "defaultValue": "'false'"
389
+ },
390
+ "isStandAlone": {
391
+ "type": "string",
392
+ "mutable": false,
393
+ "complexType": {
394
+ "original": "string",
395
+ "resolved": "string",
396
+ "references": {}
397
+ },
398
+ "required": false,
399
+ "optional": false,
400
+ "docs": {
401
+ "tags": [],
402
+ "text": ""
403
+ },
404
+ "attribute": "is-stand-alone",
405
+ "reflect": true,
406
+ "defaultValue": "'true'"
407
+ }
408
+ };
409
+ }
410
+ static get states() {
411
+ return {
412
+ "limitStylingAppends": {},
413
+ "isSkeletonLoading": {},
414
+ "isSubmitButtonAvailable": {},
415
+ "invalidFields": {},
416
+ "isMobile": {}
417
+ };
418
+ }
419
+ static get watchers() {
420
+ return [{
421
+ "propName": "clientStyling",
422
+ "methodName": "handleStylingChange"
423
+ }, {
424
+ "propName": "clientStylingUrl",
425
+ "methodName": "handleStylingUrlChange"
426
+ }];
427
+ }
428
+ }
@@ -0,0 +1 @@
1
+ export * from './components/pam-player-documents';
@@ -0,0 +1,129 @@
1
+ export const DEFAULT_LANGUAGE = 'en';
2
+ export const TRANSLATIONS = {
3
+ "en": {
4
+ "title": "Documents",
5
+ "documentType": "Document Type",
6
+ "documentNumber": "Document Number",
7
+ "documentNumberError": "Document number is invalid",
8
+ "saveButton": "Save Changes",
9
+ "successMessage": "Your changes have been saved!",
10
+ "errorMessageUpdate": "An error has occured when attempting to update the documents information",
11
+ "errorMessageFetch": "An error has occured when attempting to fetch the documents information"
12
+ },
13
+ "zh-hk": {
14
+ "title": "文件",
15
+ "documentType": "文件類型",
16
+ "documentNumber": "文件號碼",
17
+ "documentNumberError": "文件號碼無效",
18
+ "saveButton": "保存更改",
19
+ "successMessage": "您的更改已保存!",
20
+ "errorMessageUpdate": "嘗試更新文件信息時發生錯誤",
21
+ "errorMessageFetch": "在嘗試獲取文件信息時發生錯誤"
22
+ },
23
+ "fr": {
24
+ "title": "Documents",
25
+ "documentType": "Type de document",
26
+ "documentNumber": "Numéro de document",
27
+ "documentNumberError": "Le numéro de document est invalide",
28
+ "saveButton": "Enregistrer les modifications",
29
+ "successMessage": "Vos modifications ont été enregistrées !",
30
+ "errorMessageUpdate": "Une erreur s'est produite lors de la tentative de mise à jour des informations des documents",
31
+ "errorMessageFetch": "Une erreur est survenue lors de la tentative de récupération des informations sur les documents"
32
+ },
33
+ "ro": {
34
+ "title": "Documente",
35
+ "documentType": "Tip document",
36
+ "documentNumber": "Număr document",
37
+ "documentNumberError": "Numărul documentului este invalid",
38
+ "saveButton": "Salvează modificările",
39
+ "successMessage": "Modificările dvs. au fost salvate!",
40
+ "errorMessageUpdate": "A apărut o eroare la încercarea de a actualiza informațiile documentelor",
41
+ "errorMessageFetch": "A apărut o eroare la încercarea de a obține informațiile documentelor"
42
+ },
43
+ "tr": {
44
+ "title": "Belgeler",
45
+ "documentType": "Belge Türü",
46
+ "documentNumber": "Belge Numarası",
47
+ "documentNumberError": "Belge numarası geçersiz",
48
+ "saveButton": "Değişiklikleri Kaydet",
49
+ "successMessage": "Değişiklikleriniz kaydedildi!",
50
+ "errorMessageUpdate": "Belgelerin bilgilerini güncellemeye çalışırken bir hata oluştu",
51
+ "errorMessageFetch": "Belgelerin bilgilerini almak için yapılan işlemde bir hata oluştu"
52
+ },
53
+ "es": {
54
+ "title": "Documentos",
55
+ "documentType": "Tipo de documento",
56
+ "documentNumber": "Número de documento",
57
+ "documentNumberError": "El número de documento no es válido",
58
+ "saveButton": "Guardar cambios",
59
+ "successMessage": "¡Tus cambios han sido guardados!",
60
+ "errorMessageUpdate": "Se ha producido un error al intentar actualizar la información de los documentos",
61
+ "errorMessageFetch": "Se ha producido un error al intentar obtener la información de los documentos"
62
+ },
63
+ "pt": {
64
+ "title": "Documentos",
65
+ "documentType": "Tipo de documento",
66
+ "documentNumber": "Número do documento",
67
+ "documentNumberError": "O número do documento é inválido",
68
+ "saveButton": "Salvar alterações",
69
+ "successMessage": "Suas alterações foram salvas!",
70
+ "errorMessageUpdate": "Ocorreu um erro ao tentar atualizar as informações dos documentos",
71
+ "errorMessageFetch": "Ocorreu um erro ao tentar buscar as informações dos documentos"
72
+ },
73
+ "hr": {
74
+ "title": "Dokumenti",
75
+ "documentType": "Vrsta dokumenta",
76
+ "documentNumber": "Broj dokumenta",
77
+ "documentNumberError": "Broj dokumenta je nevažeći",
78
+ "saveButton": "Spremi promjene",
79
+ "successMessage": "Vaše promjene su spremljene!",
80
+ "errorMessageUpdate": "Došlo je do pogreške prilikom pokušaja ažuriranja informacija o dokumentima",
81
+ "errorMessageFetch": "Došlo je do greške prilikom pokušaja dobijanja informacija o dokumentima"
82
+ },
83
+ "pt-br": {
84
+ "title": "Documentos",
85
+ "documentType": "Tipo de documento",
86
+ "documentNumber": "Número do documento",
87
+ "documentNumberError": "O número do documento é inválido",
88
+ "saveButton": "Salvar alterações",
89
+ "successMessage": "Suas alterações foram salvas!",
90
+ "errorMessageUpdate": "Ocorreu um erro ao tentar atualizar as informações dos documentos",
91
+ "errorMessageFetch": "Ocorreu um erro ao tentar buscar as informações dos documentos"
92
+ },
93
+ "es-mx": {
94
+ "title": "Documentos",
95
+ "documentType": "Tipo de documento",
96
+ "documentNumber": "Número de documento",
97
+ "documentNumberError": "El número de documento no es válido",
98
+ "saveButton": "Guardar cambios",
99
+ "successMessage": "¡Tus cambios han sido guardados!",
100
+ "errorMessageUpdate": "Se ha producido un error al intentar actualizar la información de los documentos",
101
+ "errorMessageFetch": "Se ha producido un error al intentar obtener la información de los documentos"
102
+ }
103
+ };
104
+ export const getTranslations = (url) => {
105
+ // fetch url, get the data, replace the TRANSLATIONS content
106
+ return new Promise((resolve) => {
107
+ fetch(url)
108
+ .then((res) => res.json())
109
+ .then((data) => {
110
+ Object.keys(data).forEach((item) => {
111
+ for (let key in data[item]) {
112
+ TRANSLATIONS[item][key] = data[item][key];
113
+ }
114
+ });
115
+ resolve(true);
116
+ });
117
+ });
118
+ };
119
+ export const translate = (key, customLang, values) => {
120
+ let lang = TRANSLATIONS[customLang] ? customLang : DEFAULT_LANGUAGE;
121
+ let translation = TRANSLATIONS[lang][key];
122
+ if (values !== undefined) {
123
+ for (const [key, value] of Object.entries(values.values)) {
124
+ const regex = new RegExp(`{${key}}`, 'g');
125
+ translation = translation.replace(regex, value);
126
+ }
127
+ }
128
+ return translation;
129
+ };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @name isMobile
3
+ * @description A method that returns if the browser used to access the app is from a mobile device or not
4
+ * @param {String} userAgent window.navigator.userAgent
5
+ * @returns {Boolean} true or false
6
+ */
7
+ export const isMobile = (userAgent) => {
8
+ return !!(userAgent.toLowerCase().match(/android/i) ||
9
+ userAgent.toLowerCase().match(/blackberry|bb/i) ||
10
+ userAgent.toLowerCase().match(/iphone|ipad|ipod/i) ||
11
+ userAgent.toLowerCase().match(/windows phone|windows mobile|iemobile|wpdesktop/i));
12
+ };
@@ -0,0 +1,3 @@
1
+ const globalScripts = () => {};
2
+
3
+ export { globalScripts as g };