tg-core-components 6.1.9-intl-test.2 → 6.2.1-alpha.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.
- package/es/components/Message/index.js +41 -0
- package/es/index.js +2 -1
- package/es/lib/utils/bonus.js +47 -0
- package/es/lib/utils/selectUnit.js +13 -9
- package/es/lib/utils/translate.js +1 -1
- package/es/widgets/AccordionWidget/index.js +11 -3
- package/es/widgets/BonusOffers/Actions.js +167 -0
- package/es/widgets/BonusOffers/BonusCode.js +62 -0
- package/es/widgets/BonusOffers/Details.js +114 -0
- package/es/widgets/BonusOffers/Finished.js +18 -0
- package/es/widgets/BonusOffers/List.js +83 -0
- package/es/widgets/BonusOffers/Overview.js +51 -0
- package/es/widgets/BonusOffers/index.js +78 -0
- package/es/widgets/BonusWidget/index.js +19 -8
- package/lib/components/Message/index.js +57 -0
- package/lib/index.js +9 -6
- package/lib/lib/utils/bonus.js +52 -0
- package/lib/lib/utils/selectUnit.js +13 -9
- package/lib/lib/utils/translate.js +1 -1
- package/lib/widgets/AccordionWidget/index.js +14 -3
- package/lib/widgets/BonusOffers/Actions.js +182 -0
- package/lib/widgets/BonusOffers/BonusCode.js +85 -0
- package/lib/widgets/BonusOffers/Details.js +144 -0
- package/lib/widgets/BonusOffers/Finished.js +31 -0
- package/lib/widgets/BonusOffers/List.js +104 -0
- package/lib/widgets/BonusOffers/Overview.js +77 -0
- package/lib/widgets/BonusOffers/index.js +95 -0
- package/lib/widgets/BonusWidget/index.js +19 -8
- package/package.json +2 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
2
|
+
|
|
3
|
+
import React from 'react';
|
|
4
|
+
import { FormattedMessage } from 'react-intl';
|
|
5
|
+
import Icon from '../../components/Icon';
|
|
6
|
+
import Notice from '../CashierAccordion/Payment/Notice';
|
|
7
|
+
import List from './List.js';
|
|
8
|
+
import BonusCode from './BonusCode.js';
|
|
9
|
+
import Finished from './Finished';
|
|
10
|
+
|
|
11
|
+
var Overview = function Overview(_ref) {
|
|
12
|
+
var bonuses = _ref.bonuses,
|
|
13
|
+
content = _ref.content,
|
|
14
|
+
defaultImage = _ref.defaultImage,
|
|
15
|
+
selectBonus = _ref.selectBonus,
|
|
16
|
+
onPreClaim = _ref.onPreClaim,
|
|
17
|
+
alert = _ref.alert;
|
|
18
|
+
|
|
19
|
+
var availableBonuses = [].concat(_toConsumableArray(bonuses.active), _toConsumableArray(bonuses.available));
|
|
20
|
+
var finishedBonuses = bonuses.finished;
|
|
21
|
+
|
|
22
|
+
return React.createElement(
|
|
23
|
+
'div',
|
|
24
|
+
{ className: 'Overview' },
|
|
25
|
+
alert && React.createElement(Notice, {
|
|
26
|
+
level: alert.level,
|
|
27
|
+
icon: alert.level === 'success' ? React.createElement(Icon, { icon: 'check' }) : React.createElement(Icon, { icon: 'stop-circle' }),
|
|
28
|
+
header: React.createElement(FormattedMessage, { id: 'label.bonus-offers.' + alert.type })
|
|
29
|
+
}),
|
|
30
|
+
React.createElement(FormattedMessage, {
|
|
31
|
+
id: 'label.bonus-offers.overview-title',
|
|
32
|
+
defaultMessage: 'My Offers',
|
|
33
|
+
tagName: 'h2'
|
|
34
|
+
}),
|
|
35
|
+
availableBonuses.length === 0 && React.createElement(FormattedMessage, {
|
|
36
|
+
id: 'label.bonus-offers.overview-no-offers',
|
|
37
|
+
defaultMessage: 'No bonus offers available...',
|
|
38
|
+
tagName: 'p'
|
|
39
|
+
}),
|
|
40
|
+
availableBonuses.length > 0 && React.createElement(List, {
|
|
41
|
+
bonuses: availableBonuses,
|
|
42
|
+
content: content,
|
|
43
|
+
defaultImage: defaultImage,
|
|
44
|
+
selectBonus: selectBonus
|
|
45
|
+
}),
|
|
46
|
+
React.createElement(BonusCode, { onSubmit: onPreClaim }),
|
|
47
|
+
finishedBonuses.length > 0 && React.createElement(Finished, { bonuses: finishedBonuses })
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default Overview;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
2
|
+
|
|
3
|
+
import React, { useState, useEffect } from 'react';
|
|
4
|
+
import Overview from './Overview';
|
|
5
|
+
import Details from './Details';
|
|
6
|
+
import { categorizeByState, getWageringProgress, getStatus } from '../../lib/utils/bonus';
|
|
7
|
+
|
|
8
|
+
var BonusOffers = function BonusOffers(_ref) {
|
|
9
|
+
var bonuses = _ref.bonuses,
|
|
10
|
+
content = _ref.content,
|
|
11
|
+
defaultImage = _ref.defaultImage,
|
|
12
|
+
onClaim = _ref.onClaim,
|
|
13
|
+
onCancel = _ref.onCancel,
|
|
14
|
+
onReject = _ref.onReject,
|
|
15
|
+
onPreClaim = _ref.onPreClaim,
|
|
16
|
+
onTriggerByPromoCode = _ref.onTriggerByPromoCode,
|
|
17
|
+
onOther = _ref.onOther,
|
|
18
|
+
getBonus = _ref.getBonus,
|
|
19
|
+
alerts = _ref.alerts,
|
|
20
|
+
removeAlert = _ref.removeAlert,
|
|
21
|
+
scrollToTop = _ref.scrollToTop;
|
|
22
|
+
|
|
23
|
+
var _useState = useState(null),
|
|
24
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
25
|
+
selectedBonus = _useState2[0],
|
|
26
|
+
_selectBonus = _useState2[1];
|
|
27
|
+
|
|
28
|
+
var mappedBonuses = categorizeByState(bonuses);
|
|
29
|
+
var alert = alerts && alerts.length > 0 ? alerts[0] : null;
|
|
30
|
+
|
|
31
|
+
useEffect(function () {
|
|
32
|
+
scrollToTop();
|
|
33
|
+
alert && removeAlert(alert.type);
|
|
34
|
+
}, [selectedBonus]);
|
|
35
|
+
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
alert && scrollToTop();
|
|
38
|
+
}, [alert]);
|
|
39
|
+
|
|
40
|
+
return React.createElement(
|
|
41
|
+
'div',
|
|
42
|
+
{ className: 'BonusOffers' },
|
|
43
|
+
!selectedBonus && React.createElement(Overview, {
|
|
44
|
+
bonuses: mappedBonuses,
|
|
45
|
+
content: content,
|
|
46
|
+
defaultImage: defaultImage,
|
|
47
|
+
selectBonus: function selectBonus(bonus) {
|
|
48
|
+
return _selectBonus(bonus);
|
|
49
|
+
},
|
|
50
|
+
onPreClaim: onPreClaim,
|
|
51
|
+
alert: alert
|
|
52
|
+
}),
|
|
53
|
+
selectedBonus && React.createElement(Details, {
|
|
54
|
+
bonus: selectedBonus,
|
|
55
|
+
content: content.find(function (c) {
|
|
56
|
+
return c.identifier === selectedBonus.Identifier;
|
|
57
|
+
}) || {},
|
|
58
|
+
defaultImage: defaultImage,
|
|
59
|
+
wageringProgress: getWageringProgress(selectedBonus),
|
|
60
|
+
onBack: function onBack() {
|
|
61
|
+
return _selectBonus(null);
|
|
62
|
+
},
|
|
63
|
+
status: getStatus(selectedBonus),
|
|
64
|
+
onClaim: onClaim,
|
|
65
|
+
onReject: onReject,
|
|
66
|
+
onCancel: onCancel,
|
|
67
|
+
onTriggerByPromoCode: onTriggerByPromoCode,
|
|
68
|
+
onOther: onOther,
|
|
69
|
+
getBonus: getBonus,
|
|
70
|
+
selectBonus: function selectBonus(bonus) {
|
|
71
|
+
return _selectBonus(bonus);
|
|
72
|
+
},
|
|
73
|
+
alert: alert
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export default BonusOffers;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
2
2
|
|
|
3
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
4
|
+
|
|
3
5
|
import React, { useState } from 'react';
|
|
4
6
|
import { FormattedNumber, FormattedDate } from 'react-intl';
|
|
5
7
|
import AccordionWidget from '../AccordionWidget';
|
|
@@ -127,7 +129,10 @@ var BonusWidget = function BonusWidget(_ref3) {
|
|
|
127
129
|
var bonuses = _ref3.bonuses,
|
|
128
130
|
handleBonusCodeSubmit = _ref3.handleBonusCodeSubmit,
|
|
129
131
|
onClaimBonus = _ref3.onClaimBonus,
|
|
130
|
-
onRejectBonus = _ref3.onRejectBonus
|
|
132
|
+
onRejectBonus = _ref3.onRejectBonus,
|
|
133
|
+
_ref3$exclude = _ref3.exclude,
|
|
134
|
+
exclude = _ref3$exclude === undefined ? [] : _ref3$exclude,
|
|
135
|
+
disableBonusCodeForm = _ref3.disableBonusCodeForm;
|
|
131
136
|
|
|
132
137
|
var bonusList = { active: null, available: null, finished: null };
|
|
133
138
|
|
|
@@ -262,19 +267,25 @@ var BonusWidget = function BonusWidget(_ref3) {
|
|
|
262
267
|
|
|
263
268
|
var menu = {
|
|
264
269
|
identifier: 'account-history',
|
|
265
|
-
items: [{
|
|
270
|
+
items: [].concat(_toConsumableArray(!exclude.includes('active') ? [{
|
|
266
271
|
name: React.createElement(Translate, { id: 'label.active', defaultMessage: 'Activate' }),
|
|
267
272
|
content: React.createElement(List, { data: bonusList['active'], noData: 'list.no_data.active' })
|
|
268
|
-
}, {
|
|
273
|
+
}] : []), _toConsumableArray(!exclude.includes('available') ? [{
|
|
269
274
|
name: React.createElement(Translate, { id: 'label.available', defaultMessage: 'Available' }),
|
|
270
|
-
content: React.createElement(List, {
|
|
271
|
-
|
|
275
|
+
content: React.createElement(List, {
|
|
276
|
+
data: bonusList['available'],
|
|
277
|
+
noData: 'list.no_data.available'
|
|
278
|
+
})
|
|
279
|
+
}] : []), _toConsumableArray(!exclude.includes('finished') ? [{
|
|
272
280
|
name: React.createElement(Translate, { id: 'label.finished', defaultMessage: 'Finished' }),
|
|
273
|
-
content: React.createElement(List, {
|
|
274
|
-
|
|
281
|
+
content: React.createElement(List, {
|
|
282
|
+
data: bonusList['finished'],
|
|
283
|
+
noData: 'list.no_data.finished'
|
|
284
|
+
})
|
|
285
|
+
}] : []), _toConsumableArray(disableBonusCodeForm && {
|
|
275
286
|
name: React.createElement(Translate, { id: 'label.bonus_code', defaultMessage: 'Bonus code' }),
|
|
276
287
|
content: React.createElement(BonusCode, { handleSubmit: handleBonusCodeSubmit })
|
|
277
|
-
}
|
|
288
|
+
}))
|
|
278
289
|
};
|
|
279
290
|
|
|
280
291
|
var items = menu.items.map(function (item, i) {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _react = require('react');
|
|
8
|
+
|
|
9
|
+
var _react2 = _interopRequireDefault(_react);
|
|
10
|
+
|
|
11
|
+
var _Icon = require('../Icon');
|
|
12
|
+
|
|
13
|
+
var _Icon2 = _interopRequireDefault(_Icon);
|
|
14
|
+
|
|
15
|
+
var _classnames = require('classnames');
|
|
16
|
+
|
|
17
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
18
|
+
|
|
19
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
+
|
|
21
|
+
var Message = function Message(_ref) {
|
|
22
|
+
var closeButton = _ref.closeButton,
|
|
23
|
+
count = _ref.count,
|
|
24
|
+
onClick = _ref.onClick,
|
|
25
|
+
onClose = _ref.onClose,
|
|
26
|
+
content = _ref.content,
|
|
27
|
+
className = _ref.className,
|
|
28
|
+
icon = _ref.icon;
|
|
29
|
+
|
|
30
|
+
return _react2.default.createElement(
|
|
31
|
+
'div',
|
|
32
|
+
{ className: (0, _classnames2.default)('Message', className), onClick: onClick },
|
|
33
|
+
closeButton && _react2.default.createElement(
|
|
34
|
+
'span',
|
|
35
|
+
{ className: 'close', onClick: onClose },
|
|
36
|
+
_react2.default.createElement(_Icon2.default, { icon: 'times' })
|
|
37
|
+
),
|
|
38
|
+
icon && _react2.default.createElement(
|
|
39
|
+
'div',
|
|
40
|
+
{ className: 'icon' },
|
|
41
|
+
_react2.default.createElement(_Icon2.default, { icon: '' + icon })
|
|
42
|
+
),
|
|
43
|
+
_react2.default.createElement(
|
|
44
|
+
'div',
|
|
45
|
+
{ className: 'content' },
|
|
46
|
+
content
|
|
47
|
+
),
|
|
48
|
+
count && _react2.default.createElement(
|
|
49
|
+
'div',
|
|
50
|
+
{ className: 'count' },
|
|
51
|
+
count
|
|
52
|
+
),
|
|
53
|
+
_react2.default.createElement(_Icon2.default, { icon: 'chevron-right' })
|
|
54
|
+
);
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.default = Message;
|
package/lib/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.AutocompleteInput = exports.Skeleton = exports.countryEmojiFlags = exports.Picture = exports.Translate = exports.VerifyAccordionWidget = exports.List = exports.ResponsibleGamingWidget = exports.ResponsibleGamingSingleSignUp = exports.ResponsibleGamingAccordionSignUp = exports.ResponsibleGamingAccordion = exports.WithdrawWidgetAccordion = exports.DepositWidgetAccordion = exports.SportsbookHistoryTable = exports.PaymentHistoryTable = exports.CasinoHistoryTable = exports.Subscriptions = exports.Verify = exports.TableWidget = exports.Settings = exports.Pagination = exports.SignIn = exports.RequestResetPassword = exports.ResetPassword = exports.ChangePassword = exports.ChangeUsername = exports.SignUp = exports.Withdraw = exports.Deposit = exports.Bonus = exports.Balance = exports.ActivateWidget = exports.AccountDetail = exports.AccordionWidget = exports.Uploader = exports.Textarea = exports.Single = exports.Select = exports.Radio = exports.Notification = exports.Money = exports.Loader = exports.InternalMessagesInbox = exports.Input = exports.Image = exports.Icon = exports.Checklist = exports.ButtonLoader = exports.Button = exports.Alert = exports.AcceptUpdatedTaC = undefined;
|
|
6
|
+
exports.AutocompleteInput = exports.Skeleton = exports.countryEmojiFlags = exports.Picture = exports.Translate = exports.VerifyAccordionWidget = exports.List = exports.ResponsibleGamingWidget = exports.ResponsibleGamingSingleSignUp = exports.ResponsibleGamingAccordionSignUp = exports.ResponsibleGamingAccordion = exports.WithdrawWidgetAccordion = exports.DepositWidgetAccordion = exports.SportsbookHistoryTable = exports.PaymentHistoryTable = exports.CasinoHistoryTable = exports.Subscriptions = exports.Verify = exports.TableWidget = exports.Settings = exports.Pagination = exports.SignIn = exports.RequestResetPassword = exports.ResetPassword = exports.ChangePassword = exports.ChangeUsername = exports.SignUp = exports.Withdraw = exports.Deposit = exports.Bonus = exports.Balance = exports.ActivateWidget = exports.AccountDetail = exports.AccordionWidget = exports.Uploader = exports.Textarea = exports.Single = exports.Select = exports.Radio = exports.Notification = exports.Money = exports.Loader = exports.InternalMessagesInbox = exports.Input = exports.Image = exports.Icon = exports.Checklist = exports.ButtonLoader = exports.Button = exports.Alert = exports.AcceptUpdatedTaC = exports.BonusOffers = undefined;
|
|
7
7
|
|
|
8
8
|
var _AcceptUpdatedTaC = require('./components/AcceptUpdatedTaC');
|
|
9
9
|
|
|
@@ -205,12 +205,19 @@ var _VerifyAccordionWidget = require('./widgets/VerifyAccordionWidget');
|
|
|
205
205
|
|
|
206
206
|
var _VerifyAccordionWidget2 = _interopRequireDefault(_VerifyAccordionWidget);
|
|
207
207
|
|
|
208
|
+
var _BonusOffers = require('./widgets/BonusOffers');
|
|
209
|
+
|
|
210
|
+
var _BonusOffers2 = _interopRequireDefault(_BonusOffers);
|
|
211
|
+
|
|
208
212
|
var _countryEmojiFlags = require('./misc/countryEmojiFlags');
|
|
209
213
|
|
|
210
214
|
var _countryEmojiFlags2 = _interopRequireDefault(_countryEmojiFlags);
|
|
211
215
|
|
|
212
216
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
213
217
|
|
|
218
|
+
// widgets
|
|
219
|
+
// components
|
|
220
|
+
exports.BonusOffers = _BonusOffers2.default;
|
|
214
221
|
exports.AcceptUpdatedTaC = _AcceptUpdatedTaC2.default;
|
|
215
222
|
exports.Alert = _Alert2.default;
|
|
216
223
|
exports.Button = _Button2.default;
|
|
@@ -263,8 +270,4 @@ exports.countryEmojiFlags = _countryEmojiFlags2.default;
|
|
|
263
270
|
exports.Skeleton = _Skeleton2.default;
|
|
264
271
|
exports.AutocompleteInput = _AutocompleteInput2.default;
|
|
265
272
|
|
|
266
|
-
// misc
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
// widgets
|
|
270
|
-
// components
|
|
273
|
+
// misc
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
var bonusMapping = exports.bonusMapping = {
|
|
7
|
+
InPlay: 'active',
|
|
8
|
+
Active: 'active',
|
|
9
|
+
Initiated: 'available',
|
|
10
|
+
PreClaimed: 'available',
|
|
11
|
+
PreWager: 'available',
|
|
12
|
+
Expired: 'finished',
|
|
13
|
+
Rejected: 'finished',
|
|
14
|
+
Finished: 'finished',
|
|
15
|
+
Canceled: 'finished',
|
|
16
|
+
FinishedNoGains: 'finished',
|
|
17
|
+
AdminCanceled: 'finished'
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
var categorizeByState = exports.categorizeByState = function categorizeByState(bonuses) {
|
|
21
|
+
return {
|
|
22
|
+
available: bonuses.filter(function (b) {
|
|
23
|
+
return bonusMapping[b.State] === 'available';
|
|
24
|
+
}),
|
|
25
|
+
active: bonuses.filter(function (b) {
|
|
26
|
+
return bonusMapping[b.State] === 'active';
|
|
27
|
+
}),
|
|
28
|
+
finished: bonuses.filter(function (b) {
|
|
29
|
+
return bonusMapping[b.State] === 'finished';
|
|
30
|
+
})
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
var getStatus = exports.getStatus = function getStatus(bonus) {
|
|
35
|
+
return bonusMapping[bonus.State];
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
var getWageringProgress = exports.getWageringProgress = function getWageringProgress(bonus) {
|
|
39
|
+
var wageringRequirement = bonusMapping[bonus.State] === 'available' ? bonus.PreWageringRequirment : bonus.WageringRequirment;
|
|
40
|
+
|
|
41
|
+
var wageringRequirementRemaining = bonusMapping[bonus.State] === 'available' ? bonus.PreWageringRequirmentRemaining : bonus.WageringRequirmentRemaining;
|
|
42
|
+
|
|
43
|
+
return Boolean(wageringRequirement) ? (100 - wageringRequirementRemaining / wageringRequirement * 100).toFixed(2) : null;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var getNumberOfAvailableBonuses = exports.getNumberOfAvailableBonuses = function getNumberOfAvailableBonuses(bonuses) {
|
|
47
|
+
if (!Array.isArray(bonuses) || bonuses.length < 1) return 0;
|
|
48
|
+
|
|
49
|
+
return bonuses.filter(function (b) {
|
|
50
|
+
return bonusMapping[b.State] === 'available';
|
|
51
|
+
}).length;
|
|
52
|
+
};
|
|
@@ -13,51 +13,55 @@ var MILISECONDS = {
|
|
|
13
13
|
IN_A_YEAR: 31536000000
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
var selectUnit = exports.selectUnit = function selectUnit(
|
|
16
|
+
var selectUnit = exports.selectUnit = function selectUnit(value) {
|
|
17
|
+
var isFuture = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
18
|
+
|
|
17
19
|
var now = Date.now();
|
|
18
|
-
var ms = now -
|
|
20
|
+
var ms = isFuture ? value - now : now - value;
|
|
21
|
+
|
|
22
|
+
var operatorCalc = isFuture ? 1 : -1;
|
|
19
23
|
|
|
20
24
|
switch (true) {
|
|
21
25
|
case MILISECONDS.IN_A_SECOND < ms && ms < MILISECONDS.IN_A_MINUTE:
|
|
22
26
|
return {
|
|
23
|
-
value:
|
|
27
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_A_SECOND),
|
|
24
28
|
unit: 'second',
|
|
25
29
|
updateIntervalInSeconds: 1
|
|
26
30
|
};
|
|
27
31
|
|
|
28
32
|
case MILISECONDS.IN_A_MINUTE < ms && ms < MILISECONDS.IN_AN_HOUR:
|
|
29
33
|
return {
|
|
30
|
-
value:
|
|
34
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_A_MINUTE),
|
|
31
35
|
unit: 'minute'
|
|
32
36
|
};
|
|
33
37
|
|
|
34
38
|
case MILISECONDS.IN_AN_HOUR < ms && ms < MILISECONDS.IN_A_DAY:
|
|
35
39
|
return {
|
|
36
|
-
value:
|
|
40
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_AN_HOUR),
|
|
37
41
|
unit: 'hour'
|
|
38
42
|
};
|
|
39
43
|
|
|
40
44
|
case MILISECONDS.IN_A_DAY < ms && ms < MILISECONDS.IN_A_WEEK:
|
|
41
45
|
return {
|
|
42
|
-
value:
|
|
46
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_A_DAY),
|
|
43
47
|
unit: 'day'
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
case MILISECONDS.IN_A_WEEK < ms && ms < MILISECONDS.IN_A_MONTH:
|
|
47
51
|
return {
|
|
48
|
-
value:
|
|
52
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_A_WEEK),
|
|
49
53
|
unit: 'week'
|
|
50
54
|
};
|
|
51
55
|
|
|
52
56
|
case MILISECONDS.IN_A_MONTH < ms && ms < MILISECONDS.IN_A_YEAR:
|
|
53
57
|
return {
|
|
54
|
-
value:
|
|
58
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_A_MONTH),
|
|
55
59
|
unit: 'month'
|
|
56
60
|
};
|
|
57
61
|
|
|
58
62
|
case MILISECONDS.IN_A_YEAR < ms:
|
|
59
63
|
return {
|
|
60
|
-
value:
|
|
64
|
+
value: operatorCalc * Math.floor(ms / MILISECONDS.IN_A_YEAR),
|
|
61
65
|
unit: 'year'
|
|
62
66
|
};
|
|
63
67
|
|
|
@@ -15,7 +15,7 @@ var translate = function translate(_ref, intl) {
|
|
|
15
15
|
values = _ref.values,
|
|
16
16
|
rest = _objectWithoutProperties(_ref, ['id', 'values']);
|
|
17
17
|
|
|
18
|
-
var cacheId =
|
|
18
|
+
var cacheId = id + (JSON.stringify(values) || '');
|
|
19
19
|
if (cache[cacheId]) return cache[cacheId];
|
|
20
20
|
|
|
21
21
|
var g = typeof window !== 'undefined' && window || typeof global !== 'undefined' && global || {};
|
|
@@ -28,6 +28,10 @@ var _Icon = require('../../components/Icon');
|
|
|
28
28
|
|
|
29
29
|
var _Icon2 = _interopRequireDefault(_Icon);
|
|
30
30
|
|
|
31
|
+
var _classnames = require('classnames');
|
|
32
|
+
|
|
33
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
34
|
+
|
|
31
35
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
32
36
|
|
|
33
37
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
@@ -36,6 +40,8 @@ function _possibleConstructorReturn(self, call) { if (!self) { throw new Referen
|
|
|
36
40
|
|
|
37
41
|
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
|
38
42
|
|
|
43
|
+
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
44
|
+
|
|
39
45
|
var AccordionHeader = function AccordionHeader(_ref) {
|
|
40
46
|
var expanded = _ref.expanded,
|
|
41
47
|
header = _ref.header,
|
|
@@ -102,10 +108,14 @@ var AccordionContent = function AccordionContent(_ref2) {
|
|
|
102
108
|
var AccordionItem = function AccordionItem(_ref3) {
|
|
103
109
|
var header = _ref3.header,
|
|
104
110
|
content = _ref3.content,
|
|
105
|
-
expanded = _ref3.expanded
|
|
111
|
+
expanded = _ref3.expanded,
|
|
112
|
+
customClass = _ref3.customClass;
|
|
106
113
|
return _react2.default.createElement(
|
|
107
114
|
'div',
|
|
108
|
-
{
|
|
115
|
+
{
|
|
116
|
+
className: (0, _classnames2.default)('AccordionItem', _defineProperty({
|
|
117
|
+
'AccordionItem--expanded': expanded
|
|
118
|
+
}, 'AccordionItem--' + customClass, customClass)) },
|
|
109
119
|
header,
|
|
110
120
|
content
|
|
111
121
|
);
|
|
@@ -194,7 +204,8 @@ var Accordion = function (_Component) {
|
|
|
194
204
|
animationDuration: animationDuration,
|
|
195
205
|
contentCollapsedHeight: contentCollapsedHeight
|
|
196
206
|
}),
|
|
197
|
-
key: index
|
|
207
|
+
key: index,
|
|
208
|
+
customClass: item.customClass
|
|
198
209
|
};
|
|
199
210
|
});
|
|
200
211
|
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
8
|
+
|
|
9
|
+
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();
|
|
10
|
+
|
|
11
|
+
var _react = require('react');
|
|
12
|
+
|
|
13
|
+
var _react2 = _interopRequireDefault(_react);
|
|
14
|
+
|
|
15
|
+
var _Button = require('../../components/Button');
|
|
16
|
+
|
|
17
|
+
var _Button2 = _interopRequireDefault(_Button);
|
|
18
|
+
|
|
19
|
+
var _reactIntl = require('react-intl');
|
|
20
|
+
|
|
21
|
+
var _classnames = require('classnames');
|
|
22
|
+
|
|
23
|
+
var _classnames2 = _interopRequireDefault(_classnames);
|
|
24
|
+
|
|
25
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
26
|
+
|
|
27
|
+
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
|
28
|
+
|
|
29
|
+
function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }
|
|
30
|
+
|
|
31
|
+
var Actions = function Actions(_ref) {
|
|
32
|
+
var bonus = _ref.bonus,
|
|
33
|
+
onClaim = _ref.onClaim,
|
|
34
|
+
onCancel = _ref.onCancel,
|
|
35
|
+
onReject = _ref.onReject,
|
|
36
|
+
onTriggerByPromoCode = _ref.onTriggerByPromoCode,
|
|
37
|
+
status = _ref.status,
|
|
38
|
+
promotionCode = _ref.promotionCode,
|
|
39
|
+
onOther = _ref.onOther,
|
|
40
|
+
onSuccess = _ref.onSuccess;
|
|
41
|
+
|
|
42
|
+
var _useState = (0, _react.useState)([{
|
|
43
|
+
conditions: status === 'active' || bonus.State === 'PreWager',
|
|
44
|
+
onClick: onOther,
|
|
45
|
+
isLoading: false,
|
|
46
|
+
disabled: false,
|
|
47
|
+
type: 'primary',
|
|
48
|
+
translation: 'action.other-bonus',
|
|
49
|
+
name: 'other',
|
|
50
|
+
args: [bonus, promotionCode]
|
|
51
|
+
}, {
|
|
52
|
+
conditions: bonus.State === 'Initiated',
|
|
53
|
+
onClick: onClaim,
|
|
54
|
+
isLoading: false,
|
|
55
|
+
disabled: false,
|
|
56
|
+
type: 'primary',
|
|
57
|
+
translation: 'action.claim',
|
|
58
|
+
name: 'claim',
|
|
59
|
+
args: [bonus]
|
|
60
|
+
}, {
|
|
61
|
+
conditions: status === 'available' && bonus.State !== 'Initiated' && bonus.State !== 'PreWager' && promotionCode,
|
|
62
|
+
onClick: onTriggerByPromoCode,
|
|
63
|
+
isLoading: false,
|
|
64
|
+
isDisabled: false,
|
|
65
|
+
type: 'primary',
|
|
66
|
+
translation: 'action.claim',
|
|
67
|
+
name: 'trigger',
|
|
68
|
+
args: [promotionCode]
|
|
69
|
+
}, {
|
|
70
|
+
conditions: bonus.State === 'Initiated',
|
|
71
|
+
onClick: onReject,
|
|
72
|
+
isLoading: false,
|
|
73
|
+
disabled: false,
|
|
74
|
+
type: 'tertiary',
|
|
75
|
+
translation: 'action.reject',
|
|
76
|
+
name: 'reject',
|
|
77
|
+
args: [bonus]
|
|
78
|
+
}, {
|
|
79
|
+
conditions: status === 'active',
|
|
80
|
+
onClick: onCancel,
|
|
81
|
+
isLoading: false,
|
|
82
|
+
disabled: false,
|
|
83
|
+
type: 'tertiary',
|
|
84
|
+
translation: 'action.cancel',
|
|
85
|
+
name: 'cancel',
|
|
86
|
+
args: [bonus.Id]
|
|
87
|
+
}]),
|
|
88
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
89
|
+
buttons = _useState2[0],
|
|
90
|
+
setButtons = _useState2[1];
|
|
91
|
+
|
|
92
|
+
var actionWrapper = function () {
|
|
93
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(action, name) {
|
|
94
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
95
|
+
args[_key - 2] = arguments[_key];
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var res;
|
|
99
|
+
return regeneratorRuntime.wrap(function _callee$(_context) {
|
|
100
|
+
while (1) {
|
|
101
|
+
switch (_context.prev = _context.next) {
|
|
102
|
+
case 0:
|
|
103
|
+
setButtons([].concat(_toConsumableArray(buttons.map(function (b) {
|
|
104
|
+
if (b.name === name) {
|
|
105
|
+
return _extends({}, b, {
|
|
106
|
+
isLoading: true,
|
|
107
|
+
disabled: true
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return b;
|
|
112
|
+
}))));
|
|
113
|
+
|
|
114
|
+
_context.next = 3;
|
|
115
|
+
return action.apply(undefined, _toConsumableArray(args));
|
|
116
|
+
|
|
117
|
+
case 3:
|
|
118
|
+
res = _context.sent;
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
if (res && res.payload && res.payload.isNetworkException || res && res.payload && res.payload === 0) {
|
|
122
|
+
setButtons([].concat(_toConsumableArray(buttons.map(function (b) {
|
|
123
|
+
if (b.name === name) {
|
|
124
|
+
return _extends({}, b, {
|
|
125
|
+
isLoading: false,
|
|
126
|
+
disabled: false
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return b;
|
|
131
|
+
}))));
|
|
132
|
+
} else {
|
|
133
|
+
onSuccess();
|
|
134
|
+
|
|
135
|
+
setButtons([].concat(_toConsumableArray(buttons.map(function (b) {
|
|
136
|
+
if (b.name === name) {
|
|
137
|
+
return _extends({}, b, {
|
|
138
|
+
isLoading: false,
|
|
139
|
+
disabled: true
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
return b;
|
|
144
|
+
}))));
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
case 5:
|
|
148
|
+
case 'end':
|
|
149
|
+
return _context.stop();
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}, _callee, undefined);
|
|
153
|
+
}));
|
|
154
|
+
|
|
155
|
+
return function actionWrapper(_x, _x2) {
|
|
156
|
+
return _ref2.apply(this, arguments);
|
|
157
|
+
};
|
|
158
|
+
}();
|
|
159
|
+
|
|
160
|
+
return _react2.default.createElement(
|
|
161
|
+
'div',
|
|
162
|
+
{ className: 'Actions' },
|
|
163
|
+
buttons && buttons.filter(function (b) {
|
|
164
|
+
return b.conditions;
|
|
165
|
+
}).map(function (b) {
|
|
166
|
+
return _react2.default.createElement(
|
|
167
|
+
_Button2.default,
|
|
168
|
+
{
|
|
169
|
+
key: b.name,
|
|
170
|
+
isLoading: b.isLoading,
|
|
171
|
+
disabled: b.disabled,
|
|
172
|
+
className: (0, _classnames2.default)('button small', b.type),
|
|
173
|
+
onClick: function onClick() {
|
|
174
|
+
return actionWrapper.apply(undefined, [b.onClick, b.name].concat(_toConsumableArray(b.args)));
|
|
175
|
+
} },
|
|
176
|
+
_react2.default.createElement(_reactIntl.FormattedMessage, { id: b.translation })
|
|
177
|
+
);
|
|
178
|
+
})
|
|
179
|
+
);
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
exports.default = Actions;
|