be-components 7.2.6 → 7.2.7
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/lib/commonjs/CreateEngagement/index.js +7 -1
- package/lib/commonjs/CreateEngagement/index.js.map +1 -1
- package/lib/commonjs/PartnerPortal/api/index.js +16 -0
- package/lib/commonjs/PartnerPortal/api/index.js.map +1 -1
- package/lib/commonjs/PartnerPortal/components/FlashCampaignManager.js +402 -0
- package/lib/commonjs/PartnerPortal/components/FlashCampaignManager.js.map +1 -0
- package/lib/commonjs/PartnerPortal/index.js +1 -1
- package/lib/commonjs/PartnerPortal/index.js.map +1 -1
- package/lib/commonjs/index.js +7 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/module/CreateEngagement/index.js +7 -1
- package/lib/module/CreateEngagement/index.js.map +1 -1
- package/lib/module/PartnerPortal/api/index.js +16 -0
- package/lib/module/PartnerPortal/api/index.js.map +1 -1
- package/lib/module/PartnerPortal/components/FlashCampaignManager.js +395 -0
- package/lib/module/PartnerPortal/components/FlashCampaignManager.js.map +1 -0
- package/lib/module/PartnerPortal/index.js +1 -1
- package/lib/module/PartnerPortal/index.js.map +1 -1
- package/lib/module/index.js +2 -1
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts +2 -1
- package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/PartnerPortal/api/index.d.ts +2 -0
- package/lib/typescript/lib/commonjs/PartnerPortal/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/PartnerPortal/components/FlashCampaignManager.d.ts +10 -0
- package/lib/typescript/lib/commonjs/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts +1 -0
- package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/CreateEngagement/index.d.ts +2 -1
- package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/PartnerPortal/api/index.d.ts +2 -0
- package/lib/typescript/lib/module/PartnerPortal/api/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/PartnerPortal/components/FlashCampaignManager.d.ts +10 -0
- package/lib/typescript/lib/module/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -0
- package/lib/typescript/lib/module/index.d.ts +2 -1
- package/lib/typescript/lib/module/index.d.ts.map +1 -1
- package/lib/typescript/src/CreateEngagement/index.d.ts +2 -1
- package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
- package/lib/typescript/src/PartnerPortal/api/index.d.ts +9 -1
- package/lib/typescript/src/PartnerPortal/api/index.d.ts.map +1 -1
- package/lib/typescript/src/PartnerPortal/components/FlashCampaignManager.d.ts +13 -0
- package/lib/typescript/src/PartnerPortal/components/FlashCampaignManager.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +2 -1
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CreateEngagement/index.tsx +6 -4
- package/src/PartnerPortal/api/index.ts +17 -1
- package/src/PartnerPortal/components/FlashCampaignManager.tsx +211 -0
- package/src/PartnerPortal/index.tsx +1 -1
- package/src/index.tsx +3 -0
|
@@ -0,0 +1,211 @@
|
|
|
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.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
|
+
</View>
|
|
74
|
+
)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const renderMarkets = (data:{ item:PollProps, index:number }) => {
|
|
78
|
+
let total_volume = data.item.poll_summaries?.reduce((a,b) => a + b.stake, 0) ?? 0
|
|
79
|
+
total_volume -= data.item.base_stake ?? 0
|
|
80
|
+
if(!data.item.poll_options){ return <></> }
|
|
81
|
+
return (
|
|
82
|
+
<View float style={{ width: market_width, margin:MARKET_MARGIN, flexGrow:1 }}>
|
|
83
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
84
|
+
{data.item.poll_image?.url ?
|
|
85
|
+
<Image
|
|
86
|
+
style={{ height:35, width:35 }}
|
|
87
|
+
resizeMode='contain'
|
|
88
|
+
source={{ uri: data.item.poll_image.url }}
|
|
89
|
+
/>
|
|
90
|
+
:
|
|
91
|
+
<Icons.FlameIcon size={35} color={Colors.text.error} />
|
|
92
|
+
}
|
|
93
|
+
<View transparent style={{ flex:1, marginLeft:5, paddingLeft:5, borderLeftWidth:1, borderColor:Colors.borders.light }}>
|
|
94
|
+
<Text theme='h1'>{data.item.poll_question}</Text>
|
|
95
|
+
<Text theme='description' style={{ marginTop:3 }}>${total_volume.toFixed(2)} Volume</Text>
|
|
96
|
+
</View>
|
|
97
|
+
<Button float style={{ padding:10 }} onPress={() => onManageFlashMarket(data.item.poll_id)}>
|
|
98
|
+
<Icons.SettingsIcon size={16} color={Colors.text.action} />
|
|
99
|
+
</Button>
|
|
100
|
+
</View>
|
|
101
|
+
<View style={{ flex:1 }}>
|
|
102
|
+
<FlatList
|
|
103
|
+
data={data.item.poll_options}
|
|
104
|
+
renderItem={renderOptions}
|
|
105
|
+
key={`options_${data.item.poll_id}`}
|
|
106
|
+
keyExtractor={item => item.poll_option_id.toString()}
|
|
107
|
+
/>
|
|
108
|
+
</View>
|
|
109
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
|
|
110
|
+
<View transparent style={{ flex:1 }}>
|
|
111
|
+
<Text theme='h2'>${total_volume.toFixed(2)} Volume</Text>
|
|
112
|
+
</View>
|
|
113
|
+
<View float style={{ padding:10, borderRadius:22, backgroundColor:data.item.status == 'active' ? Colors.text.success : Colors.text.warning }}>
|
|
114
|
+
<Text theme='description' color={Colors.text.white}>{data.item.status.toUpperCase()}</Text>
|
|
115
|
+
</View>
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const renderSections = (data:{item:string, index:number}) => {
|
|
122
|
+
switch(data.item){
|
|
123
|
+
case 'header':
|
|
124
|
+
if(!flash_campaign){ return <></> }
|
|
125
|
+
return (
|
|
126
|
+
<View transparent style={{ flexDirection:'row', flexWrap:'wrap' }}>
|
|
127
|
+
|
|
128
|
+
<View float nativeID='company_info' style={{ flexGrow:1, flexBasis:1, minWidth:200, margin:10 }}>
|
|
129
|
+
<View transparent style={{ flexDirection:'row', padding:10 }}>
|
|
130
|
+
<Image
|
|
131
|
+
source={{ uri: flash_campaign.campaign_image?.url }}
|
|
132
|
+
style={{ height:50, width:50 }}
|
|
133
|
+
resizeMode='cover'
|
|
134
|
+
/>
|
|
135
|
+
<View transparent style={{ flex:1, marginLeft:10, paddingLeft:10, borderLeftWidth:1, borderColor:Colors.borders.light }}>
|
|
136
|
+
<Text theme='h1' size={20}>{flash_campaign.name}</Text>
|
|
137
|
+
<Text theme='description' size={16} style={{ marginTop:6 }}>Flash Market Campaign</Text>
|
|
138
|
+
</View>
|
|
139
|
+
</View>
|
|
140
|
+
</View>
|
|
141
|
+
|
|
142
|
+
<View float nativeID='player_count' style={{ flexGrow:1, minWidth: 100, margin:10 }}>
|
|
143
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
144
|
+
<View transparent style={{ flex:1 }}>
|
|
145
|
+
<Text theme='h1'>Total Volume</Text>
|
|
146
|
+
</View>
|
|
147
|
+
</View>
|
|
148
|
+
<View transparent style={{ flexGrow:Platform.OS == 'web' ? 1 : undefined, justifyContent:'center', alignItems:'center', padding:10 }}>
|
|
149
|
+
<Text theme='h1' size={60}>${total_stake.toFixed(2)}</Text>
|
|
150
|
+
</View>
|
|
151
|
+
</View>
|
|
152
|
+
<View float nativeID='player_count' style={{ flexGrow:1, minWidth: 100, margin:10 }}>
|
|
153
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
154
|
+
<View transparent style={{ flex:1 }}>
|
|
155
|
+
<Text theme='h1'>Total Bets Placed</Text>
|
|
156
|
+
</View>
|
|
157
|
+
</View>
|
|
158
|
+
<View transparent style={{ flexGrow:Platform.OS == 'web' ? 1 : undefined, justifyContent:'center', alignItems:'center', padding:10 }}>
|
|
159
|
+
<Text theme='h1' size={60}>{total_responses.toFixed()}</Text>
|
|
160
|
+
</View>
|
|
161
|
+
</View>
|
|
162
|
+
</View>
|
|
163
|
+
)
|
|
164
|
+
case 'markets':
|
|
165
|
+
return (
|
|
166
|
+
<View transparent>
|
|
167
|
+
<View transparent style={{ flexDirection:'row', flexWrap:'wrap' }}>
|
|
168
|
+
<View nativeID='company_competitions' style={{ flexGrow:1, flexBasis:1, minWidth:300, margin:10 }}>
|
|
169
|
+
<View style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
170
|
+
<View transparent style={{ flex:1 }}>
|
|
171
|
+
<Text theme='h1'>Flash Markets</Text>
|
|
172
|
+
<Text theme='description' style={{ marginTop:3 }}>Flash Markets Associated with this campaign</Text>
|
|
173
|
+
</View>
|
|
174
|
+
<Button
|
|
175
|
+
title='CREATE NEW'
|
|
176
|
+
type='success'
|
|
177
|
+
style={{ padding:10 }}
|
|
178
|
+
onPress={() => onCreateFlashMarket(poll_campaign_id)}
|
|
179
|
+
/>
|
|
180
|
+
</View>
|
|
181
|
+
</View>
|
|
182
|
+
</View>
|
|
183
|
+
<View transparent style={{ flexDirection:'row', flexWrap:'wrap', padding:5 }}>
|
|
184
|
+
{filtered_markets.sort((a,b) => a.priority - b.priority).map((fm,i) => {
|
|
185
|
+
return renderMarkets({ item: fm, index:i })
|
|
186
|
+
})}
|
|
187
|
+
</View>
|
|
188
|
+
</View>
|
|
189
|
+
)
|
|
190
|
+
default: return <></>
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
return (
|
|
195
|
+
<View style={{ flex:1 }} onLayout={(ev) => {
|
|
196
|
+
const { height, width } = ev.nativeEvent.layout
|
|
197
|
+
setSize({ height, width });
|
|
198
|
+
}}>
|
|
199
|
+
<FlatList
|
|
200
|
+
data={sections}
|
|
201
|
+
refreshing={loading}
|
|
202
|
+
onRefresh={() => getData()}
|
|
203
|
+
renderItem={renderSections}
|
|
204
|
+
key='flash_campign_sections'
|
|
205
|
+
keyExtractor={(item) => item}
|
|
206
|
+
/>
|
|
207
|
+
</View>
|
|
208
|
+
)
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
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}
|
|
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,
|