Proyectos de Subversion LeadersLinked - SPA

Rev

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

Rev 2186 Rev 2844
Línea 1... Línea 1...
1
import React, { useEffect, useMemo, useState } from 'react'
1
import React, { useEffect, useState } from 'react'
2
import { Link } from 'react-router-dom'
-
 
3
import { useDispatch } from 'react-redux'
2
import { useDispatch } from 'react-redux'
Línea 4... Línea 3...
4
 
3
 
5
import { axios } from '@app/utils'
4
import { axios } from '@app/utils'
6
import { addNotification } from '@app/redux/notification/notification.actions'
5
import { addNotification } from '@app/redux/notification/notification.actions'
Línea 7... Línea 6...
7
import { showReportModal } from '@app/redux/report/report.actions'
6
import { showReportModal } from '@app/redux/report/report.actions'
8
 
-
 
9
import { CommentsContainer, CommentTemplate } from './comments-ui'
7
 
-
 
8
import { CommentsContainer } from './comments-ui'
Línea 10... Línea 9...
10
import Options from '@app/components/UI/Option'
9
import ConfirmModal from '@app/components/modals/ConfirmModal'
11
import ConfirmModal from '@app/components/modals/ConfirmModal'
10
import CommentItem from './comment-item'
12
 
11
 
13
export default function CommentsList({ comments: defaultComments = [] }) {
12
export default function CommentsList({ comments: defaultComments = [] }) {
Línea 66... Línea 65...
66
 
65
 
67
  return (
66
  return (
68
    <>
67
    <>
69
      <CommentsContainer>
68
      <CommentsContainer>
70
        {comments.map((comment) => (
69
        {comments.map((comment) => (
71
          <Comment
70
          <CommentItem
72
            key={comment.unique}
71
            key={comment.unique}
73
            comment={comment}
72
            comment={comment}
74
            onDelete={handleDelete}
73
            onDelete={handleDelete}
75
            onReport={reportComment}
74
            onReport={reportComment}
Línea 82... Línea 81...
82
        onAccept={deleteComment}
81
        onAccept={deleteComment}
83
      />
82
      />
84
    </>
83
    </>
85
  )
84
  )
86
}
85
}
87
 
-
 
88
function Comment({ comment, onReport, onDelete }) {
-
 
89
  const {
-
 
90
    user_url,
-
 
91
    user_name,
-
 
92
    time_elapsed,
-
 
93
    comment: content,
-
 
94
    link_delete,
-
 
95
    link_abuse_report
-
 
96
  } = comment
-
 
97
 
-
 
98
  const actions = useMemo(() => {
-
 
99
    const options = []
-
 
100
 
-
 
101
    if (link_delete)
-
 
102
      options.push({ label: 'Borrar', action: () => onDelete(comment) })
-
 
103
 
-
 
104
    if (link_abuse_report)
-
 
105
      options.push({
-
 
106
        label: 'Reportar',
-
 
107
        action: () => onReport(link_abuse_report)
-
 
108
      })
-
 
109
 
-
 
110
    return options
-
 
111
  }, [link_delete, link_abuse_report])
-
 
112
 
-
 
113
  return (
-
 
114
    <CommentTemplate>
-
 
115
      <div className='content'>
-
 
116
        <div className='info'>
-
 
117
          <Link to={user_url}>
-
 
118
            <h3>{user_name}</h3>
-
 
119
          </Link>
-
 
120
          <span>{time_elapsed}</span>
-
 
121
        </div>
-
 
122
 
-
 
123
        <Options options={actions} />
-
 
124
 
-
 
125
        <p>{content}</p>
-
 
126
      </div>
-
 
127
    </CommentTemplate>
-
 
128
  )
-
 
129
}
-