be-components 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (123) hide show
  1. package/lib/commonjs/Competition/components/CompetitionCard.js +1 -1
  2. package/lib/commonjs/Competition/components/CompetitionCard.js.map +1 -1
  3. package/lib/commonjs/Competition/components/EnterCompetitionPrompt.js +1 -1
  4. package/lib/commonjs/Competition/components/EnterCompetitionPrompt.js.map +1 -1
  5. package/lib/commonjs/CompetitionManager/api/index.js +577 -0
  6. package/lib/commonjs/CompetitionManager/api/index.js.map +1 -0
  7. package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js +439 -0
  8. package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js.map +1 -0
  9. package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js +269 -0
  10. package/lib/commonjs/CompetitionManager/components/CompetitionInfoForm.js.map +1 -0
  11. package/lib/commonjs/CompetitionManager/components/CompetitionMatchMarketCard.js +142 -0
  12. package/lib/commonjs/CompetitionManager/components/CompetitionMatchMarketCard.js.map +1 -0
  13. package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js +370 -0
  14. package/lib/commonjs/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -0
  15. package/lib/commonjs/CompetitionManager/components/MarketSelector.js +99 -0
  16. package/lib/commonjs/CompetitionManager/components/MarketSelector.js.map +1 -0
  17. package/lib/commonjs/CompetitionManager/index.js +188 -0
  18. package/lib/commonjs/CompetitionManager/index.js.map +1 -0
  19. package/lib/commonjs/Components/Dropdown.js +98 -0
  20. package/lib/commonjs/Components/Dropdown.js.map +1 -0
  21. package/lib/commonjs/Components/Icons.js +1 -1
  22. package/lib/commonjs/Components/Icons.js.map +1 -1
  23. package/lib/commonjs/Markets/api/index.js +28 -0
  24. package/lib/commonjs/Markets/api/index.js.map +1 -0
  25. package/lib/commonjs/Markets/components/MarketButton.js +25 -0
  26. package/lib/commonjs/Markets/components/MarketButton.js.map +1 -0
  27. package/lib/commonjs/Squares/api/index.js.map +1 -1
  28. package/lib/commonjs/Squares/components/PrizeCard.js +161 -0
  29. package/lib/commonjs/Squares/components/PrizeCard.js.map +1 -0
  30. package/lib/commonjs/Squares/components/SquareCard.js.map +1 -1
  31. package/lib/commonjs/Squares/index.js +10 -1
  32. package/lib/commonjs/Squares/index.js.map +1 -1
  33. package/lib/commonjs/constants/styles.js +10 -0
  34. package/lib/commonjs/constants/styles.js.map +1 -1
  35. package/lib/commonjs/index.js +7 -0
  36. package/lib/commonjs/index.js.map +1 -1
  37. package/lib/module/Competition/components/CompetitionCard.js +1 -1
  38. package/lib/module/Competition/components/CompetitionCard.js.map +1 -1
  39. package/lib/module/Competition/components/EnterCompetitionPrompt.js +1 -1
  40. package/lib/module/Competition/components/EnterCompetitionPrompt.js.map +1 -1
  41. package/lib/module/CompetitionManager/api/index.js +571 -0
  42. package/lib/module/CompetitionManager/api/index.js.map +1 -0
  43. package/lib/module/CompetitionManager/components/CompetitionContestsForm.js +434 -0
  44. package/lib/module/CompetitionManager/components/CompetitionContestsForm.js.map +1 -0
  45. package/lib/module/CompetitionManager/components/CompetitionInfoForm.js +262 -0
  46. package/lib/module/CompetitionManager/components/CompetitionInfoForm.js.map +1 -0
  47. package/lib/module/CompetitionManager/components/CompetitionMatchMarketCard.js +135 -0
  48. package/lib/module/CompetitionManager/components/CompetitionMatchMarketCard.js.map +1 -0
  49. package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js +364 -0
  50. package/lib/module/CompetitionManager/components/CompetitionSettingsForm.js.map +1 -0
  51. package/lib/module/CompetitionManager/components/MarketSelector.js +92 -0
  52. package/lib/module/CompetitionManager/components/MarketSelector.js.map +1 -0
  53. package/lib/module/CompetitionManager/index.js +179 -0
  54. package/lib/module/CompetitionManager/index.js.map +1 -0
  55. package/lib/module/Components/Dropdown.js +89 -0
  56. package/lib/module/Components/Dropdown.js.map +1 -0
  57. package/lib/module/Components/Icons.js +1 -1
  58. package/lib/module/Components/Icons.js.map +1 -1
  59. package/lib/module/Markets/api/index.js +23 -0
  60. package/lib/module/Markets/api/index.js.map +1 -0
  61. package/lib/module/Markets/components/MarketButton.js +18 -0
  62. package/lib/module/Markets/components/MarketButton.js.map +1 -0
  63. package/lib/module/Squares/api/index.js.map +1 -1
  64. package/lib/module/Squares/components/PrizeCard.js +152 -0
  65. package/lib/module/Squares/components/PrizeCard.js.map +1 -0
  66. package/lib/module/Squares/components/SquareCard.js.map +1 -1
  67. package/lib/module/Squares/index.js +10 -1
  68. package/lib/module/Squares/index.js.map +1 -1
  69. package/lib/module/constants/styles.js +10 -0
  70. package/lib/module/constants/styles.js.map +1 -1
  71. package/lib/module/index.js +2 -1
  72. package/lib/module/index.js.map +1 -1
  73. package/lib/typescript/src/CompetitionManager/api/index.d.ts +109 -0
  74. package/lib/typescript/src/CompetitionManager/api/index.d.ts.map +1 -0
  75. package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts +23 -0
  76. package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -0
  77. package/lib/typescript/src/CompetitionManager/components/CompetitionInfoForm.d.ts +10 -0
  78. package/lib/typescript/src/CompetitionManager/components/CompetitionInfoForm.d.ts.map +1 -0
  79. package/lib/typescript/src/CompetitionManager/components/CompetitionMatchMarketCard.d.ts +17 -0
  80. package/lib/typescript/src/CompetitionManager/components/CompetitionMatchMarketCard.d.ts.map +1 -0
  81. package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts +13 -0
  82. package/lib/typescript/src/CompetitionManager/components/CompetitionSettingsForm.d.ts.map +1 -0
  83. package/lib/typescript/src/CompetitionManager/components/MarketSelector.d.ts +13 -0
  84. package/lib/typescript/src/CompetitionManager/components/MarketSelector.d.ts.map +1 -0
  85. package/lib/typescript/src/CompetitionManager/index.d.ts +8 -0
  86. package/lib/typescript/src/CompetitionManager/index.d.ts.map +1 -0
  87. package/lib/typescript/src/Components/Dropdown.d.ts +15 -0
  88. package/lib/typescript/src/Components/Dropdown.d.ts.map +1 -0
  89. package/lib/typescript/src/Markets/api/index.d.ts +7 -0
  90. package/lib/typescript/src/Markets/api/index.d.ts.map +1 -0
  91. package/lib/typescript/src/Markets/components/MarketButton.d.ts +11 -0
  92. package/lib/typescript/src/Markets/components/MarketButton.d.ts.map +1 -0
  93. package/lib/typescript/src/Squares/api/index.d.ts +2 -1
  94. package/lib/typescript/src/Squares/api/index.d.ts.map +1 -1
  95. package/lib/typescript/src/Squares/components/PrizeCard.d.ts +11 -0
  96. package/lib/typescript/src/Squares/components/PrizeCard.d.ts.map +1 -0
  97. package/lib/typescript/src/Squares/components/SquareCard.d.ts.map +1 -1
  98. package/lib/typescript/src/Squares/index.d.ts.map +1 -1
  99. package/lib/typescript/src/constants/styles.d.ts +10 -0
  100. package/lib/typescript/src/constants/styles.d.ts.map +1 -1
  101. package/lib/typescript/src/index.d.ts +2 -1
  102. package/lib/typescript/src/index.d.ts.map +1 -1
  103. package/package.json +1 -1
  104. package/src/Competition/components/CompetitionCard.tsx +1 -1
  105. package/src/Competition/components/EnterCompetitionPrompt.tsx +2 -2
  106. package/src/CompetitionManager/api/index.ts +484 -0
  107. package/src/CompetitionManager/components/CompetitionContestsForm.tsx +473 -0
  108. package/src/CompetitionManager/components/CompetitionInfoForm.tsx +171 -0
  109. package/src/CompetitionManager/components/CompetitionMatchMarketCard.tsx +155 -0
  110. package/src/CompetitionManager/components/CompetitionSettingsForm.tsx +229 -0
  111. package/src/CompetitionManager/components/MarketSelector.tsx +66 -0
  112. package/src/CompetitionManager/index.tsx +163 -0
  113. package/src/Components/Dropdown.tsx +78 -0
  114. package/src/Components/Icons.tsx +1 -1
  115. package/src/Markets/api/index.ts +18 -0
  116. package/src/Markets/components/MarketButton.tsx +24 -0
  117. package/src/Squares/api/index.ts +2 -2
  118. package/src/Squares/components/PrizeCard.tsx +90 -0
  119. package/src/Squares/components/SquareCard.tsx +0 -1
  120. package/src/Squares/index.tsx +12 -2
  121. package/src/constants/styles.ts +5 -0
  122. package/src/index.tsx +2 -0
  123. package/src/types.d.ts +26 -2
@@ -0,0 +1,155 @@
1
+ //import { TouchableOpacity, View } from "react-native"
2
+ //import { v4 } from 'uuid';
3
+ import React from "react"
4
+ import type { CompetitionMatchMarketProps, MarketProps } from "../../types";
5
+ //import { ManageCompetitionHelpers } from "../api";
6
+ //import { Text } from "../../Components";
7
+ //import Colors from "../../constants/colors";
8
+
9
+
10
+ type CompetitionMatchMarketCardProps = {
11
+ market:MarketProps,
12
+ competition_match_id:string,
13
+ competition_match_markets:CompetitionMatchMarketProps[],
14
+ side_id?:string,
15
+ event_id:string,
16
+ competition_summaries?:any[]
17
+ event_type:string
18
+ onSaveMarkets: (cmms:CompetitionMatchMarketProps[]) => void,
19
+ onUpdateMarkets: (cmms:CompetitionMatchMarketProps[]) => void,
20
+ onGenerateMarkets: () => void
21
+ }
22
+
23
+ const CompetitionMatchMarketCard = ({ }:CompetitionMatchMarketCardProps) => {
24
+
25
+ /*
26
+ const [ setDraftCompetitionMatchMarket ] = useState<CompetitionMatchMarketProps | undefined>(undefined)
27
+
28
+ const trade_side = competition_match_markets.find(cmm => cmm.side == market.trade_side);
29
+ let trade_side_pick_pct = 0, o_side_pick_pct = 0;
30
+ const o_side = competition_match_markets.find(cmm => cmm.side != market.trade_side);
31
+ let total_count = 0
32
+ if(competition_summaries){
33
+ total_count = competition_summaries.reduce((a,b) => a + parseFloat(b.count), 0)
34
+ let trade_side_summary = competition_summaries.find(cs => cs.side == market.trade_side)
35
+ let o_side_summary = competition_summaries.find(cs => cs.side != market.trade_side)
36
+ if(trade_side_summary){
37
+ trade_side_pick_pct = trade_side_summary.count / total_count
38
+ }
39
+ if(o_side_summary){
40
+ o_side_pick_pct = o_side_summary.count / total_count
41
+ }
42
+ }
43
+ */
44
+ /*
45
+
46
+ const isCMMValid = (cmm:CompetitionMatchMarketProps) => {
47
+ if(isNaN(cmm.odds)){ return false }
48
+ if(isNaN(cmm.var_1)){ return false }
49
+ if(market.type != 'Spread' && cmm.var_1 < 0){ return false }
50
+ if(market.var_1_required && cmm.var_1 == 0){ return false }
51
+ return true
52
+ }
53
+ */
54
+ /*
55
+ const handleUpdateCMM = () => {
56
+ if(!draft_competition_match_market){ return }
57
+ //First check if the draft one is valie
58
+ if(!isCMMValid(draft_competition_match_market)){ return alert('Please correct any errors') }
59
+ let cmm = { ...draft_competition_match_market }
60
+ //cmm.odds = parseFloat(cmm.odds)
61
+ //cmm.var_1 = parseFloat(cmm.var_1)
62
+ //now we need to flip sides
63
+ let other_cmm = competition_match_markets.find(ncm => ncm.side != cmm.side)
64
+ if(other_cmm){
65
+ console.log('THERE WAS AN OTHER SIDE')
66
+ other_cmm.var_1 = cmm.var_1
67
+ other_cmm.odds = cmm.odds * -1
68
+ other_cmm.probability = ManageCompetitionHelpers.calcProbabilityFromOdds(other_cmm.odds)
69
+ } else {
70
+ return alert('NOT HANDLED. PLEASE AUTO GENERATE FIRST')
71
+ }
72
+ if(market.type == 'Spread'){
73
+ other_cmm.var_1 = other_cmm.var_1 * -1
74
+ }
75
+ onUpdateMarkets([{ ...cmm, probability: ManageCompetitionHelpers.calcProbabilityFromOdds(cmm.odds), status:'pending' }, { ...other_cmm, status:'pending'}])
76
+ return setDraftCompetitionMatchMarket(undefined)
77
+ }
78
+ */
79
+
80
+ /*
81
+
82
+ if(draft_competition_match_market){
83
+ return (
84
+ <View style={{ flexDirection:'row', alignItems:'center' }}>
85
+ <Text size={14} color={Colors.brand.midnight}>{draft_competition_match_market.side.toUpperCase()}</Text>
86
+ {market.var_1_required ?
87
+ <TextInput
88
+ style={{ padding:10, borderRadius:4, backgroundColor:Colors.shades.white, marginRight:20 }}
89
+ value={draft_competition_match_market.var_1}
90
+ onChangeText={(text) => setDraftCompetitionMatchMarket({ ...draft_competition_match_market, var_1: text })}
91
+ />
92
+ :<></>}
93
+ <TextInput
94
+ style={{ padding:10, borderRadius:4, backgroundColor:Colors.shades.white }}
95
+ value={draft_competition_match_market.odds}
96
+ onChangeText={(text) => setDraftCompetitionMatchMarket({ ...draft_competition_match_market, odds: text })}
97
+ />
98
+ <Button
99
+ title='Submit'
100
+ title_color={Colors.shades.white}
101
+ backgroundColor={Colors.utility.success}
102
+ onPress={() => handleUpdateCMM()}
103
+ />
104
+ </View>
105
+ )
106
+ }
107
+ */
108
+
109
+ /*
110
+ if(!trade_side || !o_side){
111
+ return (
112
+ <View style={{ flexDirection:'row' }}>
113
+ <TouchableOpacity style={{ justifyContent:'center', alignItems:'center', padding:5, borderRadius:4, backgroundColor:Colors.shades.shade100 }} onPress={() => {
114
+ setDraftCompetitionMatchMarket({ ...ManageCompetitionHelpers.createEmptyCompetitionMatchMarket(market, side_id), event_id, event_type, competition_match_id, competition_match_market_id: v4(), pair_id:v4() })
115
+ }}>
116
+ <Icons.UserIcon size={14} color={Colors.brand.midnight} />
117
+ <Text style={{ marginTop:5 }} size={12} color={Colors.brand.midnight} weight='bold'>Enter Manually</Text>
118
+ </TouchableOpacity>
119
+ <TouchableOpacity style={{ justifyContent:'center', marginLeft:5, alignItems:'center', padding:5, borderRadius:4, backgroundColor:Colors.shades.shade100 }} onPress={() => onGenerateMarkets()}>
120
+ <Icons.SettingsIcon size={14} color={Colors.brand.electric} />
121
+ <Text style={{ marginTop:5 }} size={12} color={Colors.brand.electric} weight='bold'>Try Auto</Text>
122
+ </TouchableOpacity>
123
+ </View>
124
+ )
125
+ }
126
+
127
+ */
128
+
129
+ return <></>
130
+ /*
131
+ if(!o_side || !trade_side){ return <></> }
132
+
133
+ return (
134
+ <View style={{ flexDirection:'row' }}>
135
+ <View>
136
+ <Text style={{ marginBottom:2 }} size={12} color={Colors.brand.midnight} weight='semibold' textAlign="center">{(o_side_pick_pct*100).toFixed()} % Picked</Text>
137
+ <TouchableOpacity style={{ width:75, padding:5, backgroundColor:o_side.status == 'error' ? Colors.highlights.highlight300Faded :Colors.shades.shade600, borderRadius:4, marginRight:3 }} onPress={() => setDraftCompetitionMatchMarket(o_side)}>
138
+ <Text textAlign="center" size={12} color={Colors.brand.midnight} weight='semibold'>{o_side.side.toUpperCase()}{market.var_1_required?` ${ManageCompetitionHelpers.getVar1Label(o_side.var_1, market)}`:''}</Text>
139
+ <Text textAlign="center" size={12} color={Colors.brand.midnight} weight='semibold'>{ManageCompetitionHelpers.getOddsLabel(o_side.odds)}</Text>
140
+ </TouchableOpacity>
141
+ </View>
142
+ <View>
143
+ <Text style={{ marginBottom:2 }} size={12} color={Colors.brand.midnight} weight='semibold' textAlign="center">{(trade_side_pick_pct*100).toFixed()} % Picked</Text>
144
+ <TouchableOpacity style={{ width:75, padding:5, backgroundColor:trade_side.status == 'error' ? Colors.highlights.highlight300Faded :Colors.shades.shade600, borderRadius:4, marginLeft:3 }} onPress={() => setDraftCompetitionMatchMarket(trade_side)}>
145
+ <Text textAlign="center" size={12} color={Colors.brand.midnight} weight='semibold'>{trade_side.side.toUpperCase()}{market.var_1_required?` ${ManageCompetitionHelpers.getVar1Label(trade_side.var_1, market)}`:''}</Text>
146
+ <Text textAlign="center" size={12} color={Colors.brand.midnight} weight='semibold'>{ManageCompetitionHelpers.getOddsLabel(trade_side.odds)}</Text>
147
+ </TouchableOpacity>
148
+ </View>
149
+
150
+ </View>
151
+ )
152
+ */
153
+ }
154
+
155
+ export default CompetitionMatchMarketCard
@@ -0,0 +1,229 @@
1
+ import { FlatList, TextInput, TouchableOpacity, View } from "react-native"
2
+ import React, { useEffect, useState } from "react";
3
+ import type { CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, PublicPlayerProps } from "../../types";
4
+ import { ManageCompetitionApi } from "../api";
5
+ import Colors from "../../constants/colors";
6
+ import { Icons, Text } from "../../Components";
7
+ import { view_styles } from "../../constants/styles";
8
+ import DropDown from "../../Components/Dropdown";
9
+
10
+ type CompetitionSettingsFormProps = {
11
+ player?: PublicPlayerProps,
12
+ competition: CompetitionProps,
13
+ width:number,
14
+ competition_result_types:CompetitionResultTypeProps[],
15
+ competition_types:CompetitionTypeProps[],
16
+ onCompetitionUpdate:(c:CompetitionProps) => void
17
+ }
18
+
19
+ const market_types = ['FOR_MONEY', 'FREE']
20
+
21
+ const CompetitionSettingsForm = ({ player, width, competition, competition_types, competition_result_types, onCompetitionUpdate }: CompetitionSettingsFormProps) => {
22
+ const [ expanded, setExpanded ] = useState(false);
23
+ //const [ player_selector_visible, setPlayerSelectorVisible ] = useState(false);
24
+ const [ pacer, setPacer ] = useState<PublicPlayerProps>();
25
+
26
+ const competition_type = competition_types.find(ct => ct.competition_type_id == competition?.competition_type_id);
27
+ const competition_result_type = competition_result_types.find(crt => crt.competition_result_type_id == competition?.competition_result_type_id);
28
+
29
+
30
+
31
+ useEffect(() => {
32
+ if(!competition?.pacer_id){ return }
33
+ if(competition.pacer_id == pacer?.player_id){ return } //Already got him/her
34
+ getPacerFromServer(competition.pacer_id)
35
+ },[competition?.pacer_id])
36
+
37
+ useEffect(() => {
38
+ if(!competition_result_type){ return }
39
+ if(competition_result_type.type == 'outpace' && !competition.pacer_id){
40
+ setPacer(player)
41
+ onCompetitionUpdate({ ...competition, pacer_id: player?.player_id })
42
+ }
43
+ },[competition_result_type?.type])
44
+
45
+ const getPacerFromServer = async(player_id:string) => {
46
+ const ps = await ManageCompetitionApi.getPlayersByPlayerIds([player_id])
47
+ setPacer(ps[0])
48
+ }
49
+
50
+ const renderMarketTypes = (data:{ item:string, index:number }) => {
51
+ const selected = data.item == competition.market_type ? true : false
52
+ return (
53
+ <TouchableOpacity style={{ minWidth:75, margin:1, borderRadius:8, padding:10, backgroundColor:selected?Colors.brand.midnight:undefined }} onPress={() => onCompetitionUpdate({ ...competition, market_type: data.item })}>
54
+ <Text textAlign="center" color={selected?Colors.shades.white:Colors.brand.midnight} weight={selected?'bold':'regular'} size={14}>{data.item == 'FOR_MONEY'?'USD':'EDGE COINS'}</Text>
55
+ </TouchableOpacity>
56
+ )
57
+ }
58
+
59
+ const renderCompetitionTypes = (data:{ item:CompetitionTypeProps, index:number }) => {
60
+ const selected = data.item.competition_type_id == competition.competition_type_id ? true : false
61
+ return (
62
+ <TouchableOpacity style={{ minWidth:75, margin:1, borderRadius:8, padding:10, backgroundColor:selected?Colors.brand.midnight:undefined }} onPress={() => onCompetitionUpdate({ ...competition, competition_type_id: data.item.competition_type_id })}>
63
+ <Text textAlign="center" color={selected?Colors.shades.white:Colors.brand.midnight} weight={selected?'bold':'regular'} size={14}>{data.item.type_label}</Text>
64
+ </TouchableOpacity>
65
+ )
66
+ }
67
+
68
+ if(!competition){ return <></> }
69
+ return (
70
+ <View style={{ ...view_styles.section, flexGrow:1 }}>
71
+ <TouchableOpacity style={view_styles.section_header} onPress={() => setExpanded(!expanded)}>
72
+ <View style={{ flex:1 }}>
73
+ <Text theme='header'>Competition Settings</Text>
74
+ <Text style={{ marginTop:3 }} theme='body'>Manage the high level information of this competition</Text>
75
+ </View>
76
+ <Icons.ChevronIcon direction={expanded ? 'up' : 'down'} color={Colors.brand.midnight} size={8} />
77
+ </TouchableOpacity>
78
+ {expanded ?
79
+ <View nativeID="competition_settings" style={{ ...view_styles.section_body, maxWidth:width, backgroundColor:Colors.shades.shade100 }}>
80
+
81
+
82
+ <View nativeID="competition_currency" style={{ ...view_styles.body_row, flexWrap:'wrap', maxWidth:width}}>
83
+ <View style={{ flex:1, margin:5, minWidth:200 }}>
84
+ <Text theme="header_2">Competition Currency</Text>
85
+ <Text style={{ marginTop:3 }} theme="body">Is the ticket price in real-money or edge coins?</Text>
86
+ </View>
87
+ <View style={{ justifyContent:'flex-end', margin: 5, borderRadius:8, backgroundColor:Colors.shades.white }}>
88
+ <FlatList
89
+ data={market_types}
90
+ renderItem={renderMarketTypes}
91
+ keyExtractor={(item) => item}
92
+ horizontal
93
+ />
94
+ </View>
95
+ </View>
96
+
97
+ <View nativeID="competition_type" style={{ ...view_styles.body_row, flexWrap:'wrap', maxWidth:width}}>
98
+ <View style={{ flex:1, margin:5, minWidth:200 }}>
99
+ <Text theme="header_2">Competition Type</Text>
100
+ <Text style={{ marginTop:3 }} theme="body">{competition_type?competition_type.description:'Choose the type of competition this is.'}</Text>
101
+ </View>
102
+ <View style={{ justifyContent:'flex-end', margin:5, borderRadius:8, backgroundColor:Colors.shades.white }}>
103
+ <FlatList
104
+ data={competition_types}
105
+ renderItem={renderCompetitionTypes}
106
+ keyExtractor={(item) => item.competition_type_id.toString()}
107
+ horizontal
108
+ />
109
+ </View>
110
+ </View>
111
+
112
+ <View nativeID="competition_payout" style={{ ...view_styles.body_row, flexWrap:'wrap', maxWidth:width}}>
113
+ <View style={{ flex:1, margin:5, minWidth:200 }}>
114
+ <Text theme="header_2">Competition Payout Type</Text>
115
+ <Text style={{ marginTop:3 }} theme="body">{competition_result_type?competition_result_type.description:'Choose the type of payout for this competition'}</Text>
116
+ </View>
117
+ <View style={{ justifyContent:'flex-end', margin:5, borderRadius:8, backgroundColor:Colors.shades.white }}>
118
+ <DropDown
119
+ dropdown_options={[
120
+ {value: 'competition_result_type_id', eligible_options: competition_result_types.map(t => t.label)}
121
+ ]}
122
+ selected_value={competition_result_type?.label ?? ''}
123
+ onOptionSelect={(type) => {
124
+ const new_result_type = competition_result_types.find(crt => crt.label == type);
125
+ if(!new_result_type){ return }
126
+ onCompetitionUpdate({ ...competition, competition_result_type_id: new_result_type.competition_result_type_id })
127
+ }}
128
+ />
129
+ </View>
130
+ </View>
131
+
132
+
133
+ <View nativeID="buy_in" style={{ ...view_styles.body_row, flexWrap:'wrap', maxWidth:width}}>
134
+ <View style={{ flex:1, margin:5, minWidth:200 }}>
135
+ <Text theme="header_2">Ticket Price</Text>
136
+ <Text style={{ marginTop:3 }} theme="body">Set the amount required to purchase a ticket to participate</Text>
137
+ </View>
138
+ <TextInput
139
+ style={{ ...view_styles.input, textAlign:'center', margin:5, width:100, backgroundColor:Colors.shades.white }}
140
+ onChangeText={(text) => onCompetitionUpdate({ ...competition, buy_in: text })}
141
+ placeholder="25"
142
+ value={competition.buy_in as string}
143
+ placeholderTextColor={Colors.brand.slate}
144
+ />
145
+ </View>
146
+
147
+ <View nativeID="Max Tickets" style={{ flexDirection:'row', flexWrap:'wrap', padding:10, borderBottomWidth:1, borderBottomColor:Colors.shades.white }}>
148
+ <View style={{ flex:1, marginRight:5 }}>
149
+ <Text theme="header_2">Max Tickets</Text>
150
+ <Text style={{ marginTop:3 }} theme="body">Maximum number of tickets that can be sold</Text>
151
+ </View>
152
+ <TextInput
153
+ style={{ ...view_styles.input, textAlign:'center', width:100, backgroundColor:Colors.shades.white }}
154
+ onChangeText={(text) => onCompetitionUpdate({ ...competition, available_tickets: text })}
155
+ placeholder="100"
156
+ value={competition.available_tickets as string}
157
+ placeholderTextColor={Colors.brand.slate}
158
+ />
159
+ </View>
160
+ </View>
161
+ :<></>}
162
+ </View>
163
+ )
164
+ }
165
+
166
+ export default CompetitionSettingsForm
167
+
168
+ /*
169
+ {competition_result_type?.type == 'outpace' ?
170
+ <View nativeID="competition_payout_type" style={{ flexDirection:'row', flexWrap:'wrap', padding:10, borderBottomWidth:1, borderBottomColor:Colors.shades.white }}>
171
+ <View style={{ flex:1, marginRight:5 }}>
172
+ <Text size={16} color={Colors.brand.midnight} weight='bold'>Pacer</Text>
173
+ <Text size={14} color={Colors.brand.midnight} weight='regular'>Select the player that must be beat</Text>
174
+ </View>
175
+ <View style={{ flexDirection:'row', padding:5, backgroundColor:Colors.shades.white, borderRadius:8 }}>
176
+ {pacer?
177
+ <View style={{ flexDirection:'row', padding:5, backgroundColor:Colors.shades.white, borderRightWidth:1, borderRightColor:Colors.shades.shade600 }}>
178
+ <Image
179
+ source={{ uri: pacer.profile_pic }}
180
+ style={{ height:40, width:40, padding:5 }}
181
+ resizeMode="cover"
182
+ />
183
+ <View style={{ flex:1, padding:5 }}>
184
+ <Text size={14} color={Colors.brand.midnight}>@{pacer.username}</Text>
185
+ </View>
186
+ </View>
187
+ :<></>}
188
+ <Button
189
+ title={pacer?'Change':'Add Pacer'}
190
+ title_color={Colors.brand.electric}
191
+ onPress={() => setPlayerSelectorVisible(true)}
192
+ />
193
+ </View>
194
+ </View>
195
+ :<></>}
196
+ */
197
+
198
+
199
+ /*
200
+ <View style={{ position:'absolute', top:0, left:0, right:0, alignItems:'center' }}>
201
+ <PlayerSelector
202
+ visible={player_selector_visible}
203
+ onPlayerSelect={(player) => {
204
+ setPacer(player)
205
+ onCompetitionUpdate({ ...competition, pacer_id:player.player_id })
206
+ setPlayerSelectorVisible(false)
207
+ }}
208
+ onClose={() => setPlayerSelectorVisible(false)}
209
+ />
210
+ </View>
211
+ */
212
+
213
+ /*
214
+ {creator?.role == 'admin' ?
215
+ <View nativeID="Guaranteed_payout" style={{ flexDirection:'row', flexWrap:'wrap', padding:10, borderBottomWidth:1, borderBottomColor:Colors.shades.white }}>
216
+ <View style={{ flex:1, marginRight:5 }}>
217
+ <Text size={16} color={Colors.brand.midnight} weight='bold'>Guaranteed Payout (ADMIN ONLY)</Text>
218
+ <Text size={14} color={Colors.brand.midnight} weight='regular'>How much payout is guaranteed?</Text>
219
+ </View>
220
+ <TextInput
221
+ style={{ padding:10, borderRadius:8, backgroundColor:Colors.shades.white }}
222
+ onChangeText={(text) => onCompetitionUpdate({ ...competition, guaranteed_payout: text })}
223
+ placeholder="0"
224
+ value={competition.guaranteed_payout}
225
+ placeholderTextColor={Colors.brand.slate}
226
+ />
227
+ </View>
228
+ :<></>}
229
+ */
@@ -0,0 +1,66 @@
1
+ import React from 'react';
2
+ import { FlatList, ScrollView, TouchableOpacity, View } from "react-native"
3
+ import type { MarketProps } from '../../types';
4
+ import { Button, Switch, Text } from '../../Components';
5
+ import Colors from '../../constants/colors';
6
+ import { view_styles } from '../../constants/styles';
7
+
8
+ type MarketSelectorProps = {
9
+ visible:boolean,
10
+ markets:MarketProps[],
11
+ selected_markets:string[],
12
+ onSelectMarket: (market:MarketProps) => void,
13
+ onDeselectMarket: (market:MarketProps) => void,
14
+ onClose:() => void
15
+ }
16
+ const MarketSelector = ({ visible, markets, selected_markets, onSelectMarket, onDeselectMarket, onClose } : MarketSelectorProps) => {
17
+
18
+
19
+ const renderMarkets = (data:{item:MarketProps, index:number}) => {
20
+ const selected = selected_markets.includes(data.item.market_id) ? true : false
21
+ return (
22
+ <TouchableOpacity style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.shades.shade600 }} onPress={() => selected ? onDeselectMarket(data.item) : onSelectMarket(data.item)}>
23
+ <View style={{ flex:1, marginRight:10 }}>
24
+ <Text size={14} color={Colors.brand.midnight} weight='bold'>{data.item.type == 'Stat' ? data.item.stat_label : data.item.type}</Text>
25
+ <Text style={{ marginTop:3 }} size={14} color={Colors.brand.midnight} weight='regular'>{data.item.description}</Text>
26
+ </View>
27
+ <Switch
28
+ switch_type="on_off"
29
+ value={selected}
30
+ onChange={() => {
31
+ if(!selected){ return onSelectMarket(data.item) }
32
+ return onDeselectMarket(data.item)
33
+ }}
34
+ />
35
+ </TouchableOpacity>
36
+ )
37
+ }
38
+
39
+ if(!visible){ return <></> }
40
+
41
+ return (
42
+ <View style={{ borderRadius:8, minWidth:250, maxHeight:450, backgroundColor:Colors.shades.white, ...view_styles.float }}>
43
+ <View style={{ flexDirection:'row' }}>
44
+ <View style={{ flex:1 }} />
45
+ <Button
46
+ title="CLOSE"
47
+ style={{ alignSelf:'flex-end' }}
48
+ backgroundColor={Colors.brand.electric}
49
+ padding={10}
50
+ title_color={Colors.shades.white}
51
+ borderRadius={8}
52
+ onPress={() => onClose()}
53
+ />
54
+ </View>
55
+ <ScrollView style={{ flex:1 }}>
56
+ <FlatList
57
+ data={markets}
58
+ renderItem={renderMarkets}
59
+ keyExtractor={(item) => item.market_id.toString()}
60
+ />
61
+ </ScrollView>
62
+ </View>
63
+ )
64
+ }
65
+
66
+ export default MarketSelector
@@ -0,0 +1,163 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { ScrollView, View, ActivityIndicator } from "react-native"
3
+ import { view_styles } from '../constants/styles';
4
+ import CompetitionInfoForm from './components/CompetitionInfoForm';
5
+ import type { AthleteProps, CompetitionMatchMarketProps, CompetitionMatchProps, CompetitionPayoutTypeProps, CompetitionProps, CompetitionResultTypeProps, CompetitionTypeProps, EventProps, LeagueProps, MarketProps, MatchProps, TeamProps, TournamentProps } from '../types';
6
+ import Colors from '../constants/colors';
7
+ import { ManageCompetitionApi, ManageCompetitionMatchApi } from './api';
8
+ import CompetitionSettingsForm from './components/CompetitionSettingsForm';
9
+ import CompetitionContestsForm from './components/CompetitionContestsForm';
10
+
11
+ type CompetitionManagerProps = {
12
+ player_id?:string,
13
+ competition_id:string
14
+ }
15
+
16
+ const CompetitionManager = ({ competition_id }:CompetitionManagerProps) => {
17
+ const [ module_size, setModuleSize ] = useState({ height:0, width:0 });
18
+ const [ competition_data, setCompetitionData ] = useState<{
19
+ loaded:boolean,
20
+ loading:boolean,
21
+ competition?:CompetitionProps,
22
+ draft_competition?:CompetitionProps,
23
+ competition_result_types:CompetitionResultTypeProps[],
24
+ competition_payout_types:CompetitionPayoutTypeProps[],
25
+ competition_types:CompetitionTypeProps[],
26
+ competition_matches:CompetitionMatchProps[],
27
+ competition_match_markets:CompetitionMatchMarketProps[],
28
+ markets:MarketProps[],
29
+ leagues:LeagueProps[],
30
+ events:EventProps[],
31
+ tournaments:TournamentProps[],
32
+ matches:MatchProps[],
33
+ teams:TeamProps[],
34
+ athletes:AthleteProps[]
35
+
36
+ }>({
37
+ loaded:false,
38
+ loading:false,
39
+ competition_result_types: [],
40
+ competition_types: [],
41
+ competition_matches: [],
42
+ competition_payout_types:[],
43
+ competition_match_markets:[],
44
+ markets: [],
45
+ leagues:[],
46
+ events: [],
47
+ tournaments: [],
48
+ matches:[],
49
+ teams:[],
50
+ athletes:[]
51
+ })
52
+
53
+ const { loaded, competition, competition_result_types, competition_types, draft_competition, competition_matches, competition_match_markets, markets, leagues, events, tournaments, matches, teams, athletes } = competition_data;
54
+
55
+
56
+ useEffect(() => {
57
+ if(!loaded){ ManageCompetitionApi.setEnvironment() }
58
+ getDataFromServer(competition_id);
59
+ },[competition_id])
60
+
61
+ const getDataFromServer = async(id:string) => {
62
+ const c = await ManageCompetitionApi.getCompetitionById(id);
63
+ const cm_resp = await ManageCompetitionMatchApi.getCompetitionMatchesByCompetitionId(id);
64
+ const options = await ManageCompetitionApi.getCompetitionOptions()
65
+ const lgs = await ManageCompetitionApi.getLeagues();
66
+ const mks = await ManageCompetitionApi.getMarkets();
67
+ //Get unique contests
68
+ let event_ids = cm_resp.competition_matches.filter(cm => cm.event_type == 'team').map(cm => cm.event_id);
69
+ let tournament_ids = cm_resp.competition_matches.filter(cm => cm.event_type == 'tournament').map(cm => cm.event_id);
70
+ let match_ids = cm_resp.competition_matches.filter(cm => cm.event_type == 'match').map(cm => cm.event_id);
71
+ //Get unique side ids
72
+ let athlete_ids = cm_resp.competition_matches.filter(cm => cm.side_type_override == 'athlete').map(cm => cm.side_id_override ?? '0');
73
+ let team_ids = cm_resp.competition_matches.filter(cm => cm.side_type_override == 'team').map(cm => cm.side_id_override ?? '0');
74
+
75
+ let c_events:EventProps[] = []
76
+ if(event_ids.length > 0){ c_events = await ManageCompetitionMatchApi.getEventsByEventIds(event_ids) }
77
+
78
+ let c_tournaments:TournamentProps[] = []
79
+ if(tournament_ids.length > 0){ c_tournaments = await ManageCompetitionMatchApi.getTournamentsByTournamentIds(tournament_ids) }
80
+
81
+ let c_matches:MatchProps[] = []
82
+ if(match_ids.length > 0){ c_matches = await ManageCompetitionMatchApi.getMatchesByMatchIds(match_ids) }
83
+
84
+ let c_teams:TeamProps[] = []
85
+ if(team_ids.length > 0){ c_teams = await ManageCompetitionMatchApi.getTeamsByIds(team_ids) }
86
+
87
+ let c_athletes:AthleteProps[] = []
88
+ if(athlete_ids.length > 0){ c_athletes = await ManageCompetitionMatchApi.getAthletesByIds(athlete_ids) }
89
+
90
+ setCompetitionData({
91
+ ...competition_data,
92
+ loading: false,
93
+ competition: c,
94
+ leagues: lgs,
95
+ competition_types: options.competition_types,
96
+ competition_payout_types: options.competition_payout_types,
97
+ competition_result_types: options.competition_result_types,
98
+ draft_competition: c,
99
+ competition_matches: cm_resp.competition_matches,
100
+ competition_match_markets: cm_resp.competition_match_markets,
101
+ events: c_events,
102
+ markets: mks,
103
+ tournaments: c_tournaments,
104
+ matches: c_matches,
105
+ teams: c_teams,
106
+ athletes: c_athletes,
107
+ })
108
+
109
+ }
110
+
111
+
112
+ if(!competition || !draft_competition){
113
+ return (
114
+ <View style={{flex:1}}>
115
+ <ActivityIndicator size='large' color={Colors.brand.midnight} style={{ padding:20, alignSelf:'center' }} />
116
+ </View>
117
+ )
118
+ }
119
+ console.log(module_size)
120
+ return (
121
+ <View style={{ flex:1 }}>
122
+ <ScrollView style={{ flex:1 }} onLayout={(ev) => {
123
+ const { width, height } = ev.nativeEvent.layout;
124
+ setModuleSize({ height, width })
125
+ }}>
126
+ <View style={{ ...view_styles.wrapper }}>
127
+ <CompetitionInfoForm
128
+ competition={draft_competition}
129
+ width={module_size.width - 20}
130
+ onCompetitionUpdate={(comp) => setCompetitionData({ ...competition_data, draft_competition: comp})}
131
+ />
132
+ <CompetitionSettingsForm
133
+ competition={draft_competition}
134
+ width={module_size.width - 20}
135
+ competition_result_types={competition_result_types}
136
+ competition_types={competition_types}
137
+ onCompetitionUpdate={(comp) => setCompetitionData({ ...competition_data, draft_competition: comp})}
138
+ />
139
+ <CompetitionContestsForm
140
+ width={module_size.width - 20}
141
+ competition={draft_competition}
142
+ competition_matches={competition_matches}
143
+ competition_match_markets={competition_match_markets}
144
+ events={events}
145
+ teams={teams}
146
+ athletes={athletes}
147
+ tournaments={tournaments}
148
+ matches={matches}
149
+ leagues={leagues}
150
+ markets={markets}
151
+ onSaveCompetitionMatch={() => console.log('SAVE EVENT')}
152
+ onDeleteCompetitionMatch={() => console.log('DELEVE')}
153
+ onUpdateCompetitionMatch={() => console.log('UPDATE')}
154
+ onSaveCompetitionMatchMarkets={(smms) => console.log(smms)}
155
+ onDeleteCompetitionMatchMarkets={(cmms) => console.log(cmms)}
156
+ />
157
+ </View>
158
+ </ScrollView>
159
+ </View>
160
+ )
161
+ }
162
+
163
+ export default CompetitionManager