Skip to content

Commit 2fcf6d1

Browse files
feat(ecommerce): Validate Email Addresses (#4043)
* ✨ Validate Email Addresses * ✨ Add Email Validation to Billing * ✨ Change to HTML Form Validation Co-authored-by: Dustin Eaton <deaton@influxdata.com>
1 parent 29abdc6 commit 2fcf6d1

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

src/billing/components/PayAsYouGo/NotificationSettingsOverlay.tsx

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React, {FC, useContext, useState} from 'react'
22

33
import {
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
)

src/checkout/CheckoutForm.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ const CheckoutForm: FC = () => {
6565
}
6666

6767
return (
68-
<Form noValidate onSubmit={onSubmit}>
68+
<Form onSubmit={onSubmit}>
6969
<AppWrapper type="funnel">
7070
<FunnelPage logo={<LogoWithCubo />} enableGraphic={true}>
7171
<h1

src/users/components/UserListInviteForm.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ import {
1414
Heading,
1515
HeadingElement,
1616
Input,
17+
InputType,
1718
Panel,
1819
} from '@influxdata/clockface'
19-
2020
import {gaEvent} from 'src/cloud/utils/reporting'
2121

2222
// Constants
@@ -69,6 +69,7 @@ const UserListInviteForm: FC = () => {
6969
placeholder="email address"
7070
onChange={onChangeInvitee}
7171
value={draftInvite.email}
72+
type={InputType.Email}
7273
required={true}
7374
/>
7475
</Form.Element>

0 commit comments

Comments
 (0)