Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2843 | Rev 2864 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2843 Rev 2846
Línea 1... Línea 1...
1
import React, { useState } from 'react'
1
import React, { useState } from 'react'
2
import { useDispatch, useSelector } from 'react-redux'
2
import { useDispatch, useSelector } from 'react-redux'
3
import { Box, Button, styled, Typography } from '@mui/material'
3
import { Box, Button, styled, Typography } from '@mui/material'
4
import { ChatOutlined, SendOutlined, ShareOutlined } from '@mui/icons-material'
4
import { ChatOutlined, SendOutlined, ShareOutlined } from '@mui/icons-material'
Línea 5... Línea -...
5
 
-
 
6
import { axios } from '@app/utils'
5
 
7
import { feedTypes } from '@app/redux/feed/feed.types'
-
 
8
import { addNotification } from '@app/redux/notification/notification.actions'
6
import { feedTypes } from '@app/redux/feed/feed.types'
9
import { openShareModal } from '@app/redux/share-modal/shareModal.actions'
7
import { openShareModal } from '@app/redux/share-modal/shareModal.actions'
10
import { shareModalTypes } from '@app/redux/share-modal/shareModal.types'
8
import { shareModalTypes } from '@app/redux/share-modal/shareModal.types'
11
import withReactions from '@app/hocs/withReaction'
9
import withReactions from '@app/hocs/withReaction'
Línea 12... Línea 10...
12
import withExternalShare from '../linkedin/withExternalShare'
10
import withExternalShare from '../linkedin/withExternalShare'
13
 
-
 
14
import Widget from '@components/UI/Widget'
-
 
15
import CommentForm from '../linkedin/comments/comment-form'
11
 
-
 
12
import Widget from '@components/UI/Widget'
Línea 16... Línea 13...
16
import CommentsList from '../linkedin/comments/comment-list'
13
import FeedReactions from '../linkedin/feed/FeedReactions'
17
import FeedReactions from '../linkedin/feed/FeedReactions'
14
import Comments from '../linkedin/comments/comments'
18
 
15
 
19
const Row = styled(Box)(({ theme }) => ({
16
const Row = styled(Box)(({ theme }) => ({
Línea 25... Línea 22...
25
}))
22
}))
Línea 26... Línea 23...
26
 
23
 
27
export default function FeedActions({ id }) {
24
export default function FeedActions({ id }) {
28
  const {
25
  const {
-
 
26
    comments,
29
    comments,
27
    comment_add_url: commentAddUrl,
30
    owner_comments: totalComments,
28
    owner_comments: ownerComments,
31
    feed_reactions_url: reactionsUrl,
29
    feed_reactions_url: reactionsUrl,
32
    feed_content_type: contentType,
30
    feed_content_type: contentType,
33
    owner_shared: totalShared,
31
    owner_shared: totalShared,
34
    feed_share_external_url: shareExternalUrl,
32
    feed_share_external_url: shareExternalUrl,
Línea 42... Línea 40...
42
    feed_unique: feedUnique
40
    feed_unique: feedUnique
43
  } = useSelector(({ feed }) => feed.feeds.byId[id])
41
  } = useSelector(({ feed }) => feed.feeds.byId[id])
44
  const labels = useSelector(({ intl }) => intl.labels)
42
  const labels = useSelector(({ intl }) => intl.labels)
45
  const dispatch = useDispatch()
43
  const dispatch = useDispatch()
Línea -... Línea 44...
-
 
44
 
46
 
45
  const [totalComments, setTotalComments] = useState(ownerComments)
47
  const [reaction, setReaction] = useState(feedMyReaction)
46
  const [reaction, setReaction] = useState(feedMyReaction)
48
  const [ownerReactions, setOwnerReactions] = useState(feedReactions)
47
  const [ownerReactions, setOwnerReactions] = useState(feedReactions)
49
  const [externalShare, setExternalShare] = useState(ownerExternalShared)
48
  const [externalShare, setExternalShare] = useState(ownerExternalShared)
Línea 67... Línea 66...
67
        feedUnique
66
        feedUnique
68
      )
67
      )
69
    )
68
    )
70
  }
69
  }
Línea 71... Línea -...
71
 
-
 
72
  const addComment = (comment, comment_add_url) => {
-
 
73
    const formData = new FormData()
-
 
74
    formData.append('comment', comment)
-
 
75
 
-
 
76
    axios.post(comment_add_url, formData).then((response) => {
-
 
77
      const { success, data, total_comments } = response.data
-
 
78
 
-
 
79
      if (!success) {
-
 
80
        dispatch(
-
 
81
          addNotification({
-
 
82
            style: 'danger',
-
 
83
            msg:
-
 
84
              typeof data === 'string'
-
 
85
                ? data
-
 
86
                : 'Error interno. Intente más tarde.'
-
 
87
          })
-
 
88
        )
-
 
89
        return
-
 
90
      }
-
 
91
 
-
 
92
      dispatch(
-
 
93
        addComment({
-
 
94
          feedId: feedUnique,
-
 
95
          comment: data,
-
 
96
          totalComments: total_comments
-
 
97
        })
-
 
98
      )
-
 
99
    })
-
 
100
  }
-
 
101
 
70
 
102
  const ExternalShareButton = withExternalShare(Button, shareExternalUrl)
71
  const ExternalShareButton = withExternalShare(Button, shareExternalUrl)
Línea 103... Línea 72...
103
  const ReactionButton = withReactions(Button)
72
  const ReactionButton = withReactions(Button)
104
 
73
 
Línea 159... Línea 128...
159
        sx={{
128
        sx={{
160
          display: showComments ? 'block' : 'none',
129
          display: showComments ? 'block' : 'none',
161
          padding: 0.5
130
          padding: 0.5
162
        }}
131
        }}
163
      >
132
      >
164
        <CommentForm onSubmit={addComment} />
133
        <Comments
165
        <CommentsList comments={comments} />
134
          comments={comments}
-
 
135
          addUrl={commentAddUrl}
-
 
136
          onAdd={({ totalComments }) => setTotalComments(totalComments)}
-
 
137
        />
166
      </Box>
138
      </Box>
167
    </>
139
    </>
168
  )
140
  )
169
}
141
}