@@ -26,6 +26,9 @@ import Validator from "../../react-happy-validator/index";
26
26
import { withFormik } from "formik" ;
27
27
import * as Yup from "yup" ;
28
28
import { API } from "../../apis/CONFIG" ;
29
+ import axios from "axios" ;
30
+ import EmailVerify from "../../pages/EmailVerify/email-verify" ;
31
+ import { Redirect } from "react-router-dom" ;
29
32
30
33
const styles = theme => ( {
31
34
"@global" : {
@@ -66,18 +69,6 @@ class SignUpPage extends Component {
66
69
} ;
67
70
}
68
71
69
- // changeHandler = event => {
70
- // this.setState({ [event.target.name]: event.target.value });
71
- // };
72
-
73
- // handleSubmit = e => {
74
- // e.preventDefault();
75
- // alert(this.state.firstName);
76
- // this.props.onSubmit(this.state, () => {
77
- // window.location("/dash");
78
- // });
79
- // };
80
-
81
72
render ( ) {
82
73
const {
83
74
classes,
@@ -264,45 +255,42 @@ const Form = withFormik({
264
255
. required ( "تکرار کلمه عبور را وارد کنید !" )
265
256
. oneOf ( [ Yup . ref ( "password" ) ] , "کلمه عبور و تکرار آن مطابقت ندارند !" )
266
257
} ) ,
267
-
258
+
268
259
handleSubmit : ( values , { setSubmitting } ) => {
269
- fetch ( API . BASE + "/api/user/register" , {
270
- method : "POST" ,
271
- mode : "no-cors" ,
260
+ let setResp = this ;
261
+ const user = {
262
+ firstName : values . firstName ,
263
+ lastName : values . lastName ,
264
+ password : values . password ,
265
+ Email : values . email
266
+ } ;
267
+
268
+ fetch ( "http://localhost:17057/api/user/Register" , {
269
+ method : "post" ,
270
+ //mode: "no-cors",
272
271
headers : {
273
272
Accept : "application/json" ,
274
- "Content-Type" : "application/x-www-form-urlencoded "
273
+ "Content-Type" : "application/json "
275
274
} ,
276
- body : `FirstName='${ values . firstName } '
277
- &LastName='${ values . lastName } '
278
- &Email='${ values . Email } '
279
- &Password='${ values . password } '`
280
- //body: JSON.stringify({
281
- // FirstName: "amir",
282
- // secondParam: "yourOtherValue"
283
- //})
284
- } )
285
- . then ( response => {
286
- alert ( response . status ) ;
287
- console . log ( response ) ;
288
- if ( response . status >= 200 && response . status < 300 && response . ok ) {
289
- //dispatch(registerSuccess(userData));
290
- alert (
291
- "ایمیلی برای شما به آدرس " +
292
- values . Email +
293
- " فرستاده شد. برای ورود روی لینک " +
294
- "فعال سازی کلیک کنید یا کد فعال سازی را در فرم زیر وارد کنید. ویرایش ایمیل"
295
- ) ;
296
- } else {
297
- const error = new Error ( response . statusText ) ;
298
- error . response = response ;
299
- //dispatch(loginError(error));
300
- throw error ;
301
- }
275
+ body : JSON . stringify ( {
276
+ Email : "ramin@gmail.com" ,
277
+ Password : "dfgdfg" ,
278
+ FirstName : "FirstName" ,
279
+ LastName : "LastName"
302
280
} )
303
- . catch ( error => {
304
- console . log ( "request failed" , error ) ;
305
- } ) ;
281
+ } ) . then ( response => {
282
+ if ( response . status >= 200 && response . status < 300 && response . ok ) {
283
+ //dispatch(registerSuccess(userData));
284
+ alert ( response . status ) ;
285
+ return < EmailVerify names = { [ 'foo' , 'bar' ] } isOpen = { true } num = { 10 } />
286
+
287
+ } else {
288
+ const error = new Error ( response . statusText ) ;
289
+ error . response = response ;
290
+ //dispatch(loginError(error));
291
+ throw error ;
292
+ }
293
+ } ) ;
306
294
}
307
295
} ) ( SignUpPage ) ;
308
296
0 commit comments