be-components 7.2.6 → 7.2.8

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 (50) hide show
  1. package/lib/commonjs/CreateEngagement/index.js +7 -1
  2. package/lib/commonjs/CreateEngagement/index.js.map +1 -1
  3. package/lib/commonjs/PartnerPortal/api/index.js +16 -0
  4. package/lib/commonjs/PartnerPortal/api/index.js.map +1 -1
  5. package/lib/commonjs/PartnerPortal/components/FlashCampaignManager.js +405 -0
  6. package/lib/commonjs/PartnerPortal/components/FlashCampaignManager.js.map +1 -0
  7. package/lib/commonjs/PartnerPortal/index.js +1 -1
  8. package/lib/commonjs/PartnerPortal/index.js.map +1 -1
  9. package/lib/commonjs/index.js +7 -0
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/module/CreateEngagement/index.js +7 -1
  12. package/lib/module/CreateEngagement/index.js.map +1 -1
  13. package/lib/module/PartnerPortal/api/index.js +16 -0
  14. package/lib/module/PartnerPortal/api/index.js.map +1 -1
  15. package/lib/module/PartnerPortal/components/FlashCampaignManager.js +398 -0
  16. package/lib/module/PartnerPortal/components/FlashCampaignManager.js.map +1 -0
  17. package/lib/module/PartnerPortal/index.js +1 -1
  18. package/lib/module/PartnerPortal/index.js.map +1 -1
  19. package/lib/module/index.js +2 -1
  20. package/lib/module/index.js.map +1 -1
  21. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts +2 -1
  22. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
  23. package/lib/typescript/lib/commonjs/PartnerPortal/api/index.d.ts +2 -0
  24. package/lib/typescript/lib/commonjs/PartnerPortal/api/index.d.ts.map +1 -1
  25. package/lib/typescript/lib/commonjs/PartnerPortal/components/FlashCampaignManager.d.ts +10 -0
  26. package/lib/typescript/lib/commonjs/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -0
  27. package/lib/typescript/lib/commonjs/index.d.ts +1 -0
  28. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  29. package/lib/typescript/lib/module/CreateEngagement/index.d.ts +2 -1
  30. package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
  31. package/lib/typescript/lib/module/PartnerPortal/api/index.d.ts +2 -0
  32. package/lib/typescript/lib/module/PartnerPortal/api/index.d.ts.map +1 -1
  33. package/lib/typescript/lib/module/PartnerPortal/components/FlashCampaignManager.d.ts +10 -0
  34. package/lib/typescript/lib/module/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -0
  35. package/lib/typescript/lib/module/index.d.ts +2 -1
  36. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  37. package/lib/typescript/src/CreateEngagement/index.d.ts +2 -1
  38. package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
  39. package/lib/typescript/src/PartnerPortal/api/index.d.ts +9 -1
  40. package/lib/typescript/src/PartnerPortal/api/index.d.ts.map +1 -1
  41. package/lib/typescript/src/PartnerPortal/components/FlashCampaignManager.d.ts +13 -0
  42. package/lib/typescript/src/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -0
  43. package/lib/typescript/src/index.d.ts +2 -1
  44. package/lib/typescript/src/index.d.ts.map +1 -1
  45. package/package.json +1 -1
  46. package/src/CreateEngagement/index.tsx +6 -4
  47. package/src/PartnerPortal/api/index.ts +17 -1
  48. package/src/PartnerPortal/components/FlashCampaignManager.tsx +214 -0
  49. package/src/PartnerPortal/index.tsx +1 -1
  50. package/src/index.tsx +3 -0
@@ -0,0 +1,214 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, View } from "../../Components/Themed";
3
+ import type { FocusPositionProps, PollCampaignProps, PollOptionProps, PollProps, PollSummaryProps } from '../../types';
4
+ import { PartnerPortalApi } from '../api';
5
+ import { FlatList, Image, Platform } from 'react-native';
6
+ import { Icons } from '../../Components';
7
+ import { useColors } from '../../constants/useColors';
8
+
9
+ type FlashCampaignManagerProps = {
10
+ company_id:string,
11
+ refresh_key?:string,
12
+ poll_campaign_id:string,
13
+ onCreateFlashMarket:(poll_campaign_id:string) => void,
14
+ onManageFlashMarket:(poll_id:string) => void,
15
+ onFocusPosition:(pos:FocusPositionProps) => void
16
+ };
17
+
18
+ const sections = ['header','markets']
19
+ const MIN_MARKET_WIDTH = 300
20
+ const MARKET_MARGIN = 5
21
+ const FlashCampaignManager = ({ company_id, refresh_key, poll_campaign_id, onManageFlashMarket, onCreateFlashMarket }:FlashCampaignManagerProps) => {
22
+ const Colors = useColors();
23
+ const [ size, setSize ] = useState({ height:0, width:0 })
24
+ const [ state, setState ] = useState<{
25
+ loading: boolean,
26
+ flash_campaign?:PollCampaignProps,
27
+ flash_summaries:PollSummaryProps[],
28
+ flash_markets:PollProps[]
29
+ }>({
30
+ loading:false,
31
+ flash_markets:[],
32
+ flash_summaries: []
33
+ });
34
+ const market_count = Math.floor(size.width / MIN_MARKET_WIDTH);
35
+
36
+ //Now calc the width
37
+ const market_width = (size.width / market_count) - (MARKET_MARGIN * 2) - 5
38
+ const { loading, flash_markets, flash_campaign, flash_summaries } = state;
39
+ const filtered_markets = flash_markets.filter(fm => fm.status != 'inactive');
40
+ const total_base_stake = flash_markets.filter(fm => fm.status != 'pending').reduce((a,b) => a + (b.base_stake ?? 0), 0);
41
+ const total_stake = flash_summaries.reduce((a,b) => a + b.stake, 0) - total_base_stake
42
+ let total_responses = flash_summaries.reduce((a,b) => a + b.count, 0) - flash_markets.length
43
+ if(total_responses < 0){ total_responses = 0 }
44
+
45
+ useEffect(() => {
46
+ PartnerPortalApi.setEnvironment();
47
+ getData()
48
+ },[poll_campaign_id, company_id, refresh_key]);
49
+
50
+ const getData = async() => {
51
+ setState({ ...state, loading:true });
52
+ const resp = await PartnerPortalApi.EngagementApi.getFlashCampaignById(poll_campaign_id);
53
+ if(!resp){ return alert('Unable to get flash market at this time. Please try again later') }
54
+ const p_resp = await PartnerPortalApi.EngagementApi.getFlashMarketsByCampaignId(poll_campaign_id);
55
+ if(!p_resp){ return alert('Unable to get flash market at this time. Please try again later') }
56
+ let summaries:PollSummaryProps[] = []
57
+ p_resp.polls.map(p => p.poll_summaries?.map(s => summaries.push(s)));
58
+ setState({
59
+ ...state,
60
+ flash_campaign: resp.poll_campaign,
61
+ flash_markets: p_resp.polls,
62
+ flash_summaries: summaries,
63
+ loading: false
64
+ })
65
+ }
66
+
67
+ const renderOptions = (data: { item:PollOptionProps, index:number }) => {
68
+ return (
69
+ <View transparent type='row' style={{ padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
70
+ <View transparent style={{ flex:1 }}>
71
+ <Text theme='h2'>{data.item.option_name}</Text>
72
+ </View>
73
+ {data.item.result_ind == 'win' ?
74
+ <Icons.CheckCirlceIcon size={16} color={Colors.text.success}/>
75
+ :<></>}
76
+ </View>
77
+ )
78
+ }
79
+
80
+ const renderMarkets = (data:{ item:PollProps, index:number }) => {
81
+ let total_volume = data.item.poll_summaries?.reduce((a,b) => a + b.stake, 0) ?? 0
82
+ total_volume -= data.item.base_stake ?? 0
83
+ if(!data.item.poll_options){ return <></> }
84
+ return (
85
+ <View float style={{ width: market_width, margin:MARKET_MARGIN, flexGrow:1 }}>
86
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
87
+ {data.item.poll_image?.url ?
88
+ <Image
89
+ style={{ height:35, width:35 }}
90
+ resizeMode='contain'
91
+ source={{ uri: data.item.poll_image.url }}
92
+ />
93
+ :
94
+ <Icons.FlameIcon size={35} color={Colors.text.error} />
95
+ }
96
+ <View transparent style={{ flex:1, marginLeft:5, paddingLeft:5, borderLeftWidth:1, borderColor:Colors.borders.light }}>
97
+ <Text theme='h1'>{data.item.poll_question}</Text>
98
+ <Text theme='description' style={{ marginTop:3 }}>${total_volume.toFixed(2)} Volume</Text>
99
+ </View>
100
+ <Button float style={{ padding:10 }} onPress={() => onManageFlashMarket(data.item.poll_id)}>
101
+ <Icons.SettingsIcon size={16} color={Colors.text.action} />
102
+ </Button>
103
+ </View>
104
+ <View style={{ flex:1 }}>
105
+ <FlatList
106
+ data={data.item.poll_options}
107
+ renderItem={renderOptions}
108
+ key={`options_${data.item.poll_id}`}
109
+ keyExtractor={item => item.poll_option_id.toString()}
110
+ />
111
+ </View>
112
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
113
+ <View transparent style={{ flex:1 }}>
114
+ <Text theme='h2'>${total_volume.toFixed(2)} Volume</Text>
115
+ </View>
116
+ <View float style={{ padding:10, borderRadius:22, backgroundColor:data.item.status == 'active' ? Colors.text.success : data.item.status == 'closed' ? Colors.text.error : Colors.text.warning }}>
117
+ <Text theme='description' color={Colors.text.white}>{data.item.status.toUpperCase()}</Text>
118
+ </View>
119
+ </View>
120
+ </View>
121
+ )
122
+ }
123
+
124
+ const renderSections = (data:{item:string, index:number}) => {
125
+ switch(data.item){
126
+ case 'header':
127
+ if(!flash_campaign){ return <></> }
128
+ return (
129
+ <View transparent style={{ flexDirection:'row', flexWrap:'wrap' }}>
130
+
131
+ <View float nativeID='company_info' style={{ flexGrow:1, flexBasis:1, minWidth:200, margin:10 }}>
132
+ <View transparent style={{ flexDirection:'row', padding:10 }}>
133
+ <Image
134
+ source={{ uri: flash_campaign.campaign_image?.url }}
135
+ style={{ height:50, width:50 }}
136
+ resizeMode='cover'
137
+ />
138
+ <View transparent style={{ flex:1, marginLeft:10, paddingLeft:10, borderLeftWidth:1, borderColor:Colors.borders.light }}>
139
+ <Text theme='h1' size={20}>{flash_campaign.name}</Text>
140
+ <Text theme='description' size={16} style={{ marginTop:6 }}>Flash Market Campaign</Text>
141
+ </View>
142
+ </View>
143
+ </View>
144
+
145
+ <View float nativeID='player_count' style={{ flexGrow:1, minWidth: 100, margin:10 }}>
146
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
147
+ <View transparent style={{ flex:1 }}>
148
+ <Text theme='h1'>Total Volume</Text>
149
+ </View>
150
+ </View>
151
+ <View transparent style={{ flexGrow:Platform.OS == 'web' ? 1 : undefined, justifyContent:'center', alignItems:'center', padding:10 }}>
152
+ <Text theme='h1' size={60}>${total_stake.toFixed(2)}</Text>
153
+ </View>
154
+ </View>
155
+ <View float nativeID='player_count' style={{ flexGrow:1, minWidth: 100, margin:10 }}>
156
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
157
+ <View transparent style={{ flex:1 }}>
158
+ <Text theme='h1'>Total Bets Placed</Text>
159
+ </View>
160
+ </View>
161
+ <View transparent style={{ flexGrow:Platform.OS == 'web' ? 1 : undefined, justifyContent:'center', alignItems:'center', padding:10 }}>
162
+ <Text theme='h1' size={60}>{total_responses.toFixed()}</Text>
163
+ </View>
164
+ </View>
165
+ </View>
166
+ )
167
+ case 'markets':
168
+ return (
169
+ <View transparent>
170
+ <View transparent style={{ flexDirection:'row', flexWrap:'wrap' }}>
171
+ <View nativeID='company_competitions' style={{ flexGrow:1, flexBasis:1, minWidth:300, margin:10 }}>
172
+ <View style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
173
+ <View transparent style={{ flex:1 }}>
174
+ <Text theme='h1'>Flash Markets</Text>
175
+ <Text theme='description' style={{ marginTop:3 }}>Flash Markets Associated with this campaign</Text>
176
+ </View>
177
+ <Button
178
+ title='CREATE NEW'
179
+ type='success'
180
+ style={{ padding:10 }}
181
+ onPress={() => onCreateFlashMarket(poll_campaign_id)}
182
+ />
183
+ </View>
184
+ </View>
185
+ </View>
186
+ <View transparent style={{ flexDirection:'row', flexWrap:'wrap', padding:5 }}>
187
+ {filtered_markets.sort((a,b) => a.priority - b.priority).map((fm,i) => {
188
+ return renderMarkets({ item: fm, index:i })
189
+ })}
190
+ </View>
191
+ </View>
192
+ )
193
+ default: return <></>
194
+ }
195
+ }
196
+
197
+ return (
198
+ <View style={{ flex:1 }} onLayout={(ev) => {
199
+ const { height, width } = ev.nativeEvent.layout
200
+ setSize({ height, width });
201
+ }}>
202
+ <FlatList
203
+ data={sections}
204
+ refreshing={loading}
205
+ onRefresh={() => getData()}
206
+ renderItem={renderSections}
207
+ key='flash_campign_sections'
208
+ keyExtractor={(item) => item}
209
+ />
210
+ </View>
211
+ )
212
+ }
213
+
214
+ export default FlashCampaignManager
@@ -365,7 +365,7 @@ const PartnerPortal = ({ me, company_id, refresh_key, onCreateEngagement, onSele
365
365
  <View transparent type='row'>
366
366
  <View transparent style={{ flex:1 }}>
367
367
  <Text theme='h1' size={32}>{company.company_name}</Text>
368
- <Text theme='h2' style={{ marginTop:3, flexWrap:'wrap', flexShrink:1 }} size={14}>{company.company_description} with more long text</Text>
368
+ <Text theme='h2' style={{ marginTop:3, flexWrap:'wrap', flexShrink:1 }} size={14}>{company.company_description}</Text>
369
369
  </View>
370
370
  <ImageUploader onFinishUpload={(obj) => console.log(obj.secure_url)} public_id={`company_logo_${company_id}_${Math.random()*100000}`}>
371
371
  <Image
package/src/index.tsx CHANGED
@@ -67,6 +67,8 @@ import PartnerPortal from './PartnerPortal';
67
67
  import EmbedManager from './PartnerPortal/components/EmbedManager';
68
68
  import CreateEmbed from './PartnerPortal/components/CreateEmbed';
69
69
  import ReferralCodeManager from './PartnerPortal/components/ReferralCodeManager';
70
+ import FlashCampaignManager from './PartnerPortal/components/FlashCampaignManager';
71
+
70
72
  export {
71
73
  Authenticator,
72
74
  Observer,
@@ -75,6 +77,7 @@ export {
75
77
  CreateEngagement,
76
78
  DiscordConnectionManager,
77
79
  BEEventApi,
80
+ FlashCampaignManager,
78
81
  EmbedManager,
79
82
  RankingsCard,
80
83
  ManageFlashMarket,