Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 7140 Rev 7142
Línea 21... Línea 21...
21
import Avatar from '../../UI/AvatarImage'
21
import Avatar from '../../UI/AvatarImage'
22
import ConfirmModal from '../../modals/ConfirmModal'
22
import ConfirmModal from '../../modals/ConfirmModal'
23
import FeedCommentSection from '../CommentSection'
23
import FeedCommentSection from '../CommentSection'
24
import withExternalShare from './withExternalShare'
24
import withExternalShare from './withExternalShare'
25
import FeedModal from '../FeedModal'
25
import FeedModal from '../FeedModal'
26
import withReactions from '../withReaction'
-
 
27
import SurveyForm from '../../survey-form/SurveyForm'
26
import SurveyForm from '../../survey-form/SurveyForm'
Línea 28... Línea 27...
28
 
27
 
-
 
28
import './Feed.scss'
Línea 29... Línea 29...
29
import './Feed.scss'
29
import ReactionsButton from '../../UI/buttons/ReactionsButton'
30
 
30
 
31
const Feed = (props) => {
31
const Feed = (props) => {
32
  const {
32
  const {
33
    isShare = false,
33
    isShare = false,
34
    feed_unique,
34
    feed_unique,
35
    feed_share_url,
35
    feed_share_url,
36
    feed_share_external_url,
36
    feed_share_external_url,
37
    feed_delete_url,
-
 
38
    feed_my_reaction,
-
 
39
    feed_save_reaction_recommended_url,
-
 
40
    feed_save_reaction_support_url,
-
 
41
    feed_save_reaction_love_url,
-
 
42
    feed_save_reaction_interest_url,
-
 
43
    feed_save_reaction_fun_url,
37
    feed_delete_url,
44
    feed_delete_reaction_url,
38
    feed_my_reaction,
45
    feed_reactions,
39
    feed_reactions,
46
    owner_url,
40
    owner_url,
47
    image,
41
    image,
Línea 68... Línea 62...
68
    shared_file_document,
62
    shared_file_document,
69
    shared_url,
63
    shared_url,
70
    feed_increment_external_counter_url,
64
    feed_increment_external_counter_url,
71
    feed_content_type,
65
    feed_content_type,
72
    feed_vote_url,
66
    feed_vote_url,
-
 
67
    save_reaction_url,
73
    addNotification, // REDUX ACTION
68
    delete_reaction_url,
74
    openShareModal, // REDUX ACTION
69
    openShareModal, // REDUX ACTION
75
  } = props
70
  } = props
76
  const [ownerReactions, setOwnerReaction] = useState(feed_reactions)
71
  const [ownerReactions, setOwnerReaction] = useState(feed_reactions)
77
  const [currentReaction, setCurrentReaction] = useState(feed_my_reaction)
-
 
78
  const [totalReactions, setTotalReactions] = useState(0)
72
  const [totalReactions, setTotalReactions] = useState(0)
79
  const [totalComments, setTotalComments] = useState(owner_comments)
73
  const [totalComments, setTotalComments] = useState(owner_comments)
80
  const [externalShare, setExternalShare] = useState(owner_external_shared)
74
  const [externalShare, setExternalShare] = useState(owner_external_shared)
81
  const [sharedState, setSharedState] = useState(owner_shared)
75
  const [sharedState, setSharedState] = useState(owner_shared)
82
  const [showComments, setShowComments] = useState(false)
76
  const [showComments, setShowComments] = useState(false)
Línea 119... Línea 113...
119
    )
113
    )
120
  const handleExternalShare = (value) => setExternalShare(value)
114
  const handleExternalShare = (value) => setExternalShare(value)
Línea 121... Línea 115...
121
 
115
 
Línea 122... Línea -...
122
  const displayCommentSection = () => setShowComments(!showComments)
-
 
123
 
-
 
124
  const saveReaction = async (type) => {
-
 
125
    const reactionTypesUrl = {
-
 
126
      r: feed_save_reaction_recommended_url,
-
 
127
      s: feed_save_reaction_support_url,
-
 
128
      l: feed_save_reaction_love_url,
-
 
129
      i: feed_save_reaction_interest_url,
-
 
130
      f: feed_save_reaction_fun_url,
-
 
131
    }
-
 
132
 
-
 
133
    await axios.post(reactionTypesUrl[type]).then((res) => {
-
 
134
      const { success, data } = res.data
-
 
135
 
-
 
136
      if (!success) {
-
 
137
        addNotification({ style: 'danger', msg: data })
-
 
138
      }
-
 
139
 
-
 
140
      setOwnerReaction(data.reactions)
-
 
141
      setCurrentReaction(type)
-
 
142
    })
-
 
143
  }
-
 
144
 
-
 
145
  const deleteReaction = async () => {
-
 
146
    await axios.post(feed_delete_reaction_url).then((res) => {
-
 
147
      const { success, data } = res.data
-
 
148
 
-
 
149
      if (!success) {
-
 
150
        addNotification({ style: 'danger', msg: data })
-
 
151
        return
-
 
152
      }
-
 
153
 
-
 
154
      setOwnerReaction(data.reactions)
-
 
155
      setCurrentReaction('')
-
 
156
    })
-
 
157
  }
116
  const displayCommentSection = () => setShowComments(!showComments)
158
 
117
 
159
  const ExternalShareButton = withExternalShare(
118
  const ExternalShareButton = withExternalShare(
160
    InputOption,
119
    InputOption,
161
    feed_share_external_url,
120
    feed_share_external_url,
Línea 167... Línea 126...
167
      setValue: handleExternalShare,
126
      setValue: handleExternalShare,
168
      withTitle: true,
127
      withTitle: true,
169
    }
128
    }
170
  )
129
  )
Línea 171... Línea -...
171
 
-
 
172
  const WithReactionIcon = withReactions(InputOption, {
-
 
173
    onSelect: saveReaction,
-
 
174
    onDelete: deleteReaction,
-
 
175
    myReaction: currentReaction,
-
 
176
    withTitle: true,
-
 
177
  })
-
 
178
 
130
 
Línea 179... Línea 131...
179
  useEffect(() => setSharedState(owner_shared), [owner_shared])
131
  useEffect(() => setSharedState(owner_shared), [owner_shared])
180
 
132
 
181
  useEffect(() => {
133
  useEffect(() => {
Línea 263... Línea 215...
263
          </div>
215
          </div>
264
        )}
216
        )}
Línea 265... Línea 217...
265
 
217
 
266
        {!isShare && feed_content_type !== 'fast-survey' && (
218
        {!isShare && feed_content_type !== 'fast-survey' && (
267
          <div className="feed__buttons">
219
          <div className="feed__buttons">
-
 
220
            <ReactionsButton
-
 
221
              currentReaction={feed_my_reaction}
-
 
222
              saveUrl={save_reaction_url}
-
 
223
              deleteUrl={delete_reaction_url}
-
 
224
              onChange={(reactions) => setOwnerReaction(reactions)}
-
 
225
              withLabel
268
            <WithReactionIcon withTitle />
226
            />
269
            <InputOption
227
            <InputOption
270
              Icon={ChatOutlinedIcon}
228
              Icon={ChatOutlinedIcon}
271
              title={labels.comment}
229
              title={labels.comment}
272
              color="gray"
230
              color="gray"