Repository navigation
Expand file tree
/
Copy pathForgotPasswordForm.tsx
More file actions
71 lines (59 loc) · 1.75 KB
/
Copy pathForgotPasswordForm.tsx
File metadata and controls
71 lines (59 loc) · 1.75 KB
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import "./assets/forms.scss";
import { AppForm } from "@getpack/core-components";
import { I18nContextConsumer } from "@getpack/core-locales";
import { memoize } from "lodash-es";
import React from "react";
import { TextFormField } from "../form/TextFormField";
export interface ForgotPasswordFormValues {
number: string;
}
type RegisterFormErrors = {
[P in keyof ForgotPasswordFormValues]?: null | string | boolean
};
interface Props {
submitError?: Error;
initialValues?: Partial<ForgotPasswordFormValues>;
submitting: boolean;
onSubmit: (values: ForgotPasswordFormValues) => void;
}
const validateForm = memoize(ctx => (values: ForgotPasswordFormValues) => {
const errors: RegisterFormErrors = {};
if (!values.number) {
errors.number = ctx.RegisterFormValidMobileNumber;
}
return errors;
});
export function ForgotPasswordForm(props: Props) {
const { submitting } = props;
return (
<I18nContextConsumer>
{ctx => (
<AppForm
onSubmit={props.onSubmit}
validate={validateForm(ctx)}
initialValues={props.initialValues}
render={({ handleSubmit }) => (
<form
className="d-flex flex-column auth-form"
onSubmit={handleSubmit}
>
<TextFormField
name="number"
className="mb-3"
disabled={submitting}
label={ctx.GenericMobileNumber}
/>
<button
type="submit"
disabled={submitting}
className="btn btn-lg btn-secondary mb-5 text-uppercase"
>
{ctx.GenericContinue}
</button>
</form>
)}
/>
)}
</I18nContextConsumer>
);
}