tg-core-components 6.0.6 → 6.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,15 @@
1
1
  import React, { Fragment } from 'react';
2
- import { FormattedNumber } from 'react-intl';
2
+ import { FormattedNumber, useIntl } from 'react-intl';
3
3
  import Icon from '../../../../components/Icon';
4
4
  import Notice from '../Notice';
5
5
  import marked from 'marked';
6
6
  import Translate from '../../../../components/Translate';
7
+ import { getKey } from '../../../../components/Alert';
7
8
 
8
9
  var CashierResult = function CashierResult(_ref) {
9
10
  var status = _ref.status,
10
11
  generalError = _ref.generalError,
12
+ providerType = _ref.providerType,
11
13
  cashierType = _ref.cashierType,
12
14
  currency = _ref.currency,
13
15
  wallet = _ref.wallet,
@@ -18,6 +20,8 @@ var CashierResult = function CashierResult(_ref) {
18
20
  if (wallet && wallet.isLoading) return null;
19
21
 
20
22
  if (status === 'success' || status === 'pending') {
23
+ var intl = useIntl();
24
+ var messageKey = 'message.' + (cashierType ? 'deposit' : 'withdrawal') + '.' + status + '.' + providerType;
21
25
  return React.createElement(
22
26
  'div',
23
27
  { className: 'cashier-accordion' },
@@ -28,7 +32,7 @@ var CashierResult = function CashierResult(_ref) {
28
32
  level: 'success',
29
33
  icon: React.createElement(Icon, { icon: 'check' }),
30
34
  header: React.createElement(Translate, {
31
- id: 'message.' + (cashierType ? 'deposit' : 'withdrawal') + '.' + status
35
+ id: getKey(intl, messageKey)
32
36
  })
33
37
  }),
34
38
  successMessage && React.createElement(
@@ -26,8 +26,10 @@ var ResponsibleGaming = function ResponsibleGaming(_ref) {
26
26
  limitIncreaseInfo = _ref.limitIncreaseInfo,
27
27
  jurisdiction = _ref.jurisdiction,
28
28
  currency = _ref.currency,
29
+ onChangeLimits = _ref.onChangeLimits,
29
30
  isLoading = _ref.isLoading,
30
- className = _ref.className;
31
+ className = _ref.className,
32
+ hideSubmit = _ref.hideSubmit;
31
33
 
32
34
  var _useState = useState(limits || []),
33
35
  _useState2 = _slicedToArray(_useState, 2),
@@ -40,6 +42,10 @@ var ResponsibleGaming = function ResponsibleGaming(_ref) {
40
42
 
41
43
  var normalizedLimits = normalize(localLimits, content);
42
44
 
45
+ useEffect(function () {
46
+ onChangeLimits && onChangeLimits(localLimits);
47
+ }, [localLimits]);
48
+
43
49
  /**
44
50
  * Validate the normalized limits
45
51
  */
@@ -135,6 +141,7 @@ var ResponsibleGaming = function ResponsibleGaming(_ref) {
135
141
  React.createElement(LimitContent, _extends({
136
142
  onSubmitLimits: onSubmitLimits(normalizedLimits.type, normalizedLimits.product),
137
143
  onChangeLimit: onChangeLimit(normalizedLimits.type, normalizedLimits.product),
144
+ hideSubmit: hideSubmit,
138
145
  onConfirmLimit: onConfirmLimit,
139
146
  onDeclineLimit: onDeclineLimit,
140
147
  getValidationState: getValidationState(normalizedLimits.type),
@@ -175,7 +182,8 @@ var LimitContent = function LimitContent(_ref3) {
175
182
  valueType = _ref3.valueType,
176
183
  hideRemainingLimit = _ref3.hideRemainingLimit,
177
184
  showCurrentValue = _ref3.showCurrentValue,
178
- hideOther = _ref3.hideOther;
185
+ hideOther = _ref3.hideOther,
186
+ hideSubmit = _ref3.hideSubmit;
179
187
 
180
188
  var formIsValid = Object.keys(timespans).every(function (t) {
181
189
  return getValidationState(t).isValid();
@@ -240,7 +248,7 @@ var LimitContent = function LimitContent(_ref3) {
240
248
  hideOther: hideOther
241
249
  }, t));
242
250
  }),
243
- React.createElement(
251
+ !hideSubmit && React.createElement(
244
252
  Button,
245
253
  {
246
254
  type: 'submit',
@@ -26,11 +26,14 @@ var _Translate = require('../../../../components/Translate');
26
26
 
27
27
  var _Translate2 = _interopRequireDefault(_Translate);
28
28
 
29
+ var _Alert = require('../../../../components/Alert');
30
+
29
31
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
30
32
 
31
33
  var CashierResult = function CashierResult(_ref) {
32
34
  var status = _ref.status,
33
35
  generalError = _ref.generalError,
36
+ providerType = _ref.providerType,
34
37
  cashierType = _ref.cashierType,
35
38
  currency = _ref.currency,
36
39
  wallet = _ref.wallet,
@@ -41,6 +44,8 @@ var CashierResult = function CashierResult(_ref) {
41
44
  if (wallet && wallet.isLoading) return null;
42
45
 
43
46
  if (status === 'success' || status === 'pending') {
47
+ var intl = (0, _reactIntl.useIntl)();
48
+ var messageKey = 'message.' + (cashierType ? 'deposit' : 'withdrawal') + '.' + status + '.' + providerType;
44
49
  return _react2.default.createElement(
45
50
  'div',
46
51
  { className: 'cashier-accordion' },
@@ -51,7 +56,7 @@ var CashierResult = function CashierResult(_ref) {
51
56
  level: 'success',
52
57
  icon: _react2.default.createElement(_Icon2.default, { icon: 'check' }),
53
58
  header: _react2.default.createElement(_Translate2.default, {
54
- id: 'message.' + (cashierType ? 'deposit' : 'withdrawal') + '.' + status
59
+ id: (0, _Alert.getKey)(intl, messageKey)
55
60
  })
56
61
  }),
57
62
  successMessage && _react2.default.createElement(
@@ -68,8 +68,10 @@ var ResponsibleGaming = function ResponsibleGaming(_ref) {
68
68
  limitIncreaseInfo = _ref.limitIncreaseInfo,
69
69
  jurisdiction = _ref.jurisdiction,
70
70
  currency = _ref.currency,
71
+ onChangeLimits = _ref.onChangeLimits,
71
72
  isLoading = _ref.isLoading,
72
- className = _ref.className;
73
+ className = _ref.className,
74
+ hideSubmit = _ref.hideSubmit;
73
75
 
74
76
  var _useState = (0, _react.useState)(limits || []),
75
77
  _useState2 = _slicedToArray(_useState, 2),
@@ -82,6 +84,10 @@ var ResponsibleGaming = function ResponsibleGaming(_ref) {
82
84
 
83
85
  var normalizedLimits = (0, _normalize2.default)(localLimits, content);
84
86
 
87
+ (0, _react.useEffect)(function () {
88
+ onChangeLimits && onChangeLimits(localLimits);
89
+ }, [localLimits]);
90
+
85
91
  /**
86
92
  * Validate the normalized limits
87
93
  */
@@ -177,6 +183,7 @@ var ResponsibleGaming = function ResponsibleGaming(_ref) {
177
183
  _react2.default.createElement(LimitContent, _extends({
178
184
  onSubmitLimits: onSubmitLimits(normalizedLimits.type, normalizedLimits.product),
179
185
  onChangeLimit: onChangeLimit(normalizedLimits.type, normalizedLimits.product),
186
+ hideSubmit: hideSubmit,
180
187
  onConfirmLimit: onConfirmLimit,
181
188
  onDeclineLimit: onDeclineLimit,
182
189
  getValidationState: getValidationState(normalizedLimits.type),
@@ -217,7 +224,8 @@ var LimitContent = function LimitContent(_ref3) {
217
224
  valueType = _ref3.valueType,
218
225
  hideRemainingLimit = _ref3.hideRemainingLimit,
219
226
  showCurrentValue = _ref3.showCurrentValue,
220
- hideOther = _ref3.hideOther;
227
+ hideOther = _ref3.hideOther,
228
+ hideSubmit = _ref3.hideSubmit;
221
229
 
222
230
  var formIsValid = Object.keys(timespans).every(function (t) {
223
231
  return getValidationState(t).isValid();
@@ -282,7 +290,7 @@ var LimitContent = function LimitContent(_ref3) {
282
290
  hideOther: hideOther
283
291
  }, t));
284
292
  }),
285
- _react2.default.createElement(
293
+ !hideSubmit && _react2.default.createElement(
286
294
  _Button2.default,
287
295
  {
288
296
  type: 'submit',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tg-core-components",
3
- "version": "6.0.6",
3
+ "version": "6.1.0",
4
4
  "description": "tg-core-components",
5
5
  "main": "lib/index.js",
6
6
  "module": "es/index.js",
@@ -76,5 +76,5 @@
76
76
  "webpack": "^3.0.0",
77
77
  "webpack-blocks": "^1.0.0"
78
78
  },
79
- "gitHead": "b82792457fc728444d1fb02f639470b30c901d0d"
79
+ "gitHead": "7811389b3773b83ac82b5970c9622568189e801f"
80
80
  }