be-components 7.0.6 → 7.0.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 (180) hide show
  1. package/lib/commonjs/Components/BETimePicker.js +110 -0
  2. package/lib/commonjs/Components/BETimePicker.js.map +1 -0
  3. package/lib/commonjs/Components/Icons.js +37 -0
  4. package/lib/commonjs/Components/Icons.js.map +1 -1
  5. package/lib/commonjs/Components/ImageUploader.js +4 -0
  6. package/lib/commonjs/Components/ImageUploader.js.map +1 -1
  7. package/lib/commonjs/Components/Slider.js +2 -0
  8. package/lib/commonjs/Components/Slider.js.map +1 -1
  9. package/lib/commonjs/Components/Themed.js +4 -2
  10. package/lib/commonjs/Components/Themed.js.map +1 -1
  11. package/lib/commonjs/CreateEngagement/api/index.js +89 -1
  12. package/lib/commonjs/CreateEngagement/api/index.js.map +1 -1
  13. package/lib/commonjs/CreateEngagement/index.js +306 -5
  14. package/lib/commonjs/CreateEngagement/index.js.map +1 -1
  15. package/lib/commonjs/FlashMarket/FlashHolder.js +14 -1
  16. package/lib/commonjs/FlashMarket/FlashHolder.js.map +1 -1
  17. package/lib/commonjs/FlashMarket/api/index.js +42 -0
  18. package/lib/commonjs/FlashMarket/api/index.js.map +1 -1
  19. package/lib/commonjs/FlashMarket/components/FlashOptionCard.js +265 -0
  20. package/lib/commonjs/FlashMarket/components/FlashOptionCard.js.map +1 -0
  21. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js +1244 -0
  22. package/lib/commonjs/FlashMarket/components/ManageFlashMarket.js.map +1 -0
  23. package/lib/commonjs/FlashMarket/index.js +18 -6
  24. package/lib/commonjs/FlashMarket/index.js.map +1 -1
  25. package/lib/commonjs/Group/api/index.js +6 -3
  26. package/lib/commonjs/Group/api/index.js.map +1 -1
  27. package/lib/commonjs/Group/index.js +135 -20
  28. package/lib/commonjs/Group/index.js.map +1 -1
  29. package/lib/commonjs/Poll/api/index.js +0 -1
  30. package/lib/commonjs/Poll/api/index.js.map +1 -1
  31. package/lib/commonjs/constants/useColors.js +2 -0
  32. package/lib/commonjs/constants/useColors.js.map +1 -1
  33. package/lib/commonjs/index.js +7 -0
  34. package/lib/commonjs/index.js.map +1 -1
  35. package/lib/commonjs/types.d.js.map +1 -1
  36. package/lib/module/Components/BETimePicker.js +102 -0
  37. package/lib/module/Components/BETimePicker.js.map +1 -0
  38. package/lib/module/Components/Icons.js +37 -0
  39. package/lib/module/Components/Icons.js.map +1 -1
  40. package/lib/module/Components/ImageUploader.js +4 -0
  41. package/lib/module/Components/ImageUploader.js.map +1 -1
  42. package/lib/module/Components/Slider.js +2 -0
  43. package/lib/module/Components/Slider.js.map +1 -1
  44. package/lib/module/Components/Themed.js +4 -2
  45. package/lib/module/Components/Themed.js.map +1 -1
  46. package/lib/module/CreateEngagement/api/index.js +89 -1
  47. package/lib/module/CreateEngagement/api/index.js.map +1 -1
  48. package/lib/module/CreateEngagement/index.js +306 -5
  49. package/lib/module/CreateEngagement/index.js.map +1 -1
  50. package/lib/module/FlashMarket/FlashHolder.js +14 -1
  51. package/lib/module/FlashMarket/FlashHolder.js.map +1 -1
  52. package/lib/module/FlashMarket/api/index.js +42 -0
  53. package/lib/module/FlashMarket/api/index.js.map +1 -1
  54. package/lib/module/FlashMarket/components/FlashOptionCard.js +258 -0
  55. package/lib/module/FlashMarket/components/FlashOptionCard.js.map +1 -0
  56. package/lib/module/FlashMarket/components/ManageFlashMarket.js +1236 -0
  57. package/lib/module/FlashMarket/components/ManageFlashMarket.js.map +1 -0
  58. package/lib/module/FlashMarket/index.js +18 -6
  59. package/lib/module/FlashMarket/index.js.map +1 -1
  60. package/lib/module/Group/api/index.js +6 -3
  61. package/lib/module/Group/api/index.js.map +1 -1
  62. package/lib/module/Group/index.js +135 -20
  63. package/lib/module/Group/index.js.map +1 -1
  64. package/lib/module/Poll/api/index.js +0 -1
  65. package/lib/module/Poll/api/index.js.map +1 -1
  66. package/lib/module/constants/useColors.js +2 -0
  67. package/lib/module/constants/useColors.js.map +1 -1
  68. package/lib/module/index.js +2 -1
  69. package/lib/module/index.js.map +1 -1
  70. package/lib/module/types.d.js.map +1 -1
  71. package/lib/typescript/lib/commonjs/Components/BETimePicker.d.ts +8 -0
  72. package/lib/typescript/lib/commonjs/Components/BETimePicker.d.ts.map +1 -0
  73. package/lib/typescript/lib/commonjs/Components/Icons.d.ts +5 -0
  74. package/lib/typescript/lib/commonjs/Components/Icons.d.ts.map +1 -1
  75. package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts +2 -1
  76. package/lib/typescript/lib/commonjs/Components/ImageUploader.d.ts.map +1 -1
  77. package/lib/typescript/lib/commonjs/Components/Slider.d.ts +2 -1
  78. package/lib/typescript/lib/commonjs/Components/Slider.d.ts.map +1 -1
  79. package/lib/typescript/lib/commonjs/Components/Themed.d.ts.map +1 -1
  80. package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts +40 -1
  81. package/lib/typescript/lib/commonjs/CreateEngagement/api/index.d.ts.map +1 -1
  82. package/lib/typescript/lib/commonjs/CreateEngagement/index.d.ts.map +1 -1
  83. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts +3 -1
  84. package/lib/typescript/lib/commonjs/FlashMarket/FlashHolder.d.ts.map +1 -1
  85. package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts +2 -0
  86. package/lib/typescript/lib/commonjs/FlashMarket/api/index.d.ts.map +1 -1
  87. package/lib/typescript/lib/commonjs/FlashMarket/components/FlashOptionCard.d.ts +13 -0
  88. package/lib/typescript/lib/commonjs/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
  89. package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts +11 -0
  90. package/lib/typescript/lib/commonjs/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
  91. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts +2 -1
  92. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts.map +1 -1
  93. package/lib/typescript/lib/commonjs/Group/api/index.d.ts.map +1 -1
  94. package/lib/typescript/lib/commonjs/Group/index.d.ts +2 -1
  95. package/lib/typescript/lib/commonjs/Group/index.d.ts.map +1 -1
  96. package/lib/typescript/lib/commonjs/Poll/api/index.d.ts.map +1 -1
  97. package/lib/typescript/lib/commonjs/constants/useColors.d.ts +1 -0
  98. package/lib/typescript/lib/commonjs/constants/useColors.d.ts.map +1 -1
  99. package/lib/typescript/lib/commonjs/index.d.ts +1 -0
  100. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  101. package/lib/typescript/lib/module/Components/BETimePicker.d.ts +8 -0
  102. package/lib/typescript/lib/module/Components/BETimePicker.d.ts.map +1 -0
  103. package/lib/typescript/lib/module/Components/Icons.d.ts +5 -0
  104. package/lib/typescript/lib/module/Components/Icons.d.ts.map +1 -1
  105. package/lib/typescript/lib/module/Components/ImageUploader.d.ts +2 -1
  106. package/lib/typescript/lib/module/Components/ImageUploader.d.ts.map +1 -1
  107. package/lib/typescript/lib/module/Components/Slider.d.ts +2 -1
  108. package/lib/typescript/lib/module/Components/Slider.d.ts.map +1 -1
  109. package/lib/typescript/lib/module/Components/Themed.d.ts.map +1 -1
  110. package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts +41 -1
  111. package/lib/typescript/lib/module/CreateEngagement/api/index.d.ts.map +1 -1
  112. package/lib/typescript/lib/module/CreateEngagement/index.d.ts.map +1 -1
  113. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts +3 -1
  114. package/lib/typescript/lib/module/FlashMarket/FlashHolder.d.ts.map +1 -1
  115. package/lib/typescript/lib/module/FlashMarket/api/index.d.ts +2 -0
  116. package/lib/typescript/lib/module/FlashMarket/api/index.d.ts.map +1 -1
  117. package/lib/typescript/lib/module/FlashMarket/components/FlashOptionCard.d.ts +13 -0
  118. package/lib/typescript/lib/module/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
  119. package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts +11 -0
  120. package/lib/typescript/lib/module/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
  121. package/lib/typescript/lib/module/FlashMarket/index.d.ts +2 -1
  122. package/lib/typescript/lib/module/FlashMarket/index.d.ts.map +1 -1
  123. package/lib/typescript/lib/module/Group/api/index.d.ts.map +1 -1
  124. package/lib/typescript/lib/module/Group/index.d.ts +2 -1
  125. package/lib/typescript/lib/module/Group/index.d.ts.map +1 -1
  126. package/lib/typescript/lib/module/Poll/api/index.d.ts.map +1 -1
  127. package/lib/typescript/lib/module/constants/useColors.d.ts +1 -0
  128. package/lib/typescript/lib/module/constants/useColors.d.ts.map +1 -1
  129. package/lib/typescript/lib/module/index.d.ts +2 -1
  130. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  131. package/lib/typescript/src/Components/BETimePicker.d.ts +11 -0
  132. package/lib/typescript/src/Components/BETimePicker.d.ts.map +1 -0
  133. package/lib/typescript/src/Components/Icons.d.ts +1 -0
  134. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  135. package/lib/typescript/src/Components/ImageUploader.d.ts +2 -1
  136. package/lib/typescript/src/Components/ImageUploader.d.ts.map +1 -1
  137. package/lib/typescript/src/Components/Slider.d.ts +2 -1
  138. package/lib/typescript/src/Components/Slider.d.ts.map +1 -1
  139. package/lib/typescript/src/Components/Themed.d.ts.map +1 -1
  140. package/lib/typescript/src/CreateEngagement/api/index.d.ts +8 -2
  141. package/lib/typescript/src/CreateEngagement/api/index.d.ts.map +1 -1
  142. package/lib/typescript/src/CreateEngagement/index.d.ts.map +1 -1
  143. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts +4 -2
  144. package/lib/typescript/src/FlashMarket/FlashHolder.d.ts.map +1 -1
  145. package/lib/typescript/src/FlashMarket/api/index.d.ts +2 -0
  146. package/lib/typescript/src/FlashMarket/api/index.d.ts.map +1 -1
  147. package/lib/typescript/src/FlashMarket/components/FlashOptionCard.d.ts +15 -0
  148. package/lib/typescript/src/FlashMarket/components/FlashOptionCard.d.ts.map +1 -0
  149. package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts +15 -0
  150. package/lib/typescript/src/FlashMarket/components/ManageFlashMarket.d.ts.map +1 -0
  151. package/lib/typescript/src/FlashMarket/index.d.ts +2 -1
  152. package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -1
  153. package/lib/typescript/src/Group/api/index.d.ts +5 -2
  154. package/lib/typescript/src/Group/api/index.d.ts.map +1 -1
  155. package/lib/typescript/src/Group/index.d.ts +3 -2
  156. package/lib/typescript/src/Group/index.d.ts.map +1 -1
  157. package/lib/typescript/src/Poll/api/index.d.ts.map +1 -1
  158. package/lib/typescript/src/constants/useColors.d.ts +1 -0
  159. package/lib/typescript/src/constants/useColors.d.ts.map +1 -1
  160. package/lib/typescript/src/index.d.ts +2 -1
  161. package/lib/typescript/src/index.d.ts.map +1 -1
  162. package/package.json +4 -2
  163. package/src/Components/BETimePicker.tsx +77 -0
  164. package/src/Components/Icons.tsx +17 -0
  165. package/src/Components/ImageUploader.tsx +3 -1
  166. package/src/Components/Slider.tsx +3 -1
  167. package/src/Components/Themed.tsx +6 -4
  168. package/src/CreateEngagement/api/index.ts +78 -2
  169. package/src/CreateEngagement/index.tsx +181 -7
  170. package/src/FlashMarket/FlashHolder.tsx +11 -2
  171. package/src/FlashMarket/api/index.ts +24 -1
  172. package/src/FlashMarket/components/FlashOptionCard.tsx +174 -0
  173. package/src/FlashMarket/components/ManageFlashMarket.tsx +769 -0
  174. package/src/FlashMarket/index.tsx +14 -8
  175. package/src/Group/api/index.ts +5 -5
  176. package/src/Group/index.tsx +84 -9
  177. package/src/Poll/api/index.ts +0 -2
  178. package/src/constants/useColors.tsx +2 -0
  179. package/src/index.tsx +2 -0
  180. package/src/types.d.ts +8 -1
@@ -15,9 +15,10 @@ type CldUploaderProps = {
15
15
  style?:ViewStyle,
16
16
  onCancelUpload?: () => void,
17
17
  children?:any,
18
+ disabled?:boolean,
18
19
  public_id: string
19
20
  }
20
- const ImageUploader = ({ style, onStartUpload, onFinishUpload, public_id, children }:CldUploaderProps) => {
21
+ const ImageUploader = ({ style, disabled, onStartUpload, onFinishUpload, public_id, children }:CldUploaderProps) => {
21
22
 
22
23
  /*
23
24
  const processFile = async (file:any) => {
@@ -120,6 +121,7 @@ const ImageUploader = ({ style, onStartUpload, onFinishUpload, public_id, childr
120
121
  }
121
122
 
122
123
  const handleClick = async() => {
124
+ if(disabled){ return alert('Unable to update image at this time') }
123
125
  if(onStartUpload){onStartUpload()}
124
126
  let result = await ImagePicker.launchImageLibraryAsync({
125
127
  mediaTypes: ['images', 'videos'],
@@ -7,6 +7,7 @@ type SliderProps = {
7
7
  minimum_value:number,
8
8
  maximum_value:number,
9
9
  value?:number,
10
+ disabled?:boolean,
10
11
  minimum_track_tint?:string,
11
12
  maximum_track_tint?:string,
12
13
  thumb_tint_color?:string,
@@ -14,12 +15,13 @@ type SliderProps = {
14
15
  onSlidingComplete?:(val:number) => void
15
16
  }
16
17
 
17
- const Slider = ({ width, value, minimum_track_tint, minimum_value, maximum_track_tint, maximum_value, thumb_tint_color, onSlidingStart, onSlidingComplete }:SliderProps) => {
18
+ const Slider = ({ width, value, minimum_track_tint, disabled, minimum_value, maximum_track_tint, maximum_value, thumb_tint_color, onSlidingStart, onSlidingComplete }:SliderProps) => {
18
19
 
19
20
  return (
20
21
  <RNSlider
21
22
  style={{ width, height:25 }}
22
23
  value={value}
24
+ disabled={disabled}
23
25
  minimumValue={minimum_value}
24
26
  minimumTrackTintColor={minimum_track_tint}
25
27
  maximumValue={maximum_value}
@@ -162,8 +162,8 @@ export const Button = (props:ButtonProps) => {
162
162
  }
163
163
  case 'warning':
164
164
  return {
165
- background_color: C.buttons.background.info,
166
- text_color: C.buttons.text.info,
165
+ background_color: C.buttons.background.warning,
166
+ text_color: C.text.white,
167
167
  border_color: C.buttons.borders.info,
168
168
  border_width:0
169
169
  }
@@ -269,12 +269,14 @@ export const TextInput = (props:TextInputProps) => {
269
269
  const borderWidth = transparent ? 0 : 1
270
270
  const placeholder_color = C.text.placholder
271
271
  const font_family = getFamily();
272
-
273
272
  return (
274
273
  <DefaultTextInput
275
274
  ref={inputRef}
275
+ multiline={props.multiline}
276
+ onSubmitEditing={props.onSubmitEditing}
276
277
  placeholderTextColor={placeholder_color}
277
- style={[{ padding:15, backgroundColor: background, borderColor: border, borderWidth, color, fontFamily: font_family }, style]} { ...otherProps }
278
+ style={[{ padding:15, backgroundColor: background, borderColor: border, borderWidth, color, fontFamily: font_family }, style]}
279
+ { ...otherProps }
278
280
  onFocus={handleFocus}
279
281
  />
280
282
  )
@@ -1,7 +1,8 @@
1
1
  import axios from "axios";
2
- import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, GroupPlayerProps, GroupProps, LeagueProps, SquaresCompetitionProps } from "../../types";
2
+ import type { CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, GroupPlayerProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, SquaresCompetitionProps } from "../../types";
3
3
  import { APIOverrides } from "../../ApiOverrides";
4
4
  import type { CompanyMemberProps } from "../../Authenticator/api/types";
5
+ import moment from "moment-mini";
5
6
 
6
7
  let AUTH_SVC_API = ''
7
8
  let TP_SVC_API = ''
@@ -80,12 +81,45 @@ const CreateEngagementApi = {
80
81
  } catch (e) {
81
82
  return undefined
82
83
  }
84
+ },
85
+ createPoll : async(poll:PollProps):Promise<PollProps | undefined> => {
86
+ try {
87
+ const resp = await axios.post(`${AUTH_SVC_API}/v1/polls/poll/create`, { poll })
88
+ return resp.data.poll
89
+ } catch (e) {
90
+ return undefined
91
+ }
92
+ },
93
+ createPollCampaign: async(poll_campaign:PollCampaignProps):Promise<PollCampaignProps | undefined> => {
94
+ try {
95
+ const resp = await axios.post(`${AUTH_SVC_API}/v1/polls/campaigns/campaign/create`, { poll_campaign })
96
+ return resp.data.poll_campaign
97
+ } catch (e) {
98
+ return undefined
99
+ }
100
+ },
101
+ getMyAdminFlashCampaigns: async():Promise<PollCampaignProps[]> => {
102
+ try {
103
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/admin/active`);
104
+ return resp.data.poll_campaigns
105
+ } catch (e) {
106
+ return []
107
+ }
108
+ },
109
+ getCompanyActiveFlashCampaigns: async(company_id:string):Promise<PollCampaignProps[]> => {
110
+ try {
111
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/company/active/${company_id}`);
112
+ return resp.data.poll_campaigns
113
+ } catch (e) {
114
+ console.log(e);
115
+ return []
116
+ }
83
117
  }
84
118
  }
85
119
 
86
120
 
87
121
  const CreateEngagementHelpers = {
88
- isStepValid: (step:CreateEngagementStepProps, active_engagement?:string, draft_competition?:any, draft_squares?:SquaresCompetitionProps):string[] => {
122
+ isStepValid: (step:CreateEngagementStepProps, active_engagement?:string, draft_competition?:any, draft_squares?:SquaresCompetitionProps, draft_flash?:PollProps):string[] => {
89
123
  let errors:string[] = []
90
124
  switch(step.step_key){
91
125
  case 'intro': return errors
@@ -107,6 +141,11 @@ const CreateEngagementHelpers = {
107
141
  if(!draft_squares.sq_comp_description){ errors.push('Please add a description') }
108
142
  if(!draft_squares.event_id){ errors.push('Please add an event') }
109
143
  break
144
+ case 'flash':
145
+ if(!draft_flash){ errors.push('Please complete the required steps') }
146
+ if(!draft_flash?.poll_question){ errors.push('Please add a poll question') }
147
+ if(!draft_flash?.poll_campaign_id){ errors.push('Please add to a compaign') }
148
+ break
110
149
  default: break
111
150
  }
112
151
  break
@@ -134,5 +173,42 @@ const CreateEngagementHelpers = {
134
173
  potential_winnings: 0,
135
174
  create_datetime: '',last_update_datetime: ''
136
175
  }
176
+ },
177
+ generateEmptyFlashCampaign:():PollCampaignProps => {
178
+ return {
179
+ poll_campaign_id: '',
180
+ name: '',
181
+ market_type: 'FOR_MONEY',
182
+ admins: [],
183
+ player_id: '',
184
+ company_id: '',
185
+ status: 'active',
186
+ phone: '0',
187
+ total_responses: 0,
188
+ create_datetime: '', last_update_datetime: '',
189
+ campaign_type: 'predict',
190
+ close_message_sent: false
191
+ }
192
+ },
193
+ generateFlashMarket: ():PollProps => {
194
+ return {
195
+ poll_campaign_id:'',
196
+ poll_id:'',
197
+ poll_question: '',
198
+ max_stake: 25,
199
+ minimum_stake: 1,
200
+ market_type: 'FOR_MONEY',
201
+ status: 'pending',
202
+ base_stake: 10,
203
+ require_resolution: true,
204
+ poll_type: 'select',
205
+ show_responses: true,
206
+ priority: 1,
207
+ end_datetime: moment().add(1, 'day'),
208
+ manual_close_only: false,
209
+ stake_increase_allowed: true,
210
+ multi_responses_allowed: true,
211
+ create_datetime: '', last_update_datetime:''
212
+ }
137
213
  }
138
214
  }
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useState } from 'react';
2
2
  import { Button, Text, TextInput, View } from "../Components/Themed"
3
- import type { BracketCompetitionProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, EventProps, FocusPositionProps, GroupProps, LeagueProps, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
3
+ import type { BracketCompetitionProps, CompanyProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, CreateEngagementStepProps, EventProps, FocusPositionProps, GroupProps, LeagueProps, PollCampaignProps, PollProps, PublicPlayerProps, SquaresCompetitionProps } from '../types';
4
4
  import { FlatList, Image, type ViewStyle } from 'react-native';
5
5
  import { CreateEngagementApi, CreateEngagementHelpers } from './api';
6
6
  import { Icons } from '../Components';
@@ -49,7 +49,8 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
49
49
  squares_competition?:SquaresCompetitionProps
50
50
  }>({
51
51
  create_loading: false
52
- })
52
+ });
53
+ const [ draft_flash, setDraftFlash ] = useState<PollProps | undefined>(undefined);
53
54
  const [ draft_competition, setDraftCompetition ] = useState<undefined | {
54
55
  loading:boolean,
55
56
  types_visible:boolean,
@@ -66,7 +67,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
66
67
  }>(undefined);
67
68
 
68
69
  const [ draft_image, setDraftImage ] = useState<any>(undefined);
69
- const [ active_step, setActiveStep ] = useState<CreateEngagementStepProps>(steps[0] as CreateEngagementStepProps)
70
+ const [ active_step, setActiveStep ] = useState<CreateEngagementStepProps>(steps[4] as CreateEngagementStepProps)
70
71
  const [ state, setState ] = useState<{
71
72
  loading: boolean,
72
73
  active_engagment?:'competition'|'squares'|'flash'|'bracket',
@@ -77,6 +78,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
77
78
  }>({
78
79
  loading:false,
79
80
  groups: [],
81
+ active_engagment: 'flash',
80
82
  companies: []
81
83
  });
82
84
 
@@ -103,7 +105,7 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
103
105
  loading:false
104
106
  })
105
107
  }
106
- const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares);
108
+ const errors = CreateEngagementHelpers.isStepValid(active_step, active_engagment, draft_competition, draft_squares, draft_flash);
107
109
 
108
110
  const handleNextStep = async() => {
109
111
  if(errors.length > 0){ return alert(errors.map(e => e)) }
@@ -164,6 +166,14 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
164
166
  const new_squares_comp = await CreateEngagementApi.createSquaresCompetition({ ...draft_squares, image: draft_image, company_id: active_company?.company_id, group_id: active_group?.group_id});
165
167
  setPendingEngagement({ ...pending_engagement, create_loading: false, squares_competition: new_squares_comp });
166
168
  break
169
+ case 'flash':
170
+ if(!draft_flash){ return alert('Unable to process') }
171
+ if(errors.length > 0){ return alert(errors.map(e => e)) }
172
+ setPendingEngagement({ ...pending_engagement, create_loading: true });
173
+ const new_flash_market = await CreateEngagementApi.createPoll({ ...draft_flash, poll_image: draft_image });
174
+ if(!new_flash_market){ return alert('Unable to process') }
175
+ setPendingEngagement({ ...pending_engagement, create_loading: false, poll: new_flash_market });
176
+ break
167
177
  default: return //We cdont have one!
168
178
  }
169
179
 
@@ -305,11 +315,14 @@ const CreateEngagement = ({ float, player, init_engagement, onFocusPostiion, gro
305
315
  )
306
316
  case 'create':
307
317
  if(active_step.step_key != 'create'){ return <></> }
318
+ if(!player){ return <></> }
308
319
  switch(active_engagment){
309
320
  case 'competition':
310
321
  return <CreateCompetition onUpdateDraft={(d) => setDraftCompetition(d)} onFocusPosition={onFocusPostiion} />
311
322
  case 'squares':
312
323
  return <CreateSquares onUpdateDraft={(d) => setDraftSquares(d)} onFocusPosition={onFocusPostiion}/>
324
+ case 'flash':
325
+ return <CreateFlashMarket group={active_group} onUpdateDraft={(d) => setDraftFlash(d)} onFocusPosition={onFocusPostiion} company={active_company}/>
313
326
  default: return <></>
314
327
  }
315
328
  default: return <></>
@@ -396,6 +409,169 @@ const IntroInfo = () => {
396
409
  )
397
410
  }
398
411
 
412
+ type CreateFlashMarketProps = {
413
+ company?:CompanyProps,
414
+ group?:GroupProps,
415
+ onFocusPosition?:(pos:FocusPositionProps) => void,
416
+ onUpdateDraft: (poll:PollProps) => void
417
+ }
418
+
419
+ const CreateFlashMarket = ({ company, group, onFocusPosition, onUpdateDraft }:CreateFlashMarketProps) => {
420
+ //Get active campaigns
421
+ const Colors = useColors();
422
+ const [ create_state, setCreateState ] = useState<{
423
+ draft_poll: PollProps,
424
+ campaign_loading:boolean,
425
+ new_campaign?:boolean,
426
+ draft_campaign:PollCampaignProps,
427
+ campaigns_visible:boolean,
428
+ poll_campaigns:PollCampaignProps[]
429
+ }>({
430
+ draft_poll: CreateEngagementHelpers.generateFlashMarket(),
431
+ campaigns_visible: false,
432
+ new_campaign: false,
433
+ campaign_loading:false,
434
+ draft_campaign: CreateEngagementHelpers.generateEmptyFlashCampaign(),
435
+ poll_campaigns: []
436
+ });
437
+ const { draft_poll, campaigns_visible, campaign_loading, draft_campaign, poll_campaigns, new_campaign } = create_state;
438
+ const active_campaign = poll_campaigns.find(pc => pc.poll_campaign_id == draft_poll.poll_campaign_id);
439
+ useEffect(() => {
440
+ getData();
441
+ },[company?.company_id, group?.group_id]);
442
+
443
+ useEffect(() => {
444
+ onUpdateDraft(draft_poll);
445
+ },[JSON.stringify(draft_poll)]);
446
+
447
+ const getData = async() => {
448
+ let pc = await CreateEngagementApi.getMyAdminFlashCampaigns();
449
+ if(company){
450
+ pc = await CreateEngagementApi.getCompanyActiveFlashCampaigns(company.company_id)
451
+ }
452
+ if(group){
453
+ pc = pc.filter(c => c.group_id == group.group_id)
454
+ }
455
+ setCreateState({
456
+ ...create_state,
457
+ poll_campaigns: pc.filter(pc => pc.market_type == 'FOR_MONEY')
458
+ })
459
+ }
460
+
461
+ const renderCampaigns = (data:{ item:PollCampaignProps, index:number }) => {
462
+ return (
463
+ <Button
464
+ transparent
465
+ style={{ flexDirection:'row', alignItems:'center', padding:10, borderRadius:0, borderBottomWidth:1, borderColor:Colors.borders.light }}
466
+ onPress={() => setCreateState({ ...create_state, campaigns_visible:false, draft_poll: { ...draft_poll, poll_campaign_id: data.item.poll_campaign_id } })}
467
+ >
468
+ <Image
469
+ source={{ uri: data.item.campaign_image?.url }}
470
+ style={{ height:40, width:40 }}
471
+ resizeMode='cover'
472
+ />
473
+ <View transparent style={{ flex:1, marginLeft:10 }}>
474
+ <Text theme='h1'>{data.item.name}</Text>
475
+ </View>
476
+ </Button>
477
+ )
478
+ }
479
+
480
+ return (
481
+ <View style={{ padding:10 }}>
482
+ <View style={{ padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}>
483
+ <View transparent style={{ flexDirection:'row', alignItems:'center', marginBottom:10 }}>
484
+ <View transparent style={{ flex:1 }}>
485
+ <Text theme='h1'>Select Campaign</Text>
486
+ <Text theme='description' style={{ marginTop:4 }}>Group your flash markets into like campaigns to better manage them</Text>
487
+ <Button
488
+ title={!new_campaign?'Create a new campaign' : 'Select Existing Campaign'}
489
+ title_color={ new_campaign?Colors.text.action:Colors.text.success }
490
+ transparent
491
+ style={{ alignItems:'flex-start', padding:10, paddingLeft:0 }}
492
+ onPress={() => setCreateState({ ...create_state, new_campaign: !new_campaign })}
493
+ />
494
+ </View>
495
+ </View>
496
+ {!new_campaign ?
497
+ <Button float onPress={() => setCreateState({ ...create_state, campaigns_visible:!campaigns_visible }) }>
498
+ <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
499
+ <Text style={{ flex:1, marginRight:10 }} theme='h1'>{active_campaign?.name ?? 'No Campaign'}</Text>
500
+ <Icons.ChevronIcon direction={campaigns_visible?'up':'down'} color={Colors.text.h1} size={8} />
501
+ </View>
502
+ {campaigns_visible ?
503
+ <View transparent style={{ marginTop:20 }}>
504
+ <FlatList
505
+ data={poll_campaigns}
506
+ key={'campaign_selector'}
507
+ keyExtractor={item => item.poll_campaign_id.toString()}
508
+ renderItem={renderCampaigns}
509
+ />
510
+ </View>
511
+ :<></>}
512
+ </Button>
513
+ :
514
+ <View>
515
+ <View transparent style={{ marginBottom:10 }}>
516
+ <Text theme='h1'>Campaign Name</Text>
517
+ <Text theme='description' style={{ marginTop:4 }}>Enter the campaign name here. Use a name that appropriately groups the flash markets</Text>
518
+ </View>
519
+ <TextInput
520
+ placeholder='Add Campaign Name here...'
521
+ value={draft_campaign.name}
522
+ onFocusPosition={onFocusPosition}
523
+ style={{ borderColor:draft_campaign.name ? Colors.text.success : Colors.text.warning }}
524
+ onChangeText={(text) => setCreateState({ ...create_state, draft_campaign: { ...draft_campaign, name: text } })}
525
+ />
526
+ <Button
527
+ title='CREATE CAMPAIGN'
528
+ loading={campaign_loading}
529
+ type='success'
530
+ disabled={!draft_campaign.name ? true : false}
531
+ style={{ opacity: campaign_loading || !draft_campaign.name ? 0.5: 1, marginTop:10 }}
532
+ onPress={async() => {
533
+ if(campaign_loading){ return }
534
+ if(!draft_campaign.name){ return }
535
+ //Create the new campaign!
536
+ setCreateState({ ...create_state, campaign_loading:true });
537
+ const new_pc = await CreateEngagementApi.createPollCampaign({ ...draft_campaign, group_id: group?.group_id, company_id: company?.company_id, campaign_image: company?.company_image })
538
+ if(!new_pc){
539
+ alert('Unable to create a campaign at this time');
540
+ setCreateState({ ...create_state, campaign_loading: false });
541
+ return
542
+ }
543
+ setCreateState({
544
+ ...create_state,
545
+ campaign_loading: false,
546
+ new_campaign: false,
547
+ draft_poll: { ...draft_poll, poll_campaign_id: new_pc.poll_campaign_id },
548
+ poll_campaigns: poll_campaigns.concat(new_pc)
549
+ });
550
+ }}
551
+ />
552
+ </View>
553
+ }
554
+ {group && !new_campaign ?
555
+ <Text theme='warning' style={{ marginTop:5 }}>Only showing campaigns associated with the {group.name} group. If you need a different campaign - go back and unselect this group.</Text>
556
+ :<></>}
557
+ </View>
558
+ <View style={{ padding:10 }}>
559
+ <View transparent style={{ marginBottom:10 }}>
560
+ <Text theme='h1'>Question Name</Text>
561
+ <Text theme='description' style={{ marginTop:4 }}>Enter the question here. You can modify it up until you activate it.</Text>
562
+ </View>
563
+ <TextInput
564
+ placeholder='Add Question here...'
565
+ value={draft_poll.poll_question}
566
+ onFocusPosition={onFocusPosition}
567
+ style={{ borderColor:draft_poll.poll_question ? Colors.text.success : Colors.text.warning }}
568
+ onChangeText={(text) => setCreateState({ ...create_state, draft_poll: { ...draft_poll, poll_question: text } })}
569
+ />
570
+ </View>
571
+ </View>
572
+ )
573
+ }
574
+
399
575
  type EngagementOptionProps = {
400
576
  active_engagement?: 'competition'|'squares'|'flash'|'bracket',
401
577
  onSelectEngagement: (engagement:'competition'|'squares'|'flash'|'bracket') => void
@@ -442,7 +618,6 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
442
618
  </View>
443
619
  </Button>
444
620
  :<></>}
445
- {false ?
446
621
  <Button
447
622
  key='flash'
448
623
  float
@@ -455,7 +630,6 @@ const EngagementOptions = ({active_engagement, onSelectEngagement}:EngagementOpt
455
630
  <Text theme='description' color={active_engagement == 'flash' ? Colors.text.success : Colors.text.h1} style={{ marginTop:4 }}>Create a custom flash market. Players bet on the perimutuel outcomes, get it right and get paid!</Text>
456
631
  </View>
457
632
  </Button>
458
- :<></>}
459
633
  </View>
460
634
  )
461
635
  }
@@ -719,6 +893,7 @@ const CreateCompetition = ({ onFocusPosition, onUpdateDraft }:CCProps) => {
719
893
  const { competition_name, competition_template_id, templates_visible, competition_description,competition_result_types, types_visible, competition_types, results_visible, competition_type, competition_result_type } = draft;
720
894
  const template = templates.find(t => t.competition_id == competition_template_id)
721
895
  useEffect(() => {
896
+ CreateEngagementApi.setEnvironment();
722
897
  getData();
723
898
  },[]);
724
899
 
@@ -728,7 +903,6 @@ const CreateCompetition = ({ onFocusPosition, onUpdateDraft }:CCProps) => {
728
903
 
729
904
  const getData = async() => {
730
905
  setDraft({ ...draft, loading:true });
731
- CreateEngagementApi.setEnvironment();
732
906
  let options = await CreateEngagementApi.getCompetitionOptions();
733
907
  let temps = await CreateEngagementApi.getTemplateCompetitions();
734
908
  setDraft({
@@ -21,6 +21,7 @@ type FlashHolderProps = {
21
21
  contest_type?:string,
22
22
  parent_style?:ViewStyle,
23
23
  hide_footer?:boolean,
24
+ poll_campaign_id?:string,
24
25
  contest_id?:string,
25
26
  hide_tabs?:boolean,
26
27
  style?:ViewStyle,
@@ -31,13 +32,14 @@ type FlashHolderProps = {
31
32
  side_id?:string,
32
33
  default_poll_id?:string,
33
34
  poll_id?:string,
35
+ onManageFlash?: (poll:PollProps) => void,
34
36
  onSelectCompactPoll?:(poll_id:string) => void,
35
37
  onRequestLocation:() => void,
36
38
  onFocusPosition?: (position:{ x:number, y:number, width:number, height:number }) => void,
37
39
  onRequestAuthenticate: () => void
38
40
  }
39
41
  const sections = [ 'selector','explainer','flash_market','options','footer' ]
40
- const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_timer, distinct_id, hide_footer, no_highlight, hide_tabs, parent_style, league_id, init_expanded, player_id, player, location, contest_type, contest_id, side_type, side_id, poll_id, onSelectCompactPoll, onRequestAuthenticate, onFocusPosition, onRequestLocation } : FlashHolderProps) => {
42
+ const FlashHolder = ({ float, poll_campaign_id, company_id, compact, style, default_poll_id, hide_timer, distinct_id, hide_footer, no_highlight, hide_tabs, parent_style, league_id, init_expanded, player_id, player, location, contest_type, contest_id, side_type, side_id, poll_id, onSelectCompactPoll, onRequestAuthenticate, onFocusPosition, onRequestLocation, onManageFlash } : FlashHolderProps) => {
41
43
  const Colors = useColors();
42
44
  const [ needs_reload, setNeedsReload ] = useState(false);
43
45
  const [ socket_campaigns, setSocketCampaigns ] = useState<PollCampaignProps[]>([]);
@@ -77,7 +79,7 @@ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_
77
79
  const [ active_flash_market, setActiveFlashMarket ] = useState<string | undefined>(undefined);
78
80
  const flash_market = flash_markets.find(fm => fm.poll_id == active_flash_market);
79
81
  const sorted_flashes = flash_markets.sort((a,b) => moment(a.end_datetime).unix() - moment(b.end_datetime).unix() || parseInt(a.poll_id) - parseInt(b.poll_id))
80
-
82
+
81
83
  useEffect(() => {
82
84
  loadData();
83
85
  },[league_id, contest_type, contest_id, side_type, side_id, poll_id]);
@@ -167,6 +169,12 @@ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_
167
169
  return handleSelectPoll(poll_id, options);
168
170
  }
169
171
 
172
+ if(poll_campaign_id){
173
+ let resp = await FlashMarketApi.getPollsByCampaignId(poll_campaign_id);
174
+ let active_polls = resp.filter(p => p.status != 'closed');
175
+ setFlashData({ ...flash_data, loaded:true, holder_loading: false, flash_markets:active_polls })
176
+ }
177
+
170
178
  let found_polls:PollProps[] = []
171
179
  if(company_id){
172
180
  let resp = await FlashMarketApi.getActiveMarkets(company_id);
@@ -301,6 +309,7 @@ const FlashHolder = ({ float, company_id, compact, style, default_poll_id, hide_
301
309
  header_style={{ borderTopRightRadius:0, borderTopLeftRadius:0 }}
302
310
  onReload={() => loadMarket(active_flash_market)}
303
311
  onRequestAuthenticate={onRequestAuthenticate}
312
+ onManageFlash={onManageFlash}
304
313
  onRequestLocation={onRequestLocation}
305
314
  onFocusPosition={onFocusPosition}
306
315
  />
@@ -29,6 +29,14 @@ const FlashMarketApi = {
29
29
  return undefined
30
30
  }
31
31
  },
32
+ getPollsByCampaignId: async(poll_campaign_id:string):Promise<PollProps[]> => {
33
+ try {
34
+ const resp = await axios.get(`${AUTH_SVC_API}/v1/polls/campaign/${poll_campaign_id}`);
35
+ return resp.data.polls
36
+ } catch (e) {
37
+ return []
38
+ }
39
+ },
32
40
  getActiveFlashMarkets: async():Promise<PollProps[]> => {
33
41
  try {
34
42
  const resp = await axios.get(`${AUTH_SVC_API}/v2/pm/flash/active`);
@@ -107,7 +115,22 @@ export const FlashMarketHelpers = {
107
115
  toWin: (stake:number, parimutuel_odds?:number):number => {
108
116
  if(!parimutuel_odds){ return 0 }
109
117
  return stake / parimutuel_odds
110
-
118
+ },
119
+ isNewValid: (options:PollOptionProps[], summaries:PollSummaryProps[], poll?:PollProps) => {
120
+ let errors:string[] = []
121
+ if(!poll){ return ['Waiting for market'] }
122
+ options.map(o => !o.option_name ? errors.push('Option must have a valid name') : console.log(''))
123
+ if(options.length <= 1){ errors.push('Need at least 2 options') }
124
+ let total_prob = options.reduce((a,b) => a + (b.initial_odds ?? 0), 0);
125
+ let total_stake = summaries.reduce((a,b) => a + b.count, 0)
126
+ if(!poll.poll_question){ errors.push('Please enter a question') }
127
+ if(poll.max_stake < 1){ errors.push('Max stake must be at least $1') }
128
+ if(poll.minimum_stake < 0.1){ errors.push('Min stake must be greater than 10 cents') }
129
+ if(moment().isAfter(moment(poll.end_datetime))){ errors.push('Market close time is in the past') }
130
+ if(poll.status != 'pending'){ errors.push('Only pending markets can be activated') }
131
+ if(total_stake > 0){ errors.push('Cannot activate with existing responses') }
132
+ if(total_prob.toFixed(2) != '1.00'){ errors.push('Initial probabilities do not add to 1') }
133
+ return errors
111
134
  },
112
135
  getResponseStats: (option:PollOptionProps, poll_response?:PollResponseProps) => {
113
136
  let empty_reponse = { stake: 0, potential_winnings: 0, winnings: 0, earnings:0 }