import React from "react"; import { connect } from "react-redux"; import { DesignerPanel, DesignerPanelContent, DesignerPanelHeader } from "../designer_panel"; import { t } from "../../i18next_wrapper"; import { getPathArray } from "../../history"; import { TaggedToolSlotPointer } from "farmbot"; import { edit, save, destroy } from "../../api/crud"; import { history } from "../../history"; import { Panel } from "../panel_header"; import { SlotEditRows } from "./tool_slot_edit_components"; import { moveAbs } from "../../devices/actions"; import { isExpressBoard } from "../../devices/components/firmware_hardware_support"; import { EditToolSlotProps, mapStateToPropsEdit } from "./map_to_props_add_edit"; export class RawEditToolSlot extends React.Component { get stringyID() { return getPathArray()[4] || ""; } get toolSlot() { return this.props.findToolSlot(this.stringyID); } get tool() { return this.toolSlot && this.props.findTool(this.toolSlot.body.tool_id || 0); } updateSlot = (toolSlot: TaggedToolSlotPointer) => (update: Partial) => { this.props.dispatch(edit(toolSlot, update)); this.props.dispatch(save(toolSlot.uuid)); } render() { const { toolSlot } = this; !toolSlot && history.push("/app/designer/tools"); const panelName = "edit-tool-slot"; return {toolSlot ?
: {t("Redirecting")}...}
; } } export const EditToolSlot = connect(mapStateToPropsEdit)(RawEditToolSlot);