be-components 1.9.7 → 1.9.9

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 (115) hide show
  1. package/lib/commonjs/Components/Icons.js +186 -0
  2. package/lib/commonjs/Components/Icons.js.map +1 -1
  3. package/lib/commonjs/Components/ViewportObserver.js.map +1 -1
  4. package/lib/commonjs/MarketComponents/api/index.js +10 -1
  5. package/lib/commonjs/MarketComponents/api/index.js.map +1 -1
  6. package/lib/commonjs/MarketComponents/components/AthleteMarket/index.js +7 -2
  7. package/lib/commonjs/MarketComponents/components/AthleteMarket/index.js.map +1 -1
  8. package/lib/commonjs/MarketComponents/components/BetScopeIndicator.js +19 -0
  9. package/lib/commonjs/MarketComponents/components/BetScopeIndicator.js.map +1 -0
  10. package/lib/commonjs/MarketComponents/components/MarketButton/index.js +6 -1
  11. package/lib/commonjs/MarketComponents/components/MarketButton/index.js.map +1 -1
  12. package/lib/commonjs/MarketComponents/components/OrderGradeBar.js +2 -2
  13. package/lib/commonjs/MarketComponents/components/OrderGradeBar.js.map +1 -1
  14. package/lib/commonjs/MarketComponents/components/TeamEventMarket/index.js +125 -6
  15. package/lib/commonjs/MarketComponents/components/TeamEventMarket/index.js.map +1 -1
  16. package/lib/commonjs/Poll/components/CampaignHeader.js +53 -0
  17. package/lib/commonjs/Poll/components/CampaignHeader.js.map +1 -0
  18. package/lib/commonjs/Poll/components/CampaignLeaderboard.js +295 -0
  19. package/lib/commonjs/Poll/components/CampaignLeaderboard.js.map +1 -0
  20. package/lib/commonjs/Poll/components/CampaignPlay.js +11 -89
  21. package/lib/commonjs/Poll/components/CampaignPlay.js.map +1 -1
  22. package/lib/commonjs/Poll/components/CampaignProgressBar.js +0 -1
  23. package/lib/commonjs/Poll/components/CampaignProgressBar.js.map +1 -1
  24. package/lib/commonjs/Poll/components/CampaignResult.js +44 -345
  25. package/lib/commonjs/Poll/components/CampaignResult.js.map +1 -1
  26. package/lib/commonjs/Poll/components/PollCard.js +2 -1
  27. package/lib/commonjs/Poll/components/PollCard.js.map +1 -1
  28. package/lib/commonjs/Poll/components/PollQuestionsSection.js +81 -0
  29. package/lib/commonjs/Poll/components/PollQuestionsSection.js.map +1 -0
  30. package/lib/commonjs/Poll/components/PollSelectCard.js +1 -2
  31. package/lib/commonjs/Poll/components/PollSelectCard.js.map +1 -1
  32. package/lib/commonjs/Poll/index.js +132 -36
  33. package/lib/commonjs/Poll/index.js.map +1 -1
  34. package/lib/module/Components/Icons.js +186 -0
  35. package/lib/module/Components/Icons.js.map +1 -1
  36. package/lib/module/Components/ViewportObserver.js.map +1 -1
  37. package/lib/module/MarketComponents/api/index.js +10 -1
  38. package/lib/module/MarketComponents/api/index.js.map +1 -1
  39. package/lib/module/MarketComponents/components/AthleteMarket/index.js +8 -3
  40. package/lib/module/MarketComponents/components/AthleteMarket/index.js.map +1 -1
  41. package/lib/module/MarketComponents/components/BetScopeIndicator.js +12 -0
  42. package/lib/module/MarketComponents/components/BetScopeIndicator.js.map +1 -0
  43. package/lib/module/MarketComponents/components/MarketButton/index.js +6 -1
  44. package/lib/module/MarketComponents/components/MarketButton/index.js.map +1 -1
  45. package/lib/module/MarketComponents/components/OrderGradeBar.js +2 -2
  46. package/lib/module/MarketComponents/components/OrderGradeBar.js.map +1 -1
  47. package/lib/module/MarketComponents/components/TeamEventMarket/index.js +126 -7
  48. package/lib/module/MarketComponents/components/TeamEventMarket/index.js.map +1 -1
  49. package/lib/module/Poll/components/CampaignHeader.js +46 -0
  50. package/lib/module/Poll/components/CampaignHeader.js.map +1 -0
  51. package/lib/module/Poll/components/CampaignLeaderboard.js +286 -0
  52. package/lib/module/Poll/components/CampaignLeaderboard.js.map +1 -0
  53. package/lib/module/Poll/components/CampaignPlay.js +11 -89
  54. package/lib/module/Poll/components/CampaignPlay.js.map +1 -1
  55. package/lib/module/Poll/components/CampaignProgressBar.js +0 -1
  56. package/lib/module/Poll/components/CampaignProgressBar.js.map +1 -1
  57. package/lib/module/Poll/components/CampaignResult.js +48 -348
  58. package/lib/module/Poll/components/CampaignResult.js.map +1 -1
  59. package/lib/module/Poll/components/PollCard.js +2 -1
  60. package/lib/module/Poll/components/PollCard.js.map +1 -1
  61. package/lib/module/Poll/components/PollQuestionsSection.js +72 -0
  62. package/lib/module/Poll/components/PollQuestionsSection.js.map +1 -0
  63. package/lib/module/Poll/components/PollSelectCard.js +1 -2
  64. package/lib/module/Poll/components/PollSelectCard.js.map +1 -1
  65. package/lib/module/Poll/index.js +133 -38
  66. package/lib/module/Poll/index.js.map +1 -1
  67. package/lib/typescript/src/Components/Icons.d.ts +2 -0
  68. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  69. package/lib/typescript/src/Components/ViewportObserver.d.ts.map +1 -1
  70. package/lib/typescript/src/MarketComponents/api/index.d.ts +1 -0
  71. package/lib/typescript/src/MarketComponents/api/index.d.ts.map +1 -1
  72. package/lib/typescript/src/MarketComponents/components/AthleteMarket/index.d.ts +2 -2
  73. package/lib/typescript/src/MarketComponents/components/AthleteMarket/index.d.ts.map +1 -1
  74. package/lib/typescript/src/MarketComponents/components/BetScopeIndicator.d.ts +7 -0
  75. package/lib/typescript/src/MarketComponents/components/BetScopeIndicator.d.ts.map +1 -0
  76. package/lib/typescript/src/MarketComponents/components/MarketButton/index.d.ts +2 -2
  77. package/lib/typescript/src/MarketComponents/components/MarketButton/index.d.ts.map +1 -1
  78. package/lib/typescript/src/MarketComponents/components/TeamEventMarket/index.d.ts +4 -2
  79. package/lib/typescript/src/MarketComponents/components/TeamEventMarket/index.d.ts.map +1 -1
  80. package/lib/typescript/src/MarketComponents/index.d.ts +5 -4
  81. package/lib/typescript/src/MarketComponents/index.d.ts.map +1 -1
  82. package/lib/typescript/src/Poll/components/CampaignHeader.d.ts +9 -0
  83. package/lib/typescript/src/Poll/components/CampaignHeader.d.ts.map +1 -0
  84. package/lib/typescript/src/Poll/components/CampaignLeaderboard.d.ts +12 -0
  85. package/lib/typescript/src/Poll/components/CampaignLeaderboard.d.ts.map +1 -0
  86. package/lib/typescript/src/Poll/components/CampaignPlay.d.ts.map +1 -1
  87. package/lib/typescript/src/Poll/components/CampaignProgressBar.d.ts.map +1 -1
  88. package/lib/typescript/src/Poll/components/CampaignResult.d.ts +3 -7
  89. package/lib/typescript/src/Poll/components/CampaignResult.d.ts.map +1 -1
  90. package/lib/typescript/src/Poll/components/PollCard.d.ts.map +1 -1
  91. package/lib/typescript/src/Poll/components/PollQuestionsSection.d.ts +11 -0
  92. package/lib/typescript/src/Poll/components/PollQuestionsSection.d.ts.map +1 -0
  93. package/lib/typescript/src/Poll/components/PollSelectCard.d.ts +1 -2
  94. package/lib/typescript/src/Poll/components/PollSelectCard.d.ts.map +1 -1
  95. package/lib/typescript/src/Poll/index.d.ts +4 -2
  96. package/lib/typescript/src/Poll/index.d.ts.map +1 -1
  97. package/package.json +1 -1
  98. package/src/Components/Icons.tsx +64 -0
  99. package/src/Components/ViewportObserver.tsx +2 -4
  100. package/src/MarketComponents/api/index.ts +10 -1
  101. package/src/MarketComponents/components/AthleteMarket/index.tsx +12 -4
  102. package/src/MarketComponents/components/BetScopeIndicator.tsx +17 -0
  103. package/src/MarketComponents/components/MarketButton/index.tsx +5 -2
  104. package/src/MarketComponents/components/OrderGradeBar.tsx +2 -2
  105. package/src/MarketComponents/components/TeamEventMarket/index.tsx +75 -10
  106. package/src/Poll/components/CampaignHeader.tsx +35 -0
  107. package/src/Poll/components/CampaignLeaderboard.tsx +181 -0
  108. package/src/Poll/components/CampaignPlay.tsx +11 -82
  109. package/src/Poll/components/CampaignProgressBar.tsx +0 -1
  110. package/src/Poll/components/CampaignResult.tsx +42 -162
  111. package/src/Poll/components/PollCard.tsx +2 -1
  112. package/src/Poll/components/PollQuestionsSection.tsx +66 -0
  113. package/src/Poll/components/PollSelectCard.tsx +2 -3
  114. package/src/Poll/index.tsx +120 -31
  115. package/src/types.d.ts +1 -0
@@ -35,7 +35,7 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
35
35
  //const [ shareImage, setImage ] = useState<any>(undefined)
36
36
  const [ share_in_process ] = useState(false);
37
37
  const [ play_width, setPlayWidth ] = useState(0);
38
- const [ show_live, setShowLive ] = useState(false);
38
+ //const [ show_live, setShowLive ] = useState(false);
39
39
  const [ active_poll, setActivePoll ] = useState<PollProps|undefined>(undefined);
40
40
  const [ active_view, setActiveView ] = useState('select_poll')
41
41
 
@@ -45,7 +45,7 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
45
45
  if(a.priority && b.priority){ return a.priority - b.priority }
46
46
  else { return parseInt(b.poll_id) - parseInt(a.poll_id) }
47
47
  })
48
- const playable_polls = polls.filter(p => ['closed','active'].includes(p.status))
48
+ const playable_polls = polls.filter(p => ['closed','active','paused'].includes(p.status))
49
49
  const active_polls = polls.filter(p => p.status == 'active');
50
50
  const pending_polls = polls.filter(p => ['pending','paused'].includes(p.status));
51
51
  const closed_polls = polls.filter(p => p.status == 'closed');
@@ -57,6 +57,7 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
57
57
  const active_responded = poll_responses.find(pr => pr.poll_id == active_poll?.poll_id) ? true : false;
58
58
  let active_index = playable_polls.findIndex(p => p.poll_id == active_poll?.poll_id)
59
59
 
60
+ console.log(playable_polls)
60
61
 
61
62
  //const progressRef = useRef()
62
63
 
@@ -105,66 +106,6 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
105
106
  setLoading(false);
106
107
  }
107
108
 
108
- /*
109
- const getImage = async() => {
110
- if(!progressRef?.current){ return alert('Nothing to capture') }
111
- setShareInProcess(true)
112
- }
113
- */
114
-
115
-
116
- /*
117
- const share = async(newImage:string) => {
118
- if(!player){ return }
119
- if(!company){ return alert('no company')}
120
- let text = '';
121
- let url = `https://share.mybe.app/polls/${company.short_name}?poll_campaign_id=${poll_campaign.poll_campaign_id}`
122
- setShareInProcess(false)
123
- if(!newImage){ return alert('No image!') }
124
- if(!navigator?.share){ return alert('Browser does not support sharing')}
125
- const blob = await (await fetch(newImage)).blob();
126
- const filesArray = [
127
- new File([blob], `${player.player_id}_poll.png`, { type:blob.type } )
128
- ]
129
- navigator.share({ text, files:filesArray, url }).then(() => {
130
- //segEventTrack({ event: 'Shared Position', properties: { be_type:route.params.be_type, result:shareablePosition.result_ind } })
131
- }).catch((e) => console.log(e))
132
- }
133
- */
134
-
135
- /*
136
-
137
- const nativeShare = () => {
138
- if(!navigator?.share){ return alert('Your browser does not support native sharing') }
139
- if(!company){ return alert('no company')}
140
- let text = ``
141
- let total = playable_polls.length
142
- let total_resolved = playable_polls.filter(pp => pp.winning_option_id || pp.winning_value).length
143
- let wins = 0
144
- playable_polls.sort((a,b) => a.priority - b.priority).map(pp => {
145
- let resp = poll_responses.find(pr => pr.poll_id == pp.poll_id)
146
- if(!resp && (!pp.winning_option_id || !pp.winning_value)){ return }
147
- if(!resp){ text += `🕚`; return }
148
- if(!resp.result_ind){ text += '🕚'; return }
149
- if(resp.result_ind == 'win'){ wins += 1; text += '✅'; return }
150
- if(resp.result_ind == 'lose'){ text += '❌'; return }
151
- text += '🕚'
152
- return
153
- })
154
- let message = `I just went ${wins} out of ${total} in ${poll_campaign.name}! \n${text}`
155
- if(total_resolved < total){ message = `I just completed the ${poll_campaign.name}!` }
156
- let link = window.location.href
157
- //let link = `https://share.mybe.app/polls/${company.short_name}?poll_campaign_id=${poll_campaign.poll_campaign_id}`
158
- navigator.share({
159
- text:`${message}`,
160
- url: link
161
- }).then(() => {
162
- //segEventTrack({ event: 'Shared Position', properties: { be_type:route.params.be_type, result:shareablePosition.result_ind } })
163
- }).catch((e) => console.log(e))
164
-
165
- }
166
- */
167
-
168
109
  const handleNavPoll = (poll:PollProps) => {
169
110
  if(active_poll?.seconds_allowed){
170
111
  let responded = poll_responses.find(pr => pr.poll_id == active_poll.poll_id)
@@ -187,9 +128,9 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
187
128
  const selected = active_poll?.poll_id == data.item.poll_id ? true : false;
188
129
  const poll_response = poll_responses.find(pr => pr.poll_id == data.item.poll_id);
189
130
  const response_option = data.item.poll_options?.find(po => po.poll_option_id == poll_response?.poll_option_id)
131
+ console.log(data.item)
190
132
  return (
191
133
  <PollSelectCard
192
- index={data.index}
193
134
  poll_campaign={poll_campaign}
194
135
  disabled={data.item.status == 'pending' ? true : false}
195
136
  poll={data.item}
@@ -234,22 +175,10 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
234
175
  <TouchableOpacity style={{ padding:10 }} onPress={() => console.log('NATIVE SHARE')}>
235
176
  <Icons.ShareIcon color={Colors.brand.midnight} size={12}/>
236
177
  </TouchableOpacity>
237
- {poll_campaign.stream ?
238
- <TouchableOpacity style={{ padding:10 }} onPress={() => setShowLive(!show_live)}>
239
- {show_live ?
240
- <Icons.CloseIcon color={Colors.utility.error} size={14}/>
241
- :
242
- <Icons.TVIcon color={Colors.brand.midnight} size={14} />
243
- }
244
- </TouchableOpacity>
245
- :<></>}
178
+
246
179
  </View>
247
180
  </View>
248
- {poll_campaign.stream ?
249
- <View nativeID='campaign_stream' style={{ marginTop: show_live ? 5: 0, height:show_live ? undefined : 0, overflow:'hidden', justifyContent:'center', alignItems:'center' }}>
250
- <Text>STREAM!</Text>
251
- </View>
252
- :<></>}
181
+
253
182
  </View>
254
183
  <View style={{ flex:1 }}>
255
184
  <View nativeID='progress' style={{ padding:10, backgroundColor:Colors.shades.shade600 }}>
@@ -277,7 +206,7 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
277
206
  </View>
278
207
  <View nativeID='active_questions_list' style={{ marginTop: 10, backgroundColor:Colors.shades.shade100, borderRadius:22 }}>
279
208
  <FlatList
280
- data={active_polls}
209
+ data={playable_polls.sort((a,b) => a.priority - b.priority)}
281
210
  renderItem={renderPolls}
282
211
  />
283
212
  </View>
@@ -391,11 +320,11 @@ const CampaignPlay = ({ player_id, poll_campaign_id, onActiveViewChange, onReque
391
320
  <View nativeID='campaign_results' style={{ flex:1 }}>
392
321
  <CampaignResult
393
322
  poll_campaign={poll_campaign}
394
- polls={polls}
323
+ //polls={polls}
395
324
  //hide_back={init_view && init_view !='undefined' ? true : false}
396
- onShare={() => console.log('Share this bad boi!')}
397
- poll_responses={poll_responses}
398
- onClose={() => setActiveView('select_poll')}
325
+ //onShare={() => console.log('Share this bad boi!')}
326
+ //poll_responses={poll_responses}
327
+ //onClose={() => setActiveView('select_poll')}
399
328
  />
400
329
  </View>
401
330
  :<></>}
@@ -27,7 +27,6 @@ const CampaignProgressBar = ({ poll_responses, active_poll, polls, onPollSelect}
27
27
  let color = Colors.shades.white
28
28
  let response = poll_responses.find(pr => pr.poll_id == data.item.poll_id)
29
29
  if(response){ color = getBarColor(response) }
30
- console.log('rendering!!!')
31
30
  const active = active_poll == data.item.poll_id ? true : false
32
31
  return (
33
32
  <TouchableOpacity
@@ -1,174 +1,35 @@
1
- import { FlatList, Image, ScrollView, TouchableOpacity, View } from "react-native"
2
- import React, { useEffect, useState } from "react"
3
- import { PollCampaignApi } from "../api"
4
- import type { PollCampaignLeaderProps, PollCampaignProps, PollProps, PollResponseProps, PublicPlayerProps } from "../../types"
5
- import { Button, Icons, Text } from "../../Components"
1
+ import { TouchableOpacity, View } from "react-native"
2
+ import React, { useState } from "react"
3
+ import type { PollCampaignProps } from "../../types"
4
+ import { Icons, Text } from "../../Components"
6
5
  import Colors from '../../constants/colors';
6
+ import { view_styles } from "../../constants/styles"
7
+ import CampaignLeaderboard from "./CampaignLeaderboard"
7
8
 
8
9
  type CampaignResultProps = {
9
10
  poll_campaign:PollCampaignProps,
10
- polls:PollProps[],
11
- onShare?:() => void,
12
- hide_back?:boolean,
13
- poll_responses:PollResponseProps[],
14
- onClose: () => void
11
+ onShowFullLeaderboard?:() => void
15
12
  }
16
- const CampaignResult = ({ poll_campaign, polls, poll_responses, hide_back, onClose, onShare } : CampaignResultProps) => {
17
- const [ leaders_state, setLeadersState ] = useState<{
18
- loading:boolean,
19
- offset:number,
20
- players:PublicPlayerProps[]
21
- poll_campaign_leaders:PollCampaignLeaderProps[]
22
- }>({
23
- loading:false,
24
- offset:0,
25
- poll_campaign_leaders:[],
26
- players: []
27
- });
28
- const [ points_expanded, setPointsExpanded ] = useState(false);
29
13
 
30
- const { players, poll_campaign_leaders } = leaders_state;
31
-
32
- useEffect(() => {
33
- getDataFromServer(poll_campaign.poll_campaign_id, 0)
34
- },[poll_campaign.poll_campaign_id])
35
-
36
- const getDataFromServer = async(poll_campaign_id:string, offset:number) => {
37
- setLeadersState({ ...leaders_state, loading:true })
38
- const leaders = await PollCampaignApi.getLeadersByCampaignId(poll_campaign_id, offset)
39
- const player_ids = leaders.poll_campaign_leaders.map(l => l.player_id);
40
- const ps = await PollCampaignApi.getPlayersByPlayerIds(player_ids);
41
- setLeadersState({
42
- loading:false,
43
- poll_campaign_leaders: leaders.poll_campaign_leaders,
44
- players: ps,
45
- offset
46
- })
47
- }
48
-
49
- const renderTrophy = (place:number) => {
50
- switch(place){
51
- case 1: return <Icons.TrophyIcon color={Colors.incentive.gold} size={16}/>
52
- case 2: return <Icons.TrophyIcon color={Colors.incentive.silver} size={16}/>
53
- case 3: return <Icons.TrophyIcon color={Colors.incentive.bronze} size={16}/>
54
- default: return <></>
55
- }
56
- }
57
-
58
- const renderLeaders = (data: {item:PollCampaignLeaderProps, index:number}) => {
59
- const player = players.find(p => p.player_id == data.item.player_id);
60
- if(!player){ return <></> }
61
- return (
62
- <View style={{ flexDirection:'row', alignItems:'center', margin:4, padding:10, borderRadius:22, backgroundColor:Colors.shades.white }}>
63
- <View nativeID="place" style={{ margin:5, height:20, width:20, justifyContent:'center', alignItems:'center', borderRadius:100, borderWidth:1, borderColor:Colors.brand.slate }}>
64
- <Text size={10} color={Colors.brand.midnight} weight='bold' textAlign="center">{data.index+1}</Text>
65
- </View>
66
- <View nativeID="player" style={{ flex:1, flexDirection:'row', alignItems:'center' }}>
67
- <View nativeID="profile_pic" style={{ marginRight:10 }}>
68
- <Image
69
- source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1689262384/default-avatar_bbkn2t.png' }}
70
- style={{ height:40, width:40, borderRadius:100 }}
71
- resizeMode='cover'
72
- />
73
- </View>
74
- <View style={{ flex:1 }} nativeID="name">
75
- <Text size={14} color={Colors.brand.midnight} weight='bold'>{player.username}</Text>
76
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>{data.item.winnings.toFixed(2)} Points</Text>
77
- </View>
78
- <View>
79
- {renderTrophy(data.index + 1)}
80
- </View>
81
- </View>
82
- </View>
83
- )
84
- }
85
-
86
-
87
- //const questions_answered = poll_responses.length
88
- let correct_answers = poll_responses.filter(pr => pr.result_ind == 'win').length
89
- //let incorrect_answers = poll_responses.filter(pr => pr.result_ind == 'lose').length
90
- let ungraded_answers = poll_responses.filter(pr => !pr.result_ind).length
91
- let points_earned = poll_responses.reduce((a,b) => a + b.winnings, 0)
14
+ const CampaignResult = ({ poll_campaign, onShowFullLeaderboard } : CampaignResultProps) => {
15
+ const [ expanded, setExpanded ] = useState(true);
92
16
 
93
17
  return (
94
- <View style={{ flex:1 }}>
95
- <ScrollView style={{ flex:1, padding:10, marginBottom:10 }}>
96
- <TouchableOpacity
97
- style={{ flexDirection:'row', padding:10, paddingRight:15, paddingLeft:15, borderRadius:22, justifyContent:'center', alignItems:'center', marginBottom:10, backgroundColor:Colors.incentive.gold }}
98
- onPress={() => {
99
- if(onShare){ onShare() }
100
- }}
101
- >
102
- <Icons.ShareSocialIcon color={Colors.shades.white} size={14}/>
103
- <Text style={{ marginLeft:5 }} size={14} color={Colors.shades.white} weight='bold'>Share your results for a chance at a prize!</Text>
104
- </TouchableOpacity>
105
- <View nativeID="my_results">
106
- <Text style={{ margin:10 }} size={16} color={Colors.brand.midnight} weight='bold'>My Results</Text>
107
- <View style={{borderRadius:22, backgroundColor:Colors.shades.shade100, padding:20}}>
108
- <View nativeID="completion" style={{ flexDirection: 'row' }}>
109
- <View nativeID="total_questions" style={{ flex:1 }}>
110
- <Text size={12} color={Colors.brand.slate} weight='semibold'>TOTAL QUESTIONS</Text>
111
- <Text style={{ marginTop:5 }} size={16} color={Colors.brand.midnight} weight='bold'>{polls.length} Questions</Text>
112
- </View>
113
- <View nativeID="completion_pct" style={{ flex:1 }}>
114
- <Text size={12} color={Colors.brand.slate} weight='semibold'>COMPLETION</Text>
115
- <Text style={{ marginTop:5 }} size={16} color={Colors.brand.midnight} weight='bold'>{(((polls.length - ungraded_answers) / polls.length) * 100).toFixed()}%</Text>
116
- </View>
117
- </View>
118
- <View nativeID="performance" style={{ flexDirection: 'row', marginTop:10 }}>
119
- <View nativeID="total_questions" style={{ flex:1 }}>
120
- <Text size={12} color={Colors.brand.slate} weight='semibold'>SUCCESS RATE</Text>
121
- <Text style={{ marginTop:5 }} size={16} color={Colors.brand.midnight} weight='bold'>{((correct_answers / polls.length)*100).toFixed()}%</Text>
122
- </View>
123
- <View nativeID="completion_pct" style={{ flex:1 }}>
124
- <Text size={12} color={Colors.brand.slate} weight='semibold'>POINTS EARNED</Text>
125
- <Text style={{ marginTop:5 }} size={16} color={Colors.brand.midnight} weight='bold'>{points_earned.toFixed()} Points</Text>
126
- </View>
127
- </View>
128
- <View style={{ borderRadius:22, backgroundColor:Colors.highlights.highlight200Faded, padding:10, marginTop:10 }}>
129
- <TouchableOpacity style={{ flexDirection:'row', alignItems:'center' }} onPress={() => setPointsExpanded(!points_expanded)}>
130
- <View style={{ flexDirection:'row', alignItems:'center', flex:1 }}>
131
- <Icons.AlertIcon color={Colors.brand.midnight} size={14}/>
132
- <Text style={{ marginLeft:5 }} size={14} color={Colors.brand.midnight} weight='semibold'>How are points calculated?</Text>
133
- </View>
134
- <Icons.ChevronIcon direction={points_expanded ? 'up' : 'down'} color={Colors.brand.midnight}/>
135
- </TouchableOpacity>
136
- {points_expanded ?
137
- <>
138
- <Text size={12} color={Colors.brand.midnight} style={{ marginTop:10 }} weight='regular'>Points are calculated based on the total responses by all participants. Each response is worth 1 point. The responders that selected the winning option will split the total point pool.</Text>
139
- <Text size={12} color={Colors.brand.midnight} style={{ marginTop:5 }} weight='regular'>Therefore, points earned will not be updated until the question is closed!</Text>
140
- </>
141
- :<></>}
142
- </View>
143
- </View>
144
- </View>
145
- <View nativeID="leader_header" style={{ margin:10, flexDirection:'row', alignItems:'center' }}>
146
- <Text style={{ flex:1 }} size={16} color={Colors.brand.midnight} weight='bold'>Leaderboard</Text>
147
- <View style={{ borderRadius:22, padding:10, backgroundColor:Colors.accents.accent100 }}>
148
- <Text size={14} color={Colors.brand.midnight} weight='regular' textAlign="center">{poll_campaign.total_responders} Participants</Text>
149
- </View>
150
- </View>
151
- <View nativeID="leaderboard" style={{ flex:1, borderTopRightRadius:22, borderTopLeftRadius:22, padding:10, backgroundColor:Colors.shades.shade100}}>
152
- {poll_campaign.status == 'active' ?
153
- <Text size={12} color={Colors.utility.warning} textAlign="center">Points change as new responses come in</Text>
154
- :<></>}
155
- <FlatList
156
- data={poll_campaign_leaders}
157
- renderItem={renderLeaders}
158
- keyExtractor={((item) => item.player_id.toString())}
159
- />
18
+ <View style={{ flex:1, ...view_styles.section }}>
19
+ <TouchableOpacity style={{ ...view_styles.section_header }} onPress={() => setExpanded(!expanded)}>
20
+ <Icons.PodiumIcon size={18} color={Colors.brand.midnight} />
21
+ <View style={{flex:1, marginLeft:10}}>
22
+ <Text theme="header">Leaderboard</Text>
23
+ <Text style={{ marginTop:3 }} theme="body">Below are the leaderboard results!</Text>
160
24
  </View>
161
- </ScrollView>
162
- {!hide_back ?
163
- <View nativeID="result_actions" style={{ marginTop:5, padding:10 }}>
164
- <Button
165
- title='Go Back'
166
- title_color={Colors.brand.electric}
167
- borderWidth={1}
168
- padding={14}
169
- borderColor={Colors.brand.electric}
170
- onPress={() => onClose()}
171
- borderRadius={22}
25
+ <Icons.ChevronIcon size={8} color={Colors.brand.midnight} direction={expanded ? 'up' : 'down'} />
26
+ </TouchableOpacity>
27
+ {expanded ?
28
+ <View style={{ ...view_styles.section_body, padding:0, backgroundColor:Colors.shades.shade100 }}>
29
+ <CampaignLeaderboard
30
+ view_mode="short"
31
+ poll_campaign={poll_campaign}
32
+ onShowFullLeaderboard={onShowFullLeaderboard}
172
33
  />
173
34
  </View>
174
35
  :<></>}
@@ -176,4 +37,23 @@ const CampaignResult = ({ poll_campaign, polls, poll_responses, hide_back, onClo
176
37
  )
177
38
  }
178
39
 
40
+
41
+ /*
42
+ <View style={{ borderRadius:22, backgroundColor:Colors.highlights.highlight200Faded, padding:10, marginTop:10 }}>
43
+ <TouchableOpacity style={{ flexDirection:'row', alignItems:'center' }} onPress={() => setPointsExpanded(!points_expanded)}>
44
+ <View style={{ flexDirection:'row', alignItems:'center', flex:1 }}>
45
+ <Icons.AlertIcon color={Colors.brand.midnight} size={14}/>
46
+ <Text style={{ marginLeft:5 }} size={14} color={Colors.brand.midnight} weight='semibold'>How are points calculated?</Text>
47
+ </View>
48
+ <Icons.ChevronIcon direction={points_expanded ? 'up' : 'down'} color={Colors.brand.midnight}/>
49
+ </TouchableOpacity>
50
+ {points_expanded ?
51
+ <View>
52
+ <Text size={12} color={Colors.brand.midnight} style={{ marginTop:10 }} weight='regular'>Points are calculated based on the total responses by all participants. Each response is worth 1 point. The responders that selected the winning option will split the total point pool.</Text>
53
+ <Text size={12} color={Colors.brand.midnight} style={{ marginTop:5 }} weight='regular'>Therefore, points earned will not be updated until the question is closed!</Text>
54
+ </View>
55
+ :<></>}
56
+ </View>
57
+ */
58
+
179
59
  export default CampaignResult
@@ -6,6 +6,7 @@ import type { PollOptionProps, PollProps, PollResponseProps, PollSummaryProps }
6
6
  import { PollApi, PollResponseApi } from '../api';
7
7
  import { Button, Icons, Text } from '../../Components';
8
8
  import Colors from '../../constants/colors';
9
+ import { view_styles } from '../../constants/styles';
9
10
 
10
11
  type PollCardProps = {
11
12
  poll:PollProps,
@@ -182,7 +183,7 @@ const PollCard = ({ poll, question_number, total_questions, onSkip, onCancel, on
182
183
  return <></>
183
184
  }
184
185
  return (
185
- <View nativeID='poll' style={{ flex:1 }} onLayout={(ev) => {
186
+ <View nativeID='poll' style={{ ...view_styles.section }} onLayout={(ev) => {
186
187
  const { width } = ev.nativeEvent.layout
187
188
  setPollWidth(width)
188
189
  }}>
@@ -0,0 +1,66 @@
1
+ import React, { useState } from 'react';
2
+ import { View, TouchableOpacity, FlatList } from "react-native"
3
+ import type { PollCampaignProps, PollProps, PollResponseProps } from "../../types"
4
+ import { view_styles } from '../../constants/styles';
5
+ import { Icons, Text } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+ import PollSelectCard from './PollSelectCard';
8
+
9
+ type PollQuestionsSectionProps = {
10
+ poll_campaign:PollCampaignProps,
11
+ polls:PollProps[],
12
+ poll_responses:PollResponseProps[],
13
+ onSelectPoll:(p:PollProps) => void
14
+ }
15
+
16
+ const PollQuestionsSection = ({ poll_campaign, polls, onSelectPoll }:PollQuestionsSectionProps) => {
17
+ const [ section_data, setSectionData ] = useState<{
18
+ loading:boolean,
19
+ expanded:boolean,
20
+ }>({
21
+ loading: false,
22
+ expanded: true
23
+ });
24
+ const { expanded } = section_data;
25
+
26
+
27
+ const renderPolls = (data:{item:PollProps, index:number}) => {
28
+ return (
29
+ <View>
30
+ <PollSelectCard
31
+ poll={data.item}
32
+ disabled={false}
33
+ selected={false}
34
+ poll_campaign={poll_campaign}
35
+ show_response={false}
36
+ response_option={undefined}
37
+ onSelect={(p) => onSelectPoll(p)}
38
+ />
39
+ </View>
40
+ )
41
+ }
42
+
43
+ return (
44
+ <View style={{ ...view_styles.section }}>
45
+ <TouchableOpacity style={{ ...view_styles.section_header }} onPress={() => setSectionData({ ...section_data, expanded: !expanded })}>
46
+ <Icons.QuestionIcon size={18} color={Colors.brand.midnight} />
47
+ <View style={{flex:1, marginLeft:10}}>
48
+ <Text theme='header'>Questions</Text>
49
+ <Text style={{ marginTop:3 }} theme='body'>Available questions can be found below</Text>
50
+ </View>
51
+ <Icons.ChevronIcon direction={expanded?'up':'down'} color={Colors.brand.midnight} size={8} />
52
+ </TouchableOpacity>
53
+ {expanded ?
54
+ <View style={{ ...view_styles.section_body }}>
55
+ <FlatList
56
+ data={polls.sort((a,b) => a.priority - b.priority)}
57
+ renderItem={renderPolls}
58
+ keyExtractor={(item) => item.poll_id.toString()}
59
+ />
60
+ </View>
61
+ :<></>}
62
+ </View>
63
+ )
64
+ }
65
+
66
+ export default PollQuestionsSection
@@ -9,14 +9,13 @@ type PollSelectCardProps = {
9
9
  poll_campaign:PollCampaignProps,
10
10
  poll:PollProps,
11
11
  disabled?:boolean,
12
- index:number,
13
12
  show_response?:boolean,
14
13
  response_option?:PollOptionProps,
15
14
  poll_response?:PollResponseProps,
16
15
  onSelect:(poll:PollProps) => void
17
16
  }
18
17
 
19
- const PollSelectCard = ({ index, poll, disabled, selected, poll_campaign, poll_response, show_response, response_option, onSelect }:PollSelectCardProps) => {
18
+ const PollSelectCard = ({ poll, disabled, selected, poll_campaign, poll_response, show_response, response_option, onSelect }:PollSelectCardProps) => {
20
19
 
21
20
  const getResultColor = () => {
22
21
  switch(poll_response?.result_ind){
@@ -66,7 +65,7 @@ const PollSelectCard = ({ index, poll, disabled, selected, poll_campaign, poll_r
66
65
  return (
67
66
  <TouchableOpacity disabled={disabled} style={{ padding:10, borderRadius:22, backgroundColor:selected?Colors.highlights.highlight500Faded:undefined, flexDirection:'row' }} onPress={() => onSelect(poll)}>
68
67
  <View style={{ height:20, width:20, borderRadius:100, backgroundColor:Colors.shades.white, marginRight:10, justifyContent:'center' }}>
69
- <Text size={12} color={Colors.brand.midnight} weight='bold' textAlign='center'>{(index + 1).toString()}</Text>
68
+ <Text size={12} color={Colors.brand.midnight} weight='bold' textAlign='center'>{poll.priority}</Text>
70
69
  </View>
71
70
  <View style={{ flex:1 }}>
72
71
  {poll_campaign.campaign_type == 'trivia' && !poll_response && poll.status != 'closed' ?