Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 6624 Rev 6625
Línea 32... Línea 32...
32
 
32
 
33
import FeedCommentSection from './CommentSection'
33
import FeedCommentSection from './CommentSection'
Línea 34... Línea 34...
34
import useOutsideClick from '../../hooks/useOutsideClick'
34
import useOutsideClick from '../../hooks/useOutsideClick'
35
 
-
 
36
import FeedModal from './FeedModal'
-
 
37
import withReactions from './withReaction'
35
 
38
import IconButton from '../UI/IconButton'
36
import FeedModal from './FeedModal'
-
 
37
import ConfirmModal from '../modals/ConfirmModal'
Línea 39... Línea 38...
39
import ConfirmModal from '../modals/ConfirmModal'
38
import SurveyForm from '../survey-form/SurveyForm'
40
import SurveyForm from '../survey-form/SurveyForm'
39
import ReactionsButton from '../UI/buttons/ReactionsButton'
41
 
40
 
42
const Feed = ({ feed, owner_shared, image }) => {
41
const Feed = ({ feed, owner_shared, image }) => {
Línea 57... Línea 56...
57
    comment_add_url,
56
    comment_add_url,
58
    feed_share_external_url,
57
    feed_share_external_url,
59
  } = feed
58
  } = feed
60
  const [totalComments, setTotalComments] = useState(0)
59
  const [totalComments, setTotalComments] = useState(0)
61
  const [ownerReactions, setOwnerReaction] = useState(feed.feed_reactions)
60
  const [ownerReactions, setOwnerReaction] = useState(feed.feed_reactions)
62
  const [currentReaction, setCurrentReaction] = useState(feed.feed_my_reaction)
-
 
63
  const [totalReactions, setTotalReactions] = useState(0)
61
  const [totalReactions, setTotalReactions] = useState(0)
64
  const [sharedState, setSharedState] = useState(owner_shared)
62
  const [sharedState, setSharedState] = useState(owner_shared)
65
  const [shareUrl, setShareUrl] = useState('')
63
  const [shareUrl, setShareUrl] = useState('')
Línea 66... Línea 64...
66
 
64
 
67
  const [showComments, setShowComments] = useState(false)
65
  const [showComments, setShowComments] = useState(false)
68
  const [shareOptions, setShareOptions] = useState(false)
66
  const [shareOptions, setShareOptions] = useState(false)
Línea 69... Línea 67...
69
  const [show, setShow] = useState(false)
67
  const [show, setShow] = useState(false)
70
 
68
 
-
 
69
  const shareContainer = useRef(null)
71
  const shareContainer = useRef(null)
70
  const dispatch = useDispatch()
Línea 72... Línea 71...
72
  const dispatch = useDispatch()
71
 
73
  useOutsideClick(shareContainer, () => setShareOptions(false))
72
  useOutsideClick(shareContainer, () => setShareOptions(false))
74
 
73
 
Línea 114... Línea 113...
114
        })
113
        })
115
        .catch((err) => reject(err))
114
        .catch((err) => reject(err))
116
    }
115
    }
117
  })
116
  })
Línea 118... Línea -...
118
 
-
 
119
  const saveReaction = async (type) => {
-
 
120
    const reactionTypesUrl = {
-
 
121
      r: feed.feed_save_reaction_recommended_url,
-
 
122
      s: feed.feed_save_reaction_support_url,
-
 
123
      l: feed.feed_save_reaction_love_url,
-
 
124
      i: feed.feed_save_reaction_interest_url,
-
 
125
      f: feed.feed_save_reaction_fun_url,
-
 
126
    }
-
 
127
 
-
 
128
    await axios.post(reactionTypesUrl[type]).then((res) => {
-
 
129
      const { success, data } = res.data
-
 
130
 
-
 
131
      if (!success) {
-
 
132
        dispatch(addNotification({ style: 'danger', msg: data }))
-
 
133
      }
-
 
134
 
-
 
135
      setOwnerReaction(data.reactions)
-
 
136
      setCurrentReaction(type)
-
 
137
    })
-
 
138
  }
-
 
139
 
117
 
140
  const deleteReaction = async () => {
-
 
141
    await axios.post(feed.feed_delete_reaction_url).then((res) => {
-
 
142
      const { success, data } = res.data
-
 
143
 
-
 
144
      if (!success) {
-
 
145
        dispatch(addNotification({ style: 'danger', msg: data }))
-
 
146
        return
-
 
147
      }
-
 
148
 
-
 
149
      setOwnerReaction(data.reactions)
118
  const displayComments = () => {
150
      setCurrentReaction('')
-
 
151
    })
119
    setShowComments(!showComments)
Línea 152... Línea -...
152
  }
-
 
153
 
-
 
154
  const displayComments = () => setShowComments(!showComments)
120
  }
155
 
121
 
156
  const btnShareHandler = () => {
122
  const btnShareHandler = () => {
157
    dispatch(
123
    dispatch(
158
      openShareModal(
124
      openShareModal(
Línea 162... Línea 128...
162
        feed_unique
128
        feed_unique
163
      )
129
      )
164
    )
130
    )
165
  }
131
  }
Línea 166... Línea -...
166
 
-
 
167
  const WithReactionIcon = withReactions(IconButton, {
-
 
168
    onSelect: saveReaction,
-
 
169
    onDelete: deleteReaction,
-
 
170
    myReaction: currentReaction,
-
 
171
    withTitle: true,
-
 
172
  })
-
 
173
 
132
 
Línea 174... Línea 133...
174
  useEffect(() => setSharedState(owner_shared), [owner_shared])
133
  useEffect(() => setSharedState(owner_shared), [owner_shared])
175
 
134
 
176
  useEffect(() => {
135
  useEffect(() => {
Línea 231... Línea 190...
231
            .map((reaction) => reaction.icon)}
190
            .map((reaction) => reaction.icon)}
232
          <span>{totalReactions} reacciones</span>
191
          <span>{totalReactions} reacciones</span>
233
        </div>
192
        </div>
234
        <ul className="reactions-list">
193
        <ul className="reactions-list">
235
          <li>
194
          <li>
236
            <WithReactionIcon />
195
            <ReactionsButton
-
 
196
              onChange={(reactions) => setOwnerReaction(reactions)}
-
 
197
              currentReaction={feed.feed_my_reaction}
-
 
198
              withLabel
-
 
199
              deleteUrl={feed.feed_delete_reaction_url}
-
 
200
              reactionTypesUrl={{
-
 
201
                r: feed.feed_save_reaction_recommended_url,
-
 
202
                s: feed.feed_save_reaction_support_url,
-
 
203
                l: feed.feed_save_reaction_love_url,
-
 
204
                i: feed.feed_save_reaction_interest_url,
-
 
205
                f: feed.feed_save_reaction_fun_url,
-
 
206
              }}
-
 
207
            />
237
          </li>
208
          </li>
238
          <li>
209
          <li>
239
            <button
210
            <button
240
              type="button"
211
              type="button"
241
              id={`btn-comments-${feed_unique}`}
212
              id={`btn-comments-${feed_unique}`}
Línea 306... Línea 277...
306
              </div>
277
              </div>
307
            )}
278
            )}
308
          </li>
279
          </li>
309
        </ul>
280
        </ul>
310
        <FeedCommentSection
281
        <FeedCommentSection
311
          feedId={feed.feed_unique}
282
          isShow={showComments}
312
          image={image}
283
          image={image}
313
          addUrl={comment_add_url}
284
          addUrl={comment_add_url}
314
          updateTotalComments={(total) => setTotalComments(total)}
-
 
315
          currentComments={comments}
285
          currentComments={comments}
-
 
286
          updateTotalComments={(totalComments) =>
316
          isShow={showComments}
287
            setTotalComments(totalComments)
-
 
288
          }
317
        />
289
        />
318
      </div>
290
      </div>
319
    </>
291
    </>
320
  )
292
  )
321
}
293
}