Proyectos de Subversion LeadersLinked - Backend

Rev

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

Rev 16660 Rev 16666
Línea 1... Línea 1...
1
import React, { useEffect, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import { deleteFeed } from '../../redux/feed/feed.actions'
2
import { deleteFeed } from '../../redux/feed/feed.actions'
3
import DeleteModal from '../../shared/DeleteModal'
3
import DeleteModal from '../../shared/DeleteModal'
-
 
4
import CommentForm from './CommentForm'
4
import CommentSection from './CommentSection'
5
import CommentsList from './CommentsList'
5
import parse from 'html-react-parser'
6
import parse from 'html-react-parser'
6
import styles from './feeds.module.scss'
7
import styles from './feeds.module.scss'
7
import Options from '../../shared/options/Options'
8
import Options from '../../shared/options/Options'
Línea 8... Línea 9...
8
 
9
 
9
const FeedTemplate = ({ feed }) => {
10
const FeedTemplate = ({ feed }) => {
-
 
11
  const [comments, setComments] = useState(feed.comments)
10
  const [commentState, setCommentState] = useState(feed.owner_comments)
12
  const [totalComments, setTotalComments] = useState(feed.owner_comments)
11
  const [showDeleteModal, setShowDeleteModal] = useState(false)
13
  const [showDeleteModal, setShowDeleteModal] = useState(false)
Línea 12... Línea 14...
12
  const [options, setOptions] = useState([])
14
  const [options, setOptions] = useState([])
13
 
15
 
14
  const toggleModal = () => {
16
  const toggleModal = () => {
Línea -... Línea 17...
-
 
17
    setShowDeleteModal(!showDeleteModal)
-
 
18
  }
-
 
19
 
-
 
20
  const deleteComment = (id) => {
-
 
21
    setComments((prevComments) =>
-
 
22
      prevComments.filter((comment) => comment.unique === id)
15
    setShowDeleteModal(!showDeleteModal)
23
    )
16
  }
24
  }
17
 
25
 
18
  useEffect(() => {
26
  useEffect(() => {
19
    if (feed.feed_delete_url) {
27
    if (feed.feed_delete_url) {
Línea 46... Línea 54...
46
            owner_file_video: feed.shared_file_video,
54
            owner_file_video: feed.shared_file_video,
47
            owner_file_document: feed.shared_file_document,
55
            owner_file_document: feed.shared_file_document,
48
            owner_time_elapse: feed.shared_time_elapse
56
            owner_time_elapse: feed.shared_time_elapse
49
          }}
57
          }}
50
        />
58
        />
51
        <CommentSection
59
        <CommentForm
52
          comments_link_add={feed.comment_add_url}
60
          image={feed.owner_image}
53
          comments={feed.comments}
61
          profileUrl={feed.owner_url}
54
          owner_image={feed.owner_image}
62
          sendUrl={feed.comments_link_add}
55
          owner_url={feed.owner_url}
63
          onSubmit={(data) => {
-
 
64
            setTotalComments(data.total_comments)
56
          setComment={setCommentState}
65
            setComments(data.data)
-
 
66
          }}
57
        />
67
        />
-
 
68
        <CommentsList comments={comments} onDelete={deleteComment} />
58
      </article>
69
      </article>
59
      <DeleteModal
70
      <DeleteModal
60
        url={feed.feed_delete_url}
71
        url={feed.feed_delete_url}
61
        isOpen={showDeleteModal}
72
        isOpen={showDeleteModal}
62
        closeModal={toggleModal}
73
        closeModal={toggleModal}
Línea 122... Línea 133...
122
  return (
133
  return (
123
    <div className={styles.feed_content}>
134
    <div className={styles.feed_content}>
124
      {description && htmlParsedText(description)}
135
      {description && htmlParsedText(description)}
125
      {image && (
136
      {image && (
126
        <div className={styles.img_container}>
137
        <div className={styles.img_container}>
127
          <img src={image} alt="" />
138
          <img src={image} alt="Article image" />
128
          <img src={image} alt="" />
139
          <img src={image} alt="Article image" />
129
        </div>
140
        </div>
130
      )}
141
      )}
131
      {video && (
142
      {video && (
132
        <video src={video} preload="none" poster={previewImage} controls />
143
        <video src={video} preload="none" poster={previewImage} controls />
133
      )}
144
      )}