be-components 6.9.2 → 6.9.4
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.
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js +1 -1
- package/lib/commonjs/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/commonjs/Squares/components/BidForm.js +31 -31
- package/lib/commonjs/Squares/components/BidForm.js.map +1 -1
- package/lib/commonjs/Squares/components/OfferForm.js +53 -60
- package/lib/commonjs/Squares/components/OfferForm.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOfferCard.js +134 -121
- package/lib/commonjs/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquareOffersCard.js +32 -6
- package/lib/commonjs/Squares/components/SquareOffersCard.js.map +1 -1
- package/lib/commonjs/Squares/components/SquaresBoard.js +16 -8
- package/lib/commonjs/Squares/components/SquaresBoard.js.map +1 -1
- package/lib/commonjs/Squares/index.js +65 -18
- package/lib/commonjs/Squares/index.js.map +1 -1
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js +1 -1
- package/lib/module/CompetitionManager/components/CompetitionContestsForm.js.map +1 -1
- package/lib/module/Squares/components/BidForm.js +31 -31
- package/lib/module/Squares/components/BidForm.js.map +1 -1
- package/lib/module/Squares/components/OfferForm.js +54 -61
- package/lib/module/Squares/components/OfferForm.js.map +1 -1
- package/lib/module/Squares/components/SquareOfferCard.js +123 -109
- package/lib/module/Squares/components/SquareOfferCard.js.map +1 -1
- package/lib/module/Squares/components/SquareOffersCard.js +32 -6
- package/lib/module/Squares/components/SquareOffersCard.js.map +1 -1
- package/lib/module/Squares/components/SquaresBoard.js +16 -8
- package/lib/module/Squares/components/SquaresBoard.js.map +1 -1
- package/lib/module/Squares/index.js +65 -18
- package/lib/module/Squares/index.js.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts +1 -2
- package/lib/typescript/lib/commonjs/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts +2 -1
- package/lib/typescript/lib/commonjs/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/lib/commonjs/Squares/index.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts +1 -2
- package/lib/typescript/lib/module/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts +5 -3
- package/lib/typescript/lib/module/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts +2 -1
- package/lib/typescript/lib/module/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/lib/module/Squares/index.d.ts.map +1 -1
- package/lib/typescript/src/CompetitionManager/components/CompetitionContestsForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/BidForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/OfferForm.d.ts +1 -1
- package/lib/typescript/src/Squares/components/OfferForm.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts +3 -2
- package/lib/typescript/src/Squares/components/SquareOfferCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts +3 -2
- package/lib/typescript/src/Squares/components/SquareOffersCard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/components/SquaresBoard.d.ts.map +1 -1
- package/lib/typescript/src/Squares/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/CompetitionManager/components/CompetitionContestsForm.tsx +1 -2
- package/src/Squares/components/BidForm.tsx +23 -25
- package/src/Squares/components/OfferForm.tsx +40 -36
- package/src/Squares/components/SquareOfferCard.tsx +75 -45
- package/src/Squares/components/SquareOffersCard.tsx +13 -9
- package/src/Squares/components/SquaresBoard.tsx +14 -8
- package/src/Squares/index.tsx +77 -41
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { FlatList } from 'react-native';
|
|
3
|
-
import { view_styles } from '../../constants/styles';
|
|
4
3
|
import { Checkbox } from '../../Components';
|
|
5
|
-
import Colors from '../../constants/colors';
|
|
6
4
|
import type { PlayerBalanceProps, PlayerSquareProps, SquareProps } from '../../types';
|
|
7
5
|
import BidToggle from './BidToggle';
|
|
8
6
|
import { Button, Text, View } from '../../Components/Themed';
|
|
@@ -27,7 +25,7 @@ type BidFormProps = {
|
|
|
27
25
|
const form_sections = ['header','bids','actions']
|
|
28
26
|
|
|
29
27
|
const BidForm = ({ player_id, player_balance, market_type, home_abbr, away_abbr, submit_ready, square_bids, squares, onSubmitBid, onClearBids, onBidAmountChange, onRequestAuthenticate }:BidFormProps) => {
|
|
30
|
-
const
|
|
28
|
+
const Colors = useColors();
|
|
31
29
|
const [ promo_balance, setPromoBalance ] = useState(false);
|
|
32
30
|
const cl = market_type == 'FOR_MONEY' ? '$' : 'E'
|
|
33
31
|
const total_bid_amount = square_bids.reduce((a,b) => a + b.purchase_price, 0)
|
|
@@ -39,7 +37,7 @@ const BidForm = ({ player_id, player_balance, market_type, home_abbr, away_abbr,
|
|
|
39
37
|
let square = squares.find(s => s.sq_square_id == data.item.sq_square_id)
|
|
40
38
|
if(!square){ return ( <></> ) }
|
|
41
39
|
return (
|
|
42
|
-
<View type='row' transparent style={{ borderBottomWidth:1, borderColor:
|
|
40
|
+
<View type='row' transparent style={{ borderBottomWidth:1, borderColor:Colors.borders.light, padding:5}}>
|
|
43
41
|
<View transparent style={{flex:1}}>
|
|
44
42
|
<Text theme='h2'>SQUARE: {home_abbr}: {square.square_score_x}, {away_abbr}: {square.square_score_y}</Text>
|
|
45
43
|
<Text theme="description">Current Bid: {cl}{square.last_purchase_price.toFixed(2)}</Text>
|
|
@@ -55,13 +53,13 @@ const BidForm = ({ player_id, player_balance, market_type, home_abbr, away_abbr,
|
|
|
55
53
|
switch(data.item){
|
|
56
54
|
case 'header':
|
|
57
55
|
return (
|
|
58
|
-
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10 }}>
|
|
56
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
59
57
|
<View transparent style={{ flex:1 }}>
|
|
60
58
|
<Text theme="h1">SET BID AMOUNTS</Text>
|
|
61
|
-
<Text style={{ marginTop:3 }} color={Colors.
|
|
59
|
+
<Text style={{ marginTop:3 }} color={Colors.text.error} size={12} weight='regular'>All purchases are final and cannot be removed</Text>
|
|
62
60
|
</View>
|
|
63
|
-
<View
|
|
64
|
-
<Text size={12}
|
|
61
|
+
<View float style={{ height:24, width:24, borderRadius:100, justifyContent:'center', alignItems:'center', marginLeft: 5 }}>
|
|
62
|
+
<Text size={12} theme='h1' textAlign='center'>{square_bids.length}</Text>
|
|
65
63
|
</View>
|
|
66
64
|
</View>
|
|
67
65
|
)
|
|
@@ -69,12 +67,12 @@ const BidForm = ({ player_id, player_balance, market_type, home_abbr, away_abbr,
|
|
|
69
67
|
return (
|
|
70
68
|
<View type='body' transparent style={{ padding:20, flexGrow:1 }}>
|
|
71
69
|
<FlatList data={square_bids.sort((a,b) => parseInt(a.sq_square_id) - parseInt(b.sq_square_id))} renderItem={renderBids} keyExtractor={(item) => `b-${item.sq_square_id}`}/>
|
|
72
|
-
<View transparent style={
|
|
70
|
+
<View transparent type='row' style={{ marginTop:5 }}>
|
|
73
71
|
<Text style={{ flex:1 }} theme='description'>Total</Text>
|
|
74
72
|
<Text theme='h2'>{cl}{total_bid_amount.toFixed(2)}</Text>
|
|
75
73
|
</View>
|
|
76
74
|
{player_balance && player_balance.promo_balance > 0 ?
|
|
77
|
-
<Button transparent style={{ flexDirection:'row', alignItems:'center', margin:5, padding:5, backgroundColor:
|
|
75
|
+
<Button transparent style={{ flexDirection:'row', alignItems:'center', margin:5, padding:5, backgroundColor:Colors.text.gold, borderRadius:8 }} onPress={() => setPromoBalance(!promo_balance)}>
|
|
78
76
|
<Checkbox
|
|
79
77
|
checked={promo_balance}
|
|
80
78
|
disabled
|
|
@@ -82,8 +80,8 @@ const BidForm = ({ player_id, player_balance, market_type, home_abbr, away_abbr,
|
|
|
82
80
|
onSelect={() => setPromoBalance(!promo_balance)}
|
|
83
81
|
/>
|
|
84
82
|
<View transparent style={{ flex:1, marginLeft:10 }}>
|
|
85
|
-
<Text size={12} color={
|
|
86
|
-
<Text size={10} color={
|
|
83
|
+
<Text size={12} color={Colors.text.white} weight='bold'>${player_balance.promo_balance.toFixed(2)} Promotion Available</Text>
|
|
84
|
+
<Text size={10} color={Colors.text.white} weight='regular' style={{ marginTop:3 }}>Press / Click here to use promo balance</Text>
|
|
87
85
|
</View>
|
|
88
86
|
</Button>
|
|
89
87
|
:<></>}
|
|
@@ -102,27 +100,27 @@ const BidForm = ({ player_id, player_balance, market_type, home_abbr, away_abbr,
|
|
|
102
100
|
renderItem={renderSections}
|
|
103
101
|
keyExtractor={(item) => item}
|
|
104
102
|
/>
|
|
105
|
-
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10}}>
|
|
103
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
|
|
106
104
|
<Button
|
|
105
|
+
type='error'
|
|
107
106
|
title='CLEAR'
|
|
108
|
-
style={{ flex:1 }}
|
|
109
|
-
type='close'
|
|
110
|
-
onPress={() => onClearBids()}>
|
|
107
|
+
style={{ flex:1 }} onPress={() => onClearBids()}>
|
|
111
108
|
</Button>
|
|
112
109
|
{player_id ?
|
|
113
110
|
<Button
|
|
111
|
+
disabled={!can_submit || submit_ready.is_loading}
|
|
114
112
|
loading={submit_ready.is_loading}
|
|
115
|
-
style={{ flex:
|
|
116
|
-
|
|
113
|
+
style={{ flex:2, opacity:submit_ready.is_loading || !can_submit ? 0.5:1, marginLeft:5, backgroundColor:submit_ready.is_ready?Colors.text.success:Colors.text.action }}
|
|
114
|
+
type='success'
|
|
115
|
+
title={submit_ready.is_ready?'SUBMIT OFFER':'REVIEW OFFER'}
|
|
117
116
|
onPress={() => onSubmitBid(promo_balance)}
|
|
118
|
-
|
|
119
|
-
title={submit_ready.is_ready?'Submit Bids':'Review Bids'}
|
|
120
|
-
>
|
|
121
|
-
|
|
122
|
-
</Button>
|
|
117
|
+
/>
|
|
123
118
|
:
|
|
124
|
-
<Button
|
|
125
|
-
|
|
119
|
+
<Button
|
|
120
|
+
style={{ flex:2, marginLeft:5 }}
|
|
121
|
+
type='success'
|
|
122
|
+
onPress={() => onRequestAuthenticate()}>
|
|
123
|
+
<Text size={14} weight='semibold' textAlign='center' color={Colors.text.white}>Sign Up</Text>
|
|
126
124
|
</Button>
|
|
127
125
|
}
|
|
128
126
|
</View>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { FlatList } from "react-native"
|
|
3
3
|
import type { PlayerBalanceProps, PlayerSquareProps, SquareOfferProps, SquareProps } from "../../types"
|
|
4
4
|
import BidToggle from "./BidToggle"
|
|
5
|
-
import { view_styles } from "../../constants/styles"
|
|
6
|
-
import Colors from "../../constants/colors"
|
|
7
5
|
import { Button, Text, View } from '../../Components/Themed';
|
|
6
|
+
import { useColors } from '../../constants/useColors';
|
|
8
7
|
|
|
9
8
|
type OfferFormProps = {
|
|
10
9
|
player_id?:string,
|
|
@@ -23,7 +22,8 @@ type OfferFormProps = {
|
|
|
23
22
|
squares:SquareProps[]
|
|
24
23
|
}
|
|
25
24
|
|
|
26
|
-
const OfferForm = ({ player_id, player_balance, market_type,
|
|
25
|
+
const OfferForm = ({ player_id, player_balance, market_type, squares, submit_ready, home_abbr, away_abbr, player_squares, draft_square_offers, onRequestAuthenticate, onOfferAmountChange, onClearOffers, onSubmitOffer }:OfferFormProps) => {
|
|
26
|
+
const Colors = useColors();
|
|
27
27
|
const cl = market_type == 'FOR_MONEY' ? '$' : 'E'
|
|
28
28
|
const total_offer_amount = draft_square_offers.reduce((a,b) => a + b.amount, 0)
|
|
29
29
|
|
|
@@ -36,12 +36,12 @@ const OfferForm = ({ player_id, player_balance, market_type, width, squares, sub
|
|
|
36
36
|
let square = squares.find(s => s.sq_square_id == ps?.sq_square_id)
|
|
37
37
|
if(!square){ return ( <></> ) }
|
|
38
38
|
return (
|
|
39
|
-
<View style={{flex:1, flexDirection:'row', alignItems:'center', marginBottom:8}}>
|
|
40
|
-
<View style={{flex:1}}>
|
|
39
|
+
<View transparent style={{flex:1, flexDirection:'row', alignItems:'center', marginBottom:8}}>
|
|
40
|
+
<View transparent style={{flex:1}}>
|
|
41
41
|
<Text theme='description'>SQUARE: {home_abbr}: {square.square_score_x}, {away_abbr}: {square.square_score_y}</Text>
|
|
42
42
|
<Text theme='description'>Purchased Price: {cl}{ps.purchase_price.toFixed(2)}</Text>
|
|
43
43
|
</View>
|
|
44
|
-
<View>
|
|
44
|
+
<View transparent>
|
|
45
45
|
<BidToggle sq_square_id={square.sq_square_id} amount={data.item.amount} cl={cl} onAmountChange={(dir) => onOfferAmountChange(data.item, ps, dir)}/>
|
|
46
46
|
</View>
|
|
47
47
|
</View>
|
|
@@ -51,9 +51,9 @@ const OfferForm = ({ player_id, player_balance, market_type, width, squares, sub
|
|
|
51
51
|
if(!draft_square_offers[0]){ return <></> }
|
|
52
52
|
|
|
53
53
|
return (
|
|
54
|
-
<View
|
|
55
|
-
<View style={
|
|
56
|
-
<View style={{ flex:1 }}>
|
|
54
|
+
<View float>
|
|
55
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius:8, borderTopLeftRadius:8 }}>
|
|
56
|
+
<View transparent style={{ flex:1 }}>
|
|
57
57
|
<Text theme="h1">SET YOUR {draft_square_offers[0].buy_sell_ind==='buy'?'OFFER AMOUNTS':'SELL PRICE'}</Text>
|
|
58
58
|
{draft_square_offers[0].buy_sell_ind === 'buy' ?
|
|
59
59
|
<Text style={{ marginTop:3 }} theme="description">How much are you willing to offer the current square owner</Text>
|
|
@@ -61,38 +61,42 @@ const OfferForm = ({ player_id, player_balance, market_type, width, squares, sub
|
|
|
61
61
|
<Text style={{ marginTop:3 }} theme="description">How much are you willing to sell the selected square for?</Text>
|
|
62
62
|
}
|
|
63
63
|
</View>
|
|
64
|
-
<View style={{ height:24, width:24, borderRadius:100,
|
|
65
|
-
<Text size={12} color={Colors.
|
|
64
|
+
<View float style={{ height:24, width:24, borderRadius:100, justifyContent:'center', alignItems:'center', marginLeft: 5 }}>
|
|
65
|
+
<Text size={12} color={Colors.text.h1} textAlign='center'>{draft_square_offers.length}</Text>
|
|
66
66
|
</View>
|
|
67
67
|
</View>
|
|
68
68
|
|
|
69
|
-
<View style={{
|
|
69
|
+
<View transparent type='body' style={{ padding:10 }}>
|
|
70
70
|
<FlatList data={draft_square_offers.sort((a,b) => parseInt(a.sq_player_square_id) - parseInt(b.sq_player_square_id))} renderItem={renderDraftOffers} keyExtractor={(item) => `o-${item.sq_player_square_id}`}/>
|
|
71
|
-
<View style={
|
|
72
|
-
<Text style={{ flex:1 }} theme='
|
|
73
|
-
<Text theme='
|
|
74
|
-
</View>
|
|
75
|
-
<View style={{ ...view_styles.body_row }}>
|
|
76
|
-
<Button style={{ flex:1/3, padding:12, borderRadius:4, borderWidth:1, borderColor:Colors.brand.cobalt, justifyContent:'center', alignItems:'center', marginRight:4 }} onPress={() => onClearOffers()}>
|
|
77
|
-
<Text size={14} weight='semibold' textAlign='center' color={Colors.brand.cobalt}>Clear</Text>
|
|
78
|
-
</Button>
|
|
79
|
-
{player_id ?
|
|
80
|
-
<Button
|
|
81
|
-
disabled={!can_submit}
|
|
82
|
-
style={{ flex:2/3, padding:12, borderRadius:4, backgroundColor:submit_ready.is_ready?Colors.highlights.highlight400:Colors.highlights.highlight200, justifyContent:'center', alignItems:'center', marginLeft:4, opacity:submit_ready.is_loading || !can_submit ? 0.5:1 }} onPress={() => onSubmitOffer()}>
|
|
83
|
-
{submit_ready.is_loading ?
|
|
84
|
-
<ActivityIndicator size='small' color={Colors.shades.white}/>
|
|
85
|
-
:
|
|
86
|
-
<Text size={14} weight='semibold' textAlign='center' color={Colors.shades.white}>{submit_ready.is_ready?'Submit Offers':'Review Offers'}</Text>
|
|
87
|
-
}
|
|
88
|
-
</Button>
|
|
89
|
-
:
|
|
90
|
-
<Button style={{ flex:2/3, padding:12, borderRadius:4, backgroundColor:Colors.highlights.highlight400, justifyContent:'center', alignItems:'center', marginLeft:4 }} onPress={() => onRequestAuthenticate()}>
|
|
91
|
-
<Text size={14} weight='semibold' textAlign='center' color={Colors.shades.white}>Sign Up</Text>
|
|
92
|
-
</Button>
|
|
93
|
-
}
|
|
71
|
+
<View transparent type='row' style={{ marginTop:5 }}>
|
|
72
|
+
<Text style={{ flex:1 }} theme='h2'>Total</Text>
|
|
73
|
+
<Text theme='h1'>{cl}{total_offer_amount.toFixed(2)}</Text>
|
|
94
74
|
</View>
|
|
95
75
|
</View>
|
|
76
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', padding:10, borderBottomRightRadius:8, borderBottomLeftRadius:8 }}>
|
|
77
|
+
<Button
|
|
78
|
+
type='error'
|
|
79
|
+
title='CLEAR'
|
|
80
|
+
style={{ flex:1 }} onPress={() => onClearOffers()}>
|
|
81
|
+
</Button>
|
|
82
|
+
{player_id ?
|
|
83
|
+
<Button
|
|
84
|
+
disabled={!can_submit || submit_ready.is_loading}
|
|
85
|
+
loading={submit_ready.is_loading}
|
|
86
|
+
style={{ flex:2, opacity:submit_ready.is_loading || !can_submit ? 0.5:1, marginLeft:5, backgroundColor:submit_ready.is_ready?Colors.text.success:Colors.text.action }}
|
|
87
|
+
type='success'
|
|
88
|
+
title={submit_ready.is_ready?'SUBMIT OFFER':'REVIEW OFFER'}
|
|
89
|
+
onPress={() => onSubmitOffer()}
|
|
90
|
+
/>
|
|
91
|
+
:
|
|
92
|
+
<Button
|
|
93
|
+
style={{ flex:2, marginLeft:5 }}
|
|
94
|
+
type='success'
|
|
95
|
+
onPress={() => onRequestAuthenticate()}>
|
|
96
|
+
<Text size={14} weight='semibold' textAlign='center' color={Colors.text.white}>Sign Up</Text>
|
|
97
|
+
</Button>
|
|
98
|
+
}
|
|
99
|
+
</View>
|
|
96
100
|
</View>
|
|
97
101
|
)
|
|
98
102
|
}
|
|
@@ -1,22 +1,25 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
import { Text } from '../../Components';
|
|
4
|
-
import Colors from '../../constants/colors';
|
|
5
|
-
import type { PlayerSquareProps, SquareOfferProps, SquareProps } from '../../types';
|
|
2
|
+
import type { PlayerSquareProps, PublicPlayerProps, SquareOfferProps, SquareProps } from '../../types';
|
|
6
3
|
import { SquaresApi } from '../api';
|
|
7
|
-
import {
|
|
4
|
+
import { Button, Text, View } from '../../Components/Themed';
|
|
5
|
+
import { useColors } from '../../constants/useColors';
|
|
6
|
+
import { showConfirmAlert } from '../../Components/ConfirmAlert';
|
|
7
|
+
import { Image } from 'react-native';
|
|
8
8
|
|
|
9
9
|
type SquareOfferCardProps = {
|
|
10
10
|
player_id?:string,
|
|
11
11
|
square:SquareProps,
|
|
12
|
+
offer_owner?:PublicPlayerProps,
|
|
12
13
|
player_square:PlayerSquareProps,
|
|
13
14
|
square_offer:SquareOfferProps,
|
|
14
15
|
home_abbr?:string,
|
|
15
16
|
away_abbr?:string,
|
|
16
17
|
onRequestAuthenticate: () => void
|
|
17
18
|
}
|
|
18
|
-
const SquareOfferCard = ({ player_id, square, player_square, square_offer, away_abbr, home_abbr, onRequestAuthenticate }: SquareOfferCardProps ) => {
|
|
19
|
-
const
|
|
19
|
+
const SquareOfferCard = ({ player_id, offer_owner, square, player_square, square_offer, away_abbr, home_abbr, onRequestAuthenticate }: SquareOfferCardProps ) => {
|
|
20
|
+
const Colors = useColors();
|
|
21
|
+
const [ loading, setLoading ] = useState(false);
|
|
22
|
+
const [ hidden, setHidden ] = useState(false);
|
|
20
23
|
const handleResponse = async(response:string) => {
|
|
21
24
|
if(loading){ return } //No mashymashy
|
|
22
25
|
if(!player_id){ onRequestAuthenticate() }
|
|
@@ -26,6 +29,7 @@ const SquareOfferCard = ({ player_id, square, player_square, square_offer, away_
|
|
|
26
29
|
await SquaresApi.offserSquare({ ...square_offer, status: 'accepted' })
|
|
27
30
|
break
|
|
28
31
|
case 'rejected':
|
|
32
|
+
if(square_offer.buy_sell_ind == 'sell'){ return setHidden(true) }
|
|
29
33
|
await SquaresApi.offserSquare({ ...square_offer, status: 'rejected' })
|
|
30
34
|
break
|
|
31
35
|
case 'withdrawn':
|
|
@@ -35,56 +39,82 @@ const SquareOfferCard = ({ player_id, square, player_square, square_offer, away_
|
|
|
35
39
|
}
|
|
36
40
|
setLoading(false)
|
|
37
41
|
}
|
|
42
|
+
|
|
43
|
+
const handleConfirmResponse = (response:string) => {
|
|
44
|
+
showConfirmAlert('Are you sure?', 'Your response is final and cannot be modified',
|
|
45
|
+
() => handleResponse(response),
|
|
46
|
+
() => console.log('')
|
|
47
|
+
)
|
|
48
|
+
}
|
|
38
49
|
|
|
50
|
+
if(hidden){ return <></> }
|
|
39
51
|
|
|
40
52
|
const cl = square_offer.market_type === 'FOR_MONEY' ? '$' : 'E'
|
|
41
53
|
const mine = square_offer.offerer_id == player_id ? true : false
|
|
42
54
|
return (
|
|
43
|
-
<View style={{
|
|
44
|
-
<View style={{
|
|
45
|
-
|
|
55
|
+
<View float style={{ minWidth:250, maxWidth:275, flexGrow:1 }}>
|
|
56
|
+
<View type='header' style={{ flexDirection:'row', alignItems:'center', padding:10, borderTopRightRadius: 8, borderTopLeftRadius:8}}>
|
|
57
|
+
{offer_owner ?
|
|
58
|
+
<View float style={{ padding:2, marginRight:5, borderRadius:100 }}>
|
|
59
|
+
<Image
|
|
60
|
+
source={{ uri:offer_owner.profile_pic }}
|
|
61
|
+
style={{ height:35, width:35, borderRadius:100 }}
|
|
62
|
+
resizeMode='cover'
|
|
63
|
+
/>
|
|
64
|
+
</View>
|
|
65
|
+
:<></>}
|
|
66
|
+
<View transparent style={{ flex:1 }}>
|
|
67
|
+
<Text theme='h1'>Squares{square_offer.buy_sell_ind === 'sell'?' Sale':' Buy'} Offer</Text>
|
|
68
|
+
{square_offer.buy_sell_ind == 'sell' && mine ?
|
|
69
|
+
<Text theme='description'>This is your sell offer. Other players can buy this square for the price noted below</Text>
|
|
70
|
+
: square_offer.buy_sell_ind == 'sell' && !mine ?
|
|
71
|
+
<Text theme='description'>This is a sale offer from another user. You can buy their square for the stated price right now</Text>
|
|
72
|
+
:square_offer.buy_sell_ind == 'buy' && !mine ?
|
|
73
|
+
<Text theme='description'>This is an offer from another user to purchase your square. Sell or reject the offer below</Text>
|
|
74
|
+
:
|
|
75
|
+
<Text theme='description'>This is your buy offer. The owner can accept or reject your offer</Text>
|
|
76
|
+
}
|
|
77
|
+
</View>
|
|
46
78
|
</View>
|
|
47
|
-
<View style={
|
|
48
|
-
<View style={
|
|
49
|
-
<Text style={{ flex:1 }} theme='
|
|
50
|
-
<Text theme='
|
|
79
|
+
<View transparent type='body' style={{ padding:5, flexGrow:1 }}>
|
|
80
|
+
<View transparent type='row' style={{ padding:5, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
81
|
+
<Text style={{ flex:1 }} theme='description'>Square</Text>
|
|
82
|
+
<Text theme='h2'>{home_abbr??''}: {square.square_score_x}, {away_abbr??''}: {square.square_score_y}</Text>
|
|
51
83
|
</View>
|
|
52
|
-
<View style={
|
|
53
|
-
<Text style={{ flex:1 }} theme='
|
|
54
|
-
<Text theme='
|
|
84
|
+
<View transparent type='row' style={{ padding:5, borderBottomWidth:1, borderColor:Colors.borders.light }}>
|
|
85
|
+
<Text style={{ flex:1 }} theme='description'>Purchased For</Text>
|
|
86
|
+
<Text theme='h2'>{cl}{player_square.purchase_price.toFixed(2)}</Text>
|
|
55
87
|
</View>
|
|
56
|
-
<View style={
|
|
57
|
-
<Text style={{ flex:1 }} theme='
|
|
58
|
-
<Text theme='
|
|
88
|
+
<View transparent type='row' style={{ padding:5 }}>
|
|
89
|
+
<Text style={{ flex:1 }} theme='description'>Offer Amount</Text>
|
|
90
|
+
<Text theme='h1' color={Colors.text.success}>{cl}{square_offer.amount.toFixed(2)}</Text>
|
|
59
91
|
</View>
|
|
60
92
|
</View>
|
|
61
|
-
<View style={{
|
|
62
|
-
|
|
63
|
-
<View
|
|
64
|
-
<
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
<Text size={12} weight='semibold' textAlign='center' color={Colors.shades.white}>Withdraw</Text>
|
|
71
|
-
</TouchableOpacity>
|
|
72
|
-
</View>
|
|
93
|
+
<View type='footer' style={{ flexDirection:'row', alignItems:'center', borderBottomRightRadius:8, borderBottomLeftRadius:8, padding:10 }}>
|
|
94
|
+
{mine ?
|
|
95
|
+
<View type='row' transparent style={{ flex:1 }}>
|
|
96
|
+
<Button
|
|
97
|
+
type='error'
|
|
98
|
+
loading={loading}
|
|
99
|
+
title='WITHDRAW'
|
|
100
|
+
style={{flex:1, padding:12, opacity: loading?0.5:1 }} onPress={() => handleConfirmResponse('withdrawn')}
|
|
101
|
+
/>
|
|
73
102
|
</View>
|
|
74
103
|
:
|
|
75
|
-
<View
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
104
|
+
<View type='row' transparent style={{ flex:1 }}>
|
|
105
|
+
<Button
|
|
106
|
+
style={{flex:1, padding:12, opacity: loading?0.5:1 }}
|
|
107
|
+
type='error'
|
|
108
|
+
loading={loading}
|
|
109
|
+
title='DECLINE'
|
|
110
|
+
onPress={() => handleConfirmResponse('rejected')}
|
|
111
|
+
/>
|
|
112
|
+
<Button
|
|
113
|
+
type='success'
|
|
114
|
+
loading={loading}
|
|
115
|
+
title='ACCEPT'
|
|
116
|
+
style={{flex:1, padding:12, marginLeft:5, opacity: loading?0.5:1 }} onPress={() => handleConfirmResponse('accepted')}
|
|
117
|
+
/>
|
|
88
118
|
</View>
|
|
89
119
|
}
|
|
90
120
|
</View>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import { FlatList } from 'react-native';
|
|
3
|
-
import type { PlayerSquareProps, SquareOfferProps, SquareProps } from "../../types"
|
|
4
|
-
import { view_styles } from '../../constants/styles';
|
|
3
|
+
import type { PlayerSquareProps, PublicPlayerProps, SquareOfferProps, SquareProps } from "../../types"
|
|
5
4
|
import { Icons } from '../../Components';
|
|
6
5
|
import SquareOfferCard from './SquareOfferCard';
|
|
7
6
|
import { Button, Text, View } from '../../Components/Themed';
|
|
@@ -9,6 +8,7 @@ import { useColors } from '../../constants/useColors';
|
|
|
9
8
|
|
|
10
9
|
type SquareOffersCardProps = {
|
|
11
10
|
player_id?:string,
|
|
11
|
+
players:PublicPlayerProps[],
|
|
12
12
|
squares:SquareProps[],
|
|
13
13
|
player_squares:PlayerSquareProps[],
|
|
14
14
|
home_abbr?:string,
|
|
@@ -16,7 +16,7 @@ type SquareOffersCardProps = {
|
|
|
16
16
|
square_offers:SquareOfferProps[],
|
|
17
17
|
onRequestAuthenticate:() => void
|
|
18
18
|
}
|
|
19
|
-
const SquareOffersCard = ({ square_offers, squares, player_squares, player_id, away_abbr, home_abbr, onRequestAuthenticate }:SquareOffersCardProps) => {
|
|
19
|
+
const SquareOffersCard = ({ square_offers, players, squares, player_squares, player_id, away_abbr, home_abbr, onRequestAuthenticate }:SquareOffersCardProps) => {
|
|
20
20
|
const C = useColors();
|
|
21
21
|
const [ expanded, setExpanded ] = useState(true);
|
|
22
22
|
|
|
@@ -25,11 +25,13 @@ const SquareOffersCard = ({ square_offers, squares, player_squares, player_id, a
|
|
|
25
25
|
if(!player_square){ return <></> }
|
|
26
26
|
const square = squares.find(s => s.sq_square_id == player_square.sq_square_id);
|
|
27
27
|
if(!square){ return <></> }
|
|
28
|
+
const offer_from = players.find(p => p.player_id == data.item.offerer_id);
|
|
28
29
|
return (
|
|
29
|
-
<View>
|
|
30
|
+
<View transparent style={{ margin:5 }}>
|
|
30
31
|
<SquareOfferCard
|
|
31
32
|
square_offer={data.item}
|
|
32
33
|
square={square}
|
|
34
|
+
offer_owner={offer_from}
|
|
33
35
|
home_abbr={home_abbr}
|
|
34
36
|
away_abbr={away_abbr}
|
|
35
37
|
player_square={player_square}
|
|
@@ -39,18 +41,20 @@ const SquareOffersCard = ({ square_offers, squares, player_squares, player_id, a
|
|
|
39
41
|
</View>
|
|
40
42
|
)
|
|
41
43
|
}
|
|
42
|
-
|
|
43
44
|
return (
|
|
44
|
-
<View
|
|
45
|
-
<Button transparent style={{ flexDirection:'row', alignItems:'center' }} onPress={() => setExpanded(!expanded)}>
|
|
45
|
+
<View style={{ minWidth:350 }}>
|
|
46
|
+
<Button transparent style={{ borderRadius:0, flexDirection:'row', alignItems:'center', backgroundColor:C.views.header }} onPress={() => setExpanded(!expanded)}>
|
|
47
|
+
<View float style={{ marginRight:10, height:26, width:26, borderRadius:100, justifyContent:'center', alignItems:'center', backgroundColor:C.text.success }}>
|
|
48
|
+
<Text theme='h1' color={C.text.white}>{square_offers.length}</Text>
|
|
49
|
+
</View>
|
|
46
50
|
<View transparent style={{flex:1, marginRight:10}}>
|
|
47
51
|
<Text theme='h1'>SQUARE OFFERS</Text>
|
|
48
|
-
<Text style={{ marginTop:3 }} theme='description'>These are offers from other users to buy or sell squares during the game</Text>
|
|
52
|
+
<Text style={{ marginTop:3 }} theme='description'>These are offers from you or other users to buy or sell squares during the game</Text>
|
|
49
53
|
</View>
|
|
50
54
|
<Icons.ChevronIcon direction={expanded?'up':'down'} size={8} color={C.text.h1} />
|
|
51
55
|
</Button>
|
|
52
56
|
{expanded ?
|
|
53
|
-
<View style={
|
|
57
|
+
<View transparent type='body' style={{ padding:10 }}>
|
|
54
58
|
<FlatList
|
|
55
59
|
data={square_offers}
|
|
56
60
|
renderItem={renderOffers}
|
|
@@ -33,14 +33,17 @@ const SquaresBoard = ({
|
|
|
33
33
|
}:SquaresBoardProps) => {
|
|
34
34
|
const C = useColors();
|
|
35
35
|
const [ expanded, setExpanded ] = useState(true);
|
|
36
|
+
const [ transform_ready, setTransformReady ] = useState(false);
|
|
36
37
|
const [ times_up, setTimesUp ] = useState(false);
|
|
37
38
|
const [ refresh_allowed, setRefreshAllowed ] = useState(false);
|
|
38
39
|
const [ square_bid, setSquareBid ] = useState<{square?:SquareProps, action?:'remove'|'add'}>({});
|
|
39
40
|
|
|
40
41
|
useEffect(() => {
|
|
42
|
+
if(!transform_ready){ setTransformReady(true) }
|
|
41
43
|
if(!square_bid.square || !square_bid.action){ return }
|
|
42
44
|
handleSquareSelect(square_bid.square, square_bid.action)
|
|
43
|
-
},[square_bid.action, square_bid.square])
|
|
45
|
+
},[square_bid.action, square_bid.square]);
|
|
46
|
+
|
|
44
47
|
|
|
45
48
|
const comp_status = SqauresHelpers.getCompStatus(event, squares_competition);
|
|
46
49
|
const unique_score_y = [ ...new Set(squares.map(s => s.square_score_y)) ].sort((a,b) => a - b)
|
|
@@ -179,18 +182,21 @@ const SquaresBoard = ({
|
|
|
179
182
|
</View>
|
|
180
183
|
:<></>}
|
|
181
184
|
{event && event.away ?
|
|
182
|
-
<View transparent style={{ position:'absolute', top:0, left:4, bottom:0, justifyContent:'center' }}>
|
|
185
|
+
<View key={transform_ready?'rotate':'nope'} transparent style={{ position:'absolute', top:0, left:4, bottom:0, justifyContent:'center' }}>
|
|
183
186
|
<View transparent style={{ width: TEXT_HEIGHT, height: TEXT_LENGTH }}>
|
|
184
|
-
<Text
|
|
187
|
+
<Text
|
|
185
188
|
textAlign="center"
|
|
186
|
-
|
|
189
|
+
style={{
|
|
190
|
+
...(transform_ready && {
|
|
187
191
|
transform: [
|
|
188
|
-
{ rotate: "-90deg" },
|
|
189
|
-
{ translateX: -OFFSET },
|
|
190
|
-
{ translateY: -OFFSET }
|
|
192
|
+
{ rotate: "-90deg" },
|
|
193
|
+
{ translateX: -OFFSET },
|
|
194
|
+
{ translateY: -OFFSET },
|
|
191
195
|
],
|
|
196
|
+
}),
|
|
192
197
|
width: TEXT_LENGTH,
|
|
193
|
-
height: TEXT_HEIGHT
|
|
198
|
+
height: TEXT_HEIGHT,
|
|
199
|
+
textAlign: "center",
|
|
194
200
|
}}
|
|
195
201
|
theme="h2"
|
|
196
202
|
>
|