@everymatrix/casino-wagering-bonuses-controller 1.15.0 → 1.15.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.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@everymatrix/casino-wagering-bonuses-controller",
|
|
3
|
-
"version": "1.15.
|
|
3
|
+
"version": "1.15.2",
|
|
4
4
|
"main": "dist/casino-wagering-bonuses-controller.js",
|
|
5
5
|
"svelte": "src/index.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -35,5 +35,5 @@
|
|
|
35
35
|
"publishConfig": {
|
|
36
36
|
"access": "public"
|
|
37
37
|
},
|
|
38
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "c590519dbcc5d9ba61081face50b61df6f79981d"
|
|
39
39
|
}
|
|
@@ -2,25 +2,30 @@
|
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
|
|
4
4
|
import '@everymatrix/casino-wagering-bonus'
|
|
5
|
+
import '@everymatrix/general-animation-loading'
|
|
5
6
|
|
|
6
|
-
import { fetchApi, setWageringEventSource } from '@everymatrix/casino-wagering-bonus/src/business'
|
|
7
|
+
import { fetchApi, getRequestStatusByStatusFilter, setWageringEventSource } from '@everymatrix/casino-wagering-bonus/src/business'
|
|
7
8
|
import {
|
|
8
9
|
clearEventSource,
|
|
9
10
|
composeEventSourceMessageHandler,
|
|
10
|
-
onSvelteMountMessage
|
|
11
|
+
onSvelteMountMessage,
|
|
12
|
+
_postMessage
|
|
11
13
|
} from '@everymatrix/casino-wagering-bonus/src/message'
|
|
12
14
|
import type { TEventSource } from '@everymatrix/casino-wagering-bonus/src/message'
|
|
13
|
-
import { Bonus, BonusStatus, Lang } from '@everymatrix/casino-wagering-bonus/src/types'
|
|
15
|
+
import { Bonus, BonusStatus, BonusStatusFilterType, Lang } from '@everymatrix/casino-wagering-bonus/src/types'
|
|
14
16
|
import { setTranslations } from '@everymatrix/casino-wagering-bonus/src/svelte.i18n';
|
|
15
17
|
import { translations } from '@everymatrix/casino-wagering-bonus/src/translations';
|
|
16
18
|
import { onMount } from 'svelte';
|
|
17
19
|
import { classWithPart } from '@everymatrix/casino-wagering-bonus/src/util';
|
|
20
|
+
import { infoParts } from '@everymatrix/casino-wagering-bonus/src/private.exportparts';
|
|
21
|
+
|
|
22
|
+
import { _, setLocale } from '@everymatrix/casino-wagering-bonus/src/svelte.i18n';
|
|
18
23
|
|
|
19
24
|
export let endpoint = ''
|
|
20
25
|
export let lang = Lang.en
|
|
21
26
|
export let session = ''
|
|
22
27
|
export let currency: string = 'EUR';
|
|
23
|
-
export let
|
|
28
|
+
export let filter: BonusStatusFilterType = BonusStatusFilterType.claimable
|
|
24
29
|
export let limit: string = ''
|
|
25
30
|
|
|
26
31
|
let isMounted = false
|
|
@@ -32,10 +37,11 @@
|
|
|
32
37
|
}
|
|
33
38
|
})
|
|
34
39
|
|
|
35
|
-
let bonuses:
|
|
40
|
+
let bonuses: any[] = []
|
|
36
41
|
let eventSource: TEventSource
|
|
37
42
|
let isLoading: boolean = true;
|
|
38
43
|
let errorMessage: string = ''
|
|
44
|
+
let abortController: AbortController
|
|
39
45
|
|
|
40
46
|
setTranslations(translations)
|
|
41
47
|
|
|
@@ -47,7 +53,7 @@
|
|
|
47
53
|
if(!item) return bonus
|
|
48
54
|
|
|
49
55
|
let { status: _status, level, levelIncrement, gap } = item
|
|
50
|
-
let _bonus:
|
|
56
|
+
let _bonus: any = {...bonus}
|
|
51
57
|
|
|
52
58
|
_bonus = { ..._bonus, wageringProgress: {
|
|
53
59
|
..._bonus.wageringProgress,
|
|
@@ -59,17 +65,24 @@
|
|
|
59
65
|
if(_status){
|
|
60
66
|
_bonus = { ..._bonus, status: _status}
|
|
61
67
|
setTimeout(() => init(), 500)
|
|
68
|
+
|
|
69
|
+
if(_status !== filter){
|
|
70
|
+
return null
|
|
71
|
+
}
|
|
62
72
|
}
|
|
63
73
|
|
|
64
74
|
return _bonus
|
|
65
|
-
})
|
|
75
|
+
}).filter(b => b)
|
|
66
76
|
},
|
|
67
77
|
})
|
|
68
78
|
|
|
69
79
|
const initCore = async () => {
|
|
70
|
-
|
|
80
|
+
abortController?.abort()
|
|
81
|
+
abortController = new AbortController();
|
|
82
|
+
|
|
83
|
+
const response: any = await fetchApi.list(abortController, endpoint, session, {
|
|
71
84
|
lang,
|
|
72
|
-
status,
|
|
85
|
+
status: filter === 'claimable' ? 'claimable' : getRequestStatusByStatusFilter(filter),
|
|
73
86
|
limit,
|
|
74
87
|
})
|
|
75
88
|
|
|
@@ -77,21 +90,16 @@
|
|
|
77
90
|
errorMessage = response.errorMessage
|
|
78
91
|
}else{
|
|
79
92
|
bonuses = (response.items || response.bonuses)
|
|
80
|
-
// if(status !== BonusStatus.claimable){
|
|
81
|
-
// bonuses = _bonuses.filter(bonus => bonus.status === status)
|
|
82
|
-
// }else{
|
|
83
|
-
// bonuses = _bonuses
|
|
84
|
-
// }
|
|
85
93
|
|
|
86
94
|
clearEventSource(eventSource, eventSourceHandler)
|
|
87
|
-
if(
|
|
95
|
+
if(filter === BonusStatusFilterType.active){
|
|
88
96
|
eventSource = setWageringEventSource(endpoint, session, bonuses, eventSourceHandler)
|
|
89
97
|
}
|
|
90
98
|
}
|
|
91
99
|
}
|
|
92
100
|
|
|
93
101
|
const init = async () => {
|
|
94
|
-
if(!isMounted || !
|
|
102
|
+
if(!isMounted || !filter || !lang || !session || !endpoint) return;
|
|
95
103
|
|
|
96
104
|
isLoading = true
|
|
97
105
|
await initCore()
|
|
@@ -108,49 +116,64 @@
|
|
|
108
116
|
$: lang && init()
|
|
109
117
|
$: session && init()
|
|
110
118
|
|
|
119
|
+
let innerWidth
|
|
120
|
+
$: isMobileView = innerWidth <= 648
|
|
121
|
+
|
|
122
|
+
$: classWithPartMatchMobile = (partAndClass) =>
|
|
123
|
+
classWithPart(`${partAndClass}${isMobileView ? ` ${partAndClass}Mobile` : ''}`)
|
|
124
|
+
|
|
125
|
+
$: locale = (key, values = {}) => $_('wageringBonuses.' + key, {values})
|
|
111
126
|
</script>
|
|
112
127
|
|
|
113
|
-
<div {...
|
|
114
|
-
<
|
|
115
|
-
{#each Object.
|
|
116
|
-
<
|
|
117
|
-
|
|
128
|
+
<div bind:clientWidth={innerWidth} {...classWithPartMatchMobile(`Root`)}>
|
|
129
|
+
<section {...classWithPartMatchMobile(`WageringTabs`)}>
|
|
130
|
+
{#each Object.values(BonusStatusFilterType) as statusFilter}
|
|
131
|
+
<div
|
|
132
|
+
{...classWithPartMatchMobile(`WageringTab`)}
|
|
133
|
+
class:active={filter === statusFilter}
|
|
118
134
|
on:click={() => {
|
|
119
|
-
if(
|
|
120
|
-
|
|
135
|
+
if(filter === statusFilter) return;
|
|
136
|
+
filter = statusFilter
|
|
121
137
|
init()
|
|
122
138
|
}}
|
|
123
139
|
>
|
|
124
|
-
{
|
|
125
|
-
</
|
|
140
|
+
{locale(statusFilter)}
|
|
141
|
+
</div>
|
|
126
142
|
{/each}
|
|
127
|
-
</
|
|
128
|
-
</div>
|
|
143
|
+
</section>
|
|
129
144
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
{#if bonuses.length > 0}
|
|
134
|
-
{#each bonuses as item}
|
|
135
|
-
<casino-wagering-bonus {...{
|
|
136
|
-
endpoint,
|
|
137
|
-
session,
|
|
138
|
-
lang,
|
|
139
|
-
currency,
|
|
140
|
-
rawbonus: JSON.stringify(item),
|
|
141
|
-
status,
|
|
142
|
-
}}
|
|
143
|
-
/>
|
|
144
|
-
{/each}
|
|
145
|
-
{:else}
|
|
146
|
-
{#if errorMessage}
|
|
147
|
-
<div style="color: red;">Error: {errorMessage}</div>
|
|
145
|
+
<div>
|
|
146
|
+
{#if isLoading}
|
|
147
|
+
<general-animation-loading />
|
|
148
148
|
{:else}
|
|
149
|
-
|
|
149
|
+
<div {...classWithPartMatchMobile(`Bonuses`)}>
|
|
150
|
+
{#if bonuses.length > 0}
|
|
151
|
+
{#each bonuses as item}
|
|
152
|
+
<casino-wagering-bonus {...{
|
|
153
|
+
endpoint,
|
|
154
|
+
session,
|
|
155
|
+
lang,
|
|
156
|
+
currency,
|
|
157
|
+
rawbonus: JSON.stringify(item),
|
|
158
|
+
exportparts: infoParts([
|
|
159
|
+
{ key: 'ExpiryTime'},
|
|
160
|
+
{ key: 'Status'},
|
|
161
|
+
{ key: 'Levels'},
|
|
162
|
+
])
|
|
163
|
+
}} />
|
|
164
|
+
{/each}
|
|
165
|
+
{:else}
|
|
166
|
+
{#if errorMessage}
|
|
167
|
+
<div class="Error">Error: {errorMessage}</div>
|
|
168
|
+
{:else}
|
|
169
|
+
{locale('noBonuses')}
|
|
170
|
+
{/if}
|
|
171
|
+
{/if}
|
|
172
|
+
</div>
|
|
150
173
|
{/if}
|
|
151
|
-
|
|
152
|
-
{/if}
|
|
174
|
+
</div>
|
|
153
175
|
|
|
176
|
+
</div>
|
|
154
177
|
|
|
155
178
|
<style lang="scss">
|
|
156
179
|
|
|
@@ -170,21 +193,55 @@
|
|
|
170
193
|
margin-bottom: 30px;
|
|
171
194
|
}
|
|
172
195
|
|
|
196
|
+
.Bonuses {
|
|
197
|
+
display: flex;
|
|
198
|
+
flex-wrap: wrap;
|
|
199
|
+
justify-content: left;
|
|
200
|
+
margin-top: 10px;
|
|
201
|
+
column-gap: 10px;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
.BonusesMobile {
|
|
205
|
+
// justify-content:initial;
|
|
206
|
+
& > casino-wagering-bonus {
|
|
207
|
+
width: 100%;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
173
211
|
.WageringTabs {
|
|
174
212
|
margin: 20px 0;
|
|
213
|
+
font-size: 16px;
|
|
214
|
+
}
|
|
175
215
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
border: 1px #ccc solid;
|
|
181
|
-
cursor: pointer;
|
|
216
|
+
.WageringTab {
|
|
217
|
+
display: inline;
|
|
218
|
+
padding: 8px;
|
|
219
|
+
cursor: pointer;
|
|
182
220
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
221
|
+
color: #000000;
|
|
222
|
+
border-bottom: 1px solid #00AEEF;
|
|
223
|
+
|
|
224
|
+
&.active {
|
|
225
|
+
color: #00AEEF;
|
|
226
|
+
border-bottom-width: 3px;
|
|
227
|
+
padding-bottom: 6px;
|
|
228
|
+
|
|
229
|
+
font-weight: 700;
|
|
187
230
|
}
|
|
231
|
+
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
.WageringTabsMobile {
|
|
235
|
+
display: flex;
|
|
236
|
+
justify-content: space-around;
|
|
237
|
+
}
|
|
238
|
+
.WageringTabMobile {
|
|
239
|
+
width: 100%;
|
|
240
|
+
text-align: center;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
.Error {
|
|
244
|
+
color: red;
|
|
188
245
|
}
|
|
189
246
|
|
|
190
247
|
</style>
|