11import React from "react" ;
22import { connect } from "react-redux" ;
3- import { Table } from "semantic-ui-react" ;
3+ import {
4+ Table ,
5+ Button ,
6+ Icon ,
7+ } from "semantic-ui-react" ;
48import _ from "lodash" ;
59
610import { getEntitiesSession } from "features/entities/entitySelectors" ;
11+ import { deleteEntity } from "features/entities/entityActions" ;
12+
713
814const mapState = ( state , ownProps ) => {
915 const session = getEntitiesSession ( state ) ;
@@ -37,7 +43,12 @@ const mapState = (state, ownProps) => {
3743 return { pilot} ;
3844}
3945
40- const PilotsListRow = ( { pilot= { } , onPilotClicked= _ . noop , selected} ) => {
46+ const actions = {
47+ deleteEntity,
48+ } ;
49+
50+
51+ const PilotsListRow = ( { pilot= { } , onPilotClicked= _ . noop , selected, deleteEntity} ) => {
4152 const {
4253 id = null ,
4354 name = "" ,
@@ -48,6 +59,8 @@ const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected}) => {
4859 mechType = "" ,
4960 } = pilot ;
5061
62+ const onDeleteClicked = ( ) => deleteEntity ( "Pilot" , id ) ;
63+
5164 return (
5265 < Table . Row onClick = { ( ) => onPilotClicked ( id ) } active = { selected } >
5366 < Table . Cell >
@@ -65,8 +78,21 @@ const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected}) => {
6578 < Table . Cell >
6679 { mechType }
6780 </ Table . Cell >
81+
82+ < Table . Cell >
83+ < Button
84+ compact
85+ basic
86+ circular
87+ size = "tiny"
88+ color = "red"
89+ icon = { < Icon name = "delete" /> }
90+ onClick = { onDeleteClicked }
91+ >
92+ </ Button >
93+ </ Table . Cell >
6894 </ Table . Row >
6995 ) ;
7096}
7197
72- export default connect ( mapState ) ( PilotsListRow ) ;
98+ export default connect ( mapState , actions ) ( PilotsListRow ) ;
0 commit comments