@everymatrix/casino-wagering-bonuses-controller 0.0.400 → 0.0.402

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": "0.0.400",
3
+ "version": "0.0.402",
4
4
  "main": "index.js",
5
5
  "svelte": "src/index.ts",
6
6
  "scripts": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "2b9ea7d441ad474249a446a0bc5da5c02293b70b"
39
+ "gitHead": "c34a1b1831353cf2d35cc737b5b85cbfd12f9e62"
40
40
  }
@@ -4,32 +4,61 @@
4
4
  export let endpoint = ''
5
5
  export let lang = ''
6
6
  export let session = ''
7
+ export let sorttype = ''
7
8
 
8
9
  import '@everymatrix/casino-wagering-bonus'
9
- import { fetchApi } from '@everymatrix/casino-wagering-bonus/src/business'
10
- import { clearEventSource, composeEventSourceMessageHandler, updateEventSourceLifeCycle } from '@everymatrix/casino-wagering-bonus/src/message'
10
+ import { fetchApi, isSetUpdate } from '@everymatrix/casino-wagering-bonus/src/business'
11
+ import { clearEventSource, composeEventSourceMessageHandler, updateEventSourceLifeCycle, onMountMessageLifeCycle } from '@everymatrix/casino-wagering-bonus/src/message'
11
12
  import { cvtParamsToString } from '@everymatrix/casino-wagering-bonus/src/util'
12
13
  import type { CasinoCommonClientBonusApiDataContractsNodesWageringBonusNode as Bonus } from '@everymatrix/casino-wagering-bonus/src/api'
13
14
  import { onMount } from 'svelte';
14
-
15
+
16
+ enum BonusStatus {
17
+ BeforeClaimed = 'BeforeClaimed',
18
+ active = 'active',
19
+ completed = 'completed',
20
+ forfeited = 'forfeited',
21
+ expired = 'expired',
22
+ released = 'released',
23
+ closed = 'closed',
24
+ }
25
+
15
26
  let bonuses: Bonus[] = []
16
27
  let eventSource
28
+ let isLoading = true;
29
+ let errorMessage = ''
17
30
 
18
- const fetcher = async () => {
19
- if(!endpoint || !lang) return;
31
+ const init = async () => {
32
+ if(!endpoint || !lang || !session) return;
33
+ isLoading = true
20
34
 
21
- const result: any = await fetchApi.list(endpoint, lang, session)
22
-
23
- bonuses = result.items
35
+ const result: any = await fetchApi.list(endpoint, lang, {
36
+ session,
37
+ sorttype,
38
+ })
39
+
40
+ if(!result.success) {
41
+ errorMessage = result.errorMessage
42
+ }else{
43
+ bonuses = result.items
24
44
 
25
- setEventSource()
45
+ setEventSource()
46
+ }
47
+
48
+ isLoading = false
49
+
50
+
26
51
  }
27
52
 
28
53
  const eventSourceHandler = composeEventSourceMessageHandler({
29
54
  "WageringProgressUpdate": (data) => {
30
55
  bonuses = bonuses.map(bonus => {
31
56
  let currentLevel = data?.items[bonus.bonusWalletID]
32
- return { ...bonus, currentLevel }
57
+ if(currentLevel){
58
+ return { ...bonus, currentLevel }
59
+ }else{
60
+ return bonus
61
+ }
33
62
  })
34
63
  },
35
64
  })
@@ -38,7 +67,7 @@
38
67
  if(!bonuses) return;
39
68
 
40
69
  const params = {
41
- bonusWalletIDs: bonuses?.map(bonus => bonus.bonusWalletID).join(','),
70
+ bonusWalletIDs: bonuses?.filter(_bonus => isSetUpdate(_bonus, BonusStatus)).map(bonus => bonus.bonusWalletID).join(','),
42
71
  XSessionId: session,
43
72
  }
44
73
 
@@ -51,9 +80,13 @@
51
80
  )
52
81
  }
53
82
 
54
- $: endpoint && fetcher()
55
- $: lang && fetcher()
56
- $: session && fetcher()
83
+ onMountMessageLifeCycle({
84
+ 'OnWageringBonusClaimed': () => init()
85
+ })
86
+
87
+ $: endpoint && init()
88
+ $: lang && init()
89
+ $: session && init()
57
90
 
58
91
  onMount(() => {
59
92
  return () => {
@@ -63,14 +96,27 @@
63
96
  })
64
97
  </script>
65
98
 
66
- {#each bonuses as item, index}
67
- <casino-wagering-bonus
68
- {endpoint}
69
- {lang}
70
- {session}
71
- rawbonus={JSON.stringify(item)}
72
- />
73
- {/each}
99
+ {#if isLoading}
100
+ Loading, please wait ...
101
+ {:else}
102
+ {#if bonuses.length > 0}
103
+ {#each bonuses as item, index}
104
+ <casino-wagering-bonus
105
+ {endpoint}
106
+ {lang}
107
+ {session}
108
+ rawbonus={JSON.stringify(item)}
109
+ />
110
+ {/each}
111
+ {:else}
112
+ {#if errorMessage}
113
+ <div style="color: red;">Error: {errorMessage}</div>
114
+ {:else}
115
+ No wagering bonuses found
116
+ {/if}
117
+ {/if}
118
+ {/if}
119
+
74
120
 
75
121
  <style lang="scss">
76
122
  :host {