Farmbot-Web-App/frontend/farm_designer/farm_events/edit_farm_event.tsx

38 lines
1.2 KiB
TypeScript
Raw Normal View History

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";
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}
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}
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();
}
}