From 6738cb883c37f2e388f1c86c84bd4c34a98699bd Mon Sep 17 00:00:00 2001 From: Determinant Date: Thu, 14 Feb 2019 18:28:06 -0500 Subject: ... --- src/Settings.tsx | 61 ++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 24 deletions(-) (limited to 'src/Settings.tsx') diff --git a/src/Settings.tsx b/src/Settings.tsx index 1626a7a..e08a89b 100644 --- a/src/Settings.tsx +++ b/src/Settings.tsx @@ -1,6 +1,6 @@ import React from 'react'; import PropTypes from 'prop-types'; -import { withStyles } from '@material-ui/core/styles'; +import { Theme, withStyles } from '@material-ui/core/styles'; import CssBaseline from '@material-ui/core/CssBaseline'; import Typography from '@material-ui/core/Typography'; import Button from '@material-ui/core/Button'; @@ -30,7 +30,7 @@ import MenuItem from '@material-ui/core/MenuItem'; import Select from '@material-ui/core/Select'; import { Duration } from './duration'; -const styles = theme => ({ +const styles = (theme: Theme) => ({ tableHead: { verticalAlign: 'top', textAlign: 'right', @@ -59,12 +59,19 @@ const CompactListItem = withStyles(theme => ({ }, }))(ListItem); -class TrackedPeriod extends React.Component { - valueOnChange = (old, onChange) => event => { +class TrackedPeriod extends React.Component<{ + name: string + fromDuration: Duration, + toDuration: Duration, + nameOnChange: (name: string) => void, + fromOnChange: (d: Duration) => void, + toOnChange: (d: Duration) => void + }>{ + valueOnChange = (old: Duration, onChange: (d: Duration) => void) => (event: any) => { onChange(new Duration(event.target.value, old.unit)); } - unitOnChange = (old, onChange) => event => { + unitOnChange = (old: Duration, onChange: (d: Duration) => void) => (event: any) => { onChange(new Duration(old.value, event.target.value)); } @@ -78,7 +85,7 @@ class TrackedPeriod extends React.Component { } }; - static toValue(value) { + static toValue(value: any) { if (isNaN(value)) return null; let v = parseInt(value, 10); if (v < 0 || v > 999) return null; @@ -86,7 +93,7 @@ class TrackedPeriod extends React.Component { } render() { - let { classes, fromDuration, toDuration, nameOnChange, fromOnChange, toOnChange, name } = this.props; + let { fromDuration, toDuration, nameOnChange, fromOnChange, toOnChange, name } = this.props; let units = [ Day(s), Week(s), @@ -95,19 +102,19 @@ class TrackedPeriod extends React.Component { return ( nameOnChange(event.target.value)}/>: from ago to