be-components 1.4.9 → 1.5.1

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 (214) hide show
  1. package/lib/commonjs/Competition/api/index.js +15 -0
  2. package/lib/commonjs/Competition/api/index.js.map +1 -1
  3. package/lib/commonjs/Competition/components/CompetitionSeasonCard.js +1 -1
  4. package/lib/commonjs/Competition/components/CompetitionSeasonCard.js.map +1 -1
  5. package/lib/commonjs/Competition/components/SeasonCard.js +61 -0
  6. package/lib/commonjs/Competition/components/SeasonCard.js.map +1 -0
  7. package/lib/commonjs/Competition/index.js +23 -3
  8. package/lib/commonjs/Competition/index.js.map +1 -1
  9. package/lib/commonjs/CompetitionManager/api/index.js +3 -5
  10. package/lib/commonjs/CompetitionManager/api/index.js.map +1 -1
  11. package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js +1 -61
  12. package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js.map +1 -1
  13. package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js +6 -1
  14. package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
  15. package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js +4 -0
  16. package/lib/commonjs/CompetitionManager/components/ContestSettingsForm.js.map +1 -1
  17. package/lib/commonjs/CompetitionManager/components/CreateCompetitionForm.js +37 -3
  18. package/lib/commonjs/CompetitionManager/components/CreateCompetitionForm.js.map +1 -1
  19. package/lib/commonjs/CompetitionSeason/api/index.js +134 -0
  20. package/lib/commonjs/CompetitionSeason/api/index.js.map +1 -0
  21. package/lib/commonjs/CompetitionSeason/components/CompetitionsSection.js +127 -0
  22. package/lib/commonjs/CompetitionSeason/components/CompetitionsSection.js.map +1 -0
  23. package/lib/commonjs/CompetitionSeason/components/EnterSeasonPrompt.js +253 -0
  24. package/lib/commonjs/CompetitionSeason/components/EnterSeasonPrompt.js.map +1 -0
  25. package/lib/commonjs/CompetitionSeason/components/SeasonHeader.js +126 -0
  26. package/lib/commonjs/CompetitionSeason/components/SeasonHeader.js.map +1 -0
  27. package/lib/commonjs/CompetitionSeason/components/SeasonLeaderboard.js +324 -0
  28. package/lib/commonjs/CompetitionSeason/components/SeasonLeaderboard.js.map +1 -0
  29. package/lib/commonjs/CompetitionSeason/components/SeasonSettingsSection.js +175 -0
  30. package/lib/commonjs/CompetitionSeason/components/SeasonSettingsSection.js.map +1 -0
  31. package/lib/commonjs/CompetitionSeason/index.js +278 -0
  32. package/lib/commonjs/CompetitionSeason/index.js.map +1 -0
  33. package/lib/commonjs/CompetitionSeasonManager/api/index.js +182 -0
  34. package/lib/commonjs/CompetitionSeasonManager/api/index.js.map +1 -0
  35. package/lib/commonjs/CompetitionSeasonManager/components/CompetitionSelector.js +2 -0
  36. package/lib/commonjs/CompetitionSeasonManager/components/CompetitionSelector.js.map +1 -0
  37. package/lib/commonjs/CompetitionSeasonManager/components/CompetitionsForm.js +153 -0
  38. package/lib/commonjs/CompetitionSeasonManager/components/CompetitionsForm.js.map +1 -0
  39. package/lib/commonjs/CompetitionSeasonManager/components/CreateSeasonForm.js +388 -0
  40. package/lib/commonjs/CompetitionSeasonManager/components/CreateSeasonForm.js.map +1 -0
  41. package/lib/commonjs/CompetitionSeasonManager/components/SeasonHeader.js +108 -0
  42. package/lib/commonjs/CompetitionSeasonManager/components/SeasonHeader.js.map +1 -0
  43. package/lib/commonjs/CompetitionSeasonManager/components/SeasonInfoForm.js +242 -0
  44. package/lib/commonjs/CompetitionSeasonManager/components/SeasonInfoForm.js.map +1 -0
  45. package/lib/commonjs/CompetitionSeasonManager/components/SeasonSettingsForm.js +352 -0
  46. package/lib/commonjs/CompetitionSeasonManager/components/SeasonSettingsForm.js.map +1 -0
  47. package/lib/commonjs/CompetitionSeasonManager/index.js +190 -0
  48. package/lib/commonjs/CompetitionSeasonManager/index.js.map +1 -0
  49. package/lib/commonjs/Components/Switch.js +3 -0
  50. package/lib/commonjs/Components/Switch.js.map +1 -1
  51. package/lib/commonjs/Engage/api/index.js +25 -0
  52. package/lib/commonjs/Engage/api/index.js.map +1 -1
  53. package/lib/commonjs/Engage/components/SeasonCard.js +78 -0
  54. package/lib/commonjs/Engage/components/SeasonCard.js.map +1 -0
  55. package/lib/commonjs/Engage/index.js +52 -1
  56. package/lib/commonjs/Engage/index.js.map +1 -1
  57. package/lib/commonjs/index.js +14 -0
  58. package/lib/commonjs/index.js.map +1 -1
  59. package/lib/module/Competition/api/index.js +15 -0
  60. package/lib/module/Competition/api/index.js.map +1 -1
  61. package/lib/module/Competition/components/CompetitionSeasonCard.js +1 -1
  62. package/lib/module/Competition/components/CompetitionSeasonCard.js.map +1 -1
  63. package/lib/module/Competition/components/SeasonCard.js +54 -0
  64. package/lib/module/Competition/components/SeasonCard.js.map +1 -0
  65. package/lib/module/Competition/index.js +23 -3
  66. package/lib/module/Competition/index.js.map +1 -1
  67. package/lib/module/CompetitionManager/api/index.js +3 -5
  68. package/lib/module/CompetitionManager/api/index.js.map +1 -1
  69. package/lib/module/CompetitionManager/components/CompetitionInfoForm.js +1 -63
  70. package/lib/module/CompetitionManager/components/CompetitionInfoForm.js.map +1 -1
  71. package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js +6 -1
  72. package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -1
  73. package/lib/module/CompetitionManager/components/ContestSettingsForm.js +4 -0
  74. package/lib/module/CompetitionManager/components/ContestSettingsForm.js.map +1 -1
  75. package/lib/module/CompetitionManager/components/CreateCompetitionForm.js +37 -3
  76. package/lib/module/CompetitionManager/components/CreateCompetitionForm.js.map +1 -1
  77. package/lib/module/CompetitionSeason/api/index.js +128 -0
  78. package/lib/module/CompetitionSeason/api/index.js.map +1 -0
  79. package/lib/module/CompetitionSeason/components/CompetitionsSection.js +118 -0
  80. package/lib/module/CompetitionSeason/components/CompetitionsSection.js.map +1 -0
  81. package/lib/module/CompetitionSeason/components/EnterSeasonPrompt.js +244 -0
  82. package/lib/module/CompetitionSeason/components/EnterSeasonPrompt.js.map +1 -0
  83. package/lib/module/CompetitionSeason/components/SeasonHeader.js +119 -0
  84. package/lib/module/CompetitionSeason/components/SeasonHeader.js.map +1 -0
  85. package/lib/module/CompetitionSeason/components/SeasonLeaderboard.js +315 -0
  86. package/lib/module/CompetitionSeason/components/SeasonLeaderboard.js.map +1 -0
  87. package/lib/module/CompetitionSeason/components/SeasonSettingsSection.js +166 -0
  88. package/lib/module/CompetitionSeason/components/SeasonSettingsSection.js.map +1 -0
  89. package/lib/module/CompetitionSeason/index.js +269 -0
  90. package/lib/module/CompetitionSeason/index.js.map +1 -0
  91. package/lib/module/CompetitionSeasonManager/api/index.js +176 -0
  92. package/lib/module/CompetitionSeasonManager/api/index.js.map +1 -0
  93. package/lib/module/CompetitionSeasonManager/components/CompetitionSelector.js +2 -0
  94. package/lib/module/CompetitionSeasonManager/components/CompetitionSelector.js.map +1 -0
  95. package/lib/module/CompetitionSeasonManager/components/CompetitionsForm.js +144 -0
  96. package/lib/module/CompetitionSeasonManager/components/CompetitionsForm.js.map +1 -0
  97. package/lib/module/CompetitionSeasonManager/components/CreateSeasonForm.js +379 -0
  98. package/lib/module/CompetitionSeasonManager/components/CreateSeasonForm.js.map +1 -0
  99. package/lib/module/CompetitionSeasonManager/components/SeasonHeader.js +101 -0
  100. package/lib/module/CompetitionSeasonManager/components/SeasonHeader.js.map +1 -0
  101. package/lib/module/CompetitionSeasonManager/components/SeasonInfoForm.js +233 -0
  102. package/lib/module/CompetitionSeasonManager/components/SeasonInfoForm.js.map +1 -0
  103. package/lib/module/CompetitionSeasonManager/components/SeasonSettingsForm.js +343 -0
  104. package/lib/module/CompetitionSeasonManager/components/SeasonSettingsForm.js.map +1 -0
  105. package/lib/module/CompetitionSeasonManager/index.js +181 -0
  106. package/lib/module/CompetitionSeasonManager/index.js.map +1 -0
  107. package/lib/module/Components/Switch.js +3 -0
  108. package/lib/module/Components/Switch.js.map +1 -1
  109. package/lib/module/Engage/api/index.js +25 -0
  110. package/lib/module/Engage/api/index.js.map +1 -1
  111. package/lib/module/Engage/components/SeasonCard.js +71 -0
  112. package/lib/module/Engage/components/SeasonCard.js.map +1 -0
  113. package/lib/module/Engage/index.js +52 -1
  114. package/lib/module/Engage/index.js.map +1 -1
  115. package/lib/module/index.js +3 -1
  116. package/lib/module/index.js.map +1 -1
  117. package/lib/typescript/src/Competition/api/index.d.ts +1 -0
  118. package/lib/typescript/src/Competition/api/index.d.ts.map +1 -1
  119. package/lib/typescript/src/Competition/components/SeasonCard.d.ts +10 -0
  120. package/lib/typescript/src/Competition/components/SeasonCard.d.ts.map +1 -0
  121. package/lib/typescript/src/Competition/index.d.ts +3 -2
  122. package/lib/typescript/src/Competition/index.d.ts.map +1 -1
  123. package/lib/typescript/src/CompetitionManager/api/index.d.ts +1 -1
  124. package/lib/typescript/src/CompetitionManager/api/index.d.ts.map +1 -1
  125. package/lib/typescript/src/CompetitionManager/components/CompetitionInfoForm.d.ts.map +1 -1
  126. package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -1
  127. package/lib/typescript/src/CompetitionManager/components/ContestSettingsForm.d.ts.map +1 -1
  128. package/lib/typescript/src/CompetitionManager/components/CreateCompetitionForm.d.ts +3 -2
  129. package/lib/typescript/src/CompetitionManager/components/CreateCompetitionForm.d.ts.map +1 -1
  130. package/lib/typescript/src/CompetitionSeason/api/index.d.ts +41 -0
  131. package/lib/typescript/src/CompetitionSeason/api/index.d.ts.map +1 -0
  132. package/lib/typescript/src/CompetitionSeason/components/CompetitionsSection.d.ts +14 -0
  133. package/lib/typescript/src/CompetitionSeason/components/CompetitionsSection.d.ts.map +1 -0
  134. package/lib/typescript/src/CompetitionSeason/components/EnterSeasonPrompt.d.ts +16 -0
  135. package/lib/typescript/src/CompetitionSeason/components/EnterSeasonPrompt.d.ts.map +1 -0
  136. package/lib/typescript/src/CompetitionSeason/components/SeasonHeader.d.ts +15 -0
  137. package/lib/typescript/src/CompetitionSeason/components/SeasonHeader.d.ts.map +1 -0
  138. package/lib/typescript/src/CompetitionSeason/components/SeasonLeaderboard.d.ts +18 -0
  139. package/lib/typescript/src/CompetitionSeason/components/SeasonLeaderboard.d.ts.map +1 -0
  140. package/lib/typescript/src/CompetitionSeason/components/SeasonSettingsSection.d.ts +12 -0
  141. package/lib/typescript/src/CompetitionSeason/components/SeasonSettingsSection.d.ts.map +1 -0
  142. package/lib/typescript/src/CompetitionSeason/index.d.ts +12 -0
  143. package/lib/typescript/src/CompetitionSeason/index.d.ts.map +1 -0
  144. package/lib/typescript/src/CompetitionSeasonManager/api/index.d.ts +31 -0
  145. package/lib/typescript/src/CompetitionSeasonManager/api/index.d.ts.map +1 -0
  146. package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionSelector.d.ts +1 -0
  147. package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionSelector.d.ts.map +1 -0
  148. package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionsForm.d.ts +12 -0
  149. package/lib/typescript/src/CompetitionSeasonManager/components/CompetitionsForm.d.ts.map +1 -0
  150. package/lib/typescript/src/CompetitionSeasonManager/components/CreateSeasonForm.d.ts +11 -0
  151. package/lib/typescript/src/CompetitionSeasonManager/components/CreateSeasonForm.d.ts.map +1 -0
  152. package/lib/typescript/src/CompetitionSeasonManager/components/SeasonHeader.d.ts +13 -0
  153. package/lib/typescript/src/CompetitionSeasonManager/components/SeasonHeader.d.ts.map +1 -0
  154. package/lib/typescript/src/CompetitionSeasonManager/components/SeasonInfoForm.d.ts +11 -0
  155. package/lib/typescript/src/CompetitionSeasonManager/components/SeasonInfoForm.d.ts.map +1 -0
  156. package/lib/typescript/src/CompetitionSeasonManager/components/SeasonSettingsForm.d.ts +12 -0
  157. package/lib/typescript/src/CompetitionSeasonManager/components/SeasonSettingsForm.d.ts.map +1 -0
  158. package/lib/typescript/src/CompetitionSeasonManager/index.d.ts +8 -0
  159. package/lib/typescript/src/CompetitionSeasonManager/index.d.ts.map +1 -0
  160. package/lib/typescript/src/Components/Switch.d.ts +2 -1
  161. package/lib/typescript/src/Components/Switch.d.ts.map +1 -1
  162. package/lib/typescript/src/Engage/api/index.d.ts +6 -1
  163. package/lib/typescript/src/Engage/api/index.d.ts.map +1 -1
  164. package/lib/typescript/src/Engage/components/SeasonCard.d.ts +10 -0
  165. package/lib/typescript/src/Engage/components/SeasonCard.d.ts.map +1 -0
  166. package/lib/typescript/src/Engage/index.d.ts +3 -2
  167. package/lib/typescript/src/Engage/index.d.ts.map +1 -1
  168. package/lib/typescript/src/index.d.ts +3 -1
  169. package/lib/typescript/src/index.d.ts.map +1 -1
  170. package/package.json +1 -1
  171. package/src/Competition/api/index.ts +15 -0
  172. package/src/Competition/components/CompetitionSeasonCard.tsx +1 -1
  173. package/src/Competition/components/SeasonCard.tsx +46 -0
  174. package/src/Competition/index.tsx +45 -27
  175. package/src/CompetitionManager/api/index.ts +2 -5
  176. package/src/CompetitionManager/components/CompetitionInfoForm.tsx +2 -64
  177. package/src/CompetitionManager/components/CompetitionSettingsForm.tsx +10 -3
  178. package/src/CompetitionManager/components/ContestSettingsForm.tsx +8 -2
  179. package/src/CompetitionManager/components/CreateCompetitionForm.tsx +20 -4
  180. package/src/CompetitionSeason/api/index.ts +111 -0
  181. package/src/CompetitionSeason/components/CompetitionsSection.tsx +99 -0
  182. package/src/CompetitionSeason/components/EnterSeasonPrompt.tsx +135 -0
  183. package/src/CompetitionSeason/components/SeasonHeader.tsx +81 -0
  184. package/src/CompetitionSeason/components/SeasonLeaderboard.tsx +205 -0
  185. package/src/CompetitionSeason/components/SeasonSettingsSection.tsx +92 -0
  186. package/src/CompetitionSeason/index.tsx +244 -0
  187. package/src/CompetitionSeasonManager/api/index.ts +127 -0
  188. package/src/CompetitionSeasonManager/components/CompetitionSelector.tsx +2 -0
  189. package/src/CompetitionSeasonManager/components/CompetitionsForm.tsx +113 -0
  190. package/src/CompetitionSeasonManager/components/CreateSeasonForm.tsx +238 -0
  191. package/src/CompetitionSeasonManager/components/SeasonHeader.tsx +75 -0
  192. package/src/CompetitionSeasonManager/components/SeasonInfoForm.tsx +124 -0
  193. package/src/CompetitionSeasonManager/components/SeasonSettingsForm.tsx +185 -0
  194. package/src/CompetitionSeasonManager/index.tsx +151 -0
  195. package/src/Components/Switch.tsx +8 -3
  196. package/src/Engage/api/index.ts +21 -2
  197. package/src/Engage/components/SeasonCard.tsx +42 -0
  198. package/src/Engage/index.tsx +44 -7
  199. package/src/index.tsx +4 -1
  200. package/src/types.d.ts +48 -5
  201. package/lib/commonjs/Competition/components/ManageSeasonForm.js +0 -605
  202. package/lib/commonjs/Competition/components/ManageSeasonForm.js.map +0 -1
  203. package/lib/commonjs/Competition/components/SeasonInfoModal.js +0 -400
  204. package/lib/commonjs/Competition/components/SeasonInfoModal.js.map +0 -1
  205. package/lib/module/Competition/components/ManageSeasonForm.js +0 -596
  206. package/lib/module/Competition/components/ManageSeasonForm.js.map +0 -1
  207. package/lib/module/Competition/components/SeasonInfoModal.js +0 -391
  208. package/lib/module/Competition/components/SeasonInfoModal.js.map +0 -1
  209. package/lib/typescript/src/Competition/components/ManageSeasonForm.d.ts +0 -10
  210. package/lib/typescript/src/Competition/components/ManageSeasonForm.d.ts.map +0 -1
  211. package/lib/typescript/src/Competition/components/SeasonInfoModal.d.ts +0 -14
  212. package/lib/typescript/src/Competition/components/SeasonInfoModal.d.ts.map +0 -1
  213. package/src/Competition/components/ManageSeasonForm.tsx +0 -271
  214. package/src/Competition/components/SeasonInfoModal.tsx +0 -212
@@ -1,271 +0,0 @@
1
- import { FlatList, Image, ScrollView, TextInput, TouchableOpacity, View } from "react-native"
2
- import React, { useEffect, useState } from "react"
3
- import type { CompetitionSeasonProps } from "../../types"
4
- import { CompetitionHelpers, CompetitionSeasonApi } from "../api"
5
- import { Button, Switch, Text } from "../../Components"
6
- import Colors from "../../constants/colors"
7
- import ImageUploader from "../../Components/ImageUploader"
8
-
9
-
10
- type ManageSeasonFormProps = {
11
- competition_season?:CompetitionSeasonProps
12
- width: number,
13
- onComplete: (status:'done'|'cancel') => void
14
- }
15
-
16
- const ManageSeasonForm = ({ competition_season, width, onComplete }:ManageSeasonFormProps) => {
17
- const [ loading, setLoading ] = useState(false);
18
- const [ show_templates, setShowTemplates ] = useState(true);
19
- const [ season_templates, setSeasonTemplates ] = useState<CompetitionSeasonProps[]>([]);
20
- const [ draft_season, setDraftSeason ] = useState(CompetitionHelpers.getEmptyCompetitionSeason())
21
- const [ payout_allocation_label, setPayoutAllocationLabel ] = useState('0')
22
-
23
- useEffect(() => {
24
- loadTemplates()
25
- if(!competition_season){ return }
26
- setDraftSeason(competition_season);
27
- setShowTemplates(false);
28
- },[competition_season])
29
-
30
- const loadTemplates = async() => {
31
- let templates = await CompetitionSeasonApi.getCompetitionSeasonTemplates()
32
- setSeasonTemplates(templates)
33
- }
34
-
35
- const handleSelectTemplate = (s:CompetitionSeasonProps) => {
36
- setDraftSeason({ ...s, competition_season_id: '', season_name:'', season_description:'', following_season_id: s.competition_season_id })
37
- setPayoutAllocationLabel((s.payout_allocation*100).toFixed())
38
- }
39
-
40
- const handleChangeAllocation = (text:string) => {
41
- let non_str_num = parseFloat(text)
42
- if(isNaN(non_str_num)){ return }
43
- if(text == ''){
44
- setPayoutAllocationLabel('')
45
- return setDraftSeason({ ...draft_season, payout_allocation: 0 })
46
- }
47
- let allocation = parseFloat(text)
48
- setPayoutAllocationLabel(text)
49
- setDraftSeason({ ...draft_season, payout_allocation: allocation / 100 })
50
- }
51
-
52
- const handleSubmit = async() => {
53
- if(!CompetitionHelpers.isSeasonValid(draft_season)){ return alert('Please complete all required firlst') }
54
- setLoading(true);
55
- await CompetitionSeasonApi.createCompetitionSeason(draft_season)
56
- setLoading(false);
57
- onComplete('done')
58
- }
59
-
60
- const renderTemplates = (data: { item:CompetitionSeasonProps, index:number }) => {
61
- const selected = draft_season.following_season_id == data.item.competition_season_id ? true : false
62
- return (
63
- <TouchableOpacity
64
- onPress={() => handleSelectTemplate(data.item)}
65
- style={{ flexDirection:'row', borderRadius:8, backgroundColor:selected?Colors.brand.electric:'transparent', alignItems:'center', margin:3, padding:5, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }}>
66
- <View>
67
- <Image
68
- source={{uri: data.item.image?.url}}
69
- style={{ height:50, width:75 }}
70
- resizeMode="cover"
71
- />
72
- </View>
73
- <View style={{ flex:1, marginLeft:5 }}>
74
- <Text size={12} color={selected?Colors.shades.white:Colors.brand.midnight} weight='bold'>{data.item.season_name}</Text>
75
- <Text size={12} color={selected?Colors.shades.white:Colors.brand.midnight} weight='regular'>{data.item.season_description}</Text>
76
- </View>
77
-
78
- </TouchableOpacity>
79
- )
80
- }
81
-
82
- let valid = CompetitionHelpers.isSeasonValid(draft_season)
83
-
84
- return (
85
- <View style={{ flex:1, backgroundColor:Colors.shades.white, padding:10 }}>
86
- <View nativeID="form_header" style={{ padding:10 }}>
87
- <Text size={14} color={Colors.brand.midnight} weight='bold' textAlign='center'>{competition_season ? draft_season.season_name : 'Create New Season'}</Text>
88
- </View>
89
- <ScrollView style={{ flex:1 }}>
90
- <View nativeID="season_template">
91
- <View nativeID="competition_details">
92
- <View nativeID="details_header" style={{ padding:10, paddingBottom:0 }}>
93
- <Text size={16} color={Colors.brand.midnight} weight='bold'>Season Template</Text>
94
- <Text style={{ marginTop:3 }} size={14} color={Colors.brand.midnight} weight='regular'>Select a template for this season or do it on your own</Text>
95
- </View>
96
- </View>
97
- <View nativeID="template_options" style={{ margin:10, padding:10, borderRadius:4, backgroundColor:Colors.shades.shade100 }}>
98
- <View nativeID="template" style={{ flexDirection:'row', alignItems:'flex-start' }}>
99
- <View nativeID="description" style={{ flex:1, marginRight:5 }}>
100
- <Text size={14} color={Colors.brand.midnight} weight='bold'>Use a Template</Text>
101
- {show_templates ?
102
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>All competitions will be auto-created with appropriate events and participants will be notified.</Text>
103
- :
104
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>You (the admin) will be responsible for creating each competition under this season.</Text>
105
- }
106
- </View>
107
-
108
- <Switch value={show_templates} switch_type='on_off' onChange={(value) => {
109
- if(!value){
110
- //Need to reset init season
111
- setDraftSeason(CompetitionHelpers.getEmptyCompetitionSeason())
112
- }
113
- setShowTemplates(!show_templates)}
114
- }/>
115
- </View>
116
- {show_templates ?
117
- <View style={{ marginTop:10 }}>
118
- <Text size={14} color={Colors.brand.midnight} weight='bold'>Template Options</Text>
119
- <View nativeID="template_options" style={{ marginTop:5, backgroundColor:Colors.shades.white, borderRadius:4, padding:10 }}>
120
- <FlatList
121
- data={season_templates}
122
- renderItem={renderTemplates}
123
- keyExtractor={(item) => item.competition_season_id.toString()}
124
- />
125
- </View>
126
- </View>
127
- :<></>}
128
- </View>
129
- </View>
130
- {!show_templates || (show_templates && draft_season.following_season_id) ?
131
- <View nativeID="form_options">
132
- <View nativeID="competition_details">
133
- <View nativeID="details_header" style={{ padding:10, paddingBottom:0 }}>
134
- <Text size={16} color={Colors.brand.midnight} weight='bold'>Season Details</Text>
135
- <Text style={{ marginTop:3 }} size={14} color={Colors.brand.midnight} weight='regular'>Name and describe this season</Text>
136
- </View>
137
- <View nativeID="details_input" style={{ margin:10, padding:10, borderRadius:4, backgroundColor:Colors.shades.shade100 }}>
138
- <View nativeID="season_name">
139
- <Text style={{ padding:10 }} size={14} color={Colors.brand.slate} weight='regular'>Name</Text>
140
- <TextInput
141
- style={{ borderRadius:4, backgroundColor:Colors.shades.white, padding:10, fontFamily:'barlow-regular', fontSize:14, color:Colors.brand.midnight }}
142
- placeholder="Season Name..."
143
- placeholderTextColor={Colors.brand.slate}
144
- value={draft_season.season_name}
145
- onChangeText={(text) => setDraftSeason({ ...draft_season, season_name: text })}
146
- />
147
- </View>
148
- <View nativeID="season_description">
149
- <Text style={{ padding:10 }} size={14} color={Colors.brand.slate} weight='regular'>Description</Text>
150
- <TextInput
151
- style={{ borderRadius:4, backgroundColor:Colors.shades.white, padding:10, fontFamily:'barlow-regular', fontSize:14, color:Colors.brand.midnight }}
152
- placeholder="Optional..."
153
- placeholderTextColor={Colors.brand.slate}
154
- value={draft_season.season_description}
155
- onChangeText={(text) => setDraftSeason({ ...draft_season, season_description: text })}
156
- />
157
- </View>
158
- </View>
159
- </View>
160
- <View nativeID="competition_image">
161
- <View nativeID="image_header" style={{ flexDirection:'row', alignItems:'center', padding:10, paddingBottom:0 }}>
162
- <View style={{ flex:1 }}>
163
- <Text size={16} color={Colors.brand.midnight} weight='bold'>Season Image</Text>
164
- <Text style={{ marginTop:3 }} size={14} color={Colors.brand.midnight} weight='regular'>Give an image to the season (2w X 1h)</Text>
165
- </View>
166
- <ImageUploader
167
- public_id={`${Math.floor(Math.random() * (1000000 - 0 + 1) + 1)}_season_image`}
168
- onFinishUpload={(obj) => setDraftSeason({ ...draft_season, image: { url: obj.secure_url, ...obj } })}
169
- >
170
- <Text size={14} color={Colors.brand.electric}>Edit Image</Text>
171
- </ImageUploader>
172
- </View>
173
- <View nativeID="season_image" style={{ justifyContent:'center', alignItems:'center', margin:5 }}>
174
- <Image
175
- source={{ uri: draft_season?.image?.url }}
176
- style={{ width:width*0.75, height: width*0.75/2 }}
177
- resizeMode="cover"
178
- />
179
- </View>
180
- </View>
181
- <View nativeID="season_options">
182
- <View nativeID="options_header" style={{ flexDirection:'row', alignItems:'center', padding:10, paddingBottom:0 }}>
183
- <View style={{ flex:1 }}>
184
- <Text size={16} color={Colors.brand.midnight} weight='bold'>Season Configurations</Text>
185
- <Text style={{ marginTop:3 }} size={14} color={Colors.brand.midnight} weight='regular'>Determines how the competition will operate and payout</Text>
186
- </View>
187
- </View>
188
- <View nativeID="options_input" style={{ margin:10, padding:10, borderRadius:4, backgroundColor:Colors.shades.shade100 }}>
189
- <View nativeID="single_buy_in" style={{ flexDirection:'row', alignItems:'flex-start' }}>
190
- <View nativeID="description" style={{ flex:1, marginRight:5 }}>
191
- <Text size={14} color={Colors.brand.midnight} weight='bold'>One Buy In</Text>
192
- {draft_season.single_buy_in ?
193
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>Once a player has purchased a ticket, they will be automatically entered into any competition created under this season.</Text>
194
- :
195
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>Players will be required to buy-in to each competition created under this season.</Text>
196
- }
197
- </View>
198
- <Switch value={draft_season.single_buy_in} switch_type='on_off' onChange={() => setDraftSeason({ ...draft_season, single_buy_in: !draft_season.single_buy_in })}/>
199
- </View>
200
- <View nativeID="single_buy_in" style={{ flexDirection:'row', alignItems:'flex-start', marginTop:15 }}>
201
- <View nativeID="description" style={{ flex:1, marginRight:5 }}>
202
- <Text size={14} color={Colors.brand.midnight} weight='bold'>Allow Late Buy In</Text>
203
- {draft_season.allow_late_buy_in ?
204
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>A player can enter this season at any time (even if the first competition has completed)</Text>
205
- :
206
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>A player must enter the first competition under the season to participate.</Text>
207
- }
208
- </View>
209
- <Switch value={draft_season.allow_late_buy_in} switch_type='on_off' onChange={() => setDraftSeason({ ...draft_season, allow_late_buy_in: !draft_season.allow_late_buy_in })}/>
210
- </View>
211
- </View>
212
- </View>
213
- <View nativeID="season_payout_details">
214
- <View nativeID="payout_header" style={{ flexDirection:'row', alignItems:'center', padding:10, paddingBottom:0 }}>
215
- <View style={{ flex:1 }}>
216
- <Text size={16} color={Colors.brand.midnight} weight='bold'>Season Payout</Text>
217
- <Text style={{ marginTop:3 }} size={14} color={Colors.brand.midnight} weight='regular'>How would you like the funds in the season to payout?</Text>
218
- </View>
219
- </View>
220
- <View nativeID="payout_input" style={{ margin:10, padding:10, borderRadius:4, backgroundColor:Colors.shades.shade100 }}>
221
- <View nativeID="payout_allocation" style={{ flexDirection:'row', alignItems:'flex-start' }}>
222
- <View nativeID="description" style={{ flex:1, marginRight:5 }}>
223
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>How much of the total pot will be paid out to the season vs each competition</Text>
224
- </View>
225
- <TextInput
226
- value={payout_allocation_label}
227
- onChangeText={(text) => handleChangeAllocation(text)}
228
- style={{ padding:10, borderRadius:4, width: width * 0.2, backgroundColor:Colors.shades.white, textAlign:'center', color:Colors.brand.midnight, fontFamily:'barlow-bold' }}
229
-
230
- />
231
- </View>
232
- <View style={{ flexDirection:'row', marginTop:10 }}>
233
- <View style={{ flex:1, padding:10, backgroundColor:Colors.shades.shade600, borderRadius:4, marginRight:5 }}>
234
- <Text size={12} color={Colors.brand.midnight} textAlign="center">Each Competition</Text>
235
- <Text style={{ marginTop:5 }} size={14} color={Colors.brand.midnight} weight='bold' textAlign="center">{((1 - draft_season.payout_allocation) * 100).toFixed()}%</Text>
236
- </View>
237
- <View style={{ flex:1, padding:10, backgroundColor:Colors.shades.shade600, borderRadius:4, marginLeft:5 }}>
238
- <Text size={12} color={Colors.brand.midnight} textAlign="center">Season</Text>
239
- <Text style={{ marginTop:5 }} size={12} color={Colors.brand.midnight} weight='bold' textAlign="center">{((draft_season.payout_allocation) * 100).toFixed()}%</Text>
240
- </View>
241
- </View>
242
- </View>
243
- </View>
244
- </View>
245
- :<></>}
246
- </ScrollView>
247
- <View nativeID="action_row" style={{ flexDirection:'row', padding:10 }}>
248
- <Button
249
- style={{ flex:1, marginRight:3 }}
250
- title="Cancel"
251
- onPress={() => onComplete('cancel')}
252
- title_color={Colors.brand.electric}
253
- borderWidth={1}
254
- padding={15}
255
- borderColor={Colors.brand.electric}
256
- />
257
- <Button
258
- disabled={!valid || loading}
259
- style={{ flex:2, marginLeft:3, opacity:valid&&!loading?1:0.5 }}
260
- title={draft_season.competition_season_id ? 'Edit Season' : 'Create Season'}
261
- onPress={() => handleSubmit()}
262
- title_color={Colors.shades.white}
263
- padding={15}
264
- backgroundColor={Colors.utility.success}
265
- />
266
- </View>
267
- </View>
268
- )
269
- }
270
-
271
- export default ManageSeasonForm
@@ -1,212 +0,0 @@
1
- import React, { useEffect, useState } from "react"
2
- import { FlatList, Image, ScrollView, TouchableOpacity, View, ActivityIndicator } from "react-native"
3
- import CompetitionCard from "./CompetitionCard"
4
- import type { CompetitionProps, CompetitionResultTypeProps, CompetitionSeasonProps, CompetitionTypeProps, PublicPlayerProps } from "../../types"
5
- import { CompetitionApi, CompetitionSeasonApi } from "../api"
6
- import { Button, Text } from "../../Components"
7
- import Colors from "../../constants/colors"
8
- import moment from "moment-mini"
9
-
10
- type SeasonInfoModalProps = {
11
- competition_season:CompetitionSeasonProps,
12
- competition_types:CompetitionTypeProps[],
13
- competition_result_types:CompetitionResultTypeProps[],
14
- width:number,
15
- height:number,
16
- onSelectCompetition: (competition:CompetitionProps) => void,
17
- onClose:() => void
18
- }
19
-
20
- const SeasonInfoModal = ({ competition_season, competition_types, competition_result_types, width, height, onClose, onSelectCompetition }:SeasonInfoModalProps) => {
21
- const [ loading, setLoading ] = useState(false);
22
- const [ active_view, setActiveView ] = useState('info');
23
- const [ leaderboard, setLeaderboard ] = useState<{
24
- players: PublicPlayerProps[],
25
- leaders: any[]
26
- }>({
27
- players: [],
28
- leaders: []
29
- });
30
- const [ competitions, setCompetitions ] = useState<CompetitionProps[]>([])
31
-
32
- const { leaders, players } = leaderboard;
33
-
34
- useEffect(() => {
35
- if(!competition_season){ return }
36
- getSeasonCompetitions(competition_season.competition_season_id)
37
- },[competition_season])
38
-
39
- useEffect(() => {
40
- switch(active_view){
41
- case 'competitions':
42
- getSeasonCompetitions(competition_season.competition_season_id)
43
- return
44
- case 'leaderboard':
45
- getSeasonLeaderboard(competition_season.competition_season_id);
46
- return
47
- default: return
48
- }
49
- },[active_view])
50
-
51
- const getSeasonCompetitions = async(competition_season_id:string) => {
52
- setLoading(true);
53
- try {
54
- let season_competitions = await CompetitionApi.getCompetitionsBySeasonId(competition_season_id)
55
- setCompetitions(season_competitions)
56
- } catch (e) {
57
- console.log(e)
58
- }
59
- setLoading(false)
60
- }
61
-
62
- const getSeasonLeaderboard = async(competition_season_id:string) => {
63
- setLoading(true);
64
- try {
65
- let season_leaderboard = await CompetitionSeasonApi.getLeaderboardBySeasonId(competition_season_id)
66
- const player_ids:string[] = season_leaderboard.map((sl:any) => sl.player_id)
67
- const leader_players = await CompetitionApi.getPlayersByPlayerIds(player_ids);
68
- setLeaderboard({
69
- leaders: season_leaderboard,
70
- players: leader_players
71
- })
72
- } catch (e) {
73
- console.log(e)
74
- }
75
- setLoading(false)
76
- }
77
-
78
- const renderCompetitions = (data: { item:CompetitionProps, index:number }) => {
79
- const competition_type = competition_types.find(ct => ct.competition_type_id == data.item.competition_type_id);
80
- const competition_result_type = competition_result_types.find(ct => ct.competition_result_type_id == data.item.competition_result_type_id);
81
- if(!competition_type || !competition_result_type){ return <></> }
82
- return (
83
- <View style={{ margin:5 }}>
84
- <CompetitionCard
85
- competition={data.item}
86
- competition_result_type={competition_result_type}
87
- competition_type={competition_type}
88
- onSelect={() => onSelectCompetition(data.item)}
89
- />
90
- </View>
91
- )
92
- }
93
-
94
- const renderLeaders = (data: { item:any, index:number }) => {
95
- const player = players.find(p => p.player_id == data.item.player_id)
96
- if(!player){ return <></> }
97
- return (
98
- <View
99
- style={{ flexDirection:'row', margin:5, alignItems:'center', borderRadius:22, backgroundColor:Colors.shades.white, padding:8, paddingLeft:15, paddingRight:15}}>
100
- <View nativeID="place" style={{ padding:5 }}>
101
- <Text size={12} color={Colors.brand.midnight} weight="bold">{data.item.place}</Text>
102
- </View>
103
- <View nativeID="image" style={{ paddingLeft:10, paddingRight:10 }}>
104
- <Image
105
- source={{ uri: player.profile_pic }}
106
- style={{ height:30, width:30, borderRadius:100 }}
107
- resizeMode="cover"
108
- />
109
- </View>
110
- <View nativeID="details" style={{ flex:1 }}>
111
- <Text size={12} color={Colors.brand.midnight} weight='semibold'>{player.username}</Text>
112
-
113
- <Text style={{ marginTop:3 }} size={12} color={Colors.brand.midnight} weight='regular'>{data.item.wins} - {data.item.losses} - {data.item.draws} ({data.item.earnings.toFixed(2)} Earnings)</Text>
114
- </View>
115
- <View nativeID="winnings">
116
- <Text size={12} color={Colors.brand.slate} weight='regular'>Hey</Text>
117
- </View>
118
- </View>
119
- )
120
- }
121
-
122
- if(!competition_season){ return }
123
- const cl = competition_season.market_type == 'FOR_MONEY' ? '$' : 'E'
124
- return (
125
- <View style={{ height, width, backgroundColor:Colors.shades.white }}>
126
- <ScrollView style={{ flex:1 }}>
127
- {loading ?
128
- <ActivityIndicator style={{ padding:20, alignSelf:'center' }} color={Colors.brand.midnight} size='large' />
129
- :<></>}
130
- <View nativeID="season_header" style={{ justifyContent:'center', alignItems:'center' }}>
131
- <Image
132
- source={{ uri: competition_season.image?.url }}
133
- style={{ width: width*0.75, height: (width*0.75) / 2 }}
134
- resizeMode='cover'
135
- />
136
- <View style={{ margin:10 }}>
137
- <Text size={14} color={Colors.brand.midnight} weight='bold' textAlign="center">{competition_season.season_name}</Text>
138
- <Text style={{ marginTop:5 }} size={14} color={Colors.brand.midnight} weight='regular' textAlign="center">{competition_season.season_description}</Text>
139
- </View>
140
- </View>
141
- <View style={{ margin:10, flexDirection:'row', padding:2, backgroundColor:Colors.shades.shade100, borderRadius:22 }}>
142
- <TouchableOpacity
143
- onPress={() => setActiveView('leaderboard')}
144
- style={{ flex:1, padding:10, borderRadius:22, backgroundColor:active_view=='leaderboard'?Colors.shades.white:undefined }}>
145
- <Text size={14} color={Colors.brand.midnight} weight={active_view=='leaderboard'?'bold':'regular'} textAlign="center">Leaderboard</Text>
146
- </TouchableOpacity>
147
- <TouchableOpacity
148
- onPress={() => setActiveView('info')}
149
- style={{ flex:1, padding:10, borderRadius:22, backgroundColor:active_view=='info'?Colors.shades.white:undefined }}>
150
- <Text size={14} color={Colors.brand.midnight} weight={active_view=='info'?'bold':'regular'} textAlign="center">Info</Text>
151
- </TouchableOpacity>
152
- <TouchableOpacity
153
- onPress={() => setActiveView('competitions')}
154
- style={{ flex:1, padding:10, borderRadius:22, backgroundColor:active_view=='competitions'?Colors.shades.white:undefined }}>
155
- <Text size={14} color={Colors.brand.midnight} weight={active_view=='competitions'?'bold':'regular'} textAlign="center">Competitions</Text>
156
- </TouchableOpacity>
157
- </View>
158
- {active_view == 'info'?
159
- <View nativeID="season_info" style={{ padding:20 }}>
160
- <View style={{ flexDirection:'row' }}>
161
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='regular'>Season Type</Text>
162
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='bold' textAlign="right">{competition_season.single_buy_in?'One Time Entry':'Each Competition Entry'}</Text>
163
- </View>
164
- <View style={{ flexDirection:'row', marginTop:10 }}>
165
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='regular'>Late Entry</Text>
166
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='bold' textAlign="right">{competition_season.allow_late_buy_in?'Allowed':'Not Allowed'}</Text>
167
- </View>
168
- <View style={{ flexDirection:'row', marginTop:10 }}>
169
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='regular'>Season Allocation</Text>
170
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='bold' textAlign="right">{(competition_season.payout_allocation*100).toFixed(2)}%</Text>
171
- </View>
172
- <View style={{ flexDirection:'row', marginTop:10 }}>
173
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='regular'>Each Competition Allocation</Text>
174
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='bold' textAlign="right">{((1-competition_season.payout_allocation)*100).toFixed(2)}%</Text>
175
- </View>
176
- <View style={{ flexDirection:'row', marginTop:10 }}>
177
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='regular'>Current Season Pot</Text>
178
- <Text style={{ flex:1 }} size={12} color={Colors.brand.midnight} weight='bold' textAlign="right">{cl}{competition_season.payout_amt.toFixed(2)}</Text>
179
- </View>
180
- </View>
181
- :active_view == 'competitions' ?
182
- <View nativeID="season_competitions" style={{ padding:10 }}>
183
- <FlatList
184
- data={competitions.sort((a,b) => moment(a.scheduled_datetime).unix() - moment(b.scheduled_datetime).unix())}
185
- renderItem={renderCompetitions}
186
- keyExtractor={(item) => item.competition_id.toString()}
187
- />
188
- </View>
189
- :active_view == 'leaderboard' ?
190
- <View nativeID="season_leaderboard" style={{ padding:10, backgroundColor:Colors.shades.shade100 }}>
191
- <FlatList
192
- data={leaders.sort((a,b) => b.wins - a.wins)}
193
- renderItem={renderLeaders}
194
- keyExtractor={(item) => item.player_id.toString()}
195
- />
196
- </View>
197
- :<></>}
198
- </ScrollView>
199
- <View nativeID="action_row" style={{ padding:10 }}>
200
- <Button
201
- borderColor={Colors.brand.electric}
202
- title="Close"
203
- title_color={Colors.brand.electric}
204
- borderWidth={1}
205
- borderRadius={22}
206
- onPress={() => onClose()}
207
- />
208
- </View>
209
- </View>
210
- )
211
- }
212
- export default SeasonInfoModal