be-components 2.4.7 → 2.4.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (134) hide show
  1. package/lib/commonjs/LocationTracker/LocationStatus.js.map +1 -1
  2. package/lib/commonjs/LocationTracker/api/index.js +14 -0
  3. package/lib/commonjs/LocationTracker/api/index.js.map +1 -1
  4. package/lib/commonjs/MarketComponents/components/TeamEventMarket/index.js +91 -3
  5. package/lib/commonjs/MarketComponents/components/TeamEventMarket/index.js.map +1 -1
  6. package/lib/commonjs/MarketMaker/api/index.js +1307 -0
  7. package/lib/commonjs/MarketMaker/api/index.js.map +1 -0
  8. package/lib/commonjs/MarketMaker/components/Contest.js +150 -0
  9. package/lib/commonjs/MarketMaker/components/Contest.js.map +1 -0
  10. package/lib/commonjs/MarketMaker/components/ContestMarkets.js +300 -0
  11. package/lib/commonjs/MarketMaker/components/ContestMarkets.js.map +1 -0
  12. package/lib/commonjs/MarketMaker/components/ContestSelector.js +111 -0
  13. package/lib/commonjs/MarketMaker/components/ContestSelector.js.map +1 -0
  14. package/lib/commonjs/MarketMaker/components/Dashboard.js +164 -0
  15. package/lib/commonjs/MarketMaker/components/Dashboard.js.map +1 -0
  16. package/lib/commonjs/MarketMaker/components/FundActions.js +232 -0
  17. package/lib/commonjs/MarketMaker/components/FundActions.js.map +1 -0
  18. package/lib/commonjs/MarketMaker/components/FundOwnershipList.js +94 -0
  19. package/lib/commonjs/MarketMaker/components/FundOwnershipList.js.map +1 -0
  20. package/lib/commonjs/MarketMaker/components/FundSelector.js +99 -0
  21. package/lib/commonjs/MarketMaker/components/FundSelector.js.map +1 -0
  22. package/lib/commonjs/MarketMaker/components/FundingRequestList.js +112 -0
  23. package/lib/commonjs/MarketMaker/components/FundingRequestList.js.map +1 -0
  24. package/lib/commonjs/MarketMaker/components/ManageFundForm.js +122 -0
  25. package/lib/commonjs/MarketMaker/components/ManageFundForm.js.map +1 -0
  26. package/lib/commonjs/MarketMaker/components/MarketSelector.js +81 -0
  27. package/lib/commonjs/MarketMaker/components/MarketSelector.js.map +1 -0
  28. package/lib/commonjs/MarketMaker/components/SetMarketForm.js +305 -0
  29. package/lib/commonjs/MarketMaker/components/SetMarketForm.js.map +1 -0
  30. package/lib/commonjs/MarketMaker/components/WeightProgress.js +40 -0
  31. package/lib/commonjs/MarketMaker/components/WeightProgress.js.map +1 -0
  32. package/lib/commonjs/MarketMaker/index.js +452 -0
  33. package/lib/commonjs/MarketMaker/index.js.map +1 -0
  34. package/lib/commonjs/SocialComponents/api/index.js +0 -1
  35. package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
  36. package/lib/commonjs/index.js +7 -0
  37. package/lib/commonjs/index.js.map +1 -1
  38. package/lib/commonjs/types.d.js +4 -0
  39. package/lib/module/LocationTracker/LocationStatus.js.map +1 -1
  40. package/lib/module/LocationTracker/api/index.js +14 -0
  41. package/lib/module/LocationTracker/api/index.js.map +1 -1
  42. package/lib/module/MarketComponents/components/TeamEventMarket/index.js +91 -3
  43. package/lib/module/MarketComponents/components/TeamEventMarket/index.js.map +1 -1
  44. package/lib/module/MarketMaker/api/index.js +1301 -0
  45. package/lib/module/MarketMaker/api/index.js.map +1 -0
  46. package/lib/module/MarketMaker/components/Contest.js +143 -0
  47. package/lib/module/MarketMaker/components/Contest.js.map +1 -0
  48. package/lib/module/MarketMaker/components/ContestMarkets.js +291 -0
  49. package/lib/module/MarketMaker/components/ContestMarkets.js.map +1 -0
  50. package/lib/module/MarketMaker/components/ContestSelector.js +102 -0
  51. package/lib/module/MarketMaker/components/ContestSelector.js.map +1 -0
  52. package/lib/module/MarketMaker/components/Dashboard.js +155 -0
  53. package/lib/module/MarketMaker/components/Dashboard.js.map +1 -0
  54. package/lib/module/MarketMaker/components/FundActions.js +223 -0
  55. package/lib/module/MarketMaker/components/FundActions.js.map +1 -0
  56. package/lib/module/MarketMaker/components/FundOwnershipList.js +87 -0
  57. package/lib/module/MarketMaker/components/FundOwnershipList.js.map +1 -0
  58. package/lib/module/MarketMaker/components/FundSelector.js +92 -0
  59. package/lib/module/MarketMaker/components/FundSelector.js.map +1 -0
  60. package/lib/module/MarketMaker/components/FundingRequestList.js +105 -0
  61. package/lib/module/MarketMaker/components/FundingRequestList.js.map +1 -0
  62. package/lib/module/MarketMaker/components/ManageFundForm.js +113 -0
  63. package/lib/module/MarketMaker/components/ManageFundForm.js.map +1 -0
  64. package/lib/module/MarketMaker/components/MarketSelector.js +74 -0
  65. package/lib/module/MarketMaker/components/MarketSelector.js.map +1 -0
  66. package/lib/module/MarketMaker/components/SetMarketForm.js +297 -0
  67. package/lib/module/MarketMaker/components/SetMarketForm.js.map +1 -0
  68. package/lib/module/MarketMaker/components/WeightProgress.js +33 -0
  69. package/lib/module/MarketMaker/components/WeightProgress.js.map +1 -0
  70. package/lib/module/MarketMaker/index.js +442 -0
  71. package/lib/module/MarketMaker/index.js.map +1 -0
  72. package/lib/module/SocialComponents/api/index.js +0 -1
  73. package/lib/module/SocialComponents/api/index.js.map +1 -1
  74. package/lib/module/index.js +2 -1
  75. package/lib/module/index.js.map +1 -1
  76. package/lib/module/types.d.js +1 -1
  77. package/lib/typescript/src/LocationTracker/LocationStatus.d.ts.map +1 -1
  78. package/lib/typescript/src/LocationTracker/api/index.d.ts.map +1 -1
  79. package/lib/typescript/src/MarketComponents/components/TeamEventMarket/index.d.ts +2 -2
  80. package/lib/typescript/src/MarketComponents/components/TeamEventMarket/index.d.ts.map +1 -1
  81. package/lib/typescript/src/MarketComponents/index.d.ts +2 -2
  82. package/lib/typescript/src/MarketComponents/index.d.ts.map +1 -1
  83. package/lib/typescript/src/MarketMaker/api/index.d.ts +131 -0
  84. package/lib/typescript/src/MarketMaker/api/index.d.ts.map +1 -0
  85. package/lib/typescript/src/MarketMaker/components/Contest.d.ts +25 -0
  86. package/lib/typescript/src/MarketMaker/components/Contest.d.ts.map +1 -0
  87. package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts +26 -0
  88. package/lib/typescript/src/MarketMaker/components/ContestMarkets.d.ts.map +1 -0
  89. package/lib/typescript/src/MarketMaker/components/ContestSelector.d.ts +19 -0
  90. package/lib/typescript/src/MarketMaker/components/ContestSelector.d.ts.map +1 -0
  91. package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts +25 -0
  92. package/lib/typescript/src/MarketMaker/components/Dashboard.d.ts.map +1 -0
  93. package/lib/typescript/src/MarketMaker/components/FundActions.d.ts +12 -0
  94. package/lib/typescript/src/MarketMaker/components/FundActions.d.ts.map +1 -0
  95. package/lib/typescript/src/MarketMaker/components/FundOwnershipList.d.ts +9 -0
  96. package/lib/typescript/src/MarketMaker/components/FundOwnershipList.d.ts.map +1 -0
  97. package/lib/typescript/src/MarketMaker/components/FundSelector.d.ts +13 -0
  98. package/lib/typescript/src/MarketMaker/components/FundSelector.d.ts.map +1 -0
  99. package/lib/typescript/src/MarketMaker/components/FundingRequestList.d.ts +11 -0
  100. package/lib/typescript/src/MarketMaker/components/FundingRequestList.d.ts.map +1 -0
  101. package/lib/typescript/src/MarketMaker/components/ManageFundForm.d.ts +10 -0
  102. package/lib/typescript/src/MarketMaker/components/ManageFundForm.d.ts.map +1 -0
  103. package/lib/typescript/src/MarketMaker/components/MarketSelector.d.ts +12 -0
  104. package/lib/typescript/src/MarketMaker/components/MarketSelector.d.ts.map +1 -0
  105. package/lib/typescript/src/MarketMaker/components/SetMarketForm.d.ts +15 -0
  106. package/lib/typescript/src/MarketMaker/components/SetMarketForm.d.ts.map +1 -0
  107. package/lib/typescript/src/MarketMaker/components/WeightProgress.d.ts +10 -0
  108. package/lib/typescript/src/MarketMaker/components/WeightProgress.d.ts.map +1 -0
  109. package/lib/typescript/src/MarketMaker/index.d.ts +7 -0
  110. package/lib/typescript/src/MarketMaker/index.d.ts.map +1 -0
  111. package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
  112. package/lib/typescript/src/index.d.ts +2 -1
  113. package/lib/typescript/src/index.d.ts.map +1 -1
  114. package/package.json +1 -1
  115. package/src/LocationTracker/LocationStatus.tsx +0 -1
  116. package/src/LocationTracker/api/index.tsx +16 -0
  117. package/src/MarketComponents/components/TeamEventMarket/index.tsx +54 -4
  118. package/src/MarketMaker/api/index.ts +1023 -0
  119. package/src/MarketMaker/components/Contest.tsx +106 -0
  120. package/src/MarketMaker/components/ContestMarkets.tsx +174 -0
  121. package/src/MarketMaker/components/ContestSelector.tsx +84 -0
  122. package/src/MarketMaker/components/Dashboard.tsx +112 -0
  123. package/src/MarketMaker/components/FundActions.tsx +149 -0
  124. package/src/MarketMaker/components/FundOwnershipList.tsx +54 -0
  125. package/src/MarketMaker/components/FundSelector.tsx +65 -0
  126. package/src/MarketMaker/components/FundingRequestList.tsx +71 -0
  127. package/src/MarketMaker/components/ManageFundForm.tsx +83 -0
  128. package/src/MarketMaker/components/MarketSelector.tsx +50 -0
  129. package/src/MarketMaker/components/SetMarketForm.tsx +213 -0
  130. package/src/MarketMaker/components/WeightProgress.tsx +25 -0
  131. package/src/MarketMaker/index.tsx +378 -0
  132. package/src/SocialComponents/api/index.ts +0 -1
  133. package/src/index.tsx +2 -1
  134. package/src/types.d.ts +135 -0
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import { View, FlatList, Image } from 'react-native';
3
+ import type { FundOwnershipProps, PublicPlayerProps } from "../../types"
4
+ import { view_styles } from '../../constants/styles';
5
+ import { Text } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+ import moment from 'moment-mini';
8
+
9
+ type FundOwnershipListProps = {
10
+ fund_ownerships:FundOwnershipProps[],
11
+ players:PublicPlayerProps[]
12
+ }
13
+ const FundOwnershipList = ({ fund_ownerships, players }:FundOwnershipListProps) => {
14
+
15
+ const renderFundOwnerships = (data:{ item:FundOwnershipProps, index:number }) => {
16
+ const player = players.find(p => p.player_id == data.item.player_id);
17
+ if(!player){ return <></> }
18
+ return (
19
+ <View style={{ ...view_styles.body_row, padding:10, borderBottomWidth:1, borderColor:Colors.shades.shade600 }}>
20
+ <Image
21
+ source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
22
+ style={{ height:40, width:40, borderRadius:100 }}
23
+ resizeMode='cover'
24
+ />
25
+ <View style={{ flex:1, marginLeft:10 }}>
26
+ <Text size={14} color={Colors.brand.midnight} weight='bold'>{player.first_name} {player.last_name}</Text>
27
+ <Text style={{ marginTop:3 }} size={12} weight='regular' color={Colors.brand.midnight}>Owner since {moment(data.item.create_datetime).format('MMM DD YYYY')}</Text>
28
+ </View>
29
+ <Text size={14} weight='bold' color={Colors.brand.midnight}>{(data.item.ownership_pct * 100).toFixed(2)}%</Text>
30
+ </View>
31
+ )
32
+ }
33
+
34
+ return (
35
+ <View style={{ ...view_styles.section }}>
36
+ <View style={{ ...view_styles.section_header }}>
37
+ <View style={{ flex:1 }}>
38
+ <Text theme='header'>Fund Owners</Text>
39
+ <Text style={{ marginTop:3 }} theme='body'>Below are the players that have invested in this fund sorted by their ownership pct.</Text>
40
+ </View>
41
+ </View>
42
+ <View style={{ ...view_styles.section_body, padding:0 }}>
43
+ <FlatList
44
+ key={'fund_ownerships'}
45
+ data={fund_ownerships.sort((a,b) => b.ownership_pct - a.ownership_pct)}
46
+ keyExtractor={(item) => item.fund_ownership_id.toString()}
47
+ renderItem={renderFundOwnerships}
48
+ />
49
+ </View>
50
+ </View>
51
+ )
52
+ }
53
+
54
+ export default FundOwnershipList
@@ -0,0 +1,65 @@
1
+ import React from 'react';
2
+ import { View, FlatList, TouchableOpacity } from 'react-native';
3
+ import { view_styles } from "../../constants/styles"
4
+ import type { FundProps } from '../../types';
5
+ import { Button, Checkbox, Icons, Text } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+ import { MarketMakerApi } from '../api';
8
+
9
+
10
+ type FundSelectorProps = {
11
+ funds:FundProps[],
12
+ selected_fund_id?:string,
13
+ maxHeight:number,
14
+ onSelectFund:(f:FundProps) => void,
15
+ onCreateFund:(f:FundProps) => void,
16
+ onEditFund:(f:FundProps) => void
17
+ }
18
+ const FundSelector = ({ selected_fund_id, funds, maxHeight, onSelectFund, onCreateFund, onEditFund }:FundSelectorProps) => {
19
+
20
+ const renderFunds = (data:{item:FundProps, index:number}) => {
21
+ const selected = selected_fund_id == data.item.fund_id ? true : false
22
+ return (
23
+ <TouchableOpacity style={{ ...view_styles.body_row, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }} onPress={() => onSelectFund(data.item)}>
24
+ <Checkbox checked={selected} disabled onSelect={() => console.log('')}/>
25
+ <View style={{ flex:1, marginLeft:10 }}>
26
+ <Text size={12} weight='bold' color={Colors.brand.midnight}>{data.item.name}</Text>
27
+ <Text style={{ marginTop:3 }} theme='body_2'>This is a cool fund!</Text>
28
+ </View>
29
+ <TouchableOpacity onPress={() => onEditFund(data.item)}>
30
+ <Icons.EditIcon size={18} color={Colors.brand.electric} />
31
+ </TouchableOpacity>
32
+ </TouchableOpacity>
33
+ )
34
+ }
35
+ return (
36
+ <View style={{ ...view_styles.section, maxHeight }}>
37
+ <View style={{ ...view_styles.section_header }}>
38
+ <View style={{ flex:1 }}>
39
+ <Text theme='header'>Select Fund</Text>
40
+ <Text style={{ marginTop:3 }} theme='body_2'>Select a fund to populate the dashboard with the funds orders and data</Text>
41
+ </View>
42
+ <Button
43
+ title='NEW'
44
+ backgroundColor={Colors.utility.success}
45
+ title_color={Colors.shades.white}
46
+ onPress={async() => {
47
+ const new_fund = await MarketMakerApi.createFund('Pending Fund', 100, 'FOR_MONEY');
48
+ if(!new_fund){ return alert('Unable to process') }
49
+ onCreateFund(new_fund)
50
+ }}
51
+ />
52
+ </View>
53
+ <View style={{ ...view_styles.section_body }}>
54
+ <FlatList
55
+ key={'market_selector'}
56
+ data={funds}
57
+ renderItem={renderFunds}
58
+ keyExtractor={(item) => item.fund_id.toString()}
59
+ />
60
+ </View>
61
+ </View>
62
+ )
63
+ }
64
+
65
+ export default FundSelector
@@ -0,0 +1,71 @@
1
+ import React from 'react';
2
+ import { View, FlatList, Image } from 'react-native';
3
+ import type { FundingRequestProps, PublicPlayerProps } from "../../types"
4
+ import { view_styles } from '../../constants/styles';
5
+ import { Button, Text } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+ import moment from 'moment-mini';
8
+
9
+ type FundingRequestListProps = {
10
+ funding_requests:FundingRequestProps[],
11
+ players:PublicPlayerProps[],
12
+ onApproveRequest:(funding_request_id:string) => void,
13
+ onDeclineRequest:(funding_request_id:string) => void
14
+ }
15
+ const FundingRequestList = ({ funding_requests, players, onApproveRequest, onDeclineRequest }:FundingRequestListProps) => {
16
+
17
+ const renderFundingRequests = (data:{ item:FundingRequestProps, index:number }) => {
18
+ const player = players.find(p => p.player_id == data.item.player_id)
19
+ if(!player){ return <></> }
20
+ return (
21
+ <View style={{ ...view_styles.body_row, padding:10, borderBottomWidth:1, borderColor:Colors.shades.shade600 }}>
22
+ <Image
23
+ source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
24
+ style={{ height:40, width:40, borderRadius:100 }}
25
+ resizeMode='cover'
26
+ />
27
+ <View style={{ flex:1, marginLeft:10 }}>
28
+ <Text size={14} color={Colors.brand.midnight} weight='bold'>{player.first_name} {player.last_name}</Text>
29
+ <Text style={{ marginTop:3 }} size={12} weight='regular' color={Colors.brand.midnight}>Requested on {moment(data.item.create_datetime).format('MMM DD hh:mm a')}</Text>
30
+ </View>
31
+ <Text size={14} weight='bold' color={Colors.brand.midnight}>${data.item.amount.toFixed(2)}</Text>
32
+ <Button
33
+ title='DECLINE'
34
+ style={{ marginRight:5, marginLeft:5 }}
35
+ title_color={Colors.shades.white}
36
+ backgroundColor={Colors.utility.error}
37
+ borderRadius={4}
38
+ onPress={() => onDeclineRequest(data.item.funding_request_id)}
39
+ />
40
+ <Button
41
+ title='APPROVE'
42
+ title_color={Colors.shades.white}
43
+ backgroundColor={Colors.utility.success}
44
+ borderRadius={4}
45
+ onPress={() => onApproveRequest(data.item.funding_request_id)}
46
+ />
47
+ </View>
48
+ )
49
+ }
50
+
51
+ return (
52
+ <View style={{ ...view_styles.section }}>
53
+ <View style={{ ...view_styles.section_header }}>
54
+ <View style={{ flex:1 }}>
55
+ <Text theme='header'>Funding Requests</Text>
56
+ <Text style={{ marginTop:3 }} theme='body'>Below are the pending funding requests. Approve or decline them.</Text>
57
+ </View>
58
+ </View>
59
+ <View style={{ ...view_styles.section_body, padding:0 }}>
60
+ <FlatList
61
+ key={'funding_requests'}
62
+ data={funding_requests}
63
+ keyExtractor={(item) => item.funding_request_id.toString()}
64
+ renderItem={renderFundingRequests}
65
+ />
66
+ </View>
67
+ </View>
68
+ )
69
+ }
70
+
71
+ export default FundingRequestList
@@ -0,0 +1,83 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import type { FundProps } from '../../types';
4
+ import { view_styles } from '../../constants/styles';
5
+ import { Button, Text, TextInput } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+ import { MarketMakerApi } from '../api';
8
+
9
+ type ManageFundFormProps = {
10
+ fund: FundProps
11
+ onFundUpdate:(fund:FundProps) => void,
12
+ onClose:() => void
13
+ }
14
+ const ManageFundForm = ({ fund, onFundUpdate, onClose }:ManageFundFormProps) => {
15
+ const [ form_data, setFormData ] = useState<{
16
+ loading:boolean,
17
+ draft_fund?:FundProps
18
+ }>({
19
+ loading:false
20
+ });
21
+ const { loading, draft_fund } = form_data;
22
+
23
+ useEffect(() => {
24
+ setFormData({ ...form_data, draft_fund: fund })
25
+ },[fund])
26
+
27
+ if(!draft_fund){ return <></> }
28
+
29
+ const is_name_changed = fund.name != draft_fund.name ? true : false
30
+
31
+ return (
32
+ <View style={{ ...view_styles.section }}>
33
+ <View style={{ ...view_styles.section_header }}>
34
+ <View style={{ flex:1 }}>
35
+ <Text theme='header'>Manage Fund</Text>
36
+ <Text style={{ marginTop:3 }} theme='body'>Update fund settings below and save</Text>
37
+ </View>
38
+ <Button
39
+ title='X'
40
+ title_color={Colors.brand.midnight}
41
+ borderRadius={100}
42
+ backgroundColor={Colors.shades.shade100}
43
+ onPress={() => onClose()}
44
+ />
45
+ </View>
46
+ <View style={{ ...view_styles.section_body }}>
47
+ <View style={{ ...view_styles.body_row }}>
48
+ <View style={{ flex:1 }}>
49
+ <Text theme='header_2'>Fund Name</Text>
50
+ <View style={{ marginTop:5, flexDirection:'row', alignItems:'center' }}>
51
+ <TextInput
52
+ style={{ ...view_styles.input }}
53
+ value={draft_fund.name}
54
+ onChangeText={(text) => setFormData({ ...form_data, draft_fund: { ...draft_fund, name: text } })}
55
+ />
56
+ <Button
57
+ title='SAVE'
58
+ backgroundColor={Colors.utility.success}
59
+ style={{ opacity: is_name_changed && !loading ? 1: 0.5, marginLeft:10 }}
60
+ disabled={!is_name_changed || loading}
61
+ onPress={async() => {
62
+ setFormData({ ...form_data, loading: true });
63
+ let new_fund = await MarketMakerApi.udpateFundName(fund.fund_id, draft_fund.name)
64
+ if(!new_fund){ return alert('Unable to process') }
65
+ setFormData({
66
+ ...form_data,
67
+ loading: false,
68
+ draft_fund: new_fund
69
+ });
70
+ onFundUpdate(new_fund)
71
+ }}
72
+ />
73
+ </View>
74
+
75
+ </View>
76
+ </View>
77
+ </View>
78
+
79
+ </View>
80
+ )
81
+ }
82
+
83
+ export default ManageFundForm
@@ -0,0 +1,50 @@
1
+ import React from 'react';
2
+ import { View, FlatList, TouchableOpacity } from 'react-native';
3
+ import { view_styles } from "../../constants/styles"
4
+ import type { MarketProps } from '../../types';
5
+ import { Checkbox, Text } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+
8
+
9
+ type MarketSelectorProps = {
10
+ maxHeight?:number,
11
+ markets:MarketProps[],
12
+ selected_markets:string[],
13
+ onSelectMarket:(m:MarketProps) => void,
14
+ onDeselectMarket:(m:MarketProps) => void
15
+ }
16
+ const MarketSelector = ({ maxHeight, markets, selected_markets, onSelectMarket, onDeselectMarket }:MarketSelectorProps) => {
17
+
18
+ const renderMarkets = (data:{item:MarketProps, index:number}) => {
19
+ const selected = selected_markets.find(se => se == data.item.market_id) ? true : false;
20
+ return (
21
+ <TouchableOpacity style={{ ...view_styles.body_row, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }} onPress={() => selected ? onDeselectMarket(data.item) : onSelectMarket(data.item)}>
22
+ <Checkbox checked={selected} disabled onSelect={() => console.log('')}/>
23
+ <View style={{ flex:1, marginLeft:10 }}>
24
+ <Text size={12} weight='bold' color={Colors.brand.midnight}>{data.item.type == 'Stat' ? data.item.stat_label : data.item.type}</Text>
25
+ <Text style={{ marginTop:3 }} theme='body_2'>{data.item.description}</Text>
26
+ </View>
27
+ </TouchableOpacity>
28
+ )
29
+ }
30
+ return (
31
+ <View style={{ ...view_styles.section, maxHeight }}>
32
+ <View style={{ ...view_styles.section_header }}>
33
+ <View style={{ flex:1 }}>
34
+ <Text theme='header'>Select Market</Text>
35
+ <Text style={{ marginTop:3 }} theme='body_2'>Manage the markets that are shown on the dashboard</Text>
36
+ </View>
37
+ </View>
38
+ <View style={{ ...view_styles.section_body }}>
39
+ <FlatList
40
+ key={'market_selector'}
41
+ data={markets}
42
+ renderItem={renderMarkets}
43
+ keyExtractor={(item) => item.market_id.toString()}
44
+ />
45
+ </View>
46
+ </View>
47
+ )
48
+ }
49
+
50
+ export default MarketSelector
@@ -0,0 +1,213 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { View } from 'react-native';
3
+ import type { ExternalPriceProps, FundProps, MarketProps, OrderProps } from '../../types';
4
+ import { view_styles } from '../../constants/styles';
5
+ import { Button, Text, TextInput } from '../../Components';
6
+ import Colors from '../../constants/colors';
7
+ import { MarketMaketHelpers } from '../api';
8
+
9
+ type SetMarketFormProps = {
10
+ fund:FundProps,
11
+ form_key:string,
12
+ orders:OrderProps[],
13
+ market:MarketProps,
14
+ prices:ExternalPriceProps[],
15
+ spread_pct:string,
16
+ onSetMarket:(orders:OrderProps[]) => void
17
+ onClose:() => void
18
+ }
19
+ const SetMarketForm = ({ form_key, orders, market, prices, onClose, onSetMarket }:SetMarketFormProps) => {
20
+ const [ form_data, setFormData ] = useState<{
21
+ spread_pct:string,
22
+ trade_side?:OrderProps,
23
+ o_side?:OrderProps
24
+ }>({
25
+ spread_pct: '5'
26
+ })
27
+ const { trade_side, o_side, spread_pct } = form_data;
28
+
29
+ const no_vig_data = MarketMaketHelpers.getNoVigPrice(prices, market);
30
+
31
+ useEffect(() => {
32
+ if(!form_key) { return }
33
+ let trade_side_o = orders.find(o => o.side == market.trade_side);
34
+ let o_side_o = orders.find(o => o.side != market.trade_side);
35
+ setFormData({ trade_side:trade_side_o, o_side: o_side_o, spread_pct });
36
+ },[form_key])
37
+
38
+ if(!trade_side || !o_side){ return <></> }
39
+ const actual_margin = (1 - [trade_side, o_side].reduce((a, b) => a + b.probability, 0)) * 100
40
+
41
+ return (
42
+ <View style={{ ...view_styles.section, minWidth:330 }}>
43
+ <View style={{ ...view_styles.section_header, paddingLeft:10 }}>
44
+ <View style={{ flex:1 }}>
45
+ <Text theme='header'>Set Market</Text>
46
+ <Text style={{ marginTop:3 }} theme='body'>Customize the orders below or submit</Text>
47
+ </View>
48
+ <Button
49
+ title='X'
50
+ borderRadius={100}
51
+ backgroundColor={Colors.shades.shade100}
52
+ title_color={Colors.utility.error}
53
+ onPress={() => onClose()}
54
+ />
55
+ </View>
56
+ <View style={{ ...view_styles.section_body, padding:0 }}>
57
+ {no_vig_data ?
58
+ <View style={{ ...view_styles.body_row, padding:10 }}>
59
+ <View style={{ flex:1 }}>
60
+ <Text theme='header_2'>{no_vig_data.external_name}</Text>
61
+ <Text style={{ marginTop:3 }} theme='body_2'>The NO VIG price retrieved from {no_vig_data.external_name}</Text>
62
+ </View>
63
+ <Text size={16}>{MarketMaketHelpers.getOddsLabel(no_vig_data.trade_side_odds)}</Text>
64
+ </View>
65
+ :<></>}
66
+ <View style={{ ...view_styles.body_row, padding:10, borderBottomWidth:1, borderColor:Colors.shades.shade600, backgroundColor:Colors.shades.shade100 }}>
67
+ <View style={{ flex:1, marginRight:10}}>
68
+ <Text theme='header_2'>Customize Margin</Text>
69
+ <Text style={{ marginTop:3 }} theme='body_2'>Set the margin pct to automatically create prices.</Text>
70
+ </View>
71
+ {actual_margin.toFixed(2) != parseInt(spread_pct).toFixed(2) ?
72
+ <Text size={14} color={actual_margin < 0 ? Colors.utility.error : actual_margin < 5 ? Colors.utility.success : actual_margin > 8 ? Colors.utility.error : Colors.utility.warning} weight='bold'>{actual_margin .toFixed(2)}%</Text>
73
+ :<></>}
74
+ <TextInput
75
+ style={{ ...view_styles.input, width:40 }}
76
+ value={spread_pct}
77
+ onChangeText={(text) => setFormData({ ...form_data, spread_pct: text })}
78
+ />
79
+ <Text size={16} color={Colors.brand.midnight}>%</Text>
80
+ </View>
81
+ <View style={{ ...view_styles.body_row, paddingBottom:10 }}>
82
+ <View style={{ flex:1 }}>
83
+ <View style={{ padding:10, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }}>
84
+ <Text size={14} color={Colors.brand.midnight} weight='bold' textAlign='center'>{o_side.title}</Text>
85
+ </View>
86
+ </View>
87
+ <View style={{ flex:1 }}>
88
+ <View style={{ padding:10, borderBottomWidth:1, borderBottomColor:Colors.shades.shade600 }}>
89
+ <Text size={14} color={Colors.brand.midnight} weight='bold' textAlign='center'>{trade_side.title}</Text>
90
+ </View>
91
+ </View>
92
+ </View>
93
+
94
+ <View style={{ ...view_styles.body_row }}>
95
+ <Text style={{ flex:1 }} textAlign='center' size={14} color={Colors.brand.midnight}>${o_side.open_amt.toFixed(2)}</Text>
96
+ <Text size={14} color={Colors.brand.midnight} textAlign='center'>TO STAKE</Text>
97
+ <Text style={{ flex:1 }} textAlign='center' size={14} color={Colors.brand.midnight}>${trade_side.open_amt.toFixed(2)}</Text>
98
+ </View>
99
+ </View>
100
+ <View style={{ ...view_styles.section_footer }}>
101
+ <Button
102
+ title='Review'
103
+ style={{ flex:1 }}
104
+ borderRadius={4}
105
+ backgroundColor={Colors.brand.electric}
106
+ title_color={Colors.shades.white}
107
+ onPress={() => onSetMarket([o_side, trade_side])}
108
+ />
109
+ </View>
110
+
111
+ </View>
112
+ )
113
+ }
114
+
115
+ export default SetMarketForm
116
+
117
+
118
+ /*
119
+
120
+ <View style={{ ...view_styles.body_row, padding:10 }}>
121
+ <TextInput
122
+ style={{ flex:1, ...view_styles.input }}
123
+ value={o_side.working_pct}
124
+ onChangeText={(text) => {
125
+ let open_amt = fund.working_capital * parseFloat(text)
126
+
127
+ setFormData({
128
+ ...form_data,
129
+ o_side: {
130
+ ...o_side,
131
+ working_pct: text,
132
+ open_amt: open_amt,
133
+ potential_winnings: MarketMaketHelpers.calcPotentialWinnings(open_amt, o_side.odds)
134
+ }
135
+ })
136
+ }}
137
+ />
138
+ <Text style={{ marginLeft:5, marginRight:5 }} size={14} color={Colors.brand.midnight}>WORK %</Text>
139
+ <TextInput
140
+ style={{ flex:1, ...view_styles.input }}
141
+ value={trade_side.working_pct}
142
+ onChangeText={(text) => {
143
+ let open_amt = fund.working_capital * parseFloat(text)
144
+
145
+ setFormData({
146
+ ...form_data,
147
+ trade_side: {
148
+ ...trade_side,
149
+ working_pct: text,
150
+ open_amt: open_amt,
151
+ potential_winnings: MarketMaketHelpers.calcPotentialWinnings(open_amt, trade_side.odds)
152
+ }
153
+ })
154
+ }}
155
+ />
156
+ </View>
157
+ <View style={{ ...view_styles.body_row, padding:10 }}>
158
+ <TextInput
159
+ style={{ flex:1, ...view_styles.input }}
160
+ value={o_side.potential_winnings}
161
+ onChangeText={(text) => setFormData({
162
+ ...form_data,
163
+ o_side: {
164
+ ...o_side,
165
+ potential_winnings: text,
166
+ open_amt: MarketMaketHelpers.calcSaleValue(o_side.odds, text)
167
+ }
168
+ })}
169
+ />
170
+ <Text style={{ marginLeft:5, marginRight:5 }} size={14} color={Colors.brand.midnight}>TO WIN</Text>
171
+ <TextInput
172
+ style={{ flex:1, ...view_styles.input }}
173
+ value={trade_side.potential_winnings}
174
+ onChangeText={(text) => setFormData({
175
+ ...form_data,
176
+ trade_side: {
177
+ ...trade_side,
178
+ potential_winnings: text,
179
+ open_amt: MarketMaketHelpers.calcSaleValue(trade_side.odds, text)
180
+ }
181
+ })}
182
+ />
183
+ </View>
184
+ <View style={{ ...view_styles.body_row, padding:10 }}>
185
+ <TextInput
186
+ style={{ flex:1, ...view_styles.input }}
187
+ value={o_side.odds}
188
+ onChangeText={(text) => setFormData({
189
+ ...form_data,
190
+ o_side: {
191
+ ...o_side,
192
+ odds: text,
193
+ probability: MarketMaketHelpers.calcProbabilityFromOdds(parseInt(text)),
194
+ potential_winnings: MarketMaketHelpers.calcPotentialWinnings(parseInt(text), o_side.potential_winnings)
195
+ }
196
+ })}
197
+ />
198
+ <Text style={{ marginLeft:5, marginRight:5 }} size={14} color={Colors.brand.midnight}>ODDS</Text>
199
+ <TextInput
200
+ style={{ flex:1, ...view_styles.input }}
201
+ value={trade_side.odds}
202
+ onChangeText={(text) => setFormData({
203
+ ...form_data,
204
+ trade_side: {
205
+ ...trade_side,
206
+ odds: text,
207
+ probability: MarketMaketHelpers.calcProbabilityFromOdds(parseInt(text)),
208
+ open_amt: MarketMaketHelpers.calcSaleValue(parseInt(text), trade_side.potential_winnings)
209
+ }
210
+ })}
211
+ />
212
+ </View>
213
+ */
@@ -0,0 +1,25 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import Colors from '../../constants/colors';
4
+
5
+ type WeightProgressProps = {
6
+ min_value:number,
7
+ max_value:number,
8
+ value: number,
9
+ width:number
10
+ }
11
+
12
+ const WeightProgress = ({ width, value }:WeightProgressProps) => {
13
+ let progress_width = value * width / 2
14
+ let start_point = width/2
15
+ if(progress_width < 0){
16
+ start_point += progress_width
17
+ }
18
+ return (
19
+ <View style={{ alignSelf:'center', width: width, height:4, borderRadius:2, backgroundColor:Colors.shades.white }}>
20
+ <View style={{ position:'absolute', left:start_point, width:Math.abs(progress_width), backgroundColor:Colors.brand.midnight, height:4, borderRadius:4 }}/>
21
+ </View>
22
+ )
23
+ }
24
+
25
+ export default WeightProgress