Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2190 | Rev 2377 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
2190 stevensc 1
import React, { useState } from 'react'
2
import { useSelector } from 'react-redux'
3
import { SendOutlined, ChatOutlined } from '@mui/icons-material'
4
 
5
import withExternalShare from '../dashboard/linkedin/withExternalShare'
6
import withReactions from '@app/hocs/withReaction'
7
 
8
import Button from '../UI/buttons/Buttons'
9
import WidgetWrapper from '../widgets/WidgetLayout'
10
import Paraphrase from '../UI/Paraphrase'
11
import PostFile from './PostFile'
12
import FeedReactions from '../dashboard/linkedin/feed/FeedReactions'
2245 stevensc 13
 
2190 stevensc 14
import CommentForm from '../dashboard/linkedin/comments/comment-form'
15
import CommentsList from '../dashboard/linkedin/comments/comment-list'
16
 
17
function PostCard({
18
  post,
19
  addComment,
20
  updateReactions,
21
  updateMyReaction,
22
  updateTotalShare
23
}) {
24
  const {
25
    reactions,
26
    my_reaction,
27
    reactions_url,
28
    save_reaction_url,
29
    delete_reaction_url,
30
    total_share_external,
31
    image,
32
    title,
33
    description,
34
    file,
35
    type,
36
    comments,
37
    share_external_url,
38
    share_increment_external_counter_url
39
  } = post
40
  const [showComments, setShowComments] = useState(false)
41
  const labels = useSelector(({ intl }) => intl.labels)
42
 
43
  const displayCommentSection = () => {
44
    setShowComments(!showComments)
45
  }
46
 
2245 stevensc 47
  const ExternalShareButton = withExternalShare(Button, share_external_url)
2190 stevensc 48
 
49
  const ReactionButton = withReactions(Button)
50
 
51
  return (
52
    <WidgetWrapper>
53
      <img
54
        src={image}
55
        style={{
56
          width: '100%',
57
          maxHeight: '450px',
58
          objectFit: 'contain'
59
        }}
60
      />
61
      <WidgetWrapper.Body>
62
        <h2>{title}</h2>
63
        <Paraphrase>{description}</Paraphrase>
64
        <PostFile file={file} type={type} />
65
      </WidgetWrapper.Body>
66
 
67
      <div className='d-flex justify-content-between align-items-center px-3'>
68
        <FeedReactions reactions={reactions} reactionsUrl={reactions_url} />
69
 
70
        {!!total_share_external && (
71
          <span>{`${total_share_external} ${labels.sends?.toLowerCase()}`}</span>
72
        )}
73
      </div>
74
 
75
      <WidgetWrapper.Actions>
76
        <ReactionButton
77
          currentReactionType={my_reaction}
78
          saveUrl={save_reaction_url}
79
          deleteUrl={delete_reaction_url}
80
          onReaction={({ reactions }, currentReaction) => {
81
            updateReactions(reactions)
82
            updateMyReaction(currentReaction)
83
          }}
84
        />
85
 
86
        <Button onClick={displayCommentSection}>
87
          <ChatOutlined style={{ color: 'gray' }} />
88
          {labels.comment}
89
        </Button>
90
 
2245 stevensc 91
        <ExternalShareButton
92
          shorterUrl={share_increment_external_counter_url}
93
          setValue={updateTotalShare}
94
        >
95
          <SendOutlined style={{ color: 'gray' }} />
96
          {labels.send}
97
        </ExternalShareButton>
2190 stevensc 98
      </WidgetWrapper.Actions>
99
 
100
      {showComments && (
101
        <div className='px-3 pb-2'>
102
          <CommentForm onSubmit={addComment} />
103
          <CommentsList comments={comments} />
104
        </div>
105
      )}
106
    </WidgetWrapper>
107
  )
108
}
109
 
110
export default PostCard