-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathLoginInitLoaded.tsx
More file actions
76 lines (70 loc) · 1.82 KB
/
LoginInitLoaded.tsx
File metadata and controls
76 lines (70 loc) · 1.82 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
72
73
74
75
76
import React, { useRef } from 'react';
import useLoginInputEventLow from '../../../hooks/useLoginInputEventLow';
import useShared from '../../../hooks/useShared';
import InputField from '../../shared/InputField';
import { LinkButton } from '../../shared/LinkButton';
import { Notification } from '../../shared/Notification';
import { PrimaryButton } from '../../shared/PrimaryButton';
interface Props {
isLoading: boolean;
error: string | undefined;
autoComplete: string;
enableEventLow?: boolean;
onSignupClick?: () => void;
handleSubmit: () => void;
handleIdentifierUpdate: (v: string) => void;
}
const LoginInitLoaded = ({
isLoading,
error,
onSignupClick,
autoComplete,
enableEventLow = false,
handleSubmit,
handleIdentifierUpdate,
}: Props) => {
const inputRef = useRef<HTMLInputElement>(null);
const { getConnectService } = useShared();
useLoginInputEventLow({
inputRef,
connectService: getConnectService(),
enabled: enableEventLow,
});
return (
<>
{error ? (
<Notification
message={error}
className='cb-error-notification'
/>
) : null}
<InputField
name='email'
label='Email address'
type='email'
autoComplete={autoComplete}
autoFocus={true}
placeholder=''
ref={inputRef}
onChange={e => handleIdentifierUpdate(e.target.value)}
/>
<PrimaryButton
type='submit'
className='cb-login-init-submit'
isLoading={isLoading}
onClick={handleSubmit}
>
Login
</PrimaryButton>
{onSignupClick && (
<LinkButton
onClick={() => onSignupClick?.()}
className='cb-login-init-signup'
>
Signup for an account
</LinkButton>
)}
</>
);
};
export default LoginInitLoaded;