Editing Pilot Entries
We'll cover the following...
Now that we have our generic entity update reducer in place, we can implement the ability to edit Pilot entries. We already set up the “start/stop editing” toggle last time, so we just need to hook up the event handlers and dispatch the right actions.
Hooking Up Pilot Inputs
We’ll start with the Pilot’s name
field:
features/pilots/PilotDetails.jsx
+import {updateEntity} from "features/entities/entityActions";
+import {getValueFromEvent} from "common/utils/clientUtils";
const actions = {
startEditingPilot,
stopEditingPilot,
+ updateEntity,
}
export class PilotDetails extends Component {
+ onNameChanged = (e) => {
+ const newValues = getValueFromEvent(e);
+ const {id} = this.props.pilot;
+
+ this.props.updateEntity("Pilot", id, newValues);
+ }
// Omit most rendering code
<Form.Field
name="name"
label="Name"
width={16}
placeholder="Name"
value={name}
disabled={!canStopEditing}
+
...