be-components 2.1.3 → 2.1.5
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/Components/Icons.js +173 -0
- package/lib/commonjs/Components/Icons.js.map +1 -1
- package/lib/commonjs/MarketComponents/components/TeamEventMarket/api/index.js +1 -1
- package/lib/commonjs/MarketComponents/components/TeamEventMarket/api/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/PlayerCard.js +7 -6
- package/lib/commonjs/SocialComponents/PlayerCard.js.map +1 -1
- package/lib/commonjs/SocialComponents/PlayerList.js +1 -0
- package/lib/commonjs/SocialComponents/PlayerList.js.map +1 -1
- package/lib/commonjs/SocialComponents/PlayerProfile/api/index.js +149 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/api/index.js.map +1 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/components/PlayerFollowersList.js +138 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/components/PlayerFollowersList.js.map +1 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/components/PostsList.js +102 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/components/PostsList.js.map +1 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/index.js +565 -0
- package/lib/commonjs/SocialComponents/PlayerProfile/index.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/DraftTextEntities.js +36 -0
- package/lib/commonjs/SocialComponents/PostCard/components/DraftTextEntities.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/DraftTextViewer.js +59 -0
- package/lib/commonjs/SocialComponents/PostCard/components/DraftTextViewer.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/EntityHelpers.js +52 -0
- package/lib/commonjs/SocialComponents/PostCard/components/EntityHelpers.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js +51 -0
- package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/PostHeader.js +48 -0
- package/lib/commonjs/SocialComponents/PostCard/components/PostHeader.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.js +139 -0
- package/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.js.map +1 -0
- package/lib/commonjs/SocialComponents/PostCard/index.js +236 -0
- package/lib/commonjs/SocialComponents/PostCard/index.js.map +1 -0
- package/lib/commonjs/SocialComponents/SocialOrderCard.js +225 -0
- package/lib/commonjs/SocialComponents/SocialOrderCard.js.map +1 -0
- package/lib/commonjs/SocialComponents/SocialOrdersList.js +104 -0
- package/lib/commonjs/SocialComponents/SocialOrdersList.js.map +1 -0
- package/lib/commonjs/SocialComponents/api/index.js +292 -1
- package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
- package/lib/commonjs/SocialComponents/index.js +7 -0
- package/lib/commonjs/SocialComponents/index.js.map +1 -1
- package/lib/module/Components/Icons.js +173 -0
- package/lib/module/Components/Icons.js.map +1 -1
- package/lib/module/MarketComponents/components/TeamEventMarket/api/index.js +1 -1
- package/lib/module/MarketComponents/components/TeamEventMarket/api/index.js.map +1 -1
- package/lib/module/SocialComponents/PlayerCard.js +7 -6
- package/lib/module/SocialComponents/PlayerCard.js.map +1 -1
- package/lib/module/SocialComponents/PlayerList.js +1 -0
- package/lib/module/SocialComponents/PlayerList.js.map +1 -1
- package/lib/module/SocialComponents/PlayerProfile/api/index.js +143 -0
- package/lib/module/SocialComponents/PlayerProfile/api/index.js.map +1 -0
- package/lib/module/SocialComponents/PlayerProfile/components/PlayerFollowersList.js +129 -0
- package/lib/module/SocialComponents/PlayerProfile/components/PlayerFollowersList.js.map +1 -0
- package/lib/module/SocialComponents/PlayerProfile/components/PostsList.js +94 -0
- package/lib/module/SocialComponents/PlayerProfile/components/PostsList.js.map +1 -0
- package/lib/module/SocialComponents/PlayerProfile/index.js +557 -0
- package/lib/module/SocialComponents/PlayerProfile/index.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/DraftTextEntities.js +27 -0
- package/lib/module/SocialComponents/PostCard/components/DraftTextEntities.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/DraftTextViewer.js +51 -0
- package/lib/module/SocialComponents/PostCard/components/DraftTextViewer.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/EntityHelpers.js +41 -0
- package/lib/module/SocialComponents/PostCard/components/EntityHelpers.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/ImageList.js +44 -0
- package/lib/module/SocialComponents/PostCard/components/ImageList.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/PostHeader.js +41 -0
- package/lib/module/SocialComponents/PostCard/components/PostHeader.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/components/PostReactionBar.js +130 -0
- package/lib/module/SocialComponents/PostCard/components/PostReactionBar.js.map +1 -0
- package/lib/module/SocialComponents/PostCard/index.js +227 -0
- package/lib/module/SocialComponents/PostCard/index.js.map +1 -0
- package/lib/module/SocialComponents/SocialOrderCard.js +216 -0
- package/lib/module/SocialComponents/SocialOrderCard.js.map +1 -0
- package/lib/module/SocialComponents/SocialOrdersList.js +95 -0
- package/lib/module/SocialComponents/SocialOrdersList.js.map +1 -0
- package/lib/module/SocialComponents/api/index.js +292 -1
- package/lib/module/SocialComponents/api/index.js.map +1 -1
- package/lib/module/SocialComponents/index.js +2 -1
- package/lib/module/SocialComponents/index.js.map +1 -1
- package/lib/typescript/src/Components/Icons.d.ts +6 -0
- package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/PlayerCard.d.ts +2 -1
- package/lib/typescript/src/SocialComponents/PlayerCard.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/PlayerList.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/PlayerProfile/api/index.d.ts +19 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/api/index.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/components/PlayerFollowersList.d.ts +13 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/components/PlayerFollowersList.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/components/PostsList.d.ts +13 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/components/PostsList.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/index.d.ts +19 -0
- package/lib/typescript/src/SocialComponents/PlayerProfile/index.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/DraftTextEntities.d.ts +4 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/DraftTextEntities.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/DraftTextViewer.d.ts +12 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/DraftTextViewer.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/EntityHelpers.d.ts +12 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/EntityHelpers.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts +9 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/PostHeader.d.ts +9 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/PostHeader.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/PostReactionBar.d.ts +13 -0
- package/lib/typescript/src/SocialComponents/PostCard/components/PostReactionBar.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/PostCard/index.d.ts +15 -0
- package/lib/typescript/src/SocialComponents/PostCard/index.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts +17 -0
- package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts +13 -0
- package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts.map +1 -0
- package/lib/typescript/src/SocialComponents/api/index.d.ts +34 -2
- package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
- package/lib/typescript/src/SocialComponents/index.d.ts +2 -1
- package/lib/typescript/src/SocialComponents/index.d.ts.map +1 -1
- package/package.json +5 -1
- package/src/Components/Icons.tsx +93 -0
- package/src/MarketComponents/components/TeamEventMarket/api/index.ts +1 -1
- package/src/SocialComponents/PlayerCard.tsx +6 -5
- package/src/SocialComponents/PlayerList.tsx +2 -1
- package/src/SocialComponents/PlayerProfile/api/index.ts +138 -0
- package/src/SocialComponents/PlayerProfile/components/PlayerFollowersList.tsx +111 -0
- package/src/SocialComponents/PlayerProfile/components/PostsList.tsx +100 -0
- package/src/SocialComponents/PlayerProfile/index.tsx +412 -0
- package/src/SocialComponents/PostCard/components/DraftTextEntities.tsx +25 -0
- package/src/SocialComponents/PostCard/components/DraftTextViewer.tsx +61 -0
- package/src/SocialComponents/PostCard/components/EntityHelpers.tsx +44 -0
- package/src/SocialComponents/PostCard/components/ImageList.tsx +46 -0
- package/src/SocialComponents/PostCard/components/PostHeader.tsx +29 -0
- package/src/SocialComponents/PostCard/components/PostReactionBar.tsx +93 -0
- package/src/SocialComponents/PostCard/index.tsx +176 -0
- package/src/SocialComponents/SocialOrderCard.tsx +146 -0
- package/src/SocialComponents/SocialOrdersList.tsx +101 -0
- package/src/SocialComponents/api/index.ts +170 -3
- package/src/SocialComponents/index.tsx +3 -2
- package/src/types.d.ts +245 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { FlatList, View, TouchableOpacity, ActivityIndicator } from "react-native"
|
|
3
|
+
import type { PostReactionProps, PostReactionStatsProps } from '../../../types';
|
|
4
|
+
import { Button, Text } from '../../../Components';
|
|
5
|
+
import Colors from '../../../constants/colors';
|
|
6
|
+
import { view_styles } from '../../../constants/styles';
|
|
7
|
+
|
|
8
|
+
type PostReactionBarProps = {
|
|
9
|
+
post_id:string,
|
|
10
|
+
post_reaction_stats: PostReactionStatsProps[],
|
|
11
|
+
my_post_reactions: PostReactionProps[],
|
|
12
|
+
featured?:boolean,
|
|
13
|
+
loading?:boolean,
|
|
14
|
+
onReactionSelect: (post_reaction:PostReactionProps) => void
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const available_reactions = [
|
|
18
|
+
{ reaction: 'like', label: '❤️' },
|
|
19
|
+
{ reaction: 'celebrate', label: '🎉' },
|
|
20
|
+
{ reaction: 'fire', label: '🔥' },
|
|
21
|
+
{ reaction: 'clap', label: '👏' },
|
|
22
|
+
{ reaction: 'trophy', label: '🏆' },
|
|
23
|
+
{ reaction: 'strong', label: '💪' },
|
|
24
|
+
{ reaction: 'money', label: '💰' },
|
|
25
|
+
{ reaction: 'eyes', label: '👀' },
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
const PostReactionBar = ({ post_id, loading, post_reaction_stats, my_post_reactions, onReactionSelect }:PostReactionBarProps) => {
|
|
29
|
+
const [ more_selected, setMoreSelected ] = useState(false);
|
|
30
|
+
|
|
31
|
+
const handleReaction = async(reaction:string) => {
|
|
32
|
+
if(!onReactionSelect){ return }
|
|
33
|
+
let existing_reaction = my_post_reactions.find(pr => pr.reaction == reaction)
|
|
34
|
+
onReactionSelect({
|
|
35
|
+
post_reaction_id:existing_reaction?.post_reaction_id ?? '',
|
|
36
|
+
post_type:'memo',
|
|
37
|
+
activity_post_id:post_id,
|
|
38
|
+
reaction,
|
|
39
|
+
status: existing_reaction ? 'hidden' : 'visible',
|
|
40
|
+
player_id: '',
|
|
41
|
+
create_datetime: '',
|
|
42
|
+
last_update_datetime:''
|
|
43
|
+
})
|
|
44
|
+
setMoreSelected(false)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
const renderAvailableReactions = (data: {item:any, index:number}) => {
|
|
48
|
+
const reacted = post_reaction_stats.length > 0 && !more_selected
|
|
49
|
+
const reaction_stat = post_reaction_stats.find(p => p.reaction === data.item.reaction)
|
|
50
|
+
const my_reaction = my_post_reactions.find(pr => pr.reaction === data.item.reaction)
|
|
51
|
+
const selected = my_reaction?.status === 'visible' ? true : false
|
|
52
|
+
return (
|
|
53
|
+
<TouchableOpacity style={
|
|
54
|
+
reacted ?
|
|
55
|
+
{ ...view_styles.float, marginBottom:5, marginLeft:data.index===0?0:-5, paddingRight:10, paddingLeft:5, flexDirection:'row', alignItems:'center', padding:2, borderRadius:100, backgroundColor:selected?Colors.highlights.highlight200:Colors.shades.white }
|
|
56
|
+
:
|
|
57
|
+
{}} onPress={() => handleReaction(data.item.reaction)}>
|
|
58
|
+
|
|
59
|
+
<Text style={{fontSize:12, padding:6}}>{data.item.label}</Text>
|
|
60
|
+
{reaction_stat && !more_selected && post_reaction_stats.length < 5 ?
|
|
61
|
+
<Text size={12} color={selected ? Colors.shades.white : Colors.brand.midnight} weight='regular' style={{ padding:3 }}>{reaction_stat.reaction_count}</Text>
|
|
62
|
+
:<></>}
|
|
63
|
+
</TouchableOpacity>
|
|
64
|
+
)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
let visible_reactions = available_reactions
|
|
68
|
+
if(post_reaction_stats.length > 0 && !more_selected){
|
|
69
|
+
visible_reactions = visible_reactions.filter(r => post_reaction_stats.find(pr => pr.reaction === r.reaction && pr.reaction_count > 0))
|
|
70
|
+
}
|
|
71
|
+
return (
|
|
72
|
+
<View style={{ flexDirection:'row', alignItems:'center' }}>
|
|
73
|
+
<FlatList key='reactions' data={visible_reactions} renderItem={renderAvailableReactions} keyExtractor={(item) => item.reaction} horizontal/>
|
|
74
|
+
{post_reaction_stats.length > 0 && !more_selected ?
|
|
75
|
+
<Button
|
|
76
|
+
title='MORE'
|
|
77
|
+
title_color={Colors.brand.electric}
|
|
78
|
+
title_size={10}
|
|
79
|
+
style={{ marginLeft:4 }}
|
|
80
|
+
padding={0}
|
|
81
|
+
onPress={() => setMoreSelected(true)}
|
|
82
|
+
/>
|
|
83
|
+
:<></>}
|
|
84
|
+
{loading ?
|
|
85
|
+
<View style={{ position:'absolute', top:0, left:0, right:0, bottom:0, justifyContent:'center', backgroundColor:Colors.shades.black_faded, borderRadius:22 }}>
|
|
86
|
+
<ActivityIndicator size='small' color={Colors.brand.midnight} />
|
|
87
|
+
</View>
|
|
88
|
+
:<></>}
|
|
89
|
+
</View>
|
|
90
|
+
)
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
export default PostReactionBar
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { View, TouchableOpacity } from 'react-native';
|
|
3
|
+
import DraftTextViewer from './components/DraftTextViewer';
|
|
4
|
+
import type { OrderProps, PostCommentStatProps, PostProps, PostReactionProps, PostReactionStatsProps, PublicPlayerProps } from '../../types';
|
|
5
|
+
import PostHeader from './components/PostHeader';
|
|
6
|
+
import { view_styles } from '../../constants/styles';
|
|
7
|
+
import { useIsInViewport } from '../../Components/ViewportObserver';
|
|
8
|
+
import { SocialProfileApi } from '../PlayerProfile/api';
|
|
9
|
+
|
|
10
|
+
import PostReactionBar from './components/PostReactionBar';
|
|
11
|
+
import Colors from '../../constants/colors';
|
|
12
|
+
import { Icons, Text } from '../../Components';
|
|
13
|
+
import SocialOrdersList from '../SocialOrdersList';
|
|
14
|
+
import ImageList from './components/ImageList';
|
|
15
|
+
import { SocialComponentApi } from '../api';
|
|
16
|
+
|
|
17
|
+
type PostCardProps = {
|
|
18
|
+
post: PostProps,
|
|
19
|
+
player:PublicPlayerProps,
|
|
20
|
+
orders:OrderProps[],
|
|
21
|
+
player_id?:string,
|
|
22
|
+
onRequestAuthenticate:() => void,
|
|
23
|
+
onCopyOrder?:(order:OrderProps) => void,
|
|
24
|
+
onFadeOrder?:(order:OrderProps) => void,
|
|
25
|
+
onViewComments:(post_id:string) => void
|
|
26
|
+
}
|
|
27
|
+
const PostCard = ({ player_id, post, player, orders, onRequestAuthenticate, onCopyOrder, onFadeOrder, onViewComments }:PostCardProps) => {
|
|
28
|
+
const [ post_data, setPostData ] = useState<{
|
|
29
|
+
loading:boolean,
|
|
30
|
+
reactions_loaded:boolean,
|
|
31
|
+
post_comment_stat:PostCommentStatProps,
|
|
32
|
+
post_reaction_stats:PostReactionStatsProps[],
|
|
33
|
+
}>({
|
|
34
|
+
loading:false,
|
|
35
|
+
reactions_loaded: false,
|
|
36
|
+
post_comment_stat: { activity_post_id:post.memo_post_id, comment_count: 0 },
|
|
37
|
+
post_reaction_stats: []
|
|
38
|
+
})
|
|
39
|
+
const { reactions_loaded, post_reaction_stats, post_comment_stat } = post_data;
|
|
40
|
+
|
|
41
|
+
const [ my_data, setMyData ] = useState<{
|
|
42
|
+
my_data_loading:boolean,
|
|
43
|
+
my_reactions:PostReactionProps[]
|
|
44
|
+
}>({
|
|
45
|
+
my_data_loading:false,
|
|
46
|
+
my_reactions:[]
|
|
47
|
+
})
|
|
48
|
+
const { my_reactions, my_data_loading } = my_data;
|
|
49
|
+
const post_ref = useRef();
|
|
50
|
+
const is_in_viewport = useIsInViewport(post_ref);
|
|
51
|
+
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if(!is_in_viewport || reactions_loaded){ return }
|
|
54
|
+
getPostReactionData();
|
|
55
|
+
if(player_id){ getMyData(player_id) }
|
|
56
|
+
},[is_in_viewport]);
|
|
57
|
+
|
|
58
|
+
const getMyData = async(player_id:string) => {
|
|
59
|
+
setMyData({ ...my_data, my_data_loading: true });
|
|
60
|
+
const mr = await SocialProfileApi.getReactionsByPostAndPlayer(player_id, post.memo_post_id, 'memo');
|
|
61
|
+
setMyData({
|
|
62
|
+
...my_data,
|
|
63
|
+
my_data_loading: false,
|
|
64
|
+
my_reactions: mr
|
|
65
|
+
})
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const getPostReactionData = async() => {
|
|
69
|
+
setPostData({ ...post_data, loading: true });
|
|
70
|
+
const pr_stats = await SocialProfileApi.getReactionStatsByPostId(post.memo_post_id, 'memo');
|
|
71
|
+
const pc_stat = await SocialProfileApi.getCommentStatsByPostId(post.memo_post_id, 'memo');
|
|
72
|
+
setPostData({
|
|
73
|
+
...post_data,
|
|
74
|
+
reactions_loaded:true,
|
|
75
|
+
loading: false,
|
|
76
|
+
post_reaction_stats: pr_stats,
|
|
77
|
+
post_comment_stat: pc_stat ? pc_stat: post_comment_stat
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const handleReaction = async(reaction:PostReactionProps) => {
|
|
82
|
+
if(!player_id){ return onRequestAuthenticate() }
|
|
83
|
+
setMyData({ ...my_data, my_data_loading: true });
|
|
84
|
+
if(reaction.status == 'visible'){
|
|
85
|
+
let new_reaction = await SocialComponentApi.createPostReaction(reaction);
|
|
86
|
+
if(!new_reaction){ return setMyData({ ...my_data, my_data_loading: false }) }
|
|
87
|
+
setMyData({
|
|
88
|
+
...my_data,
|
|
89
|
+
my_data_loading:false,
|
|
90
|
+
my_reactions: my_reactions.concat(new_reaction)
|
|
91
|
+
})
|
|
92
|
+
let reaction_stats = post_reaction_stats.find(s => s.reaction == reaction.reaction)
|
|
93
|
+
if(!reaction_stats){ reaction_stats = { activity_post_id: post.memo_post_id, reaction:reaction.reaction, reaction_count:1 } }
|
|
94
|
+
else { reaction_stats = { ...reaction_stats, reaction_count: reaction_stats.reaction_count + 1 } }
|
|
95
|
+
//IUpdate reaction stats
|
|
96
|
+
setPostData({
|
|
97
|
+
...post_data,
|
|
98
|
+
post_reaction_stats: post_reaction_stats.filter(ps => ps.reaction != reaction.reaction).concat(reaction_stats)
|
|
99
|
+
})
|
|
100
|
+
} else {
|
|
101
|
+
let updated_reaction = await SocialComponentApi.updatePostReaction(reaction);
|
|
102
|
+
if(!updated_reaction){ return setMyData({ ...my_data, my_data_loading: false }) }
|
|
103
|
+
|
|
104
|
+
setMyData({
|
|
105
|
+
...my_data,
|
|
106
|
+
my_data_loading: false,
|
|
107
|
+
my_reactions: my_reactions.filter(r => r.post_reaction_id != updated_reaction.post_reaction_id)
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
let reaction_stats = post_reaction_stats.find(s => s.reaction == reaction.reaction)
|
|
111
|
+
if(!reaction_stats){ reaction_stats = { activity_post_id: post.memo_post_id, reaction:reaction.reaction, reaction_count:0 } }
|
|
112
|
+
else { reaction_stats = { ...reaction_stats, reaction_count: reaction_stats.reaction_count - 1 } }
|
|
113
|
+
setPostData({
|
|
114
|
+
...post_data,
|
|
115
|
+
post_reaction_stats: post_reaction_stats.filter(ps => ps.reaction != reaction.reaction).concat(reaction_stats)
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return (
|
|
121
|
+
<View ref={post_ref as any} style={{ ...view_styles.section, padding:0, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
122
|
+
<PostHeader
|
|
123
|
+
player={player}
|
|
124
|
+
post={post}
|
|
125
|
+
/>
|
|
126
|
+
<View style={{ padding:10 }}>
|
|
127
|
+
<Text theme='header_2'>{post.title}</Text>
|
|
128
|
+
</View>
|
|
129
|
+
<View style={{ padding:10, paddingTop:0, paddingBottom:0 }}>
|
|
130
|
+
<DraftTextViewer
|
|
131
|
+
post_id={post.memo_post_id}
|
|
132
|
+
formatted_body={post.formatted_body}
|
|
133
|
+
view_type='memo'
|
|
134
|
+
text_fallback={post.body}
|
|
135
|
+
/>
|
|
136
|
+
</View>
|
|
137
|
+
{post.memo_orders && post.memo_orders.length > 0 ?
|
|
138
|
+
<SocialOrdersList
|
|
139
|
+
players={[player]}
|
|
140
|
+
show_player={true}
|
|
141
|
+
orders={orders}
|
|
142
|
+
direction='horizontal'
|
|
143
|
+
onCopyOrder={onCopyOrder}
|
|
144
|
+
onFadeOrder={onFadeOrder}
|
|
145
|
+
/>
|
|
146
|
+
:<></>}
|
|
147
|
+
{post.memo_images && post.memo_images.length > 0 ?
|
|
148
|
+
<ImageList
|
|
149
|
+
post_id={post.memo_post_id}
|
|
150
|
+
images={post.memo_images}
|
|
151
|
+
width={300}
|
|
152
|
+
/>
|
|
153
|
+
:<></>}
|
|
154
|
+
<View style={{ ...view_styles.section_footer, padding:5, backgroundColor:Colors.shades.white }}>
|
|
155
|
+
<View style={{}}>
|
|
156
|
+
<PostReactionBar
|
|
157
|
+
loading={my_data_loading}
|
|
158
|
+
post_id={post.memo_post_id}
|
|
159
|
+
post_reaction_stats={post_reaction_stats}
|
|
160
|
+
my_post_reactions={my_reactions}
|
|
161
|
+
onReactionSelect={(r) => handleReaction(r)}
|
|
162
|
+
/>
|
|
163
|
+
</View>
|
|
164
|
+
<TouchableOpacity
|
|
165
|
+
style={{ flex:1, flexDirection:'row', alignItems:'center', justifyContent:'flex-end' }}
|
|
166
|
+
onPress={() => onViewComments(post.memo_post_id)}
|
|
167
|
+
>
|
|
168
|
+
<Text style={{ marginRight:4 }} theme='header_2'>{post_comment_stat.comment_count}</Text>
|
|
169
|
+
<Icons.ChatIcon size={18} color={Colors.brand.midnight}/>
|
|
170
|
+
</TouchableOpacity>
|
|
171
|
+
</View>
|
|
172
|
+
</View>
|
|
173
|
+
)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export default PostCard
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import { View, Image } from 'react-native';
|
|
3
|
+
import type { AthleteProps, LeagueProps, OrderProps, PublicPlayerProps, TeamProps } from '../types';
|
|
4
|
+
import { view_styles } from '../constants/styles';
|
|
5
|
+
import { Button, Icons, Text } from '../Components';
|
|
6
|
+
import { SocialComponentApi, SocialOrderHelpers } from './api';
|
|
7
|
+
import Colors from '../constants/colors';
|
|
8
|
+
import moment from 'moment-mini';
|
|
9
|
+
|
|
10
|
+
type SocialOrderCardProps = {
|
|
11
|
+
player?:PublicPlayerProps,
|
|
12
|
+
show_player?:boolean,
|
|
13
|
+
contest_title:string,
|
|
14
|
+
contest_time:string,
|
|
15
|
+
order:OrderProps,
|
|
16
|
+
athlete?:AthleteProps,
|
|
17
|
+
team?:TeamProps,
|
|
18
|
+
league?:LeagueProps,
|
|
19
|
+
onCopyOrder?:(order:OrderProps) => void,
|
|
20
|
+
onFadeOrder?:(order:OrderProps) => void
|
|
21
|
+
}
|
|
22
|
+
const SocialOrderCard = ({ player, show_player, league, team, order, contest_title, contest_time, onCopyOrder, onFadeOrder }:SocialOrderCardProps) => {
|
|
23
|
+
const [ fade_loading, setFadeLoading ] = useState(false);
|
|
24
|
+
const { result_label, color } = SocialOrderHelpers.getResultDetails(order)
|
|
25
|
+
|
|
26
|
+
const handleFadeOrder = async() => {
|
|
27
|
+
if(!onFadeOrder){ return }
|
|
28
|
+
if(fade_loading){ return }
|
|
29
|
+
setFadeLoading(true);
|
|
30
|
+
let reversed_order = await SocialComponentApi.reverseOrder(order);
|
|
31
|
+
if(!reversed_order){ return alert('Unable to fade this order at this time') }
|
|
32
|
+
onFadeOrder({
|
|
33
|
+
...reversed_order,
|
|
34
|
+
buy_sell_ind:'buy',
|
|
35
|
+
influencer_id: order.player_id,
|
|
36
|
+
influence_type: 'fade',
|
|
37
|
+
selling_position_id:undefined,
|
|
38
|
+
open_amt:10,
|
|
39
|
+
player_id:'',
|
|
40
|
+
order_type: 'limit',
|
|
41
|
+
collar_pct: 0,
|
|
42
|
+
h2h_id:undefined,
|
|
43
|
+
order_id: '',
|
|
44
|
+
called_amt: 0,
|
|
45
|
+
potential_winnings: SocialOrderHelpers.calcPotentialWinnings(reversed_order.odds, 10)
|
|
46
|
+
})
|
|
47
|
+
setFadeLoading(false);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<View style={{ ...view_styles.section, minWidth:175, borderWidth:1, borderColor:Colors.shades.shade600 }}>
|
|
52
|
+
{show_player && player ?
|
|
53
|
+
<View style={{ ...view_styles.section_header, backgroundColor:Colors.shades.shade100 }}>
|
|
54
|
+
<Image
|
|
55
|
+
source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
|
|
56
|
+
style={{ height:35, width:35, borderRadius:100 }}
|
|
57
|
+
resizeMode='cover'
|
|
58
|
+
/>
|
|
59
|
+
<View style={{ flex:1, marginLeft:10, marginRight:10 }}>
|
|
60
|
+
<Text theme='header'>{player.first_name} {player.last_name}</Text>
|
|
61
|
+
<Text theme='body_2' style={{ marginTop:3 }}>@{player.username}</Text>
|
|
62
|
+
</View>
|
|
63
|
+
<Text size={14} color={color} weight='bold'>{result_label}</Text>
|
|
64
|
+
</View>
|
|
65
|
+
:<></>}
|
|
66
|
+
<View style={{ ...view_styles.section_header }}>
|
|
67
|
+
|
|
68
|
+
<View style={{ flex:1, marginRight:10 }}>
|
|
69
|
+
<Text theme='body_2'>{contest_title}</Text>
|
|
70
|
+
<Text style={{ marginTop:3 }} size={12} color={Colors.brand.slate} weight='regular'>{contest_time}</Text>
|
|
71
|
+
</View>
|
|
72
|
+
{league ?
|
|
73
|
+
<Image
|
|
74
|
+
source={{ uri: league.league_image }}
|
|
75
|
+
style={{ height:30, width:30, borderRadius:4 }}
|
|
76
|
+
resizeMode='cover'
|
|
77
|
+
/>
|
|
78
|
+
:
|
|
79
|
+
<View style={{ height:30, width:30, borderRadius:4, justifyContent:'center', alignItems:'center', backgroundColor:SocialOrderHelpers.getIconColor(order) }}>
|
|
80
|
+
<Icons.ActivityIcon size={14} color={Colors.shades.white}/>
|
|
81
|
+
</View>
|
|
82
|
+
}
|
|
83
|
+
</View>
|
|
84
|
+
<View style={{ ...view_styles.section_body, padding:10 }}>
|
|
85
|
+
<View style={{ ...view_styles.body_row }}>
|
|
86
|
+
{team ?
|
|
87
|
+
<Image
|
|
88
|
+
source={{ uri: team.image?.url }}
|
|
89
|
+
style={{ height:35, width:35 }}
|
|
90
|
+
resizeMode='cover'
|
|
91
|
+
/>
|
|
92
|
+
:<></>}
|
|
93
|
+
<View style={{ flex:1, marginLeft:10, marginRight:10 }}>
|
|
94
|
+
<Text theme='header_2'>{order.title}</Text>
|
|
95
|
+
<Text style={{ marginTop:3 }} theme='body_2'>Created on {moment(order.create_datetime).format('MM/DD hh:mm a')}</Text>
|
|
96
|
+
</View>
|
|
97
|
+
<View>
|
|
98
|
+
<Text theme='header'>{SocialOrderHelpers.getOddsLabel(order.odds)}</Text>
|
|
99
|
+
{!show_player ?
|
|
100
|
+
<Text style={{ marginTop:3 }} size={14} color={color} weight='bold'>{result_label}</Text>
|
|
101
|
+
:<></>}
|
|
102
|
+
</View>
|
|
103
|
+
</View>
|
|
104
|
+
</View>
|
|
105
|
+
{order.resolution_status == 'inprogress' ?
|
|
106
|
+
<View style={{ ...view_styles.body_row, padding:0 }}>
|
|
107
|
+
{onCopyOrder ?
|
|
108
|
+
<Button
|
|
109
|
+
style={{ flex:1, borderRadius:0, borderBottomLeftRadius:8 }}
|
|
110
|
+
title='Copy'
|
|
111
|
+
title_color={Colors.shades.white}
|
|
112
|
+
backgroundColor={Colors.brand.midnight}
|
|
113
|
+
onPress={() => onCopyOrder({
|
|
114
|
+
...order,
|
|
115
|
+
buy_sell_ind:'buy',
|
|
116
|
+
influencer_id: order.player_id,
|
|
117
|
+
influence_type: 'copy',
|
|
118
|
+
order_type:'limit',
|
|
119
|
+
collar_pct:0,
|
|
120
|
+
selling_position_id:undefined,
|
|
121
|
+
open_amt:10,
|
|
122
|
+
player_id:'',
|
|
123
|
+
h2h_id:undefined,
|
|
124
|
+
order_id: '',
|
|
125
|
+
called_amt: 0,
|
|
126
|
+
potential_winnings: SocialOrderHelpers.calcPotentialWinnings(order.odds, 10)
|
|
127
|
+
})}
|
|
128
|
+
/>
|
|
129
|
+
:<></>}
|
|
130
|
+
{onFadeOrder ?
|
|
131
|
+
<Button
|
|
132
|
+
style={{ flex:1, borderRadius:0, borderBottomRightRadius:8, opacity:fade_loading?0.5:1 }}
|
|
133
|
+
title='Fade'
|
|
134
|
+
loading={fade_loading}
|
|
135
|
+
title_color={Colors.shades.white}
|
|
136
|
+
backgroundColor={Colors.brand.cyan}
|
|
137
|
+
onPress={() => handleFadeOrder()}
|
|
138
|
+
/>
|
|
139
|
+
:<></>}
|
|
140
|
+
</View>
|
|
141
|
+
:<></>}
|
|
142
|
+
</View>
|
|
143
|
+
)
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export default SocialOrderCard
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { View, FlatList } from 'react-native';
|
|
3
|
+
import type { AthleteProps, EventProps, LeagueProps, MatchProps, OrderProps, PublicPlayerProps, TeamProps, TournamentProps } from '../types';
|
|
4
|
+
import SocialOrderCard from './SocialOrderCard';
|
|
5
|
+
import { SocialComponentApi, SocialOrderHelpers } from './api';
|
|
6
|
+
|
|
7
|
+
type SocialOrdersListProps = {
|
|
8
|
+
players:PublicPlayerProps[],
|
|
9
|
+
show_player?:boolean,
|
|
10
|
+
orders:OrderProps[],
|
|
11
|
+
direction: 'vertical'|'horizontal',
|
|
12
|
+
onCopyOrder?:(order:OrderProps) => void,
|
|
13
|
+
onFadeOrder?:(order:OrderProps) => void
|
|
14
|
+
}
|
|
15
|
+
const SocialOrdersList = ({ players, show_player, orders, direction, onCopyOrder, onFadeOrder }:SocialOrdersListProps) => {
|
|
16
|
+
const [list_data, setListData] = useState<{
|
|
17
|
+
loading:boolean,
|
|
18
|
+
leagues:LeagueProps[],
|
|
19
|
+
events:EventProps[],
|
|
20
|
+
tournaments:TournamentProps[],
|
|
21
|
+
matches:MatchProps[],
|
|
22
|
+
athletes:AthleteProps[],
|
|
23
|
+
teams:TeamProps[]
|
|
24
|
+
}>({
|
|
25
|
+
loading:false,
|
|
26
|
+
leagues:[],
|
|
27
|
+
events:[],
|
|
28
|
+
tournaments:[],
|
|
29
|
+
matches:[],
|
|
30
|
+
athletes:[],
|
|
31
|
+
teams:[]
|
|
32
|
+
});
|
|
33
|
+
const { leagues, events, tournaments, matches, athletes, teams } = list_data;
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
SocialComponentApi.setEnvironment()
|
|
39
|
+
getDataFromServer();
|
|
40
|
+
},[orders.length])
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
const getDataFromServer = async() => {
|
|
44
|
+
setListData({ ...list_data, loading:true });
|
|
45
|
+
//Get event_ids
|
|
46
|
+
const { event_ids, tournament_ids, match_ids, athlete_ids, team_ids } = SocialOrderHelpers.getIdsFromOrders(orders);
|
|
47
|
+
let l = await SocialComponentApi.getLeagues();
|
|
48
|
+
let e = await SocialComponentApi.getEventsByEventIds(event_ids);
|
|
49
|
+
let t = await SocialComponentApi.getTournamentsByTournamentIds(tournament_ids);
|
|
50
|
+
let m = await SocialComponentApi.getMatchesByMatchIds(match_ids);
|
|
51
|
+
let a = await SocialComponentApi.getAthletesByIds(athlete_ids);
|
|
52
|
+
let tm = await SocialComponentApi.getTeamsByIds(team_ids);
|
|
53
|
+
//Now lets grab the data!
|
|
54
|
+
setListData({
|
|
55
|
+
...list_data,
|
|
56
|
+
loading:false,
|
|
57
|
+
leagues: l,
|
|
58
|
+
events: e,
|
|
59
|
+
tournaments: t,
|
|
60
|
+
matches: m,
|
|
61
|
+
athletes: a,
|
|
62
|
+
teams: tm
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
const renderOrders = (data:{item:OrderProps, index:number}) => {
|
|
69
|
+
let { title, time, league, team, athlete } = SocialOrderHelpers.getContestDetails(data.item, events, tournaments, matches, athletes, teams, leagues);
|
|
70
|
+
let player = players.find(p => p.player_id == data.item.player_id)
|
|
71
|
+
return (
|
|
72
|
+
<View>
|
|
73
|
+
<SocialOrderCard
|
|
74
|
+
show_player={show_player}
|
|
75
|
+
player={player}
|
|
76
|
+
league={league}
|
|
77
|
+
team={team}
|
|
78
|
+
athlete={athlete}
|
|
79
|
+
contest_title={title}
|
|
80
|
+
contest_time={time}
|
|
81
|
+
order={data.item}
|
|
82
|
+
onFadeOrder={onFadeOrder}
|
|
83
|
+
onCopyOrder={onCopyOrder}
|
|
84
|
+
/>
|
|
85
|
+
</View>
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<View>
|
|
91
|
+
<FlatList
|
|
92
|
+
data={orders}
|
|
93
|
+
renderItem={renderOrders}
|
|
94
|
+
horizontal={direction == 'horizontal' ? true : false}
|
|
95
|
+
keyExtractor={(item) => item.order_id.toString()}
|
|
96
|
+
/>
|
|
97
|
+
</View>
|
|
98
|
+
)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export default SocialOrdersList
|