be-components 2.1.4 → 2.1.6

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 (69) hide show
  1. package/lib/commonjs/Components/Icons.js +29 -0
  2. package/lib/commonjs/Components/Icons.js.map +1 -1
  3. package/lib/commonjs/SocialComponents/PlayerProfile/components/PostsList.js +10 -2
  4. package/lib/commonjs/SocialComponents/PlayerProfile/components/PostsList.js.map +1 -1
  5. package/lib/commonjs/SocialComponents/PlayerProfile/index.js +110 -27
  6. package/lib/commonjs/SocialComponents/PlayerProfile/index.js.map +1 -1
  7. package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js +51 -0
  8. package/lib/commonjs/SocialComponents/PostCard/components/ImageList.js.map +1 -0
  9. package/lib/commonjs/SocialComponents/PostCard/components/PostHeader.js +2 -1
  10. package/lib/commonjs/SocialComponents/PostCard/components/PostHeader.js.map +1 -1
  11. package/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.js +29 -3
  12. package/lib/commonjs/SocialComponents/PostCard/components/PostReactionBar.js.map +1 -1
  13. package/lib/commonjs/SocialComponents/PostCard/index.js +130 -19
  14. package/lib/commonjs/SocialComponents/PostCard/index.js.map +1 -1
  15. package/lib/commonjs/SocialComponents/SocialOrderCard.js +139 -29
  16. package/lib/commonjs/SocialComponents/SocialOrderCard.js.map +1 -1
  17. package/lib/commonjs/SocialComponents/SocialOrdersList.js +11 -3
  18. package/lib/commonjs/SocialComponents/SocialOrdersList.js.map +1 -1
  19. package/lib/commonjs/SocialComponents/api/index.js +88 -0
  20. package/lib/commonjs/SocialComponents/api/index.js.map +1 -1
  21. package/lib/module/Components/Icons.js +29 -0
  22. package/lib/module/Components/Icons.js.map +1 -1
  23. package/lib/module/SocialComponents/PlayerProfile/components/PostsList.js +10 -2
  24. package/lib/module/SocialComponents/PlayerProfile/components/PostsList.js.map +1 -1
  25. package/lib/module/SocialComponents/PlayerProfile/index.js +110 -27
  26. package/lib/module/SocialComponents/PlayerProfile/index.js.map +1 -1
  27. package/lib/module/SocialComponents/PostCard/components/ImageList.js +44 -0
  28. package/lib/module/SocialComponents/PostCard/components/ImageList.js.map +1 -0
  29. package/lib/module/SocialComponents/PostCard/components/PostHeader.js +2 -1
  30. package/lib/module/SocialComponents/PostCard/components/PostHeader.js.map +1 -1
  31. package/lib/module/SocialComponents/PostCard/components/PostReactionBar.js +30 -4
  32. package/lib/module/SocialComponents/PostCard/components/PostReactionBar.js.map +1 -1
  33. package/lib/module/SocialComponents/PostCard/index.js +130 -19
  34. package/lib/module/SocialComponents/PostCard/index.js.map +1 -1
  35. package/lib/module/SocialComponents/SocialOrderCard.js +138 -30
  36. package/lib/module/SocialComponents/SocialOrderCard.js.map +1 -1
  37. package/lib/module/SocialComponents/SocialOrdersList.js +11 -3
  38. package/lib/module/SocialComponents/SocialOrdersList.js.map +1 -1
  39. package/lib/module/SocialComponents/api/index.js +88 -0
  40. package/lib/module/SocialComponents/api/index.js.map +1 -1
  41. package/lib/typescript/src/Components/Icons.d.ts +1 -0
  42. package/lib/typescript/src/Components/Icons.d.ts.map +1 -1
  43. package/lib/typescript/src/SocialComponents/PlayerProfile/components/PostsList.d.ts +6 -2
  44. package/lib/typescript/src/SocialComponents/PlayerProfile/components/PostsList.d.ts.map +1 -1
  45. package/lib/typescript/src/SocialComponents/PlayerProfile/index.d.ts +12 -1
  46. package/lib/typescript/src/SocialComponents/PlayerProfile/index.d.ts.map +1 -1
  47. package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts +9 -0
  48. package/lib/typescript/src/SocialComponents/PostCard/components/ImageList.d.ts.map +1 -0
  49. package/lib/typescript/src/SocialComponents/PostCard/components/PostReactionBar.d.ts +4 -2
  50. package/lib/typescript/src/SocialComponents/PostCard/components/PostReactionBar.d.ts.map +1 -1
  51. package/lib/typescript/src/SocialComponents/PostCard/index.d.ts +5 -1
  52. package/lib/typescript/src/SocialComponents/PostCard/index.d.ts.map +1 -1
  53. package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts +6 -2
  54. package/lib/typescript/src/SocialComponents/SocialOrderCard.d.ts.map +1 -1
  55. package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts +6 -2
  56. package/lib/typescript/src/SocialComponents/SocialOrdersList.d.ts.map +1 -1
  57. package/lib/typescript/src/SocialComponents/api/index.d.ts +9 -1
  58. package/lib/typescript/src/SocialComponents/api/index.d.ts.map +1 -1
  59. package/package.json +1 -1
  60. package/src/Components/Icons.tsx +17 -0
  61. package/src/SocialComponents/PlayerProfile/components/PostsList.tsx +10 -2
  62. package/src/SocialComponents/PlayerProfile/index.tsx +69 -29
  63. package/src/SocialComponents/PostCard/components/ImageList.tsx +46 -0
  64. package/src/SocialComponents/PostCard/components/PostHeader.tsx +1 -1
  65. package/src/SocialComponents/PostCard/components/PostReactionBar.tsx +23 -5
  66. package/src/SocialComponents/PostCard/index.tsx +84 -14
  67. package/src/SocialComponents/SocialOrderCard.tsx +90 -19
  68. package/src/SocialComponents/SocialOrdersList.tsx +12 -4
  69. package/src/SocialComponents/api/index.ts +53 -1
@@ -13,10 +13,20 @@ import SocialOrdersList from '../SocialOrdersList';
13
13
  type PlayerProfileProps = {
14
14
  viewing_player_id:string,
15
15
  player_id?:string,
16
- height?:number
16
+ height?:number,
17
+ onStartChat?:(player_id:string) => void,
18
+ onHeadToHead?: (player_id:string) => void,
19
+ onFadeOrder: (order:OrderProps) => void,
20
+ onCopyOrder:(order:OrderProps) => void,
21
+ onShareProfile?:(player_id:string) => void,
22
+ onSharePost?:(post_id:string) => void,
23
+ onViewPostComments:(post_id:string) => void,
24
+ onSelectPlayer:(player_id:string) => void,
25
+ onRequestAuthenticate:() => void,
26
+ onBack?:() => void
17
27
  }
18
28
 
19
- const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfileProps) => {
29
+ const PlayerProfile = ({ viewing_player_id, player_id, height, onStartChat, onHeadToHead, onCopyOrder, onFadeOrder, onViewPostComments, onSelectPlayer, onRequestAuthenticate, onBack }:PlayerProfileProps) => {
20
30
  const [ module_size, setModuleSize ] = useState({ height:755, width:330 });
21
31
  const [ show_following, setShowFollowing ] = useState<{
22
32
  visible:boolean,
@@ -65,7 +75,7 @@ const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfilePro
65
75
  }>({
66
76
  loading:false,
67
77
  player_links:[],
68
- active_toggle:'Posts'
78
+ active_toggle:'Activity'
69
79
  });
70
80
  const { player, active_toggle, player_links, player_follower_stats } = profile_data;
71
81
 
@@ -155,7 +165,7 @@ const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfilePro
155
165
  width={120}
156
166
  border
157
167
  alignment='vertical'
158
- onSelectPlayer={() => console.log(data.item)}
168
+ onSelectPlayer={(p) => onSelectPlayer(p.player_id)}
159
169
  onFollowingUpdate={(pf) => console.log(pf)}
160
170
  />
161
171
  </View>
@@ -195,7 +205,7 @@ const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfilePro
195
205
  }
196
206
 
197
207
  return (
198
- <View style={{ flex:1 }} onLayout={(ev) => {
208
+ <View style={{ flex:1, backgroundColor:Colors.shades.black_faded, maxWidth:500 }} onLayout={(ev) => {
199
209
  const { height, width } = ev.nativeEvent.layout
200
210
  setModuleSize({ width, height });
201
211
  }}>
@@ -205,10 +215,11 @@ const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfilePro
205
215
  style={{ width: module_size.width, height: module_size.width, borderBottomRightRadius:50, borderBottomLeftRadius:50 }}
206
216
  resizeMode='cover'
207
217
  />
218
+
208
219
  </View>
209
220
  <ScrollView style={{ flex:1 }}>
210
- <View style={{ ...view_styles.section, marginTop:module_size.width - 200 }}>
211
- <View style={{ ...view_styles.section_header, borderBottomWidth:0 }}>
221
+ <View style={{ ...view_styles.section, marginTop:module_size.width - 150 }}>
222
+ <View style={{ ...view_styles.section_header }}>
212
223
  <View style={{ flex:1 }}>
213
224
  <Text theme='header'>{player.first_name} {player.last_name}</Text>
214
225
  <Text style={{ marginTop:4 }} theme='body_2'>@{player.username}</Text>
@@ -222,31 +233,46 @@ const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfilePro
222
233
  onPress={() => console.log('FOLLOW')}
223
234
  />
224
235
  </View>
225
-
226
- <View style={{ ...view_styles.section_body, padding:0 }}>
227
- <View style={{ ...view_styles.body_row, padding:10, borderTopWidth:1, borderColor:Colors.shades.shade600 }}>
228
- <Text theme='header_2' style={{flex:1}}>Engage With @{player.username}</Text>
229
- <Icons.ChatIcon size={24} color={Colors.brand.midnight} />
230
- </View>
231
- <View style={{ padding:10, backgroundColor:Colors.shades.shade100 }}>
232
- <Text theme='body'>{player.bio && player.bio != '' ? player.bio : `${player.username} has not set a bio.`}</Text>
233
- </View>
236
+ <View style={{ padding:10, backgroundColor:Colors.shades.shade100 }}>
237
+ <Text theme='body'>{player.bio && player.bio != '' ? player.bio : `${player.username} has not set a bio.`}</Text>
234
238
  </View>
235
- {player_links.length > 0 ?
236
- <View style={{ ...view_styles.section_footer }}>
237
- <View style={{ flex:1 }}>
238
- <Text theme='header_2'>Checkout my socials</Text>
239
- </View>
240
- <View style={{ alignSelf:'flex-end' }}>
241
- <FlatList
242
- data={player_links}
243
- renderItem={renderLinks}
244
- keyExtractor={(item) => item.player_link_id.toString()}
245
- horizontal
246
- />
239
+ <View style={{ ...view_styles.section_header, borderBottomWidth:0 }}>
240
+ <Text theme='header_2' style={{flex:1}}>Engage With @{player.username}</Text>
241
+ </View>
242
+ <View style={{ padding:5, paddingLeft:20, paddingRight:20, paddingTop:0 }}>
243
+ {onStartChat ?
244
+ <TouchableOpacity style={{ ...view_styles.body_row, padding:10, borderBottomWidth:1, borderColor:Colors.shades.shade600 }} onPress={() => onStartChat(viewing_player_id)}>
245
+ <Text style={{ flex:1 }} theme='body'>Start a Chat</Text>
246
+ <View style={{ height:30, width:30, borderRadius:4, backgroundColor:Colors.brand.electric, justifyContent:'center', alignItems:'center' }}>
247
+ <Icons.ChatIcon size={22} color={Colors.shades.white} />
248
+ </View>
249
+ </TouchableOpacity>
250
+ :<></>}
251
+ {onHeadToHead ?
252
+ <TouchableOpacity style={{ ...view_styles.body_row, padding:10, borderBottomWidth:1, borderColor:Colors.shades.shade600 }} onPress={() => onHeadToHead(viewing_player_id)}>
253
+ <Text style={{ flex:1 }} theme='body'>Challenge Head to Head</Text>
254
+ <View style={{ height:30, width:30, borderRadius:4, backgroundColor:Colors.utility.error, justifyContent:'center', alignItems:'center' }}>
255
+ <Icons.HeadToHeadIcon size={22} color={Colors.shades.white} />
256
+ </View>
257
+ </TouchableOpacity>
258
+ :<></>}
259
+ {player_links.length > 0 ?
260
+ <View style={{ ...view_styles.body_row, padding:10, paddingRight:5 }}>
261
+ <View style={{ flex:1 }}>
262
+ <Text theme='body'>Checkout Socials</Text>
263
+ </View>
264
+ <View style={{ alignSelf:'flex-end' }}>
265
+ <FlatList
266
+ data={player_links}
267
+ renderItem={renderLinks}
268
+ keyExtractor={(item) => item.player_link_id.toString()}
269
+ horizontal
270
+ />
271
+ </View>
247
272
  </View>
273
+ :<></>}
248
274
  </View>
249
- :<></>}
275
+
250
276
  </View>
251
277
  <View style={{ ...view_styles.section }}>
252
278
  <View style={{ ...view_styles.section_header }}>
@@ -339,17 +365,31 @@ const PlayerProfile = ({ viewing_player_id, player_id, height }:PlayerProfilePro
339
365
  <PostsList
340
366
  viewing_player={player}
341
367
  player_id={player_id}
368
+ onRequestAuthenticate={onRequestAuthenticate}
369
+ onCopyOrder={onCopyOrder}
370
+ onFadeOrder={onFadeOrder}
371
+ onViewComments={onViewPostComments}
342
372
  />
343
373
  :active_toggle == 'Activity' ?
344
374
  <SocialOrdersList
375
+ players={[player]}
345
376
  orders={orders}
346
377
  direction='vertical'
378
+ onCopyOrder={onCopyOrder}
379
+ onFadeOrder={onFadeOrder}
347
380
  />
348
381
  :<></>}
349
382
 
350
383
  </View>
351
384
  </View>
352
385
  </ScrollView>
386
+ {onBack ?
387
+ <TouchableOpacity
388
+ style={{ position:'absolute', top:0, left:0, ...view_styles.section, backgroundColor:Colors.shades.shade100, height:50, width:50, borderRadius:100, justifyContent:'center', alignItems:'center' }}
389
+ onPress={() => onBack()}>
390
+ <Icons.ChevronIcon direction='left' color={Colors.brand.midnight} size={14} />
391
+ </TouchableOpacity>
392
+ :<></>}
353
393
  {show_following.visible ?
354
394
  <View style={{ position:'absolute', top:0, left:0, right:0, bottom:0, backgroundColor:Colors.shades.black_faded }}>
355
395
  <Spring
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { FlatList, View, Image } from 'react-native';
3
+
4
+ type ImageListProps = {
5
+ post_id:string,
6
+ images: any[],
7
+ width:number
8
+ }
9
+ const ImageList = ({ post_id, width, images }:ImageListProps) => {
10
+
11
+ const resizeImage = (image:any) => {
12
+ let image_width = image.width ?? width
13
+ let image_height = image.height ?? width
14
+ const ratio = image_height / image_width
15
+ let new_width = width
16
+ let new_height = width * ratio
17
+ return { width: new_width, height: new_height }
18
+ }
19
+
20
+ const renderImages = (data: { item:any, index:number }) => {
21
+ const { width, height } = resizeImage(data.item);
22
+ return (
23
+ <View>
24
+ <Image
25
+ source={{ uri:data.item.url }}
26
+ style={{ width, height }}
27
+ resizeMode='cover'
28
+ />
29
+ </View>
30
+ )
31
+ }
32
+
33
+ return (
34
+ <View>
35
+ <FlatList
36
+ key={`${post_id}_post_images`}
37
+ data={images}
38
+ horizontal
39
+ renderItem={renderImages}
40
+ keyExtractor={(item) => item.url}
41
+ />
42
+ </View>
43
+ )
44
+ }
45
+
46
+ export default ImageList
@@ -12,7 +12,7 @@ type PostHeaderProps = {
12
12
 
13
13
  const PostHeader = ({ player, post }:PostHeaderProps) => {
14
14
  return (
15
- <View style={{ ...view_styles.section_header, padding:5 }}>
15
+ <View style={{ ...view_styles.section_header, paddingLeft:10, padding:10 }}>
16
16
  <Image
17
17
  source={{ uri: player.profile_pic && player.profile_pic != '' ? player.profile_pic : 'https://res.cloudinary.com/hoabts6mc/image/upload/v1722453927/default_man_n96ofq.webp' }}
18
18
  style={{ height:32, width:32, borderRadius:100 }}
@@ -1,15 +1,17 @@
1
1
  import React, { useState } from 'react';
2
- import { FlatList, View, TouchableOpacity } from "react-native"
2
+ import { FlatList, View, TouchableOpacity, ActivityIndicator } from "react-native"
3
3
  import type { PostReactionProps, PostReactionStatsProps } from '../../../types';
4
4
  import { Button, Text } from '../../../Components';
5
5
  import Colors from '../../../constants/colors';
6
6
  import { view_styles } from '../../../constants/styles';
7
7
 
8
8
  type PostReactionBarProps = {
9
+ post_id:string,
9
10
  post_reaction_stats: PostReactionStatsProps[],
10
11
  my_post_reactions: PostReactionProps[],
11
12
  featured?:boolean,
12
- onReactionSelect: (reaction:string) => void
13
+ loading?:boolean,
14
+ onReactionSelect: (post_reaction:PostReactionProps) => void
13
15
  }
14
16
 
15
17
  const available_reactions = [
@@ -23,11 +25,22 @@ const available_reactions = [
23
25
  { reaction: 'eyes', label: '👀' },
24
26
  ]
25
27
 
26
- const PostReactionBar = ({ post_reaction_stats, my_post_reactions, onReactionSelect }:PostReactionBarProps) => {
28
+ const PostReactionBar = ({ post_id, loading, post_reaction_stats, my_post_reactions, onReactionSelect }:PostReactionBarProps) => {
27
29
  const [ more_selected, setMoreSelected ] = useState(false);
30
+
28
31
  const handleReaction = async(reaction:string) => {
29
32
  if(!onReactionSelect){ return }
30
- onReactionSelect(reaction)
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
+ })
31
44
  setMoreSelected(false)
32
45
  }
33
46
 
@@ -53,7 +66,7 @@ const PostReactionBar = ({ post_reaction_stats, my_post_reactions, onReactionSel
53
66
 
54
67
  let visible_reactions = available_reactions
55
68
  if(post_reaction_stats.length > 0 && !more_selected){
56
- visible_reactions = visible_reactions.filter(r => post_reaction_stats.find(pr => pr.reaction === r.reaction))
69
+ visible_reactions = visible_reactions.filter(r => post_reaction_stats.find(pr => pr.reaction === r.reaction && pr.reaction_count > 0))
57
70
  }
58
71
  return (
59
72
  <View style={{ flexDirection:'row', alignItems:'center' }}>
@@ -68,6 +81,11 @@ const PostReactionBar = ({ post_reaction_stats, my_post_reactions, onReactionSel
68
81
  onPress={() => setMoreSelected(true)}
69
82
  />
70
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
+ :<></>}
71
89
  </View>
72
90
  )
73
91
  }
@@ -1,23 +1,30 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import { View, TouchableOpacity } from 'react-native';
3
3
  import DraftTextViewer from './components/DraftTextViewer';
4
- import type { OrderProps, PostCommentStatProps, PostProps, PostReactionStatsProps, PublicPlayerProps } from '../../types';
4
+ import type { OrderProps, PostCommentStatProps, PostProps, PostReactionProps, PostReactionStatsProps, PublicPlayerProps } from '../../types';
5
5
  import PostHeader from './components/PostHeader';
6
6
  import { view_styles } from '../../constants/styles';
7
7
  import { useIsInViewport } from '../../Components/ViewportObserver';
8
8
  import { SocialProfileApi } from '../PlayerProfile/api';
9
+
9
10
  import PostReactionBar from './components/PostReactionBar';
10
11
  import Colors from '../../constants/colors';
11
12
  import { Icons, Text } from '../../Components';
12
13
  import SocialOrdersList from '../SocialOrdersList';
14
+ import ImageList from './components/ImageList';
15
+ import { SocialComponentApi } from '../api';
13
16
 
14
17
  type PostCardProps = {
15
18
  post: PostProps,
16
19
  player:PublicPlayerProps,
17
20
  orders:OrderProps[],
18
- player_id?:string
21
+ player_id?:string,
22
+ onRequestAuthenticate:() => void,
23
+ onCopyOrder?:(order:OrderProps) => void,
24
+ onFadeOrder?:(order:OrderProps) => void,
25
+ onViewComments:(post_id:string) => void
19
26
  }
20
- const PostCard = ({ post, player, orders }:PostCardProps) => {
27
+ const PostCard = ({ player_id, post, player, orders, onRequestAuthenticate, onCopyOrder, onFadeOrder, onViewComments }:PostCardProps) => {
21
28
  const [ post_data, setPostData ] = useState<{
22
29
  loading:boolean,
23
30
  reactions_loaded:boolean,
@@ -30,7 +37,7 @@ const PostCard = ({ post, player, orders }:PostCardProps) => {
30
37
  post_reaction_stats: []
31
38
  })
32
39
  const { reactions_loaded, post_reaction_stats, post_comment_stat } = post_data;
33
- /*
40
+
34
41
  const [ my_data, setMyData ] = useState<{
35
42
  my_data_loading:boolean,
36
43
  my_reactions:PostReactionProps[]
@@ -38,37 +45,88 @@ const PostCard = ({ post, player, orders }:PostCardProps) => {
38
45
  my_data_loading:false,
39
46
  my_reactions:[]
40
47
  })
41
- */
48
+ const { my_reactions, my_data_loading } = my_data;
42
49
  const post_ref = useRef();
43
50
  const is_in_viewport = useIsInViewport(post_ref);
44
51
 
45
52
  useEffect(() => {
46
53
  if(!is_in_viewport || reactions_loaded){ return }
47
54
  getPostReactionData();
48
- },[is_in_viewport])
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
+ }
49
67
 
50
68
  const getPostReactionData = async() => {
51
69
  setPostData({ ...post_data, loading: true });
52
70
  const pr_stats = await SocialProfileApi.getReactionStatsByPostId(post.memo_post_id, 'memo');
53
- //const pc_stat = await SocialProfileApi.getCommentStatsByPostId(post.memo_post_id, 'memo');
71
+ const pc_stat = await SocialProfileApi.getCommentStatsByPostId(post.memo_post_id, 'memo');
54
72
  setPostData({
55
73
  ...post_data,
56
74
  reactions_loaded:true,
57
75
  loading: false,
58
- post_reaction_stats: pr_stats
76
+ post_reaction_stats: pr_stats,
77
+ post_comment_stat: pc_stat ? pc_stat: post_comment_stat
59
78
  })
60
79
  }
61
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
+
62
120
  return (
63
- <View ref={post_ref as any} style={{ ...view_styles.section }}>
121
+ <View ref={post_ref as any} style={{ ...view_styles.section, padding:0, borderWidth:1, borderColor:Colors.shades.shade600 }}>
64
122
  <PostHeader
65
123
  player={player}
66
124
  post={post}
67
125
  />
68
- <View>
126
+ <View style={{ padding:10 }}>
69
127
  <Text theme='header_2'>{post.title}</Text>
70
128
  </View>
71
- <View style={{ ...view_styles.section_body }}>
129
+ <View style={{ padding:10, paddingTop:0, paddingBottom:0 }}>
72
130
  <DraftTextViewer
73
131
  post_id={post.memo_post_id}
74
132
  formatted_body={post.formatted_body}
@@ -78,21 +136,33 @@ const PostCard = ({ post, player, orders }:PostCardProps) => {
78
136
  </View>
79
137
  {post.memo_orders && post.memo_orders.length > 0 ?
80
138
  <SocialOrdersList
139
+ players={[player]}
81
140
  orders={orders}
82
141
  direction='horizontal'
142
+ onCopyOrder={onCopyOrder}
143
+ onFadeOrder={onFadeOrder}
144
+ />
145
+ :<></>}
146
+ {post.memo_images && post.memo_images.length > 0 ?
147
+ <ImageList
148
+ post_id={post.memo_post_id}
149
+ images={post.memo_images}
150
+ width={300}
83
151
  />
84
152
  :<></>}
85
153
  <View style={{ ...view_styles.section_footer, padding:5, backgroundColor:Colors.shades.white }}>
86
154
  <View style={{}}>
87
155
  <PostReactionBar
156
+ loading={my_data_loading}
157
+ post_id={post.memo_post_id}
88
158
  post_reaction_stats={post_reaction_stats}
89
- my_post_reactions={[]}
90
- onReactionSelect={(r) => console.log(r)}
159
+ my_post_reactions={my_reactions}
160
+ onReactionSelect={(r) => handleReaction(r)}
91
161
  />
92
162
  </View>
93
163
  <TouchableOpacity
94
164
  style={{ flex:1, flexDirection:'row', alignItems:'center', justifyContent:'flex-end' }}
95
- onPress={() => console.log('SHOW ME THE COMMENTS')}
165
+ onPress={() => onViewComments(post.memo_post_id)}
96
166
  >
97
167
  <Text style={{ marginRight:4 }} theme='header_2'>{post_comment_stat.comment_count}</Text>
98
168
  <Icons.ChatIcon size={18} color={Colors.brand.midnight}/>
@@ -1,24 +1,74 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { View, Image } from 'react-native';
3
- import type { AthleteProps, LeagueProps, OrderProps, TeamProps } from '../types';
3
+ import type { AthleteProps, LeagueProps, OrderProps, PublicPlayerProps, TeamProps } from '../types';
4
4
  import { view_styles } from '../constants/styles';
5
5
  import { Button, Icons, Text } from '../Components';
6
- import { SocialOrderHelpers } from './api';
6
+ import { SocialComponentApi, SocialOrderHelpers } from './api';
7
7
  import Colors from '../constants/colors';
8
+ import moment from 'moment-mini';
8
9
 
9
10
  type SocialOrderCardProps = {
11
+ player?:PublicPlayerProps,
12
+ show_player?:boolean,
10
13
  contest_title:string,
11
14
  contest_time:string,
12
15
  order:OrderProps,
13
16
  athlete?:AthleteProps,
14
17
  team?:TeamProps,
15
- league?:LeagueProps
18
+ league?:LeagueProps,
19
+ onCopyOrder?:(order:OrderProps) => void,
20
+ onFadeOrder?:(order:OrderProps) => void
16
21
  }
17
- const SocialOrderCard = ({ league, team, order, contest_title, contest_time }:SocialOrderCardProps) => {
18
-
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
+
19
50
  return (
20
- <View style={{ ...view_styles.section }}>
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
+ :<></>}
21
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>
22
72
  {league ?
23
73
  <Image
24
74
  source={{ uri: league.league_image }}
@@ -30,42 +80,63 @@ const SocialOrderCard = ({ league, team, order, contest_title, contest_time }:So
30
80
  <Icons.ActivityIcon size={14} color={Colors.shades.white}/>
31
81
  </View>
32
82
  }
33
- <View style={{ flex:1, marginLeft:10 }}>
34
- <Text theme='header_2'>{contest_title}</Text>
35
- <Text style={{ marginTop:3 }} theme='body_2'>{contest_time}</Text>
36
- </View>
37
83
  </View>
38
- <View style={{ ...view_styles.section_body }}>
84
+ <View style={{ ...view_styles.section_body, padding:10 }}>
39
85
  <View style={{ ...view_styles.body_row }}>
40
86
  {team ?
41
87
  <Image
42
88
  source={{ uri: team.image?.url }}
43
- style={{ height:30, width:30 }}
89
+ style={{ height:35, width:35 }}
44
90
  resizeMode='cover'
45
91
  />
46
92
  :<></>}
47
- <View style={{ flex:1, marginLeft:10 }}>
48
- <Text theme='header_2'>{order.title} {SocialOrderHelpers.getOddsLabel(order.odds)}</Text>
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
+ :<></>}
49
102
  </View>
50
103
  </View>
51
104
  </View>
52
-
53
105
  {order.resolution_status == 'inprogress' ?
54
106
  <View style={{ ...view_styles.body_row, padding:0 }}>
107
+ {onCopyOrder ?
55
108
  <Button
56
109
  style={{ flex:1, borderRadius:0, borderBottomLeftRadius:8 }}
57
110
  title='Copy'
58
111
  title_color={Colors.shades.white}
59
112
  backgroundColor={Colors.brand.midnight}
60
- onPress={() => console.log('COPY THIS ORDER!')}
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
+ })}
61
128
  />
129
+ :<></>}
130
+ {onFadeOrder ?
62
131
  <Button
63
- style={{ flex:1, borderRadius:0, borderBottomRightRadius:8 }}
132
+ style={{ flex:1, borderRadius:0, borderBottomRightRadius:8, opacity:fade_loading?0.5:1 }}
64
133
  title='Fade'
134
+ loading={fade_loading}
65
135
  title_color={Colors.shades.white}
66
136
  backgroundColor={Colors.brand.cyan}
67
- onPress={() => console.log('FADE THIS ORDER!')}
137
+ onPress={() => handleFadeOrder()}
68
138
  />
139
+ :<></>}
69
140
  </View>
70
141
  :<></>}
71
142
  </View>