File size: 837 Bytes
cce8120
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import React from 'react';

function ItemList({ items, onUpdate, onDelete }) {
  const toggleCompleted = (item) => {
    onUpdate(item.id, { completed: !item.completed });
  };

  return (
    <ul style={{ listStyle: 'none', padding: 0 }}>
      {items.map((item) => (
        <li key={item.id} style={{ marginBottom: '0.5rem' }}>
          <span
            style={{
              textDecoration: item.completed ? 'line-through' : 'none',
              cursor: 'pointer',
            }}
            onClick={() => toggleCompleted(item)}
          >
            {item.name}: {item.description}
          </span>
          <button
            onClick={() => onDelete(item.id)}
            style={{ marginLeft: '1rem' }}
          >
            Delete
          </button>
        </li>
      ))}
    </ul>
  );
}

export default ItemList;