import * as React from "react"; import { t } from "../../i18next_wrapper"; import { getDevice } from "../../device"; import { destroy, edit, save } from "../../api/crud"; import { ResourceColor } from "../../interfaces"; import { TaggedGenericPointer, TaggedWeedPointer } from "farmbot"; import { ListItem } from "../plants/plant_panel"; import { round, cloneDeep } from "lodash"; import { Row, Col, BlurableInput, ColorPicker } from "../../ui"; import { parseIntInput } from "../../util"; import { UUID } from "../../resources/interfaces"; import { plantAge } from "../plants/map_state_to_props"; import { EditWeedStatus } from "../plants/edit_plant_status"; type PointUpdate = Partial; export const updatePoint = (point: TaggedGenericPointer | TaggedWeedPointer | undefined, dispatch: Function) => (update: PointUpdate) => { if (point) { dispatch(edit(point, update)); dispatch(save(point.uuid)); } }; export interface EditPointPropertiesProps { point: TaggedGenericPointer | TaggedWeedPointer; updatePoint(update: PointUpdate): void; } export interface AdditionalWeedPropertiesProps { point: TaggedWeedPointer; updatePoint(update: PointUpdate): void; } export const EditPointProperties = (props: EditPointPropertiesProps) => ; export const AdditionalWeedProperties = (props: AdditionalWeedPropertiesProps) => ; const REMOVAL_METHODS = ["automatic", "manual"]; const SOURCE_LOOKUP = (): Record => ({ "plant-detection": t("Weed Detector"), "farm-designer": t("Farm Designer"), }); export interface PointActionsProps { x: number; y: number; z: number; uuid: UUID; dispatch: Function; } export const PointActions = ({ x, y, z, uuid, dispatch }: PointActionsProps) =>
; export interface EditPointNameProps { updatePoint(update: PointUpdate): void; name: string; } export const EditPointName = (props: EditPointNameProps) =>
props.updatePoint({ name: e.currentTarget.value })} />
; export interface EditPointLocationProps { updatePoint(update: PointUpdate): void; xyLocation: Record<"x" | "y", number>; } export const EditPointLocation = (props: EditPointLocationProps) => {["x", "y"].map((axis: "x" | "y") => props.updatePoint({ [axis]: round(parseIntInput(e.currentTarget.value)) })} /> )} ; export interface EditPointRadiusProps { updatePoint(update: PointUpdate): void; radius: number; } export const EditPointRadius = (props: EditPointRadiusProps) => props.updatePoint({ radius: round(parseIntInput(e.currentTarget.value)) })} /> ; export interface EditPointColorProps { updatePoint(update: PointUpdate): void; color: string | undefined; } export const EditPointColor = (props: EditPointColorProps) =>
props.updatePoint({ meta: { color } })} />
;