11import React , { FC , useContext , useState } from 'react'
22
33import {
4+ ButtonType ,
45 Overlay ,
56 SlideToggle ,
67 InputLabel ,
@@ -41,7 +42,11 @@ const NotificationSettingsOverlay: FC<Props> = ({onHideOverlay}) => {
4142 )
4243 const [ hasThresholdError , setHasThresholdError ] = useState < boolean > ( false )
4344
44- const onSubmitThreshold = ( ) => {
45+ const [ notifyEmail , setNotifyEmail ] = useState ( billingSettings . notifyEmail )
46+
47+ const onSubmitThreshold = e => {
48+ e . preventDefault ( )
49+
4550 if ( `${ balanceThreshold } ` . includes ( '.' ) ) {
4651 setHasThresholdError ( true )
4752 return
@@ -58,8 +63,6 @@ const NotificationSettingsOverlay: FC<Props> = ({onHideOverlay}) => {
5863 onHideOverlay ( )
5964 }
6065
61- const [ notifyEmail , setNotifyEmail ] = useState ( billingSettings . notifyEmail )
62-
6366 const onToggleChange = ( ) => {
6467 setIsNotifyActive ( prevState => ! prevState )
6568 }
@@ -87,8 +90,8 @@ const NotificationSettingsOverlay: FC<Props> = ({onHideOverlay}) => {
8790 title = "Notification Settings"
8891 onDismiss = { onHideOverlay }
8992 />
90- < Overlay . Body >
91- < Form >
93+ < Form onSubmit = { onSubmitThreshold } >
94+ < Overlay . Body >
9295 < Form . Element label = "" >
9396 < FlexBox
9497 direction = { FlexDirection . Row }
@@ -111,7 +114,7 @@ const NotificationSettingsOverlay: FC<Props> = ({onHideOverlay}) => {
111114 < >
112115 < Form . Element label = "Email Address" >
113116 < Input
114- type = { InputType . Text }
117+ type = { InputType . Email }
115118 value = { notifyEmail }
116119 onChange = { onEmailChange }
117120 />
@@ -131,18 +134,18 @@ const NotificationSettingsOverlay: FC<Props> = ({onHideOverlay}) => {
131134 </ Form . Element >
132135 </ >
133136 ) : null }
134- </ Form >
135- </ Overlay . Body >
136- < Overlay . Footer >
137- < Button
138- color = { ComponentColor . Primary }
139- onClick = { onSubmitThreshold }
140- text = "Save"
141- size = { ComponentSize . Small }
142- status = { saveStatus }
143- testID = "save-settings--button"
144- / >
145- </ Overlay . Footer >
137+ </ Overlay . Body >
138+ < Overlay . Footer >
139+ < Button
140+ type = { ButtonType . Submit }
141+ color = { ComponentColor . Primary }
142+ text = "Save"
143+ size = { ComponentSize . Small }
144+ status = { saveStatus }
145+ testID = "save-settings--button"
146+ />
147+ </ Overlay . Footer >
148+ </ Form >
146149 </ Overlay . Container >
147150 </ Overlay >
148151 )
0 commit comments