Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3549 | Rev 3665 | Ir a la última revisión | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
3545 stevensc 1
import React, { useCallback } from 'react';
3508 stevensc 2
 
3
import { List } from '..';
4
import { CommentItem } from './CommentItem';
5
 
3549 stevensc 6
export function CommentList({ comments = [], onDelete, onReport }) {
3545 stevensc 7
  const handleDelete = useCallback(
8
    (url, uuid) => {
9
      if (!url || !uuid) return;
10
      onDelete(url, uuid);
11
    },
12
    [onDelete]
13
  );
14
 
15
  const handleReport = useCallback(
16
    (url) => {
17
      if (!url) return;
18
      onReport(url);
19
    },
20
    [onReport]
21
  );
22
 
3508 stevensc 23
  return (
24
    <List
25
      items={comments}
26
      renderItem={(comment) => (
27
        <CommentItem
28
          comment={comment}
3659 stevensc 29
          onDelete={comment.link_delete ? () => handleDelete(comment.link_delete) : null}
3543 stevensc 30
          onReport={
3545 stevensc 31
            comment.link_abuse_report ? () => handleReport(comment.link_abuse_report) : null
3543 stevensc 32
          }
3508 stevensc 33
        />
34
      )}
35
      emptyMessage='No hay comentarios para mostrar'
3520 stevensc 36
      keyExtractor={(comment) => comment.uuid}
3508 stevensc 37
    />
38
  );
39
}