1
1
import React from 'react' ;
2
2
import Link from 'next/link' ;
3
- import { Card , Button , Divider , Form , Message } from 'semantic-ui-react' ;
3
+ import { Card , Button , Divider } from 'semantic-ui-react' ;
4
4
5
- import { baseEventsURL , indexPageEventURL , subscribeURL } from '../utils/urls' ;
5
+ import { baseEventsURL , indexPageEventURL } from '../utils/urls' ;
6
6
import RowEvent from '../components/row-events' ;
7
7
import publicPage from '../hocs/public-page' ;
8
+ import Subscribe from '../components/subscribe' ;
8
9
9
10
const indexPageLearns = [
10
11
{
@@ -53,10 +54,6 @@ const indexPageLearns = [
53
54
class Home extends React . Component {
54
55
state = {
55
56
indexPageEvent : '' ,
56
- subscribersEmail : '' ,
57
- submittingEmail : false ,
58
- emailSubmittingError : '' ,
59
- subscriberEmailPosted : false ,
60
57
} ;
61
58
62
59
async componentDidMount ( ) {
@@ -71,56 +68,6 @@ class Home extends React.Component {
71
68
}
72
69
}
73
70
74
- handleChange = event => {
75
- this . setState ( {
76
- subscribersEmail : event . target . value ,
77
- emailSubmittingError : '' ,
78
- } ) ;
79
- } ;
80
-
81
- handleSubmit = ( ) => {
82
- this . setState ( { emailSubmittingError : '' } ) ;
83
- const emailRegx = / ^ ( ( [ ^ < > ( ) [ \] \\ . , ; : \s @ " ] + ( \. [ ^ < > ( ) [ \] \\ . , ; : \s @ " ] + ) * ) | ( " .+ " ) ) @ ( ( \[ [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } \. [ 0 - 9 ] { 1 , 3 } ] ) | ( ( [ a - z A - Z \- 0 - 9 ] + \. ) + [ a - z A - Z ] { 2 , } ) ) $ / ;
84
- const email = this . state . subscribersEmail ;
85
- if ( ! email ) {
86
- this . setState ( {
87
- emailSubmittingError : 'Please enter a email' ,
88
- } ) ;
89
- return ;
90
- }
91
- if ( ! emailRegx . test ( email ) ) {
92
- this . setState ( {
93
- emailSubmittingError : 'Please enter a valid email' ,
94
- } ) ;
95
- return ;
96
- }
97
- this . postSubscriberEmail ( email ) ;
98
- } ;
99
-
100
- async postSubscriberEmail ( subscribersEmail ) {
101
- await this . setState ( { submittingEmail : true } ) ;
102
- const postSubscriberEmailRequest = await fetch (
103
- `${ baseEventsURL } ${ subscribeURL } ` ,
104
- {
105
- method : 'post' ,
106
- headers : { 'Content-Type' : 'application/json' } ,
107
- body : JSON . stringify ( { email : subscribersEmail } ) ,
108
- } ,
109
- ) ;
110
- if ( postSubscriberEmailRequest . status === 200 ) {
111
- this . setState ( {
112
- subscriberEmailPosted : true ,
113
- submittingEmail : false ,
114
- emailSubmittingError : '' ,
115
- } ) ;
116
- } else {
117
- this . setState ( {
118
- submittingEmail : false ,
119
- emailSubmittingError : 'Submission Failed Try Again.' ,
120
- } ) ;
121
- }
122
- }
123
-
124
71
render ( ) {
125
72
return (
126
73
< div >
@@ -238,46 +185,7 @@ class Home extends React.Component {
238
185
</ Button . Group >
239
186
</ div >
240
187
</ section >
241
- < section className = "update" >
242
- < div className = "container update_container" >
243
- < h3 className = "taglines" >
244
- We are constanly updating our platform.< br /> If you would like
245
- to stay informed about our updates, drop you email.
246
- </ h3 >
247
- < div className = "update_content" >
248
- { this . state . subscriberEmailPosted ? (
249
- < h2 > Thank you, we will keep you posted</ h2 >
250
- ) : (
251
- < Form
252
- onSubmit = { this . handleSubmit }
253
- error = { this . state . emailSubmittingError }
254
- >
255
- < Form . Group >
256
- < Form . Input
257
- placeholder = "Enter email address"
258
- name = "email"
259
- value = { this . state . subscribersEmail }
260
- onChange = { this . handleChange }
261
- disabled = { this . state . submittingEmail }
262
- />
263
- < Form . Button
264
- loading = { this . state . submittingEmail }
265
- color = "pink"
266
- content = "Subscribe"
267
- />
268
- </ Form . Group >
269
- { this . state . emailSubmittingError && (
270
- < Message
271
- error
272
- header = "Action Forbidden"
273
- content = { this . state . emailSubmittingError }
274
- />
275
- ) }
276
- </ Form >
277
- ) }
278
- </ div >
279
- </ div >
280
- </ section >
188
+ < Subscribe />
281
189
</ main >
282
190
< style jsx > { `
283
191
main {
@@ -333,17 +241,7 @@ class Home extends React.Component {
333
241
.discord .container {
334
242
background: #FAFAFA;
335
243
}
336
- .update_container{
337
- background-color: #f6f6f6;
338
- }
339
- .update_content {
340
- display: flex;
341
- flex-direction: row;
342
- flex-wrap: wrap;
343
- justify-content: center;
344
- align-content: center;
345
- align-items: center;
346
- }
244
+
347
245
` } </ style >
348
246
</ div >
349
247
) ;
0 commit comments