@@ -8,18 +8,7 @@ function ApiKey() {
8
8
const dispatch = useDispatch ( )
9
9
const serverError = useSelector ( ( state ) => state . licenseReducer . error )
10
10
const isLoading = useSelector ( ( state ) => state . licenseReducer . isLoading )
11
- const isLicenceAPIkeyValid = useSelector (
12
- ( state ) => state . licenseReducer . isLicenceAPIkeyValid ,
13
- )
14
- const params = {
15
- apiKey : '' ,
16
- productCode : '' ,
17
- sharedKey : '' ,
18
- managementKey : '' ,
19
- }
20
11
21
- const [ values , setValues ] = useState ( params )
22
- const [ error , setError ] = useState ( params )
23
12
const [ submitted , setIsSubmitted ] = useState ( false )
24
13
const [ licenseKey , setLicenseKey ] = useState ( '' )
25
14
@@ -31,39 +20,6 @@ function ApiKey() {
31
20
} ) )
32
21
}
33
22
34
- useEffect ( ( ) => {
35
- checkForError ( )
36
- } , [ JSON . stringify ( values ) ] )
37
- const checkForError = ( ) => {
38
- let err = false
39
- for ( const i in values ) {
40
- if ( values [ i ] == '' ) {
41
- err = true
42
- setError ( ( prevState ) => ( {
43
- ...prevState ,
44
- [ i ] : 'This field is required' ,
45
- } ) )
46
- } else {
47
- setError ( ( prevState ) => ( {
48
- ...prevState ,
49
- [ i ] : '' ,
50
- } ) )
51
- }
52
- }
53
- return err
54
- }
55
-
56
- const submitValues = ( ) => {
57
- setIsSubmitted ( true )
58
- if ( ! checkForError ( ) ) {
59
- dispatch ( checkUserApi ( values ) )
60
- }
61
- console . log ( values )
62
- }
63
- useEffect ( ( ) => {
64
- setIsSubmitted ( false )
65
- } , [ isLicenceAPIkeyValid ] )
66
-
67
23
const submitLicenseKey = ( ) => {
68
24
setIsSubmitted ( true )
69
25
if ( licenseKey != '' ) {
@@ -104,77 +60,6 @@ function ApiKey() {
104
60
</ div >
105
61
</ div >
106
62
107
- { ! isLicenceAPIkeyValid ? (
108
- < div className = "row" >
109
- < div className = "col-md-8 mx-auto" >
110
- < label > Api Key*</ label >
111
- < input
112
- type = "text"
113
- className = {
114
- submitted && error . apiKey
115
- ? 'border-danger form-control'
116
- : 'form-control'
117
- }
118
- value = { values . apiKey }
119
- name = "apiKey"
120
- onChange = { handleChange }
121
- />
122
- < div className = "text-danger" > { submitted && error . apiKey } </ div >
123
- < label > Product Code*</ label >
124
- < input
125
- type = "text"
126
- className = {
127
- submitted && error . productCode
128
- ? 'border-danger form-control'
129
- : 'form-control'
130
- }
131
- value = { values . productCode }
132
- name = "productCode"
133
- onChange = { handleChange }
134
- />
135
- < div className = "text-danger" >
136
- { submitted && error . productCode }
137
- </ div >
138
- < label > Shared Key*</ label >
139
- < input
140
- type = "text"
141
- className = {
142
- submitted && error . sharedKey
143
- ? 'border-danger form-control'
144
- : 'form-control'
145
- }
146
- value = { values . sharedKey }
147
- name = "sharedKey"
148
- onChange = { handleChange }
149
- />
150
- < div className = "text-danger" > { submitted && error . sharedKey } </ div >
151
- < label > Management Key*</ label >
152
- < input
153
- type = "text"
154
- className = {
155
- submitted && error . managementKey
156
- ? 'border-danger form-control'
157
- : 'form-control'
158
- }
159
- value = { values . managementKey }
160
- name = "managementKey"
161
- onChange = { handleChange }
162
- />
163
- < div className = "text-danger" >
164
- { submitted && error . managementKey }
165
- </ div >
166
- < button
167
- type = "button"
168
- disabled = { isLoading }
169
- onClick = { ( ) => submitValues ( ) }
170
- className = "btn mt-3"
171
- style = { { backgroundColor : '#00a361' , color : 'white' } }
172
- >
173
- { isLoading ? 'Submitting please wait...' : 'Submit' }
174
- </ button >
175
- </ div >
176
- </ div >
177
- ) : (
178
63
< div className = "row" >
179
64
< div className = "col-md-8 mx-auto" >
180
65
< label > License Key*</ label >
@@ -203,7 +88,6 @@ function ApiKey() {
203
88
</ button >
204
89
</ div >
205
90
</ div >
206
- ) }
207
91
</ div >
208
92
</ div >
209
93
)
0 commit comments