import * as React from "react"; import { RegimenItem } from "../interfaces"; import * as moment from "moment"; import { duration } from "moment"; import { removeRegimenItem } from "../actions"; import { t } from "i18next"; interface RegimenItemListProps { items: RegimenItem[]; dispatch: Function; } export function RegimenItemList({ items, dispatch }: RegimenItemListProps) { let groups = _.groupBy(items, function(item: RegimenItem) { return Math.round(duration(item.time_offset).asDays()); }); let list = _.map(groups, function(innerItems: RegimenItem[], day: string) { return ; }); let display = list.length ? list : ; return

{ display }
; } function EmptyList({}) { return

{t("This regimen doesn't have any items!")}

{t(`You can add items by using the "bulk scheduler"`)}

; } interface RegimenItemStepProps { item: RegimenItem; dispatch: Function; } function RegimenItemStep({ item, dispatch }: RegimenItemStepProps) { let d = duration(item.time_offset); let time = moment({ hour: d.hours(), minute: d.minutes() }).format("h:mm a"); let klass = `${ item.sequence.color || "gray" }-block block-header regimen-event`; return
{ item.sequence.name } { time } dispatch(removeRegimenItem(item)) } />
; } interface RegimenItemDayGroupProps { day: string; items: RegimenItem[]; dispatch: Function; } function RegimenItemDayGroup({ day, items, dispatch }: RegimenItemDayGroupProps) { return
{ items.map(function(item, inx) { return ; }) }
; }