@@ -10,8 +10,8 @@ import toast from "../../../../services/toast";
1010type TimeSelectorScale = "seconds" | "minutes" | "hours" | "days" ;
1111
1212interface TimeSelectorProps {
13+ id ?: string ;
1314 name : string ;
14- label : string ;
1515 optionValueId : keyof OptionDefinitions ;
1616 optionTimeScaleId : keyof OptionDefinitions ;
1717 includedTimeScales ?: Set < TimeSelectorScale > ;
@@ -23,7 +23,7 @@ interface TimeScaleInfo {
2323 unit : string ;
2424}
2525
26- export default function TimeSelector ( { name , label , includedTimeScales, optionValueId, optionTimeScaleId, minimumSeconds } : TimeSelectorProps ) {
26+ export default function TimeSelector ( { id , name , includedTimeScales, optionValueId, optionTimeScaleId, minimumSeconds } : TimeSelectorProps ) {
2727 const values = useMemo ( ( ) => {
2828 const values : TimeScaleInfo [ ] = [ ] ;
2929 const timeScalesWithDefault = includedTimeScales ?? new Set ( [ "seconds" , "minutes" , "hours" , "days" ] ) ;
@@ -48,38 +48,37 @@ export default function TimeSelector({ name, label, includedTimeScales, optionVa
4848 } , [ value , scale ] ) ;
4949
5050 return (
51- < FormGroup label = { label } >
52- < div class = "d-flex gap-2" >
53- < FormTextBox
54- name = { name }
55- type = "number" min = { 0 } step = { 1 } required
56- currentValue = { displayedTime } onChange = { ( value , validity ) => {
57- if ( ! validity . valid ) {
58- toast . showError ( t ( "time_selector.invalid_input" ) ) ;
59- return false ;
60- }
51+ < div class = "d-flex gap-2" >
52+ < FormTextBox
53+ id = { id }
54+ name = { name }
55+ type = "number" min = { 0 } step = { 1 } required
56+ currentValue = { displayedTime } onChange = { ( value , validity ) => {
57+ if ( ! validity . valid ) {
58+ toast . showError ( t ( "time_selector.invalid_input" ) ) ;
59+ return false ;
60+ }
6161
62- let time = parseInt ( value , 10 ) ;
63- const minimumSecondsOrDefault = ( minimumSeconds ?? 0 ) ;
64- const newTime = convertTime ( time , scale ) . toOption ( ) ;
62+ let time = parseInt ( value , 10 ) ;
63+ const minimumSecondsOrDefault = ( minimumSeconds ?? 0 ) ;
64+ const newTime = convertTime ( time , scale ) . toOption ( ) ;
6565
66- if ( Number . isNaN ( time ) || newTime < ( minimumSecondsOrDefault ) ) {
67- toast . showError ( t ( "time_selector.minimum_input" , { minimumSeconds : minimumSecondsOrDefault } ) ) ;
68- time = minimumSecondsOrDefault ;
69- }
66+ if ( Number . isNaN ( time ) || newTime < ( minimumSecondsOrDefault ) ) {
67+ toast . showError ( t ( "time_selector.minimum_input" , { minimumSeconds : minimumSecondsOrDefault } ) ) ;
68+ time = minimumSecondsOrDefault ;
69+ }
7070
71- setValue ( newTime ) ;
72- } }
73- />
71+ setValue ( newTime ) ;
72+ } }
73+ />
7474
75- < FormSelect
76- values = { values }
77- keyProperty = "value" titleProperty = "unit"
78- style = { { width : "auto" } }
79- currentValue = { scale } onChange = { setScale }
80- />
81- </ div >
82- </ FormGroup >
75+ < FormSelect
76+ values = { values }
77+ keyProperty = "value" titleProperty = "unit"
78+ style = { { width : "auto" } }
79+ currentValue = { scale } onChange = { setScale }
80+ />
81+ </ div >
8382 )
8483}
8584
0 commit comments