-
-
Notifications
You must be signed in to change notification settings - Fork 118
/
Copy pathindex.tsx
158 lines (147 loc) · 4.25 KB
/
index.tsx
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import React, { FunctionComponent } from 'react';
import { Link } from 'react-router-dom';
import { isEmpty } from '../../../../../../ignitus-Utilities/HelperFunctions/lodashHelpers';
import { FormProps } from '../../../types';
import { AppIcon } from '../../../../../../types/iconsTypes/iconEnums';
import * as A from '../../../styles';
export const Form: FunctionComponent<FormProps> = ({
role,
authenticationType,
alternateAuth,
authRedirectText,
state,
setState,
authenticationData,
handleSubmit,
}) => {
const { message, success } = authenticationData;
return (
<A.RightRow>
<A.LeftColumnOne>
<A.Logo name={AppIcon.IgnitusLogo} />
</A.LeftColumnOne>
{/* SIGNUP SUCCESS */}
{authenticationType === 'SignUp' && success && (
<A.Message type="success">
<A.Paragraph>
<strong>Success!</strong> Please login!.
</A.Paragraph>
</A.Message>
)}
{!success && !isEmpty(message) && (
<A.Message type="alert">
<A.Paragraph>{message}</A.Paragraph>
</A.Message>
)}
{state.emptyMessage && (
<A.Message type="alert">Please fill the form to proceed!</A.Message>
)}
{state.invalidEmail && (
<A.Message type="alert">
<A.Paragraph>
<strong>Please </strong> input a valid mail!
</A.Paragraph>
</A.Message>
)}
{state.equalmessage && (
<A.Message type="alert">
<A.Paragraph>
<strong>Password </strong> does not match the confirm password.!
</A.Paragraph>
</A.Message>
)}
<A.LeftColumnTwo>
<A.InputGroup>
{authenticationType === 'SignUp' && (
<>
<A.UsernameInput
name={AppIcon.AccountCircleIcon}
type="string"
state={state.userName}
placeholder="Username"
handleChange={userName => {
setState({
...state,
userName,
});
}}
/>
<A.EmailInput
name={AppIcon.MessageIcon}
type="string"
state={state.email}
placeholder="Email"
handleChange={email => {
setState({
...state,
email,
});
}}
/>
</>
)}
{authenticationType !== 'SignUp' && (
<A.EmailUsernameInput
name={AppIcon.AccountCircleIcon}
type="string"
state={state.email}
placeholder="Username or Email"
handleChange={email => {
setState({
...state,
email,
});
}}
/>
)}
<A.PasswordInput
placeholder="Password"
state={state.password}
handleChange={password => {
setState({
...state,
password,
});
}}
/>
{/* SIGNUP CONFIRM PASSWORD */}
{authenticationType === 'SignUp' && (
<>
<A.ConfirmPasswordInput
name={AppIcon.KeyIcon}
type="password"
state={state.confirmPassword}
placeholder="Confirm Password"
handleChange={confirmPassword => {
setState({
...state,
confirmPassword,
});
}}
/>
</>
)}
</A.InputGroup>
<A.ButtonContainer>
<A.Button
category="primary"
size="large"
onClick={e => handleSubmit(e)}
>
{' '}
{authenticationType} as {role}{' '}
</A.Button>
</A.ButtonContainer>
<A.Paragraph>
{authRedirectText}{' '}
<Link
to={`/${alternateAuth.toLocaleLowerCase()}/${role.toLocaleLowerCase()}`}
>
{' '}
{alternateAuth}
</Link>
</A.Paragraph>
</A.LeftColumnTwo>
</A.RightRow>
);
};