import { observer } from "mobx-react";
import * as React from "react";
import { Table } from "semantic-ui-react";
import { Program, Schedule } from "@common/sprinklers";
@observer
export class ScheduleView extends React.Component<{ schedule: Schedule }> {
render() {
return (
{JSON.stringify(this.props.schedule)}
);
}
}
@observer
export default class ProgramTable extends React.Component<{ programs: Program[] }> {
private static renderRows(program: Program, i: number): JSX.Element[] | null {
if (!program) {
return null;
}
const { name, running, enabled, schedule, sequence } = program;
const sequenceItems = sequence.map((item, index) => (
Section {item.section + 1 + ""} for
{item.duration.minutes}M {item.duration.seconds}S
));
return [(
{"" + (i + 1)}
{name}
{running ? "Running" : "Not running"}
{enabled ? "Enabled" : "Not enabled"}
), (
)];
}
render() {
const programRows = Array.prototype.concat.apply([],
this.props.programs.map(ProgramTable.renderRows));
return (
Programs
#
Name
Running?
Enabled?
{programRows}
);
}
}