Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 3545 | Rev 3659 | 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}
3543 stevensc 29
          onDelete={
3545 stevensc 30
            comment.link_delete ? () => handleDelete(comment.link_delete, comment.uuid) : null
3543 stevensc 31
          }
32
          onReport={
3545 stevensc 33
            comment.link_abuse_report ? () => handleReport(comment.link_abuse_report) : null
3543 stevensc 34
          }
3508 stevensc 35
        />
36
      )}
37
      emptyMessage='No hay comentarios para mostrar'
3520 stevensc 38
      keyExtractor={(comment) => comment.uuid}
3508 stevensc 39
    />
40
  );
41
}