-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathEnterPhone.jsx
38 lines (35 loc) · 1.15 KB
/
EnterPhone.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import SubmitButton from "../components/SubmitButton";
import BackButton from "../components/BackButton";
import ErrorMessage from "../components/ErrorMessage";
import PhoneNumberInput from "../components/PhoneNumberInput";
/**
* A view prompting the user to enter a phone number to send a code to.
*
* @param {object} props
* @param {boolean} props.allowBack - if true, show a Back button
* @param {object} error - a Userfront error to display
* @param {function} onEvent
*/
const EnterPhone = ({ onEvent, allowBack, error }) => {
const handleSubmit = (event) => {
event.preventDefault();
onEvent({
type: "submit",
phoneNumber: event.target.elements.phoneNumber.value,
});
};
return (
<form onSubmit={handleSubmit} className="userfront-form">
<div className="userfront-form-row">
<label htmlFor="phoneNumber">Mobile phone number</label>
<PhoneNumberInput name="phoneNumber" />
</div>
<ErrorMessage error={error} />
<div className="userfront-button-row">
{allowBack && <BackButton onEvent={onEvent} />}
<SubmitButton />
</div>
</form>
);
};
export default EnterPhone;