@@ -50,6 +50,9 @@ export function Retract({
50
50
const [ speed , setSpeed ] = useState < number | null > (
51
51
retractSettings ?. speed ?? null
52
52
)
53
+ const [ delayDuration , setDelayDuration ] = useState < number | null > (
54
+ retractSettings ?. delayDuration ?? null
55
+ )
53
56
const [ position , setPosition ] = useState < number | null > (
54
57
retractSettings ?. positionFromBottom ?? null
55
58
)
@@ -64,36 +67,48 @@ export function Retract({
64
67
}
65
68
66
69
const handleClickSaveOrContinue = ( ) : void => {
67
- if ( currentStep === 1 ) {
68
- setCurrentStep ( 2 )
69
- }
70
- if ( currentStep === 2 ) {
71
- if ( speed !== null && position !== null ) {
72
- dispatch ( {
73
- type : action ,
74
- retractSettings : {
75
- speed : speed ,
76
- positionFromBottom : position ,
77
- } ,
78
- } )
79
- trackEventWithRobotSerial ( {
80
- name : ANALYTICS_QUICK_TRANSFER_SETTING_SAVED ,
81
- properties : {
82
- setting : `Retract_${ kind } ` ,
83
- } ,
84
- } )
85
- onBack ( )
86
- }
70
+ switch ( currentStep ) {
71
+ case 1 :
72
+ setCurrentStep ( 2 )
73
+ break
74
+ case 2 :
75
+ setCurrentStep ( 3 )
76
+ break
77
+ case 3 :
78
+ if ( speed !== null && position !== null && delayDuration !== null ) {
79
+ dispatch ( {
80
+ type : action ,
81
+ retractSettings : {
82
+ speed,
83
+ delayDuration,
84
+ positionFromBottom : position ,
85
+ } ,
86
+ } )
87
+ trackEventWithRobotSerial ( {
88
+ name : ANALYTICS_QUICK_TRANSFER_SETTING_SAVED ,
89
+ properties : {
90
+ setting : `Retract_${ kind } ` ,
91
+ } ,
92
+ } )
93
+ onBack ( )
94
+ }
95
+ break
87
96
}
88
97
}
98
+
89
99
const setSaveOrContinueButtonText =
90
- currentStep === 1 ? t ( 'shared:continue' ) : t ( 'shared:save' )
100
+ currentStep === 1 || currentStep === 2
101
+ ? t ( 'shared:continue' )
102
+ : t ( 'shared:save' )
91
103
92
104
let buttonIsDisabled = false
93
105
if ( speed == null && currentStep === 1 ) {
94
106
buttonIsDisabled = true
95
107
}
96
- if ( position == null && currentStep === 2 ) {
108
+ if ( delayDuration == null && currentStep === 2 ) {
109
+ buttonIsDisabled = true
110
+ }
111
+ if ( position == null && currentStep === 3 ) {
97
112
buttonIsDisabled = true
98
113
}
99
114
@@ -123,10 +138,12 @@ export function Retract({
123
138
< RetractSettingComponent
124
139
kind = { kind }
125
140
state = { state }
126
- setSpeed = { setSpeed }
127
- setPosition = { setPosition }
128
141
speed = { speed }
142
+ setSpeed = { setSpeed }
143
+ delayDuration = { delayDuration }
144
+ setDelayDuration = { setDelayDuration }
129
145
position = { position }
146
+ setPosition = { setPosition }
130
147
currentStep = { currentStep }
131
148
/>
132
149
</ Flex >
@@ -138,8 +155,10 @@ export function Retract({
138
155
interface RetractSettingComponentProps {
139
156
kind : FlowRateKind
140
157
state : QuickTransferSummaryState
141
- setSpeed : ( speed : number ) => void
142
- setPosition : ( position : number ) => void
158
+ setSpeed : ( speed : number | null ) => void
159
+ setPosition : ( position : number | null ) => void
160
+ delayDuration : number | null
161
+ setDelayDuration : ( delayDuration : number | null ) => void
143
162
speed : number | null
144
163
position : number | null
145
164
currentStep : number
@@ -150,6 +169,8 @@ function RetractSettingComponent({
150
169
state,
151
170
speed,
152
171
setSpeed,
172
+ delayDuration,
173
+ setDelayDuration,
153
174
position,
154
175
setPosition,
155
176
currentStep,
@@ -193,6 +214,33 @@ function RetractSettingComponent({
193
214
} )
194
215
: null
195
216
217
+ const handleSpeedChange = ( userInput : string ) : void => {
218
+ if ( userInput === '' ) {
219
+ setSpeed ( null )
220
+ } else {
221
+ const parsedValue = Number ( userInput )
222
+ setSpeed ( ! isNaN ( parsedValue ) ? parsedValue : null )
223
+ }
224
+ }
225
+
226
+ const handleDelayDurationChange = ( userInput : string ) : void => {
227
+ if ( userInput === '' ) {
228
+ setDelayDuration ( null )
229
+ } else {
230
+ const parsedValue = Number ( userInput )
231
+ setDelayDuration ( ! isNaN ( parsedValue ) ? parsedValue : null )
232
+ }
233
+ }
234
+
235
+ const handlePositionChange = ( userInput : string ) : void => {
236
+ if ( userInput === '' ) {
237
+ setPosition ( null )
238
+ } else {
239
+ const parsedValue = Number ( userInput )
240
+ setPosition ( ! isNaN ( parsedValue ) ? parsedValue : null )
241
+ }
242
+ }
243
+
196
244
const speedSetting = ( ) : JSX . Element => {
197
245
return (
198
246
< >
@@ -219,10 +267,43 @@ function RetractSettingComponent({
219
267
< NumericalKeyboard
220
268
key = { `${ kind } _speed_keyboard` }
221
269
keyboardRef = { keyboardRef }
270
+ isDecimal
222
271
initialValue = { String ( speed ?? '' ) }
223
- onChange = { e => {
224
- setSpeed ( Number ( e ) )
225
- } }
272
+ onChange = { handleSpeedChange }
273
+ />
274
+ </ Flex >
275
+ </ >
276
+ )
277
+ }
278
+
279
+ const delayDurationSetting = ( ) : JSX . Element => {
280
+ return (
281
+ < >
282
+ < Flex
283
+ width = "30.5rem"
284
+ height = "100%"
285
+ gridGap = { SPACING . spacing24 }
286
+ flexDirection = { DIRECTION_COLUMN }
287
+ marginTop = { SPACING . spacing68 }
288
+ >
289
+ < InputField
290
+ type = "number"
291
+ value = { delayDuration }
292
+ title = { t ( 'delay_duration_s' ) }
293
+ readOnly
294
+ />
295
+ </ Flex >
296
+ < Flex
297
+ paddingX = { SPACING . spacing24 }
298
+ height = "21.25rem"
299
+ marginTop = "7.75rem"
300
+ >
301
+ < NumericalKeyboard
302
+ key = { `${ kind } _delay_duration_keyboard` }
303
+ keyboardRef = { keyboardRef }
304
+ isDecimal
305
+ initialValue = { String ( delayDuration ?? '' ) }
306
+ onChange = { handleDelayDurationChange }
226
307
/>
227
308
</ Flex >
228
309
</ >
@@ -256,15 +337,12 @@ function RetractSettingComponent({
256
337
paddingX = { SPACING . spacing24 }
257
338
height = "21.25rem"
258
339
marginTop = "7.75rem"
259
- borderRadius = "0"
260
340
>
261
341
< NumericalKeyboard
262
342
key = { `${ kind } _position_keyboard` }
263
343
keyboardRef = { keyboardRef }
264
344
initialValue = { String ( position ?? '' ) }
265
- onChange = { e => {
266
- setPosition ( Number ( e ) )
267
- } }
345
+ onChange = { handlePositionChange }
268
346
/>
269
347
</ Flex >
270
348
</ >
@@ -275,6 +353,8 @@ function RetractSettingComponent({
275
353
case 1 :
276
354
return speedSetting ( )
277
355
case 2 :
356
+ return delayDurationSetting ( )
357
+ case 3 :
278
358
return positionSetting ( )
279
359
default :
280
360
console . error ( 'step not found' )
0 commit comments