be-components 4.5.5 → 4.5.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 (131) hide show
  1. package/lib/commonjs/Bracket/api/index.js +15 -5
  2. package/lib/commonjs/Bracket/api/index.js.map +1 -1
  3. package/lib/commonjs/Bracket/components/BracketCompetitionActions.js +17 -12
  4. package/lib/commonjs/Bracket/components/BracketCompetitionActions.js.map +1 -1
  5. package/lib/commonjs/Bracket/components/BracketCompetitionCard.js +1 -0
  6. package/lib/commonjs/Bracket/components/BracketCompetitionCard.js.map +1 -1
  7. package/lib/commonjs/Bracket/components/BracketPlay/BracketRound.js +2 -0
  8. package/lib/commonjs/Bracket/components/BracketPlay/BracketRound.js.map +1 -1
  9. package/lib/commonjs/Bracket/components/BracketPlay/index.js +0 -8
  10. package/lib/commonjs/Bracket/components/BracketPlay/index.js.map +1 -1
  11. package/lib/commonjs/Bracket/components/EditPlayerBracket.js +32 -3
  12. package/lib/commonjs/Bracket/components/EditPlayerBracket.js.map +1 -1
  13. package/lib/commonjs/Bracket/components/EnteredCompetitionsModal.js +197 -0
  14. package/lib/commonjs/Bracket/components/EnteredCompetitionsModal.js.map +1 -0
  15. package/lib/commonjs/Bracket/components/JoinCompetitionCard.js +78 -3
  16. package/lib/commonjs/Bracket/components/JoinCompetitionCard.js.map +1 -1
  17. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js +3 -3
  18. package/lib/commonjs/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  19. package/lib/commonjs/Bracket/components/PlayerBracketCard.js +21 -4
  20. package/lib/commonjs/Bracket/components/PlayerBracketCard.js.map +1 -1
  21. package/lib/commonjs/Bracket/components/PlayerBrackets.js +27 -4
  22. package/lib/commonjs/Bracket/components/PlayerBrackets.js.map +1 -1
  23. package/lib/commonjs/Bracket/components/RoomHome.js +436 -117
  24. package/lib/commonjs/Bracket/components/RoomHome.js.map +1 -1
  25. package/lib/commonjs/Bracket/index.js +254 -420
  26. package/lib/commonjs/Bracket/index.js.map +1 -1
  27. package/lib/commonjs/Competition/components/EnterCompetitionPrompt.js.map +1 -1
  28. package/lib/commonjs/Engage/index.js.map +1 -1
  29. package/lib/module/Bracket/api/index.js +15 -5
  30. package/lib/module/Bracket/api/index.js.map +1 -1
  31. package/lib/module/Bracket/components/BracketCompetitionActions.js +18 -13
  32. package/lib/module/Bracket/components/BracketCompetitionActions.js.map +1 -1
  33. package/lib/module/Bracket/components/BracketCompetitionCard.js +1 -0
  34. package/lib/module/Bracket/components/BracketCompetitionCard.js.map +1 -1
  35. package/lib/module/Bracket/components/BracketPlay/BracketRound.js +2 -0
  36. package/lib/module/Bracket/components/BracketPlay/BracketRound.js.map +1 -1
  37. package/lib/module/Bracket/components/BracketPlay/index.js +0 -8
  38. package/lib/module/Bracket/components/BracketPlay/index.js.map +1 -1
  39. package/lib/module/Bracket/components/EditPlayerBracket.js +33 -4
  40. package/lib/module/Bracket/components/EditPlayerBracket.js.map +1 -1
  41. package/lib/module/Bracket/components/EnteredCompetitionsModal.js +190 -0
  42. package/lib/module/Bracket/components/EnteredCompetitionsModal.js.map +1 -0
  43. package/lib/module/Bracket/components/JoinCompetitionCard.js +78 -3
  44. package/lib/module/Bracket/components/JoinCompetitionCard.js.map +1 -1
  45. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js +3 -3
  46. package/lib/module/Bracket/components/ManageBracketCompetitionForm.js.map +1 -1
  47. package/lib/module/Bracket/components/PlayerBracketCard.js +21 -4
  48. package/lib/module/Bracket/components/PlayerBracketCard.js.map +1 -1
  49. package/lib/module/Bracket/components/PlayerBrackets.js +28 -5
  50. package/lib/module/Bracket/components/PlayerBrackets.js.map +1 -1
  51. package/lib/module/Bracket/components/RoomHome.js +438 -119
  52. package/lib/module/Bracket/components/RoomHome.js.map +1 -1
  53. package/lib/module/Bracket/index.js +255 -421
  54. package/lib/module/Bracket/index.js.map +1 -1
  55. package/lib/module/Competition/components/EnterCompetitionPrompt.js.map +1 -1
  56. package/lib/module/Engage/index.js.map +1 -1
  57. package/lib/typescript/lib/commonjs/Bracket/api/index.d.ts +6 -1
  58. package/lib/typescript/lib/commonjs/Bracket/api/index.d.ts.map +1 -1
  59. package/lib/typescript/lib/commonjs/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  60. package/lib/typescript/lib/commonjs/Bracket/components/BracketCompetitionCard.d.ts.map +1 -1
  61. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/BracketRound.d.ts.map +1 -1
  62. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts +1 -2
  63. package/lib/typescript/lib/commonjs/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  64. package/lib/typescript/lib/commonjs/Bracket/components/EditPlayerBracket.d.ts +3 -1
  65. package/lib/typescript/lib/commonjs/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  66. package/lib/typescript/lib/commonjs/Bracket/components/EnteredCompetitionsModal.d.ts +14 -0
  67. package/lib/typescript/lib/commonjs/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  68. package/lib/typescript/lib/commonjs/Bracket/components/JoinCompetitionCard.d.ts +2 -1
  69. package/lib/typescript/lib/commonjs/Bracket/components/JoinCompetitionCard.d.ts.map +1 -1
  70. package/lib/typescript/lib/commonjs/Bracket/components/PlayerBrackets.d.ts +4 -1
  71. package/lib/typescript/lib/commonjs/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  72. package/lib/typescript/lib/commonjs/Bracket/components/RoomHome.d.ts +4 -14
  73. package/lib/typescript/lib/commonjs/Bracket/components/RoomHome.d.ts.map +1 -1
  74. package/lib/typescript/lib/commonjs/Bracket/index.d.ts.map +1 -1
  75. package/lib/typescript/lib/module/Bracket/api/index.d.ts +6 -1
  76. package/lib/typescript/lib/module/Bracket/api/index.d.ts.map +1 -1
  77. package/lib/typescript/lib/module/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  78. package/lib/typescript/lib/module/Bracket/components/BracketCompetitionCard.d.ts.map +1 -1
  79. package/lib/typescript/lib/module/Bracket/components/BracketPlay/BracketRound.d.ts.map +1 -1
  80. package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts +1 -2
  81. package/lib/typescript/lib/module/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  82. package/lib/typescript/lib/module/Bracket/components/EditPlayerBracket.d.ts +5 -2
  83. package/lib/typescript/lib/module/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  84. package/lib/typescript/lib/module/Bracket/components/EnteredCompetitionsModal.d.ts +15 -0
  85. package/lib/typescript/lib/module/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  86. package/lib/typescript/lib/module/Bracket/components/JoinCompetitionCard.d.ts +2 -1
  87. package/lib/typescript/lib/module/Bracket/components/JoinCompetitionCard.d.ts.map +1 -1
  88. package/lib/typescript/lib/module/Bracket/components/PlayerBracketCard.d.ts +3 -1
  89. package/lib/typescript/lib/module/Bracket/components/PlayerBracketCard.d.ts.map +1 -1
  90. package/lib/typescript/lib/module/Bracket/components/PlayerBrackets.d.ts +6 -2
  91. package/lib/typescript/lib/module/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  92. package/lib/typescript/lib/module/Bracket/components/RoomHome.d.ts +4 -14
  93. package/lib/typescript/lib/module/Bracket/components/RoomHome.d.ts.map +1 -1
  94. package/lib/typescript/lib/module/Bracket/index.d.ts.map +1 -1
  95. package/lib/typescript/src/Bracket/api/index.d.ts +5 -1
  96. package/lib/typescript/src/Bracket/api/index.d.ts.map +1 -1
  97. package/lib/typescript/src/Bracket/components/BracketCompetitionActions.d.ts.map +1 -1
  98. package/lib/typescript/src/Bracket/components/BracketCompetitionCard.d.ts.map +1 -1
  99. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts +1 -2
  100. package/lib/typescript/src/Bracket/components/BracketPlay/index.d.ts.map +1 -1
  101. package/lib/typescript/src/Bracket/components/EditPlayerBracket.d.ts +8 -1
  102. package/lib/typescript/src/Bracket/components/EditPlayerBracket.d.ts.map +1 -1
  103. package/lib/typescript/src/Bracket/components/EnteredCompetitionsModal.d.ts +21 -0
  104. package/lib/typescript/src/Bracket/components/EnteredCompetitionsModal.d.ts.map +1 -0
  105. package/lib/typescript/src/Bracket/components/JoinCompetitionCard.d.ts +2 -1
  106. package/lib/typescript/src/Bracket/components/JoinCompetitionCard.d.ts.map +1 -1
  107. package/lib/typescript/src/Bracket/components/PlayerBracketCard.d.ts +3 -2
  108. package/lib/typescript/src/Bracket/components/PlayerBracketCard.d.ts.map +1 -1
  109. package/lib/typescript/src/Bracket/components/PlayerBrackets.d.ts +9 -1
  110. package/lib/typescript/src/Bracket/components/PlayerBrackets.d.ts.map +1 -1
  111. package/lib/typescript/src/Bracket/components/RoomHome.d.ts +11 -18
  112. package/lib/typescript/src/Bracket/components/RoomHome.d.ts.map +1 -1
  113. package/lib/typescript/src/Bracket/index.d.ts.map +1 -1
  114. package/lib/typescript/src/Engage/index.d.ts.map +1 -1
  115. package/package.json +1 -1
  116. package/src/Bracket/api/index.ts +10 -5
  117. package/src/Bracket/components/BracketCompetitionActions.tsx +14 -12
  118. package/src/Bracket/components/BracketCompetitionCard.tsx +1 -0
  119. package/src/Bracket/components/BracketPlay/BracketRound.tsx +2 -2
  120. package/src/Bracket/components/BracketPlay/index.tsx +13 -18
  121. package/src/Bracket/components/EditPlayerBracket.tsx +58 -42
  122. package/src/Bracket/components/EnteredCompetitionsModal.tsx +113 -0
  123. package/src/Bracket/components/JoinCompetitionCard.tsx +46 -3
  124. package/src/Bracket/components/ManageBracketCompetitionForm.tsx +3 -3
  125. package/src/Bracket/components/PlayerBracketCard.tsx +9 -4
  126. package/src/Bracket/components/PlayerBrackets.tsx +45 -33
  127. package/src/Bracket/components/RoomHome.tsx +356 -117
  128. package/src/Bracket/index.tsx +277 -402
  129. package/src/Competition/components/EnterCompetitionPrompt.tsx +1 -1
  130. package/src/Engage/index.tsx +1 -0
  131. package/src/types.d.ts +1 -0
@@ -2,7 +2,6 @@ import React, { useEffect, useState } from 'react';
2
2
  import { ActivityIndicator, ScrollView, Image } from "react-native";
3
3
  import type { AthleteProps, BracketGroupProps, BracketProps, BracketRoundProps, CompetitionPlayerBracketProps, EventProps, MyPlayerProps, PlayerBracketPickProps, PlayerBracketProps, RoundEventProps, TeamProps } from '../../../types';
4
4
  import { BracketApi, BracketComeptitionApi, BracketCompetitionHelpers } from '../../api';
5
- import { Icons } from '../../../Components';
6
5
  import BracketRoundSection from './BracketRound';
7
6
  import { Button, Text, View } from '../../../Components/Themed';
8
7
  import { useColors } from '../../../constants/useColors';
@@ -12,13 +11,12 @@ type BracketPlayProps = {
12
11
  player_bracket_id?:string,
13
12
  bracket_id?:string,
14
13
  width:number,
15
- onEditPlayerBracket: (pb:PlayerBracketProps) => void,
16
14
  onRequestAuthenticate: () => void,
17
15
  onChangePlayerBracket: (bracket_id:string) => void,
18
16
  onPlayerBracketUpdate: (pb:PlayerBracketProps, cpbs:CompetitionPlayerBracketProps[]) => void,
19
17
  }
20
18
 
21
- const BracketPlay = ({ player, width, bracket_id, player_bracket_id, onEditPlayerBracket, onPlayerBracketUpdate, onChangePlayerBracket, onRequestAuthenticate }:BracketPlayProps) => {
19
+ const BracketPlay = ({ player, width, bracket_id, player_bracket_id, onPlayerBracketUpdate, onChangePlayerBracket, onRequestAuthenticate }:BracketPlayProps) => {
22
20
  const Colors = useColors();
23
21
  const [ round_event_loading, setRoundEventLoading ] = useState<string|undefined>(undefined);
24
22
  const [ play_data, setPlayData ] = useState<{
@@ -146,18 +144,18 @@ const BracketPlay = ({ player, width, bracket_id, player_bracket_id, onEditPlaye
146
144
 
147
145
  const renderBracketRounds = (data: { item:BracketRoundProps, index:number }) => {
148
146
  return (
149
- <BracketRoundSection
150
- round_event_loading={round_event_loading}
151
- bracket_round={data.item}
152
- round_events={round_events}
153
- teams={teams}
154
- athletes={athletes}
155
- player_bracket_picks={player_bracket_picks}
156
- width={round_width}
157
- orientation='right'
158
- onPick={(pick) => handlePick(pick)}
159
-
160
- />
147
+ <BracketRoundSection
148
+ round_event_loading={round_event_loading}
149
+ bracket_round={data.item}
150
+ round_events={round_events}
151
+ teams={teams}
152
+ athletes={athletes}
153
+ player_bracket_picks={player_bracket_picks}
154
+ width={round_width}
155
+ orientation='right'
156
+ onPick={(pick) => handlePick(pick)}
157
+
158
+ />
161
159
  )
162
160
  }
163
161
 
@@ -195,9 +193,6 @@ const BracketPlay = ({ player, width, bracket_id, player_bracket_id, onEditPlaye
195
193
  <Text size={14} theme='h1'>{player_bracket.bracket_name}</Text>
196
194
  <Text style={{ marginTop:3 }} size={12} theme='description'>{(player_bracket.completion_pct*100).toFixed(2)}% Complete</Text>
197
195
  </View>
198
- <Button transparent onPress={() => onEditPlayerBracket(player_bracket)}>
199
- <Icons.EditIcon size={14} color={Colors.text.action} />
200
- </Button>
201
196
  <Button
202
197
  title='Change'
203
198
  style={{ padding:10 }}
@@ -1,18 +1,25 @@
1
- import React, { useState } from 'react';
1
+ import React, { useEffect, useState } from 'react';
2
2
  import { Button, Text, TextInput, View } from "../../Components/Themed"
3
3
  import type { PlayerBracketProps } from "../../types"
4
4
  import { BracketComeptitionApi } from '../api';
5
+ import { Modal } from 'react-native';
5
6
 
6
7
  type EditPlayerBracketProps = {
7
8
  player_bracket?:PlayerBracketProps,
9
+ view_mode?:'desktop'|'mobile',
10
+ insets?:{ top:number, bottom:number, left:number, right:number },
8
11
  onUpdatePlayerBracket:(pb:PlayerBracketProps) => void,
9
12
  onFocusPosition?:(data:{ x:number, y:number, height:number, width:number }) => void,
10
13
  onClose:() => void
11
14
  }
12
- const EditPlayerBracket = ({ player_bracket, onUpdatePlayerBracket, onFocusPosition, onClose }:EditPlayerBracketProps) => {
15
+ const EditPlayerBracket = ({ player_bracket, view_mode, onUpdatePlayerBracket, onFocusPosition, insets, onClose }:EditPlayerBracketProps) => {
13
16
  const [ draft_pb, setDraftPb ] = useState(player_bracket);
14
17
  const [ action_loading, setActionLoading ] = useState(false);
15
18
 
19
+ useEffect(() => {
20
+ setDraftPb(player_bracket)
21
+ },[player_bracket])
22
+
16
23
  const is_changed = JSON.stringify(draft_pb) != JSON.stringify(player_bracket) ? true : false
17
24
 
18
25
  const handleUpdate = async() => {
@@ -35,48 +42,57 @@ const EditPlayerBracket = ({ player_bracket, onUpdatePlayerBracket, onFocusPosit
35
42
  if(!player_bracket || !draft_pb){ return <></> }
36
43
 
37
44
  return (
38
- <View transparent>
39
- <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
40
- <View transparent style={{ flex:1 }}>
41
- <Text theme='h1'>EDIT MY BRACKET</Text>
42
- <Text style={{ marginTop:3 }} theme='description'>{player_bracket.bracket_name}</Text>
43
- </View>
44
- <Button
45
- title='DELETE'
46
- type='error'
47
- loading={action_loading}
48
- style={{ padding:10, opacity:action_loading?0.5:1 }}
49
- disabled={action_loading}
50
- onPress={() => handleDelete()}
51
- />
52
- </View>
53
- <View type='body' style={{ padding:10 }}>
54
- <View>
55
- <Text style={{ marginBottom:10 }} theme='h2'>Update Bracket Name</Text>
56
- <TextInput
57
- value={draft_pb?.bracket_name}
58
- onFocusPosition={onFocusPosition}
59
- onChangeText={(text) => setDraftPb({ ...draft_pb, bracket_name: text })}
60
- />
45
+ <Modal
46
+ visible={player_bracket ? true : false}
47
+ style={{ flex:1 }}
48
+ transparent
49
+ animationType={view_mode == 'desktop' ? 'fade' : 'slide'}
50
+ >
51
+ <View type='blur' style={view_mode == 'desktop' ? { flex:1, justifyContent:'center', alignItems:'center' } : { flex:1, justifyContent:'flex-end', paddingBottom:(insets?.bottom ?? 0)}}>
52
+ <View float style={view_mode == 'desktop' ? { width:500 }:{ margin:10 }}>
53
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
54
+ <View transparent style={{ flex:1 }}>
55
+ <Text theme='h1'>EDIT MY BRACKET</Text>
56
+ <Text style={{ marginTop:3 }} theme='description'>{player_bracket.bracket_name}</Text>
57
+ </View>
58
+ <Button
59
+ title='DELETE'
60
+ type='error'
61
+ loading={action_loading}
62
+ style={{ padding:10, opacity:action_loading?0.5:1 }}
63
+ disabled={action_loading}
64
+ onPress={() => handleDelete()}
65
+ />
66
+ </View>
67
+ <View type='body' style={{ padding:10 }}>
68
+ <View>
69
+ <Text style={{ marginBottom:10 }} theme='h2'>Update Bracket Name</Text>
70
+ <TextInput
71
+ value={draft_pb?.bracket_name}
72
+ onFocusPosition={onFocusPosition}
73
+ onChangeText={(text) => setDraftPb({ ...draft_pb, bracket_name: text })}
74
+ />
75
+ </View>
76
+ </View>
77
+ <View type='footer' style={{ flexDirection:'row', padding:10, borderBottomLeftRadius:8, borderBottomRightRadius:8 }}>
78
+ <Button
79
+ style={{ flex:1 }}
80
+ title='CANCEL'
81
+ type='close'
82
+ onPress={() => onClose()}
83
+ />
84
+ <Button
85
+ style={{ flex:2, marginLeft:5, opacity: is_changed?1:0.5 }}
86
+ title='UPDATE'
87
+ loading={action_loading}
88
+ type='success'
89
+ disabled={!is_changed || action_loading}
90
+ onPress={handleUpdate}
91
+ />
92
+ </View>
61
93
  </View>
62
94
  </View>
63
- <View type='footer' style={{ flexDirection:'row', padding:10, borderBottomLeftRadius:8, borderBottomRightRadius:8 }}>
64
- <Button
65
- style={{ flex:1 }}
66
- title='CANCEL'
67
- type='close'
68
- onPress={() => onClose()}
69
- />
70
- <Button
71
- style={{ flex:2, marginLeft:5, opacity: is_changed?1:0.5 }}
72
- title='UPDATE'
73
- loading={action_loading}
74
- type='success'
75
- disabled={!is_changed || action_loading}
76
- onPress={handleUpdate}
77
- />
78
- </View>
79
- </View>
95
+ </Modal>
80
96
  )
81
97
  }
82
98
 
@@ -0,0 +1,113 @@
1
+ import React from 'react';
2
+ import { FlatList, Image, Modal } from "react-native"
3
+ import type { AthleteProps, BracketCompetitionProps, CompetitionPlayerBracketProps, PlayerBracketProps, TeamProps } from "../../types"
4
+ import { Button, Text, View } from '../../Components/Themed';
5
+ import { useColors } from '../../constants/useColors';
6
+ import { Icons } from '../../Components';
7
+ import { BracketCompetitionHelpers } from '../api';
8
+
9
+ type EnteredCompetitionsModalProps = {
10
+ view_mode: 'desktop'|'mobile',
11
+ player_bracket?:PlayerBracketProps,
12
+ insets?:{ top:number, bottom:number, left:number, right:number },
13
+ entered_competitions:BracketCompetitionProps[],
14
+ entered_brackets:CompetitionPlayerBracketProps[],
15
+ champion_team?:TeamProps,
16
+ champion_athlete?:AthleteProps,
17
+ onClose:() => void,
18
+ onSelectCompetition:(bracket_competition:BracketCompetitionProps) => void
19
+ }
20
+ const EnteredCompetitionsModal = ({ view_mode, champion_athlete, champion_team, player_bracket, insets, entered_brackets, entered_competitions, onClose, onSelectCompetition }:EnteredCompetitionsModalProps) => {
21
+ const Colors = useColors();
22
+
23
+ const renderCompetitions = (data:{item:BracketCompetitionProps, index:number}) => {
24
+ const cl = data.item.market_type == 'FOR_MONEY' ? "$" : 'E'
25
+ const cpb = entered_brackets.find(b => b.bracket_competition_id == data.item.bracket_competition_id && b.player_bracket_id == player_bracket?.player_bracket_id);
26
+ let pot = BracketCompetitionHelpers.getPayout(data.item)
27
+ return (
28
+ <Button style={{ flexDirection:'row', alignItems:'center', borderBottomWidth:1, borderColor:Colors.borders.light }} onPress={() => onSelectCompetition(data.item)}>
29
+ <Image
30
+ source={{ uri: data.item.image?.url }}
31
+ style={{ height:40, width:40 }}
32
+ resizeMode='cover'
33
+ />
34
+ <View style={{ flex:1, marginLeft:10 }}>
35
+ <Text theme='h2'>{data.item.competition_name}</Text>
36
+ {cpb ?
37
+ <Text style={{ marginTop:3 }}>{pot > 0 ? `Total Pot: ${cl}${pot.toFixed(2)}`:''}Place {cpb.place} / {data.item.tickets_sold}</Text>
38
+ :<></>}
39
+ </View>
40
+ {cpb ?
41
+ <View style={{ justifyContent:'center', alignItems:'center', marginRight:20, marginLeft:20 }}>
42
+ <Text theme='h2' color={Colors.text.success} textAlign='center'>{cl}{cpb.winnings.toFixed(2)}</Text>
43
+ <Text theme='description' color={Colors.text.success} textAlign='center'>winnings</Text>
44
+ </View>
45
+ :<></>}
46
+ <Icons.ChevronIcon direction='right' size={10} color={Colors.text.action} />
47
+ </Button>
48
+ )
49
+ }
50
+
51
+ return (
52
+ <Modal
53
+ visible={player_bracket?true : false}
54
+ style={{ flex:1 }}
55
+ transparent
56
+ animationType={view_mode == 'desktop' ? 'fade' : 'slide'}
57
+ >
58
+ <View type='blur' style={view_mode == 'desktop' ? { flex:1, justifyContent:'center', alignItems:'center' } : { flex:1, justifyContent:'flex-end', paddingBottom:(insets?.bottom ?? 0)}}>
59
+ <View float style={view_mode == 'desktop' ? { width:500 }:{ margin:10 }}>
60
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
61
+ <View transparent style={{ flex:1 }}>
62
+ <Text theme='h1'>{player_bracket?.bracket_name ?? ''}</Text>
63
+ <Text style={{ marginTop:3 }} theme='description'>Entered Competitions</Text>
64
+ </View>
65
+ {player_bracket?
66
+ <View transparent>
67
+ <Text theme='h1' color={Colors.text.h1}>{(player_bracket.completion_pct*100).toFixed(2)}%</Text>
68
+ </View>
69
+ :<></>}
70
+ {champion_team ?
71
+ <View transparent style={{ padding:5, justifyContent:'center', alignItems:'center' }}>
72
+ <Image
73
+ source={{ uri: champion_team.image?.url }}
74
+ style={{ height:30, width:30 }}
75
+ resizeMode='cover'
76
+ />
77
+ <Text theme="description" textAlign="center">{champion_team.abbr}</Text>
78
+ </View>
79
+ :champion_athlete ?
80
+ <View transparent style={{ padding:5, justifyContent:'center', alignItems:'center' }}>
81
+ <Image
82
+ source={{ uri: champion_athlete.image?.url }}
83
+ style={{ height:30, width:30 }}
84
+ resizeMode='cover'
85
+ />
86
+ <Text theme="description" textAlign="center">{champion_athlete.abbr_name}</Text>
87
+ </View>
88
+ :<></>}
89
+ </View>
90
+ <View type='body' style={{ flexGrow:1 }}>
91
+ <FlatList
92
+ key={'entered_comps'}
93
+ keyExtractor={(item) => item.bracket_competition_id}
94
+ data={entered_competitions}
95
+ renderItem={renderCompetitions}
96
+ />
97
+ </View>
98
+ <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomLeftRadius:8, borderBottomRightRadius:8 }}>
99
+ <Button
100
+ type='close'
101
+ title='CLOSE'
102
+ style={{ flex:1 }}
103
+ onPress={() => onClose()}
104
+ />
105
+ </View>
106
+ </View>
107
+ </View>
108
+
109
+ </Modal>
110
+ )
111
+ }
112
+
113
+ export default EnteredCompetitionsModal
@@ -5,6 +5,7 @@ import type { BracketCompetitionProps, CompetitionPlayerBracketProps, MyPlayerPr
5
5
  import { BracketComeptitionApi, BracketCompetitionHelpers } from '../api';
6
6
  import PlayerBalanceCard from './PlayerBalanceCard';
7
7
  import { Button, Text, View } from '../../Components/Themed';
8
+ import { useColors } from '../../constants/useColors';
8
9
 
9
10
  type JoinCompetitionCardProps = {
10
11
  player?:MyPlayerProps,
@@ -12,18 +13,39 @@ type JoinCompetitionCardProps = {
12
13
  player_bracket?:PlayerBracketProps,
13
14
  player_balance?:PlayerBalanceProps,
14
15
  bracket_competition:BracketCompetitionProps,
16
+ onRequestAuthenticate:(auth_strategy_id?:string) => void,
15
17
  onNotEnoughBalance:(data:{ bracket_competition:BracketCompetitionProps }) => void,
16
18
  onEnterCompetition:(cpb:CompetitionPlayerBracketProps, player_bracket?:PlayerBracketProps) => void,
17
19
  onClose:() => void
18
20
  }
19
21
 
20
- const JoinCompetitionCard = ({ player, player_balance, loading, player_bracket, bracket_competition, onNotEnoughBalance, onEnterCompetition, onClose }:JoinCompetitionCardProps) => {
22
+ const JoinCompetitionCard = ({ player, player_balance, loading, player_bracket, bracket_competition, onRequestAuthenticate, onNotEnoughBalance, onEnterCompetition, onClose }:JoinCompetitionCardProps) => {
23
+ const Colors = useColors();
21
24
  const [ disclaimed, setDisclaimed ] = useState(true);
25
+ const [ use_promo_balance, setUsePromoBalance ] = useState(false);
22
26
 
23
27
  const buy_in_label = BracketCompetitionHelpers.getBuyInTitle(bracket_competition)
24
28
 
29
+ const isBalanceEnough = () => {
30
+ if(!player_balance){ return false }
31
+ let buy_in = bracket_competition.buy_in;
32
+ switch(bracket_competition.market_type){
33
+ case 'FREE':
34
+ if(player_balance.free_market_balance < buy_in){ return false }
35
+ return true
36
+ case 'FOR_MONEY':
37
+ if(use_promo_balance){
38
+ if(player_balance.promo_balance < buy_in){ return false }
39
+ return true
40
+ }
41
+ if(player_balance.balance < buy_in){ return false }
42
+ return true
43
+ default: return false
44
+ }
45
+ }
46
+
25
47
  const handleEnter = async() => {
26
- if(!player){ return }
48
+ if(!player){ return onRequestAuthenticate(bracket_competition?.auth_strategy_id) }
27
49
  let player_bracket_id = player_bracket?.player_bracket_id
28
50
  let new_pb:PlayerBracketProps | undefined = undefined
29
51
  if(!player_bracket_id){
@@ -39,7 +61,7 @@ const JoinCompetitionCard = ({ player, player_balance, loading, player_bracket,
39
61
  })
40
62
  player_bracket_id = new_pb.player_bracket_id
41
63
  }
42
- const is_enough_balance = BracketCompetitionHelpers.isEnoughBalance(bracket_competition, player_balance);
64
+ const is_enough_balance = isBalanceEnough();
43
65
  if(!is_enough_balance){ return onNotEnoughBalance({ bracket_competition }) }
44
66
  const cpb = BracketCompetitionHelpers.generateCompetitionPlayerBracket(bracket_competition.bracket_competition_id, player_bracket_id)
45
67
  onEnterCompetition(cpb, new_pb)
@@ -79,6 +101,27 @@ const JoinCompetitionCard = ({ player, player_balance, loading, player_bracket,
79
101
  />
80
102
  </View>
81
103
  :<></>}
104
+ {bracket_competition.buy_in > 0 && player_balance && player_balance.promo_balance >= bracket_competition.buy_in ?
105
+ <Button style={{ margin:10, backgroundColor:Colors.text.gold, padding:10, flexDirection:'row', alignItems:'center' }} onPress={() => {
106
+ if(use_promo_balance){
107
+ //Remove promo balance and open_amt
108
+ setUsePromoBalance(false);
109
+ } else {
110
+ setUsePromoBalance(true);
111
+ }
112
+ }}>
113
+ <View transparent style={{ marginRight:10, height:30, width:30, borderWidth:1, borderColor:Colors.text.h1, justifyContent:'center', alignItems:'center' }}>
114
+ {use_promo_balance ?
115
+ <View style={{ height:20, width:20, backgroundColor:Colors.text.h1 }} />
116
+ :<></>}
117
+ </View>
118
+ <View transparent>
119
+ <Text size={14} theme="h1" color={Colors.text.white}>${player_balance?.promo_balance} Promotion Available</Text>
120
+ <Text style={{ marginTop:2}} color={Colors.text.white} theme="description">Press / Click here to use promo balance</Text>
121
+ </View>
122
+
123
+ </Button>
124
+ :<></>}
82
125
  <View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
83
126
  <Button
84
127
  title='Close'
@@ -197,7 +197,7 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
197
197
  </View>
198
198
  </View>
199
199
  <TextInput
200
- value={scoring_rule.win_points as unknown as string}
200
+ value={scoring_rule.win_points.toString() as unknown as string}
201
201
  editable={scoring}
202
202
  style={{ textAlign:'center', width:80 }}
203
203
  onChangeText={(text) => handleUpdateScoringRule({ ...scoring_rule, win_points: text as unknown as number })}
@@ -206,8 +206,8 @@ const ManageBracketCompetitionForm = ({ player_id, bracket_competition_id, onFai
206
206
  <View transparent style={{ flexDirection:'row', alignItems:'center' }}>
207
207
  <Text style={{ padding:4 }} theme='h1'>X</Text>
208
208
  <TextInput
209
- value={scoring_rule.underdog_multiplier as unknown as string}
210
- style={{ textAlign:'center', width:50 }}
209
+ value={scoring_rule.underdog_multiplier.toString() as unknown as string}
210
+ style={{ textAlign:'center', width:65 }}
211
211
  editable={scoring}
212
212
  onChangeText={(text) => handleUpdateScoringRule({ ...scoring_rule, underdog_multiplier: text as unknown as number })}
213
213
  />
@@ -11,17 +11,16 @@ type PlayerBracketCardProps = {
11
11
  champion_team?:TeamProps,
12
12
  champion_athlete?:AthleteProps,
13
13
  onEdit: (player_bracket:PlayerBracketProps) => void,
14
- onView: (bracket_id:string, player_bracket_id?:string, bracket_competition_id?:string) => void,
14
+ onShowCompetitions:() => void,
15
+ onView: (bracket_id:string, player_bracket_id?:string, bracket_competition?:BracketCompetitionProps) => void,
15
16
  bracket_competitions:BracketCompetitionProps[],
16
17
  player_bracket:PlayerBracketProps,
17
18
  competition_player_brackets:CompetitionPlayerBracketProps[]
18
19
  }
19
20
 
20
- const PlayerBracketCard = ({ onEdit, champion_team, onView, player_bracket, bracket }:PlayerBracketCardProps) => {
21
+ const PlayerBracketCard = ({ onEdit, champion_team, onView, player_bracket, bracket, competition_player_brackets, onShowCompetitions }:PlayerBracketCardProps) => {
21
22
  const Colors = useColors();
22
23
 
23
-
24
- //const cl = bracket_competition.market_type == 'FOR_MONEY' ? '$' : 'E'
25
24
  return (
26
25
  <View type='row' style={{ flex:1 }}>
27
26
  {player_bracket.champion_id ?
@@ -49,6 +48,12 @@ const PlayerBracketCard = ({ onEdit, champion_team, onView, player_bracket, brac
49
48
  <Text theme="h1">{player_bracket.bracket_name}</Text>
50
49
  <Text style={{ marginTop:4 }} theme="description">{(player_bracket.completion_pct * 100).toFixed(2)}%</Text>
51
50
  </View>
51
+ {competition_player_brackets.length > 0 ?
52
+ <Button float style={{ flexDirection:'row', alignItems:'center', padding:10 }} onPress={() => onShowCompetitions()}>
53
+ <Text style={{ marginRight:5 }} theme="h1" color={Colors.text.action}>{competition_player_brackets.length}</Text>
54
+ <Icons.TrophyIcon size={12} color={Colors.text.action} />
55
+ </Button>
56
+ :<></>}
52
57
  {player_bracket.status != 'closed' ?
53
58
  <Button
54
59
  type='text'
@@ -1,5 +1,5 @@
1
1
  import React, { useState } from 'react';
2
- import { FlatList, Image } from "react-native"
2
+ import { FlatList, Image, Modal } from "react-native"
3
3
  import type { AthleteProps, BracketCompetitionProps, BracketProps, CompetitionPlayerBracketProps, LeagueProps, PlayerBracketProps, TeamProps } from '../../types';
4
4
  import moment from 'moment-mini';
5
5
  import { Button, Text, View } from '../../Components/Themed';
@@ -9,8 +9,11 @@ import { BracketComeptitionApi, BracketCompetitionHelpers } from '../api';
9
9
  type PlayerBracketSelectorProps = {
10
10
  brackets:BracketProps[],
11
11
  player_id?:string,
12
+ visible?:boolean,
13
+ view_mode?:'desktop'|'mobile',
12
14
  bracket_id?:string,
13
15
  leagues:LeagueProps[],
16
+ insets?:{ top:number, bottom:number, left:number, right:number },
14
17
  teams:TeamProps[],
15
18
  athletes:AthleteProps[],
16
19
  player_brackets:PlayerBracketProps[],
@@ -21,7 +24,7 @@ type PlayerBracketSelectorProps = {
21
24
  onSelect:(pb:PlayerBracketProps) => void,
22
25
  }
23
26
 
24
- const PlayerBracketSelector = ({ brackets, bracket_id, leagues, teams, athletes, player_brackets, onSelect, onClose, onCreateNew }:PlayerBracketSelectorProps) => {
27
+ const PlayerBracketSelector = ({ brackets, visible, view_mode, insets, bracket_id, leagues, teams, athletes, player_brackets, onSelect, onClose, onCreateNew }:PlayerBracketSelectorProps) => {
25
28
  const Colors = useColors();
26
29
  const [ action_loading, setActionLoading ] = useState(false);
27
30
  const active_brackets = player_brackets.filter(pb => pb.status == 'active');
@@ -109,39 +112,48 @@ const PlayerBracketSelector = ({ brackets, bracket_id, leagues, teams, athletes,
109
112
 
110
113
 
111
114
  return (
112
- <View transparent style={{ flexGrow:1 }}>
113
- <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
114
- <View transparent style={{ flex:1 }}>
115
- <Text theme='h1'>My Brackets</Text>
115
+ <Modal
116
+ visible={visible}
117
+ style={{ flex:1 }}
118
+ transparent
119
+ animationType={view_mode == 'desktop' ? 'fade' : 'slide'}
120
+ >
121
+ <View type='blur' style={view_mode == 'desktop' ? { flex:1, justifyContent:'center', alignItems:'center' } : { flex:1, justifyContent:'flex-end', paddingBottom:(insets?.bottom ?? 0) }}>
122
+ <View float style={view_mode == 'desktop' ? { width:500 }:{ margin:10 }}>
123
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
124
+ <View transparent style={{ flex:1 }}>
125
+ <Text theme='h1'>My Brackets</Text>
126
+ </View>
127
+ {bracket_id && onCreateNew ?
128
+ <Button
129
+ type='success'
130
+ disabled={action_loading}
131
+ loading={action_loading}
132
+ style={{ flexDirection:'row', alignItems:'center', padding:10, opacity: action_loading?0.5:1 }}
133
+ onPress={() => handleCreateNew()}
134
+ >
135
+ <Text size={14} color={Colors.text.white}>NEW</Text>
136
+ </Button>
137
+ :<></>}
138
+ </View>
139
+ <View transparent style={{ flexGrow:1, marginTop:1 }}>
140
+ <FlatList
141
+ data={unique_bracket_ids}
142
+ renderItem={renderBrackets}
143
+ keyExtractor={(item) => item.toString()}
144
+ />
145
+ </View>
146
+ <View type='footer' style={{ flexDirection:'row', padding:10 }}>
147
+ <Button
148
+ type='close'
149
+ title='CLOSE'
150
+ style={{ flex:1 }}
151
+ onPress={() => onClose()}
152
+ />
153
+ </View>
116
154
  </View>
117
- {bracket_id && onCreateNew ?
118
- <Button
119
- type='success'
120
- disabled={action_loading}
121
- loading={action_loading}
122
- style={{ flexDirection:'row', alignItems:'center', padding:10, opacity: action_loading?0.5:1 }}
123
- onPress={() => handleCreateNew()}
124
- >
125
- <Text size={14} color={Colors.text.white}>NEW</Text>
126
- </Button>
127
- :<></>}
128
- </View>
129
- <View transparent style={{ flexGrow:1, marginTop:1 }}>
130
- <FlatList
131
- data={unique_bracket_ids}
132
- renderItem={renderBrackets}
133
- keyExtractor={(item) => item.toString()}
134
- />
135
- </View>
136
- <View type='footer' style={{ flexDirection:'row', padding:10 }}>
137
- <Button
138
- type='close'
139
- title='CLOSE'
140
- style={{ flex:1 }}
141
- onPress={() => onClose()}
142
- />
143
155
  </View>
144
- </View>
156
+ </Modal>
145
157
  )
146
158
  }
147
159