Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

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

Rev 7152 Rev 7227
Línea 17... Línea 17...
17
import EmojiEmotionsIcon from '@mui/icons-material/EmojiEmotions'
17
import EmojiEmotionsIcon from '@mui/icons-material/EmojiEmotions'
18
import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism'
18
import VolunteerActivismIcon from '@mui/icons-material/VolunteerActivism'
Línea 19... Línea 19...
19
 
19
 
20
import InputOption from './InputOption'
20
import InputOption from './InputOption'
21
import ConfirmModal from '../../modals/ConfirmModal'
21
import ConfirmModal from '../../modals/ConfirmModal'
22
import FeedCommentSection from '../CommentSection'
22
import { CommentForm, CommentsList } from '../CommentSection'
23
import withExternalShare from './withExternalShare'
23
import withExternalShare from './withExternalShare'
24
import FeedModal from '../FeedModal'
24
import FeedModal from '../FeedModal'
Línea 25... Línea 25...
25
import SurveyForm from '../../survey-form/SurveyForm'
25
import SurveyForm from '../../survey-form/SurveyForm'
Línea 50... Línea 50...
50
    owner_file_image_preview,
50
    owner_file_image_preview,
51
    owner_file_video,
51
    owner_file_video,
52
    owner_file_image,
52
    owner_file_image,
53
    owner_file_document,
53
    owner_file_document,
54
    comment_add_url,
54
    comment_add_url,
55
    comments,
55
    comments: defaultComments,
56
    shared_name,
56
    shared_name,
57
    shared_image,
57
    shared_image,
58
    shared_time_elapse,
58
    shared_time_elapse,
59
    shared_description,
59
    shared_description,
60
    shared_file_video,
60
    shared_file_video,
Línea 68... Línea 68...
68
    feed_vote_url,
68
    feed_vote_url,
69
    feed_save_reaction_url,
69
    feed_save_reaction_url,
70
    feed_delete_reaction_url,
70
    feed_delete_reaction_url,
71
    openShareModal, // REDUX ACTION
71
    openShareModal, // REDUX ACTION
72
  } = props
72
  } = props
-
 
73
  const [comments, setComments] = useState([])
73
  const [ownerReactions, setOwnerReaction] = useState(feed_reactions)
74
  const [ownerReactions, setOwnerReaction] = useState(feed_reactions)
74
  const [totalReactions, setTotalReactions] = useState(0)
-
 
75
  const [totalComments, setTotalComments] = useState(owner_comments)
75
  const [totalComments, setTotalComments] = useState(owner_comments)
76
  const [externalShare, setExternalShare] = useState(owner_external_shared)
76
  const [externalShare, setExternalShare] = useState(owner_external_shared)
77
  const [sharedState, setSharedState] = useState(owner_shared)
77
  const [sharedState, setSharedState] = useState(owner_shared)
-
 
78
  const [totalReactions, setTotalReactions] = useState(0)
-
 
79
 
78
  const [showComments, setShowComments] = useState(false)
80
  const [showComments, setShowComments] = useState(false)
79
  const [showModal, setShowModal] = useState(false)
81
  const [showModal, setShowModal] = useState(false)
80
  const labels = useSelector(({ intl }) => intl.labels)
82
  const labels = useSelector(({ intl }) => intl.labels)
-
 
83
  const dispatch = useDispatch()
Línea 81... Línea 84...
81
 
84
 
82
  const reactionsOptions = [
85
  const reactionsOptions = [
83
    {
86
    {
84
      type: 'r',
87
      type: 'r',
Línea 104... Línea 107...
104
      type: 'f',
107
      type: 'f',
105
      icon: <EmojiEmotionsIcon style={{ color: '#FF7F50' }} />,
108
      icon: <EmojiEmotionsIcon style={{ color: '#FF7F50' }} />,
106
    },
109
    },
107
  ]
110
  ]
Línea 108... Línea 111...
108
 
111
 
109
  const handleShare = () =>
112
  const handleShare = () => {
110
    openShareModal(
113
    openShareModal(
111
      feed_share_url,
114
      feed_share_url,
112
      shareModalTypes.SHARE,
115
      shareModalTypes.SHARE,
113
      feedTypes.DASHBOARD,
116
      feedTypes.DASHBOARD,
114
      feed_unique
117
      feed_unique
115
    )
-
 
-
 
118
    )
Línea -... Línea 119...
-
 
119
  }
-
 
120
 
-
 
121
  const handleExternalShare = (value) => {
-
 
122
    setExternalShare(value)
116
  const handleExternalShare = (value) => setExternalShare(value)
123
  }
-
 
124
 
-
 
125
  const displayCommentSection = () => {
-
 
126
    setShowComments(!showComments)
-
 
127
  }
-
 
128
 
-
 
129
  const addComment = ({ comment }) => {
-
 
130
    const formData = new FormData()
-
 
131
    formData.append('comment', comment)
-
 
132
 
-
 
133
    axios.post(comment_add_url, formData).then((response) => {
-
 
134
      const { success, data, total_comments } = response.data
-
 
135
 
-
 
136
      if (!success) {
-
 
137
        const errorMessage =
-
 
138
          typeof data === 'string' ? data : 'Error interno. Intente más tarde.'
-
 
139
 
-
 
140
        dispatch(addNotification({ style: 'danger', msg: errorMessage }))
-
 
141
        return
-
 
142
      }
-
 
143
 
-
 
144
      setComments((prevMessages) => [...prevMessages, data])
-
 
145
      setTotalComments(total_comments)
-
 
146
    })
-
 
147
  }
-
 
148
 
-
 
149
  const deleteComment = (commentUnique, deleteCommentUrl) => {
-
 
150
    axios
-
 
151
      .post(deleteCommentUrl)
-
 
152
      .then((response) => {
-
 
153
        const { success, data, total_comments } = response.data
-
 
154
 
-
 
155
        if (!success) {
-
 
156
          const errorMessage =
-
 
157
            typeof data === 'string'
-
 
158
              ? data
-
 
159
              : 'Error interno. Intente más tarde.'
-
 
160
 
-
 
161
          dispatch(addNotification({ style: 'danger', msg: errorMessage }))
-
 
162
          return
-
 
163
        }
-
 
164
 
-
 
165
        dispatch(addNotification({ style: 'success', msg: data }))
-
 
166
 
-
 
167
        setComments((prevComments) =>
-
 
168
          prevComments.filter((comment) => comment.unique !== commentUnique)
-
 
169
        )
-
 
170
        setTotalComments(total_comments)
-
 
171
      })
-
 
172
      .catch((error) => {
-
 
173
        dispatch(addNotification({ style: 'danger', msg: error }))
-
 
174
        throw new Error(error)
Línea 117... Línea 175...
117
 
175
      })
118
  const displayCommentSection = () => setShowComments(!showComments)
176
  }
119
 
177
 
120
  const ExternalShareButton = withExternalShare(
178
  const ExternalShareButton = withExternalShare(
Línea 138... Línea 196...
138
      0
196
      0
139
    )
197
    )
140
    setTotalReactions(feedReactions)
198
    setTotalReactions(feedReactions)
141
  }, [ownerReactions])
199
  }, [ownerReactions])
Línea -... Línea 200...
-
 
200
 
-
 
201
  useEffect(() => {
-
 
202
    setComments(defaultComments)
-
 
203
  }, [defaultComments])
142
 
204
 
143
  return (
205
  return (
144
    <>
206
    <>
145
      <div className="feed">
207
      <div className="feed">
146
        <Feed.Header
208
        <Feed.Header
Línea 235... Línea 297...
235
              withTitle
297
              withTitle
236
            />
298
            />
237
            <ExternalShareButton />
299
            <ExternalShareButton />
238
          </div>
300
          </div>
239
        )}
301
        )}
240
 
-
 
241
        <div className="px-2 pb-2">
-
 
242
          <FeedCommentSection
302
        {showComments && (
243
            feedId={feed_unique}
-
 
244
            image={image}
-
 
245
            addUrl={comment_add_url}
303
          <div className="px-2 pb-2">
246
            updateTotalComments={(total) => setTotalComments(total)}
304
            <CommentForm onSubmit={addComment} image={image} />
247
            currentComments={comments}
305
            <CommentsList comments={comments} onDelete={deleteComment} />
248
            isShow={showComments}
-
 
249
          />
306
          </div>
250
        </div>
307
        )}
251
      </div>
308
      </div>
252
      <FeedModal
309
      <FeedModal
253
        show={showModal}
310
        show={showModal}
254
        feed={props}
311
        feed={props}
255
        onClose={() => setShowModal(false)}
312
        onClose={() => setShowModal(false)}