2017-06-29 12:54:02 -06:00
|
|
|
import * as React from "react";
|
|
|
|
import { AddEditFarmEventProps } from "../interfaces";
|
|
|
|
import { connect } from "react-redux";
|
|
|
|
import { mapStateToPropsAddEdit } from "./map_state_to_props_add_edit";
|
|
|
|
import { history } from "../../history";
|
2018-08-01 07:09:30 -06:00
|
|
|
import { TaggedFarmEvent } from "farmbot";
|
2017-07-26 13:30:22 -06:00
|
|
|
import { EditFEForm } from "./edit_fe_form";
|
2019-04-02 13:59:37 -06:00
|
|
|
import { t } from "../../i18next_wrapper";
|
|
|
|
|
2017-06-29 12:54:02 -06:00
|
|
|
|
|
|
|
@connect(mapStateToPropsAddEdit)
|
|
|
|
export class EditFarmEvent extends React.Component<AddEditFarmEventProps, {}> {
|
|
|
|
redirect() {
|
|
|
|
history.push("/app/designer/farm_events");
|
|
|
|
return <div>{t("Loading")}...</div>;
|
|
|
|
}
|
|
|
|
|
|
|
|
renderForm(fe: TaggedFarmEvent) {
|
|
|
|
return <EditFEForm farmEvent={fe}
|
|
|
|
deviceTimezone={this.props.deviceTimezone}
|
|
|
|
repeatOptions={this.props.repeatOptions}
|
|
|
|
executableOptions={this.props.executableOptions}
|
|
|
|
dispatch={this.props.dispatch}
|
|
|
|
findExecutable={this.props.findExecutable}
|
2017-11-08 13:22:08 -07:00
|
|
|
title={t("Edit Farm Event")}
|
2017-12-29 10:39:04 -07:00
|
|
|
deleteBtn={true}
|
2018-04-05 14:05:54 -06:00
|
|
|
timeOffset={this.props.timeOffset}
|
2018-04-18 19:00:07 -06:00
|
|
|
autoSyncEnabled={this.props.autoSyncEnabled}
|
2018-12-20 20:18:10 -07:00
|
|
|
resources={this.props.resources}
|
|
|
|
shouldDisplay={this.props.shouldDisplay} />;
|
2017-06-29 12:54:02 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
2017-08-28 05:49:13 -06:00
|
|
|
const fe = this.props.getFarmEvent();
|
2017-06-29 12:54:02 -06:00
|
|
|
return fe ? this.renderForm(fe) : this.redirect();
|
|
|
|
}
|
|
|
|
}
|