You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
2 years ago
|
import { isEmpty } from 'lodash';
|
||
|
import React from 'react';
|
||
|
import { TimerOptionsArray } from '../../../../../state/ducks/timerOptions';
|
||
|
import { PanelButtonGroup, PanelLabel } from '../../../../buttons/PanelButton';
|
||
|
import { PanelRadioButton } from '../../../../buttons/PanelRadioButton';
|
||
|
|
||
|
type TimerOptionsProps = {
|
||
|
options: TimerOptionsArray | null;
|
||
|
selected?: number;
|
||
|
setSelected: (value: number) => void;
|
||
|
disabled?: boolean;
|
||
|
};
|
||
|
|
||
|
export const TimeOptions = (props: TimerOptionsProps) => {
|
||
|
const { options, selected, setSelected, disabled } = props;
|
||
|
|
||
|
if (!options || isEmpty(options)) {
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<PanelLabel>{window.i18n('timer')}</PanelLabel>
|
||
|
<PanelButtonGroup>
|
||
|
{options.map((option: any) => (
|
||
|
<PanelRadioButton
|
||
|
key={option.name}
|
||
|
text={option.name}
|
||
|
value={option.name}
|
||
|
isSelected={selected === option.value}
|
||
|
onSelect={() => {
|
||
|
setSelected(option.value);
|
||
|
}}
|
||
|
noBackgroundColor={true}
|
||
|
disabled={disabled}
|
||
|
/>
|
||
|
))}
|
||
|
</PanelButtonGroup>
|
||
|
</>
|
||
|
);
|
||
|
};
|