be-components 6.1.0 → 6.1.2

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 (228) hide show
  1. package/lib/commonjs/BetMatch/api/index.js +67 -1
  2. package/lib/commonjs/BetMatch/api/index.js.map +1 -1
  3. package/lib/commonjs/BetMatch/components/BetMatchCard.js +100 -46
  4. package/lib/commonjs/BetMatch/components/BetMatchCard.js.map +1 -1
  5. package/lib/commonjs/BetMatch/components/ManageFilter.js +1342 -0
  6. package/lib/commonjs/BetMatch/components/ManageFilter.js.map +1 -0
  7. package/lib/commonjs/BetMatch/index.js +204 -64
  8. package/lib/commonjs/BetMatch/index.js.map +1 -1
  9. package/lib/commonjs/Components/AthleteLozenge.js +81 -0
  10. package/lib/commonjs/Components/AthleteLozenge.js.map +1 -0
  11. package/lib/commonjs/Components/AutoScrollFlatList.js +50 -7
  12. package/lib/commonjs/Components/AutoScrollFlatList.js.map +1 -1
  13. package/lib/commonjs/Components/Icons.js +2 -0
  14. package/lib/commonjs/Components/Icons.js.map +1 -1
  15. package/lib/commonjs/Components/Jerseys.js +30 -11
  16. package/lib/commonjs/Components/Jerseys.js.map +1 -1
  17. package/lib/commonjs/Components/LeagueLozenge.js +59 -0
  18. package/lib/commonjs/Components/LeagueLozenge.js.map +1 -0
  19. package/lib/commonjs/Components/MarketLozenge.js +48 -0
  20. package/lib/commonjs/Components/MarketLozenge.js.map +1 -0
  21. package/lib/commonjs/Components/PlayerLozenge.js +61 -0
  22. package/lib/commonjs/Components/PlayerLozenge.js.map +1 -0
  23. package/lib/commonjs/Components/PremiumIcons.js +366 -0
  24. package/lib/commonjs/Components/PremiumIcons.js.map +1 -0
  25. package/lib/commonjs/Components/TeamLozenge.js +70 -0
  26. package/lib/commonjs/Components/TeamLozenge.js.map +1 -0
  27. package/lib/commonjs/Components/index.js +35 -0
  28. package/lib/commonjs/Components/index.js.map +1 -1
  29. package/lib/commonjs/FlashMarket/index.js +27 -0
  30. package/lib/commonjs/FlashMarket/index.js.map +1 -1
  31. package/lib/commonjs/Premium/api/index.js +50 -0
  32. package/lib/commonjs/Premium/api/index.js.map +1 -0
  33. package/lib/commonjs/Premium/components/ALaCartePremium.js +314 -0
  34. package/lib/commonjs/Premium/components/ALaCartePremium.js.map +1 -0
  35. package/lib/commonjs/Premium/index.js +12 -0
  36. package/lib/commonjs/Premium/index.js.map +1 -0
  37. package/lib/commonjs/ProfileManager/Components/VouchCard.js +3 -3
  38. package/lib/commonjs/ProfileManager/Components/VouchCard.js.map +1 -1
  39. package/lib/commonjs/ProfileManager/api/index.js +10 -1
  40. package/lib/commonjs/ProfileManager/api/index.js.map +1 -1
  41. package/lib/commonjs/ProfileManager/index.js +2 -2
  42. package/lib/commonjs/ProfileManager/index.js.map +1 -1
  43. package/lib/commonjs/SocialComponents/api/index.js +12 -0
  44. package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
  45. package/lib/commonjs/index.js +14 -0
  46. package/lib/commonjs/index.js.map +1 -1
  47. package/lib/module/BetMatch/api/index.js +66 -0
  48. package/lib/module/BetMatch/api/index.js.map +1 -1
  49. package/lib/module/BetMatch/components/BetMatchCard.js +102 -48
  50. package/lib/module/BetMatch/components/BetMatchCard.js.map +1 -1
  51. package/lib/module/BetMatch/components/ManageFilter.js +1333 -0
  52. package/lib/module/BetMatch/components/ManageFilter.js.map +1 -0
  53. package/lib/module/BetMatch/index.js +206 -66
  54. package/lib/module/BetMatch/index.js.map +1 -1
  55. package/lib/module/Components/AthleteLozenge.js +73 -0
  56. package/lib/module/Components/AthleteLozenge.js.map +1 -0
  57. package/lib/module/Components/AutoScrollFlatList.js +51 -8
  58. package/lib/module/Components/AutoScrollFlatList.js.map +1 -1
  59. package/lib/module/Components/Icons.js +3 -0
  60. package/lib/module/Components/Icons.js.map +1 -1
  61. package/lib/module/Components/Jerseys.js +30 -11
  62. package/lib/module/Components/Jerseys.js.map +1 -1
  63. package/lib/module/Components/LeagueLozenge.js +51 -0
  64. package/lib/module/Components/LeagueLozenge.js.map +1 -0
  65. package/lib/module/Components/MarketLozenge.js +40 -0
  66. package/lib/module/Components/MarketLozenge.js.map +1 -0
  67. package/lib/module/Components/PlayerLozenge.js +53 -0
  68. package/lib/module/Components/PlayerLozenge.js.map +1 -0
  69. package/lib/module/Components/PremiumIcons.js +359 -0
  70. package/lib/module/Components/PremiumIcons.js.map +1 -0
  71. package/lib/module/Components/TeamLozenge.js +62 -0
  72. package/lib/module/Components/TeamLozenge.js.map +1 -0
  73. package/lib/module/Components/index.js +6 -1
  74. package/lib/module/Components/index.js.map +1 -1
  75. package/lib/module/FlashMarket/index.js +27 -0
  76. package/lib/module/FlashMarket/index.js.map +1 -1
  77. package/lib/module/Premium/api/index.js +43 -0
  78. package/lib/module/Premium/api/index.js.map +1 -0
  79. package/lib/module/Premium/components/ALaCartePremium.js +305 -0
  80. package/lib/module/Premium/components/ALaCartePremium.js.map +1 -0
  81. package/lib/module/Premium/index.js +5 -0
  82. package/lib/module/Premium/index.js.map +1 -0
  83. package/lib/module/ProfileManager/Components/VouchCard.js +3 -3
  84. package/lib/module/ProfileManager/Components/VouchCard.js.map +1 -1
  85. package/lib/module/ProfileManager/api/index.js +10 -1
  86. package/lib/module/ProfileManager/api/index.js.map +1 -1
  87. package/lib/module/ProfileManager/index.js +2 -2
  88. package/lib/module/ProfileManager/index.js.map +1 -1
  89. package/lib/module/SocialComponents/api/index.js +12 -0
  90. package/lib/module/SocialComponents/api/index.js.map +1 -1
  91. package/lib/module/index.js +3 -1
  92. package/lib/module/index.js.map +1 -1
  93. package/lib/typescript/lib/commonjs/BetMatch/api/index.d.ts +7 -0
  94. package/lib/typescript/lib/commonjs/BetMatch/api/index.d.ts.map +1 -1
  95. package/lib/typescript/lib/commonjs/BetMatch/components/BetMatchCard.d.ts +10 -2
  96. package/lib/typescript/lib/commonjs/BetMatch/components/BetMatchCard.d.ts.map +1 -1
  97. package/lib/typescript/lib/commonjs/BetMatch/components/ManageFilter.d.ts +10 -0
  98. package/lib/typescript/lib/commonjs/BetMatch/components/ManageFilter.d.ts.map +1 -0
  99. package/lib/typescript/lib/commonjs/BetMatch/index.d.ts +12 -1
  100. package/lib/typescript/lib/commonjs/BetMatch/index.d.ts.map +1 -1
  101. package/lib/typescript/lib/commonjs/Components/AthleteLozenge.d.ts +11 -0
  102. package/lib/typescript/lib/commonjs/Components/AthleteLozenge.d.ts.map +1 -0
  103. package/lib/typescript/lib/commonjs/Components/AutoScrollFlatList.d.ts.map +1 -1
  104. package/lib/typescript/lib/commonjs/Components/Jerseys.d.ts.map +1 -1
  105. package/lib/typescript/lib/commonjs/Components/LeagueLozenge.d.ts +10 -0
  106. package/lib/typescript/lib/commonjs/Components/LeagueLozenge.d.ts.map +1 -0
  107. package/lib/typescript/lib/commonjs/Components/MarketLozenge.d.ts +10 -0
  108. package/lib/typescript/lib/commonjs/Components/MarketLozenge.d.ts.map +1 -0
  109. package/lib/typescript/lib/commonjs/Components/PlayerLozenge.d.ts +9 -0
  110. package/lib/typescript/lib/commonjs/Components/PlayerLozenge.d.ts.map +1 -0
  111. package/lib/typescript/lib/commonjs/Components/PremiumIcons.d.ts +85 -0
  112. package/lib/typescript/lib/commonjs/Components/PremiumIcons.d.ts.map +1 -0
  113. package/lib/typescript/lib/commonjs/Components/TeamLozenge.d.ts +10 -0
  114. package/lib/typescript/lib/commonjs/Components/TeamLozenge.d.ts.map +1 -0
  115. package/lib/typescript/lib/commonjs/Components/index.d.ts +5 -0
  116. package/lib/typescript/lib/commonjs/FlashMarket/index.d.ts.map +1 -1
  117. package/lib/typescript/lib/commonjs/Premium/api/index.d.ts +18 -0
  118. package/lib/typescript/lib/commonjs/Premium/api/index.d.ts.map +1 -0
  119. package/lib/typescript/lib/commonjs/Premium/components/ALaCartePremium.d.ts +12 -0
  120. package/lib/typescript/lib/commonjs/Premium/components/ALaCartePremium.d.ts.map +1 -0
  121. package/lib/typescript/lib/commonjs/Premium/index.d.ts +6 -0
  122. package/lib/typescript/lib/commonjs/Premium/index.d.ts.map +1 -0
  123. package/lib/typescript/lib/commonjs/ProfileManager/api/index.d.ts +1 -0
  124. package/lib/typescript/lib/commonjs/ProfileManager/api/index.d.ts.map +1 -1
  125. package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts +6 -6
  126. package/lib/typescript/lib/commonjs/SocialComponents/api/index.d.ts.map +1 -1
  127. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  128. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -1
  129. package/lib/typescript/lib/module/BetMatch/api/index.d.ts +7 -0
  130. package/lib/typescript/lib/module/BetMatch/api/index.d.ts.map +1 -1
  131. package/lib/typescript/lib/module/BetMatch/components/BetMatchCard.d.ts +10 -2
  132. package/lib/typescript/lib/module/BetMatch/components/BetMatchCard.d.ts.map +1 -1
  133. package/lib/typescript/lib/module/BetMatch/components/ManageFilter.d.ts +10 -0
  134. package/lib/typescript/lib/module/BetMatch/components/ManageFilter.d.ts.map +1 -0
  135. package/lib/typescript/lib/module/BetMatch/index.d.ts +12 -1
  136. package/lib/typescript/lib/module/BetMatch/index.d.ts.map +1 -1
  137. package/lib/typescript/lib/module/Components/AthleteLozenge.d.ts +11 -0
  138. package/lib/typescript/lib/module/Components/AthleteLozenge.d.ts.map +1 -0
  139. package/lib/typescript/lib/module/Components/AutoScrollFlatList.d.ts.map +1 -1
  140. package/lib/typescript/lib/module/Components/Jerseys.d.ts.map +1 -1
  141. package/lib/typescript/lib/module/Components/LeagueLozenge.d.ts +10 -0
  142. package/lib/typescript/lib/module/Components/LeagueLozenge.d.ts.map +1 -0
  143. package/lib/typescript/lib/module/Components/MarketLozenge.d.ts +10 -0
  144. package/lib/typescript/lib/module/Components/MarketLozenge.d.ts.map +1 -0
  145. package/lib/typescript/lib/module/Components/PlayerLozenge.d.ts +9 -0
  146. package/lib/typescript/lib/module/Components/PlayerLozenge.d.ts.map +1 -0
  147. package/lib/typescript/lib/module/Components/PremiumIcons.d.ts +86 -0
  148. package/lib/typescript/lib/module/Components/PremiumIcons.d.ts.map +1 -0
  149. package/lib/typescript/lib/module/Components/TeamLozenge.d.ts +10 -0
  150. package/lib/typescript/lib/module/Components/TeamLozenge.d.ts.map +1 -0
  151. package/lib/typescript/lib/module/Components/index.d.ts +6 -1
  152. package/lib/typescript/lib/module/Components/index.d.ts.map +1 -1
  153. package/lib/typescript/lib/module/FlashMarket/index.d.ts.map +1 -1
  154. package/lib/typescript/lib/module/Premium/api/index.d.ts +17 -0
  155. package/lib/typescript/lib/module/Premium/api/index.d.ts.map +1 -0
  156. package/lib/typescript/lib/module/Premium/components/ALaCartePremium.d.ts +17 -0
  157. package/lib/typescript/lib/module/Premium/components/ALaCartePremium.d.ts.map +1 -0
  158. package/lib/typescript/lib/module/Premium/index.d.ts +6 -0
  159. package/lib/typescript/lib/module/Premium/index.d.ts.map +1 -0
  160. package/lib/typescript/lib/module/ProfileManager/api/index.d.ts +1 -0
  161. package/lib/typescript/lib/module/ProfileManager/api/index.d.ts.map +1 -1
  162. package/lib/typescript/lib/module/SocialComponents/api/index.d.ts +6 -6
  163. package/lib/typescript/lib/module/SocialComponents/api/index.d.ts.map +1 -1
  164. package/lib/typescript/lib/module/index.d.ts +3 -1
  165. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  166. package/lib/typescript/src/BetMatch/api/index.d.ts +8 -1
  167. package/lib/typescript/src/BetMatch/api/index.d.ts.map +1 -1
  168. package/lib/typescript/src/BetMatch/components/BetMatchCard.d.ts +12 -4
  169. package/lib/typescript/src/BetMatch/components/BetMatchCard.d.ts.map +1 -1
  170. package/lib/typescript/src/BetMatch/components/ManageFilter.d.ts +12 -0
  171. package/lib/typescript/src/BetMatch/components/ManageFilter.d.ts.map +1 -0
  172. package/lib/typescript/src/BetMatch/index.d.ts +23 -2
  173. package/lib/typescript/src/BetMatch/index.d.ts.map +1 -1
  174. package/lib/typescript/src/Components/AthleteLozenge.d.ts +13 -0
  175. package/lib/typescript/src/Components/AthleteLozenge.d.ts.map +1 -0
  176. package/lib/typescript/src/Components/AutoScrollFlatList.d.ts.map +1 -1
  177. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  178. package/lib/typescript/src/Components/Jerseys.d.ts.map +1 -1
  179. package/lib/typescript/src/Components/LeagueLozenge.d.ts +13 -0
  180. package/lib/typescript/src/Components/LeagueLozenge.d.ts.map +1 -0
  181. package/lib/typescript/src/Components/MarketLozenge.d.ts +13 -0
  182. package/lib/typescript/src/Components/MarketLozenge.d.ts.map +1 -0
  183. package/lib/typescript/src/Components/PlayerLozenge.d.ts +11 -0
  184. package/lib/typescript/src/Components/PlayerLozenge.d.ts.map +1 -0
  185. package/lib/typescript/src/Components/PremiumIcons.d.ts +27 -0
  186. package/lib/typescript/src/Components/PremiumIcons.d.ts.map +1 -0
  187. package/lib/typescript/src/Components/TeamLozenge.d.ts +12 -0
  188. package/lib/typescript/src/Components/TeamLozenge.d.ts.map +1 -0
  189. package/lib/typescript/src/Components/index.d.ts +6 -1
  190. package/lib/typescript/src/Components/index.d.ts.map +1 -1
  191. package/lib/typescript/src/FlashMarket/index.d.ts.map +1 -1
  192. package/lib/typescript/src/Premium/api/index.d.ts +12 -0
  193. package/lib/typescript/src/Premium/api/index.d.ts.map +1 -0
  194. package/lib/typescript/src/Premium/components/ALaCartePremium.d.ts +16 -0
  195. package/lib/typescript/src/Premium/components/ALaCartePremium.d.ts.map +1 -0
  196. package/lib/typescript/src/Premium/index.d.ts +13 -0
  197. package/lib/typescript/src/Premium/index.d.ts.map +1 -0
  198. package/lib/typescript/src/ProfileManager/api/index.d.ts +6 -2
  199. package/lib/typescript/src/ProfileManager/api/index.d.ts.map +1 -1
  200. package/lib/typescript/src/SocialComponents/api/index.d.ts +1 -1
  201. package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
  202. package/lib/typescript/src/index.d.ts +3 -1
  203. package/lib/typescript/src/index.d.ts.map +1 -1
  204. package/package.json +1 -1
  205. package/src/BetMatch/api/index.ts +54 -2
  206. package/src/BetMatch/components/BetMatchCard.tsx +82 -43
  207. package/src/BetMatch/components/ManageFilter.tsx +830 -0
  208. package/src/BetMatch/index.tsx +142 -45
  209. package/src/Components/AthleteLozenge.tsx +52 -0
  210. package/src/Components/AutoScrollFlatList.tsx +50 -15
  211. package/src/Components/Icons.tsx +5 -0
  212. package/src/Components/Jerseys.tsx +19 -10
  213. package/src/Components/LeagueLozenge.tsx +36 -0
  214. package/src/Components/MarketLozenge.tsx +29 -0
  215. package/src/Components/PlayerLozenge.tsx +37 -0
  216. package/src/Components/PremiumIcons.tsx +201 -0
  217. package/src/Components/TeamLozenge.tsx +44 -0
  218. package/src/Components/index.tsx +10 -0
  219. package/src/FlashMarket/index.tsx +15 -0
  220. package/src/Premium/api/index.ts +32 -0
  221. package/src/Premium/components/ALaCartePremium.tsx +145 -0
  222. package/src/Premium/index.tsx +5 -0
  223. package/src/ProfileManager/Components/VouchCard.tsx +3 -3
  224. package/src/ProfileManager/api/index.ts +12 -3
  225. package/src/ProfileManager/index.tsx +2 -2
  226. package/src/SocialComponents/api/index.ts +9 -1
  227. package/src/index.tsx +4 -0
  228. package/src/types.d.ts +37 -1
@@ -0,0 +1,830 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { Button, Text, TextInput, View } from "../../Components/Themed";
3
+ import type { AthleteProps, FocusPositionProps, LeagueProps, MarketProps, MyPlayerProps, PlayerFilterProps, PublicPlayerProps, TeamProps } from '../../types';
4
+ import { BetMatchApi, BetMatchHelpers } from '../api';
5
+ import { ActivityIndicator, FlatList } from 'react-native';
6
+ import { AthleteLozenge, Checkbox, Icons, LeagueLozenge, MarketLozenge, PlayerLozenge, Toggle } from '../../Components';
7
+ import { useColors } from '../../constants/useColors';
8
+ import { MarketComponentApi } from '../../MarketComponents/api';
9
+ import SearchBox from '../../Components/SearchBox';
10
+ import TeamLozenge from '../../Components/TeamLozenge';
11
+ import Pagination from '../../Components/Pagination';
12
+
13
+ type ManageFilterProps = {
14
+ me:MyPlayerProps,
15
+ player_filter_id:string,
16
+ onFocusPosition?:(pos:FocusPositionProps) => void,
17
+ onRunFilter:(player_filter:PlayerFilterProps) => void,
18
+ onUpdateFilter:(player_filter:PlayerFilterProps) => void
19
+ }
20
+
21
+ type GradeBoxProps = {
22
+ min:number,
23
+ max:number,
24
+ success_color:string,
25
+ fail_color:string,
26
+ }
27
+
28
+ const grade_boxes:GradeBoxProps[] = [
29
+ { min: 0, max: 79, success_color: 'rgba(125,205,133,0.2)', fail_color: 'rgba(213,87, 59, 0.2)' },
30
+ { min: 80, max: 94, success_color: 'rgba(125,205,133,0.4)', fail_color: 'rgba(213,87, 59, 0.4)' },
31
+ { min:95, max: 97.5, success_color: 'rgba(125,205,133,0.6)', fail_color: 'rgba(213,87, 59, 0.6)' },
32
+ { min:97.6, max: 99.99, success_color: 'rgba(125,205,133,0.8)', fail_color: 'rgba(213,87, 59, 0)' },
33
+ { min: 100, max: 200, success_color: 'rgba(125,205,133,1)', fail_color: 'rgba(213,87, 59, 0)' }
34
+ ]
35
+
36
+ const books = [
37
+ 'DraftKings', 'FanDuel', 'MGM', 'PointsBet'
38
+ ]
39
+
40
+ const sections = ['header','name','toggle','status', 'leagues', 'market_types', 'markets','athletes','teams', 'players','order_grades','external_sources']
41
+ const ManageFilter = ({ me, player_filter_id, onFocusPosition, onRunFilter, onUpdateFilter } : ManageFilterProps) => {
42
+ const Colors = useColors();
43
+ const [ player_search, setPlayerSearch ] = useState<{
44
+ loading:boolean,
45
+ players:PublicPlayerProps[],
46
+ offset:number,
47
+ value:string
48
+ }>({
49
+ loading: false,
50
+ players:[],
51
+ offset:0,
52
+ value:''
53
+ });
54
+ const [ confirm_delete, setConfirmDelete ] = useState(false);
55
+ const [ athlete_search, setAthleteSearch ] = useState<{
56
+ loading:boolean,
57
+ value:string,
58
+ offset:number,
59
+ athletes:AthleteProps[]
60
+ }>({
61
+ loading: false,
62
+ offset: 0,
63
+ value: '',
64
+ athletes: []
65
+ });
66
+ const [ filter_athletes, setFilterAthletes ] = useState<AthleteProps[]>([]);
67
+ const [ filter_teams, setFilterTeams ] = useState<TeamProps[]>([]);
68
+ const [ filter_players, setFilterPlayers ] = useState<PublicPlayerProps[]>([]);
69
+ const [ team_search, setTeamSearch ] = useState<{
70
+ loading:boolean,
71
+ value:string,
72
+ offset:number,
73
+ teams:TeamProps[]
74
+ }>({
75
+ loading: false,
76
+ value: '',
77
+ offset:0,
78
+ teams: []
79
+ });
80
+ const [ action_loading, setActionLoading ] = useState(false);
81
+ const [ static_data, setStaticData ] = useState<{
82
+ static_loading:boolean,
83
+ loaded:boolean,
84
+ leagues:LeagueProps[],
85
+ markets:MarketProps[]
86
+ }>({
87
+ static_loading: false,
88
+ loaded:false,
89
+ leagues:[],
90
+ markets:[]
91
+ });
92
+ const { static_loading, loaded, leagues, markets } = static_data;
93
+
94
+ const [ filter_data, setFilterData ] = useState<{
95
+ loading:boolean,
96
+ player_filter?:PlayerFilterProps,
97
+ active_toggle:string,
98
+ draft_filter?:PlayerFilterProps,
99
+ }>({
100
+ loading:false,
101
+ active_toggle: 'markets',
102
+ });
103
+ const { loading, player_filter, draft_filter, active_toggle } = filter_data;
104
+ let filtered_markets = BetMatchHelpers.filterMarkets(markets, leagues, draft_filter);
105
+ const premium_allowed = me.type == 'premium' ? true : false
106
+
107
+ useEffect(() => {
108
+ if(!loaded){ return }
109
+ loadData(player_filter_id);
110
+ },[player_filter_id, loaded]);
111
+
112
+ useEffect(() => {
113
+ MarketComponentApi.setEnvironment();
114
+ BetMatchApi.setEnvironment();
115
+ loadStaticData();
116
+ },[])
117
+
118
+ const loadStaticData = async() => {
119
+ setStaticData({ ...static_data, static_loading:false });
120
+ const lgs = await MarketComponentApi.getLeagues();
121
+ const mks = await MarketComponentApi.getMarkets();
122
+ setStaticData({
123
+ ...static_data,
124
+ leagues:lgs,
125
+ markets: mks,
126
+ loaded: true,
127
+ static_loading: false
128
+ })
129
+ }
130
+
131
+ const loadData = async(id:string) => {
132
+ setFilterData({ ...filter_data, loading:true });
133
+ const pf = await BetMatchApi.getPlayerFilterById(id);
134
+ if(!pf){ return alert('Unable to get filter details. It may have been deleted') }
135
+ let athlete_ids:string[] = pf?.filter.athlete_ids ?? []
136
+ let team_ids:string[] = pf?.filter.team_ids ?? []
137
+ let player_ids:string[] = pf?.filter.player_ids ?? []
138
+ let f_players = await BetMatchApi.getPlayersByPlayerIds(player_ids)
139
+ let f_teams = await BetMatchApi.getTeamsByIds(team_ids);
140
+ let f_athletes = await BetMatchApi.getAthletesByIds(athlete_ids);
141
+ setFilterAthletes(f_athletes);
142
+ setFilterTeams(f_teams);
143
+ setFilterPlayers(f_players)
144
+ setFilterData({
145
+ ...filter_data,
146
+ loading:false,
147
+ player_filter: pf,
148
+ draft_filter: pf
149
+ });
150
+ }
151
+
152
+
153
+ const isValid = () => {
154
+ let errors:string[] = []
155
+ if(!draft_filter?.filter){ return ['Filter is empty'] }
156
+ if(!draft_filter.name || player_filter?.name == ''){ errors.push('Must add name to filter') }
157
+ if(draft_filter.filter.league_ids.length < 1){ errors.push('Need to select 1 league') }
158
+ if(!draft_filter.filter.market_types){ errors.push('Must select market type') }
159
+ if(draft_filter.filter.league_ids.length > 1){ errors.push('Filter can only include up to 1 leagues') }
160
+ if(draft_filter.filter.market_ids.length == 0){ errors.push('Need to selected at least one market') }
161
+ if(draft_filter.filter.minimum_grade > 0 && me?.type != 'premium'){ errors.push('Only premium users are allowed to create filters with minimum grades') }
162
+ if(draft_filter.filter.external_book && draft_filter.filter.external_book != '' && me?.type != 'premium'){ errors.push('Only premium users are allowed to compare to an external book') }
163
+ return errors
164
+ }
165
+
166
+ const errors = isValid();
167
+
168
+ const minimumGradeText = (minimum_grade:number) => {
169
+ let text = 'Show me everything'
170
+ if(minimum_grade >= 80){
171
+ text = 'I just want to get this fulfilled as long as its reasonable'
172
+ }
173
+ if(minimum_grade >= 95){
174
+ text = 'Around the consensus price but may not be better'
175
+ }
176
+ if(minimum_grade >= 97.5){
177
+ text = 'Better than the Consensus price with vig'
178
+ }
179
+ if(minimum_grade >= 100){
180
+ text = 'MAX - Better than the Consensus price with vig removed'
181
+ }
182
+ return text
183
+ }
184
+
185
+ const handleUpdate = async(draft_player_filter:PlayerFilterProps) => {
186
+ setActionLoading(true);
187
+ const pf = await BetMatchApi.updatePlayerFilter(draft_player_filter);
188
+ if(!pf){
189
+ setActionLoading(false);
190
+ return alert('Unable to update')
191
+ }
192
+ setFilterData({
193
+ ...filter_data,
194
+ player_filter: pf,
195
+ draft_filter: pf
196
+ })
197
+ setActionLoading(false);
198
+ onUpdateFilter(pf)
199
+ }
200
+ const handleLeagueSelect = (league:LeagueProps) => {
201
+ if(!draft_filter){ return }
202
+ let existing_leagues = draft_filter.filter.league_ids
203
+ let already_selected = existing_leagues.find(l => l == league.league_id)
204
+ if(already_selected){
205
+ existing_leagues = existing_leagues.filter(l => l != league.league_id)
206
+ } else {
207
+ if(existing_leagues.length > 0){ return alert('Only 1 league can be selected') }
208
+ existing_leagues = existing_leagues.concat(league.league_id)
209
+ }
210
+ let new_filter:PlayerFilterProps = { ...draft_filter, filter: { ...draft_filter.filter, league_ids: existing_leagues } }
211
+ handleUpdate(new_filter)
212
+ }
213
+
214
+ const handleMarketSelect = (market:MarketProps) => {
215
+ if(!draft_filter){ return }
216
+ let existing_markets = draft_filter.filter.market_ids
217
+ let already_selected = existing_markets.find(l => l == market.market_id)
218
+ if(already_selected){
219
+ existing_markets = existing_markets.filter(l => l != market.market_id)
220
+ } else {
221
+ existing_markets = existing_markets.concat(market.market_id)
222
+ }
223
+ let new_filter:PlayerFilterProps = { ...draft_filter, filter: { ...draft_filter.filter, market_ids: existing_markets } }
224
+ handleUpdate(new_filter)
225
+ }
226
+
227
+ const handlePlayerSelect = (player:PublicPlayerProps) => {
228
+ if(!draft_filter){ return }
229
+ let existing_players = draft_filter.filter.player_ids
230
+ let already_selected = existing_players.find(l => l == player.player_id)
231
+ if(already_selected){
232
+ existing_players = existing_players.filter(l => l != player.player_id)
233
+ setFilterPlayers(filter_players.filter(t => t.player_id != player.player_id));
234
+
235
+ } else {
236
+ existing_players = existing_players.concat(player.player_id)
237
+ setFilterPlayers(filter_players.concat(player));
238
+ }
239
+ let new_filter:PlayerFilterProps = { ...draft_filter, filter: { ...draft_filter.filter, player_ids: existing_players } }
240
+ handleUpdate(new_filter)
241
+ }
242
+
243
+ const handleAthleteSelect = (athlete:AthleteProps) => {
244
+ if(!draft_filter){ return }
245
+ let existing_athletes = draft_filter.filter.athlete_ids
246
+ let already_selected = existing_athletes.find(l => l == athlete.athlete_id)
247
+ if(already_selected){
248
+ existing_athletes = existing_athletes.filter(l => l != athlete.athlete_id)
249
+ setFilterAthletes(filter_athletes.filter(t => t.athlete_id != athlete.athlete_id));
250
+
251
+ } else {
252
+ existing_athletes = existing_athletes.concat(athlete.athlete_id)
253
+ setFilterAthletes(filter_athletes.concat(athlete));
254
+ }
255
+ let new_filter:PlayerFilterProps = { ...draft_filter, filter: { ...draft_filter.filter, athlete_ids: existing_athletes } }
256
+ handleUpdate(new_filter)
257
+ }
258
+
259
+ const handleTeamSelect = (team:TeamProps) => {
260
+ if(!draft_filter){ return }
261
+ let existing_teams = draft_filter.filter.team_ids
262
+ let already_selected = existing_teams.find(l => l == team.team_id)
263
+ if(already_selected){
264
+ existing_teams = existing_teams.filter(l => l != team.team_id)
265
+ setFilterTeams(filter_teams.filter(t => t.team_id != team.team_id));
266
+
267
+ } else {
268
+ existing_teams = existing_teams.concat(team.team_id);
269
+ setFilterTeams(filter_teams.concat(team));
270
+ }
271
+ let new_filter:PlayerFilterProps = { ...draft_filter, filter: { ...draft_filter.filter, team_ids: existing_teams } }
272
+ handleUpdate(new_filter)
273
+ }
274
+
275
+ const handleSearchPlayers = async(page:number) => {
276
+ setPlayerSearch({ ...player_search, loading: true });
277
+ const pls = await BetMatchApi.searchPlayersByValue(player_search.value, page);
278
+ setPlayerSearch({
279
+ ...player_search,
280
+ loading: false,
281
+ players: pls,
282
+ offset: page
283
+ })
284
+ }
285
+
286
+ const handleSearchAthletes = async(page:number) => {
287
+ setAthleteSearch({ ...athlete_search, loading: true });
288
+ const aths = await BetMatchApi.searchAthletes(athlete_search.value, page, draft_filter?.filter?.league_ids);
289
+ setAthleteSearch({
290
+ ...athlete_search,
291
+ loading: false,
292
+ athletes: aths,
293
+ offset: page
294
+ })
295
+ }
296
+
297
+ const handleSearchTeams = async(page:number) => {
298
+ setTeamSearch({ ...team_search, loading: true });
299
+ const tms = await BetMatchApi.searchTeams(team_search.value, page, draft_filter?.filter?.league_ids);
300
+ setTeamSearch({
301
+ ...athlete_search,
302
+ loading: false,
303
+ teams: tms,
304
+ offset: page
305
+ })
306
+ }
307
+
308
+ const renderSections = (data:{ item:string, index:number }) => {
309
+ switch(data.item){
310
+ case 'name':
311
+ if(!draft_filter){ return <></> }
312
+ return (
313
+ <View>
314
+ <View transparent style={{ padding:10 }}>
315
+ <Text theme='h1'>Name</Text>
316
+ <Text theme='description' style={{ marginTop:3 }}>Give this filter a memorable name based on the criteria set (i.e., NFL QB Padding Tds, etc)</Text>
317
+ </View>
318
+ <TextInput
319
+ style={{ margin:10 }}
320
+ onFocusPosition={onFocusPosition}
321
+ value={draft_filter.name}
322
+ placeholder='Enter name here ...'
323
+ onChangeText={(text) => setFilterData({ ...filter_data, draft_filter: { ...draft_filter, name: text } })}
324
+ />
325
+ </View>
326
+ )
327
+ case 'toggle':
328
+ return (
329
+ <View transparent style={{ padding:10 }}>
330
+ <Toggle
331
+ options={[
332
+ { key: 'markets', label: 'Markets' },
333
+ { key: 'people', label: 'People' },
334
+ { key: 'premium', label: 'Premium' }
335
+ ]}
336
+ onSelectOption={(option) => setFilterData({ ...filter_data, active_toggle: option })}
337
+ selected_option={active_toggle}
338
+ />
339
+ </View>
340
+ )
341
+ case 'status':
342
+ if(!draft_filter){ return <></> }
343
+ if(active_toggle != 'markets'){ return <></> }
344
+ return (
345
+ <View nativeID='filter_order_status' style={{ marginTop:10 }}>
346
+ <View type='header' style={{ padding:10 }}>
347
+ <Text theme='h1'>Event Status</Text>
348
+ <Text style={{ marginTop:3 }} theme='description'>Set to show all orders or filter to only orders related to an event that is currently inprogress</Text>
349
+ </View>
350
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
351
+ <Button transparent style={{ borderRadius:0, flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}
352
+ onPress={() => {
353
+ let new_filter:PlayerFilterProps = { ...draft_filter }
354
+ new_filter.filter.live_only = false
355
+ handleUpdate(new_filter);
356
+ }}
357
+ >
358
+ <Checkbox
359
+ style={{ borderRadius:100 }}
360
+ fill_style={{ borderRadius:100 }}
361
+ color={Colors.text.highlight}
362
+ checked={draft_filter.filter.live_only?false:true}
363
+ onSelect={() => console.log('')}
364
+ disabled
365
+ />
366
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>Any Event Status (Scheduled and Live)</Text>
367
+ </Button>
368
+ <Button transparent style={{ borderRadius:0, flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}
369
+ onPress={() => {
370
+ let new_filter:PlayerFilterProps = { ...draft_filter }
371
+ new_filter.filter.live_only = true
372
+ handleUpdate(new_filter);
373
+ }}
374
+ >
375
+ <Checkbox
376
+ style={{ borderRadius:100 }}
377
+ fill_style={{ borderRadius:100 }}
378
+ color={Colors.text.highlight}
379
+ disabled
380
+ checked={draft_filter.filter.live_only?true:false}
381
+ onSelect={() => console.log('')}
382
+ />
383
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>Live Only - Events currently in progress</Text>
384
+ </Button>
385
+ </View>
386
+ </View>
387
+ )
388
+ case 'leagues':
389
+ if(!draft_filter){ return <></> }
390
+ if(active_toggle != 'markets'){ return <></> }
391
+ return (
392
+ <View nativeID='filter_leagues' style={{ marginTop:10 }}>
393
+ <View type='header' style={{ padding:10 }}>
394
+ <Text theme='h1'>Leagues</Text>
395
+ <Text style={{ marginTop:4 }} theme='description'>Only show orders related to specific leagues (must select 1)</Text>
396
+ </View>
397
+ <View style={{ flexDirection:'row', flexWrap:'wrap', margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
398
+ {leagues.sort((a,b) => a.status.localeCompare(b.status) || a.priority - b.priority).map((l) => {
399
+ const selected = draft_filter.filter.league_ids && draft_filter.filter.league_ids.find(el => el == l.league_id) ? true : false
400
+ return (
401
+ <LeagueLozenge key={`${l.league_id.toString()}`} style={{ flexGrow:1 }} is_active={selected} league={l} onSelect={(league) => handleLeagueSelect(league)}/>
402
+ )
403
+ })}
404
+ </View>
405
+ </View>
406
+ )
407
+ case 'market_types':
408
+ if(!draft_filter){ return <></> }
409
+ if(active_toggle != 'markets'){ return <></> }
410
+ return (
411
+ <View nativeID='filter_order_status' style={{ marginTop:10 }}>
412
+ <View type='header' style={{ padding:10 }}>
413
+ <Text theme='h1'>Market Types</Text>
414
+ <Text style={{ marginTop:4 }}theme='description'>Set to show all orders or filter to only orders related to an event that is currently inprogress</Text>
415
+ </View>
416
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
417
+ <Button transparent style={{ borderRadius:0, flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}
418
+ onPress={() => {
419
+ let new_filter:PlayerFilterProps = { ...draft_filter }
420
+ new_filter.filter.market_types = 'event'
421
+ handleUpdate(new_filter);
422
+ }}
423
+ >
424
+ <Checkbox
425
+ style={{ borderRadius:100 }}
426
+ fill_style={{ borderRadius:100 }}
427
+ color={Colors.text.highlight}
428
+ checked={draft_filter.filter.market_types =='event'?true:false}
429
+ onSelect={() => console.log('')}
430
+ disabled
431
+ />
432
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>Event Level (Winner, Spread, Total)</Text>
433
+ </Button>
434
+ <Button transparent style={{ borderRadius:0, flexDirection:'row', alignItems:'center', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light }}
435
+ onPress={() => {
436
+ let new_filter:PlayerFilterProps = { ...draft_filter }
437
+ new_filter.filter.market_types = 'player_stat'
438
+ handleUpdate(new_filter);
439
+ }}
440
+ >
441
+ <Checkbox
442
+ style={{ borderRadius:100 }}
443
+ fill_style={{ borderRadius:100 }}
444
+ color={Colors.text.highlight}
445
+ checked={draft_filter.filter.market_types == 'player_stat'?true:false}
446
+ onSelect={() => console.log('')}
447
+ disabled
448
+ />
449
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>Player Stats</Text>
450
+ </Button>
451
+ </View>
452
+ </View>
453
+ )
454
+ case 'markets':
455
+ if(!draft_filter){ return <></> }
456
+ if(draft_filter.filter.league_ids?.length <= 0){ return <></> }
457
+ if(!draft_filter.filter.market_types){ return <></> }
458
+ if(active_toggle != 'markets'){ return <></> }
459
+ return (
460
+
461
+ <View nativeID='filter_leagues' style={{ marginTop:10 }}>
462
+ <View type='header' style={{ padding:10 }}>
463
+ <Text theme='h1'>Included Markets</Text>
464
+ <Text style={{ marginTop:4 }} theme='description'>Only show orders related to specific markets</Text>
465
+ </View>
466
+ <View style={{ flexDirection:'row', flexWrap:'wrap', margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
467
+ {filtered_markets.map((m) => {
468
+ const selected = draft_filter.filter.market_ids.find(el => el == m.market_id) ? true : false
469
+ return (
470
+ <MarketLozenge style={{ flexGrow:1 }} is_active={selected} market={m} onSelect={(market) => handleMarketSelect(market)}/>
471
+ )
472
+ })}
473
+ </View>
474
+ </View>
475
+ )
476
+ case 'athletes':
477
+ if(!draft_filter){ return <></> }
478
+ if(draft_filter.filter.league_ids?.length <= 0){ return <></> }
479
+ if(draft_filter.filter.market_types != 'player_stat'){ return <></> }
480
+ if(active_toggle != 'markets'){ return <></> }
481
+ return (
482
+ <View nativeID='filter_athletes' style={{ marginTop:10 }}>
483
+ <View type='header' style={{ padding:10 }}>
484
+ <Text theme='h1'>Included Athletes</Text>
485
+ <Text style={{ marginTop:4 }} theme='description'>Only show orders related to specific athletes</Text>
486
+ </View>
487
+ <View>
488
+ <View>
489
+ <SearchBox
490
+ onFocusPosition={onFocusPosition}
491
+ onChange={(text) => setAthleteSearch({ ...athlete_search, value: text })}
492
+ onSearch={() => handleSearchAthletes(0)}
493
+ />
494
+ </View>
495
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
496
+ <View style={{ flexDirection:'row', flexWrap:'wrap'}}>
497
+ {draft_filter.filter.athlete_ids.map((id) => {
498
+ const athlete = filter_athletes.find(a => a.athlete_id == id);
499
+ if(!athlete){ return <></> }
500
+ const selected = draft_filter.filter.athlete_ids.find(el => el == id) ? true : false
501
+ return (
502
+ <AthleteLozenge key={`filter_${id.toString()}`} leagues={leagues} is_active={selected} athlete={athlete} abbr_only onSelect={(athlete) => handleAthleteSelect(athlete)}/>
503
+ )
504
+ })}
505
+ </View>
506
+ <View style={{ flexDirection:'row', flexWrap:'wrap'}}>
507
+ {athlete_search.athletes.map((a) => {
508
+ const selected = draft_filter.filter.athlete_ids.find(el => el == a.athlete_id) ? true : false
509
+ if(selected){ return <></> }
510
+ return (
511
+ <AthleteLozenge key={`search_${a.athlete_id.toString()}`} leagues={leagues} is_active={false} athlete={a} onSelect={(athlete) => handleAthleteSelect(athlete)}/>
512
+ )
513
+ })}
514
+ </View>
515
+ </View>
516
+ </View>
517
+ </View>
518
+ )
519
+ case 'teams':
520
+ if(!draft_filter){ return <></> }
521
+ if(draft_filter.filter.league_ids?.length <= 0){ return <></> }
522
+ if(draft_filter.filter.market_types != 'event'){ return <></> }
523
+ if(active_toggle != 'markets'){ return <></> }
524
+ return (
525
+ <View nativeID='filter_teams' style={{ marginTop:10 }}>
526
+ <View type='header' style={{ padding:10 }}>
527
+ <Text theme='h1'>Included Teams</Text>
528
+ <Text style={{ marginTop:4 }} theme='description'>Only show orders related to specific teams</Text>
529
+ </View>
530
+ <View>
531
+ <View>
532
+ <SearchBox
533
+ onFocusPosition={onFocusPosition}
534
+ onChange={(text) => setTeamSearch({ ...team_search, value: text })}
535
+ onSearch={() => handleSearchTeams(0)}
536
+ />
537
+ </View>
538
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
539
+ <View style={{ flexDirection:'row', flexWrap:'wrap'}}>
540
+ {draft_filter.filter.team_ids.map((id) => {
541
+ const team = filter_teams.find(a => a.team_id == id);
542
+ if(!team){ return <></> }
543
+ const selected = draft_filter.filter.team_ids.find(el => el == id) ? true : false
544
+ return (
545
+ <TeamLozenge is_active={selected} team={team} leagues={leagues} onSelect={(team) => handleTeamSelect(team)}/>
546
+ )
547
+ })}
548
+ </View>
549
+ <View style={{ flexDirection:'row', flexWrap:'wrap'}}>
550
+ {team_search.teams.map((a) => {
551
+ const selected = draft_filter.filter.team_ids.find(el => el == a.team_id) ? true : false
552
+ if(selected){ return <></> }
553
+ return (
554
+ <TeamLozenge is_active={selected} team={a} leagues={leagues} onSelect={(team) => handleTeamSelect(team)}/>
555
+ )
556
+ })}
557
+ </View>
558
+ </View>
559
+ </View>
560
+ </View>
561
+ )
562
+ case 'players':
563
+ if(!draft_filter){ return <></> }
564
+ if(active_toggle != 'people'){ return <></> }
565
+ return (
566
+ <View nativeID='filter_people' style={{ marginTop:10 }}>
567
+ <View type='header' style={{ padding:10 }}>
568
+ <Text theme='h1'>Show Orders From</Text>
569
+ <Text style={{ marginTop:4 }} theme='description'>Set specific players or groups you would like to see these orders from (i.e., people I follow or Todd my neighbor)</Text>
570
+ </View>
571
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
572
+ <Button disabled style={{ flexDirection:'row', alignItems:'center', padding:0 }}>
573
+ <Checkbox
574
+ style={{ borderRadius:100 }}
575
+ fill_style={{ borderRadius:100 }}
576
+ color={Colors.text.highlight}
577
+ checked={!draft_filter.filter.custom_players && !draft_filter.filter.following_only?true:false}
578
+ onSelect={() => {
579
+ let new_filter:PlayerFilterProps = { ...draft_filter }
580
+ new_filter.filter.custom_players = false
581
+ new_filter.filter.following_only = false
582
+ handleUpdate(new_filter);
583
+ }}
584
+ />
585
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>Everyone</Text>
586
+ </Button>
587
+ <Button disabled style={{ flexDirection:'row', alignItems:'center', marginTop:12, padding:0 }}>
588
+ <Checkbox
589
+ style={{ borderRadius:100 }}
590
+ fill_style={{ borderRadius:100 }}
591
+ color={Colors.text.highlight}
592
+ checked={draft_filter.filter.following_only?true:false}
593
+ onSelect={() => {
594
+ let new_filter:PlayerFilterProps = { ...draft_filter }
595
+ new_filter.filter.following_only = true
596
+ new_filter.filter.custom_players = false
597
+ handleUpdate(new_filter);
598
+ }}
599
+ />
600
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>People I Follow</Text>
601
+ </Button>
602
+ <Button disabled style={{ flexDirection:'row', alignItems:'center', marginTop:12, padding:0 }}>
603
+ <Checkbox
604
+ style={{ borderRadius:100 }}
605
+ fill_style={{ borderRadius:100 }}
606
+ color={Colors.text.highlight}
607
+ checked={draft_filter.filter.custom_players?true:false}
608
+ onSelect={() => {
609
+ let new_filter:PlayerFilterProps = { ...draft_filter }
610
+ new_filter.filter.following_only = false
611
+ new_filter.filter.custom_players = true
612
+ handleUpdate(new_filter);
613
+ }}
614
+ />
615
+ <Text style={{ marginLeft: 14 }} size={14} theme='h2'>Custom Players</Text>
616
+ </Button>
617
+ </View>
618
+
619
+
620
+ {draft_filter.filter.custom_players ?
621
+ <View>
622
+ <View style={{ flexDirection:'row', flexWrap:'wrap', padding:10, borderBottomWidth:1, borderColor:Colors.borders.light}}>
623
+ {draft_filter.filter.player_ids.map((id) => {
624
+ const player = filter_players.find(a => a.player_id == id);
625
+ if(!player){ return <></> }
626
+ const selected = draft_filter.filter.player_ids.find(el => el == id) ? true : false
627
+ return (
628
+ <PlayerLozenge hide_name={true} is_active={selected} player={player} onSelect={(player) => handlePlayerSelect(player)}/>
629
+ )
630
+ })}
631
+ </View>
632
+ <View style={{ marginTop:5 }}>
633
+ <SearchBox
634
+ onFocusPosition={onFocusPosition}
635
+ onChange={(text) => setPlayerSearch({ ...player_search, value: text })}
636
+ onSearch={() => handleSearchPlayers(0)}
637
+ />
638
+ </View>
639
+ <Pagination
640
+ offset={player_search.offset}
641
+ onNext={() => handleSearchPlayers(player_search.offset + 1)}
642
+ onPrevious={() => handleSearchPlayers(player_search.offset - 1)}
643
+ />
644
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
645
+ <View style={{ flexDirection:'row', flexWrap:'wrap'}}>
646
+ {player_search.players.map((a) => {
647
+ const selected = draft_filter.filter.player_ids.find(el => el == a.player_id) ? true : false
648
+ if(selected){ return <></> }
649
+ return (
650
+ <PlayerLozenge is_active={selected} player={a} onSelect={(player) => handlePlayerSelect(player)}/>
651
+ )
652
+ })}
653
+ </View>
654
+ </View>
655
+ </View>
656
+ :<></>}
657
+ </View>
658
+ )
659
+ case 'order_grades':
660
+ if(active_toggle != 'premium'){ return <></> }
661
+ if(!draft_filter){ return <></> }
662
+ return (
663
+ <View nativeID='order_grades' style={{ marginTop:10 }}>
664
+ <View type='header' style={{ padding:10 }}>
665
+ <Text theme='h1'>Minimum Order Grade</Text>
666
+ <Text style={{ marginTop:4 }} theme='description'>Only show orders that are graded above a certain threshold</Text>
667
+ </View>
668
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
669
+ <View style={{ flexDirection:'row', justifyContent:'center' }}>
670
+ {grade_boxes.map(b => {
671
+ const filled = draft_filter?.filter.minimum_grade >= b.min ? true : false
672
+ const success = b.min > 97.5 ? true : false
673
+ return (
674
+ <Button
675
+ float
676
+ style={{ padding:0, height:20, width:20, margin:10, borderRadius:4, borderWidth:1, borderColor:success?b.success_color:b.fail_color, backgroundColor:filled?success?b.success_color:b.fail_color:undefined }}
677
+ onPress={() => {
678
+ if(!premium_allowed){ return alert('Must be a premium member to add this option') }
679
+ let new_filter:PlayerFilterProps = { ...draft_filter }
680
+ new_filter.filter.minimum_grade = b.min
681
+ handleUpdate(new_filter);
682
+ }}
683
+ />
684
+ )
685
+ })}
686
+ </View>
687
+ <Text size={14} weight='semibold' textAlign='center'>{minimumGradeText(draft_filter.filter.minimum_grade)}</Text>
688
+ </View>
689
+ </View>
690
+ )
691
+ case 'external_sources':
692
+ if(active_toggle != 'premium'){ return <></> }
693
+ if(!draft_filter){ return <></> }
694
+ return (
695
+ <View nativeID='filter_order_status'>
696
+ <View type='header' style={{ padding:10 }}>
697
+ <Text theme='h1'>External Price Compare</Text>
698
+ <Text style={{ marginTop:4 }} theme='description'>When viewing orders, we can show you what the price is at a specific book. Select which book below. If the price is not available, we will use the consensus if possible.</Text>
699
+ </View>
700
+ <View style={{ margin:10, padding:10, borderWidth:1, borderColor:Colors.borders.light, borderRadius:8 }}>
701
+ {books.map((b) => {
702
+ return (
703
+ <Button key={b} style={{ flexDirection:'row', alignItems:'center', padding:10}} onPress={() => {
704
+ if(!premium_allowed){ return alert('Must be a premium member to add this option') }
705
+ let new_filter:PlayerFilterProps = { ...draft_filter }
706
+ new_filter.filter.external_book = b
707
+ handleUpdate(new_filter);
708
+
709
+ }}>
710
+ <Checkbox
711
+ disabled
712
+ style={{ borderRadius:100 }}
713
+ fill_style={{ borderRadius:100 }}
714
+ color={Colors.text.highlight}
715
+ checked={draft_filter.filter.external_book == b ? true:false}
716
+ onSelect={() => console.log('')}
717
+ />
718
+ <Text style={{ marginLeft:10 }} theme='h2'>{b.toUpperCase()}</Text>
719
+ </Button>
720
+ )
721
+ })}
722
+ </View>
723
+ </View>
724
+ )
725
+ default: return <></>
726
+ }
727
+ }
728
+ const is_changed = JSON.stringify(player_filter) != JSON.stringify(draft_filter) ? true : false
729
+ return (
730
+ <View style={{ flex:1 }}>
731
+ <View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
732
+ <View transparent style={{ flex:1 }}>
733
+ <Text theme='h1'>MANAGE FILTER</Text>
734
+ <Text theme='description' style={{ marginTop:3 }}>Create rulesets to filter all open orders on BettorEdge</Text>
735
+ </View>
736
+ {errors.length > 0 ?
737
+ <Button float style={{ padding:5, borderRadius:100 }} onPress={() => alert(errors[0])}>
738
+ <Icons.AlertIcon color={Colors.text.warning} size={16} />
739
+ </Button>
740
+ :<></>}
741
+ <Button
742
+ title='SAVE'
743
+ type='success'
744
+ disabled={!is_changed || action_loading}
745
+ loading={action_loading}
746
+ style={{ marginLeft:10, padding:10, opacity: action_loading || !is_changed ? 0.5 : 1 }}
747
+ onPress={async() => {
748
+ if(!draft_filter){ return }
749
+ handleUpdate(draft_filter);
750
+ }}
751
+ />
752
+ </View>
753
+ <View style={{ flex:1 }}>
754
+ {static_loading || loading ?
755
+ <ActivityIndicator
756
+ style={{ padding:20, alignSelf:'center' }}
757
+ size={'large'}
758
+ color={Colors.text.h1}
759
+ />
760
+ :<></>}
761
+ <FlatList
762
+ data={sections}
763
+ key={'manage_filter_sections'}
764
+ keyExtractor={item => item}
765
+ renderItem={renderSections}
766
+ />
767
+ {player_filter ?
768
+ <View type='footer' style={{ flexDirection:'row', padding:10 }}>
769
+ {!confirm_delete ?
770
+ <Button
771
+ style={{ flex:1, opacity:action_loading?0.5:1 }}
772
+ type='error'
773
+ loading={action_loading}
774
+ title='DELETE'
775
+ onPress={() => {
776
+ setActionLoading(true)
777
+ setTimeout(() => {
778
+ setConfirmDelete(true);
779
+ setActionLoading(false)
780
+ }, 500);
781
+ }}
782
+ />
783
+ :<></>}
784
+ {confirm_delete ?
785
+ <Button
786
+ style={{ flex:1, opacity:action_loading?0.5:1 }}
787
+ type='error'
788
+ loading={action_loading}
789
+ title='DELETE THIS FILTER'
790
+ onPress={async() => {
791
+ setActionLoading(true);
792
+ let new_pf = await BetMatchApi.deletePlayerFilter(player_filter_id)
793
+ if(!new_pf){
794
+ setActionLoading(false);
795
+ setConfirmDelete(false);
796
+ return alert('Unable to process this')
797
+ }
798
+ setActionLoading(false);
799
+ setConfirmDelete(false);
800
+ setFilterData({
801
+ ...filter_data,
802
+ player_filter: new_pf,
803
+ draft_filter: new_pf
804
+ });
805
+ onUpdateFilter(new_pf);
806
+ }}
807
+ />
808
+ :
809
+ <Button
810
+ style={{ flex:2, marginLeft:10 }}
811
+ type='action'
812
+ title='RUN'
813
+ onPress={() => onRunFilter(player_filter)}
814
+ />
815
+ }
816
+ </View>
817
+ :<></>}
818
+ {player_filter?.status == 'deleted' ?
819
+ <View type='blur' style={{ position:'absolute', top:0, left:0, right:0, bottom:0, justifyContent:'center', alignItems:'center' }}>
820
+ <View float style={{ width:400, height:400, justifyContent:'center', alignItems:'center' }}>
821
+ <Text theme='h1'>This filter has been deleted</Text>
822
+ </View>
823
+ </View>
824
+ :<></>}
825
+ </View>
826
+ </View>
827
+ )
828
+ }
829
+
830
+ export default ManageFilter