(props)
| 1 | import {CheckboxGroup, Checkbox, Flex} from '@adobe/react-spectrum'; |
| 2 | |
| 3 | function TodoItems(props) { |
| 4 | function removeItem(id) { |
| 5 | //add selected item to the completed list |
| 6 | const found = props.list.find(element => element.id === id); |
| 7 | if (found) { |
| 8 | props.updateCompleted(found.task); |
| 9 | } |
| 10 | |
| 11 | //remove the item from the list |
| 12 | props.handleList(props.list.filter(item => item.id !== id)); |
| 13 | } |
| 14 | |
| 15 | const elements = props.list.map(item => ( |
| 16 | <Checkbox onChange={() => removeItem(item.id)} key={item.id} value={item.task}> |
| 17 | {item.task} |
| 18 | </Checkbox> |
| 19 | )); |
| 20 | |
| 21 | return ( |
| 22 | <CheckboxGroup aria-label="to-do list"> |
| 23 | <Flex direction="column">{elements}</Flex> |
| 24 | </CheckboxGroup> |
| 25 | ); |
| 26 | } |
| 27 | |
| 28 | export default TodoItems; |
nothing calls this directly
no outgoing calls
no test coverage detected