Skip to content

Commit 12e981f

Browse files
coderaminscoderamins
coderamins
authored and
coderamins
committed
234343
1 parent d6573c1 commit 12e981f

File tree

5 files changed

+188
-47
lines changed

5 files changed

+188
-47
lines changed

src/apis/sessions.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export function signup(userData) {
5454
// secondParam: "yourOtherValue"
5555
//})
5656
})
57-
.then(response => {
57+
.then(function(response) {
5858
alert(response.status);
5959
console.log(response);
6060
if (response.status >= 200 && response.status < 300 && response.ok) {

src/components/main.js

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import SignUpPage from "../pages/SignUpPage/SignUpPage.jsx";
1010
import PrivateRoute from "../components/PrivateRoute/PrivateRoute";
1111
import MainLayout from "../components/Layouts/MainLayout";
1212
import UserLayout from "../components/Layouts/UserLayout";
13+
import EmailVerify from "../pages/EmailVerify/email-verify";
1314

1415
const Main =() =>(
1516
<Switch>
@@ -18,6 +19,7 @@ const Main =() =>(
1819
<PrivateRoute path="/tutorials" component={Tutorials} layout={MainLayout} />
1920
<PrivateRoute path="/about" component={About} layout={MainLayout} />
2021
<PrivateRoute path="/contact" component={Contact} layout={MainLayout} />
22+
<Route exact path="/email-verify" component={EmailVerify} layout={EmailVerify} />
2123
<Route exact path="/signup" component={SignUpPage} layout={UserLayout} />
2224
<Route exact path="/Login" component={LoginPage} layout={UserLayout} />
2325
</Switch>

src/pages/EmailVerify/email-verify.js

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import React from "react";
2+
import clsx from "clsx";
3+
import { makeStyles } from "@material-ui/core/styles";
4+
import MenuItem from "@material-ui/core/MenuItem";
5+
import TextField from "@material-ui/core/TextField";
6+
import Grid from "@material-ui/core/Grid";
7+
import FormControl from "@material-ui/core/FormControl";
8+
import InputLabel from "@material-ui/core/InputLabel";
9+
import Input from "@material-ui/core/Input";
10+
import InputAdornment from "@material-ui/core/InputAdornment";
11+
import Paper from "@material-ui/core/Paper";
12+
import { createMuiTheme } from "@material-ui/core/styles";
13+
import { ThemeProvider } from "@material-ui/styles";
14+
import Icon from "@material-ui/core/Icon";
15+
import Button from "@material-ui/core/Button";
16+
import SendOutlined from "@material-ui/icons/SendOutlined";
17+
import NativeSelect from "@material-ui/core/NativeSelect";
18+
19+
import { create } from "jss";
20+
import rtl from "jss-rtl";
21+
import { StylesProvider, jssPreset } from "@material-ui/styles";
22+
23+
const jss = create({ plugins: [...jssPreset().plugins, rtl()] });
24+
25+
const theme = createMuiTheme({
26+
direction: "rtl" // Both here and <body dir="rtl">
27+
});
28+
29+
const subjects = [
30+
{
31+
value: "1",
32+
label: "پیشنهاد"
33+
},
34+
{
35+
value: "2",
36+
label: "انتقاد"
37+
},
38+
{
39+
value: "3",
40+
label: "سایر"
41+
}
42+
];
43+
44+
const useStyles = makeStyles(theme => ({
45+
root: {
46+
flexGrow: 1,
47+
padding: 20
48+
},
49+
paper: {
50+
padding: theme.spacing(2),
51+
textAlign: "center",
52+
color: theme.palette.text.secondary
53+
},
54+
inprow: {
55+
marginTop: theme.spacing(1)
56+
},
57+
mycard:{
58+
padding:theme.spacing(2),
59+
},
60+
textField: {
61+
marginLeft: theme.spacing(1),
62+
marginRight: theme.spacing(1),
63+
marginBottom: theme.spacing(6),
64+
marginTop: theme.spacing(6),
65+
textAlign: "center"
66+
},
67+
button: {
68+
margin: theme.spacing(1),
69+
right: "right",
70+
position: "relative"
71+
}
72+
}));
73+
74+
export default function EmailVerify() {
75+
const classes = useStyles();
76+
77+
return (
78+
<StylesProvider jss={jss}>
79+
<ThemeProvider theme={theme}>
80+
<div className={classes.root} dir="rtl">
81+
<Grid
82+
container
83+
className={classes.mycard}
84+
spacing={0}
85+
direction="column"
86+
alignItems="center"
87+
justify="center"
88+
style={{ minHeight: "30vh" }}
89+
>
90+
<Grid item xs={5}>
91+
<Paper className={classes.paper}>
92+
<FormControl fullWidth className={classes.margin}>
93+
<span>
94+
ایمیلی برای شما به آدرس {this.props.useremail} فرستاده شد. برای
95+
ورود روی لینک فعال سازی کلیک کنید یا کد فعال سازی را در فرم
96+
زیر وارد کنید.
97+
</span>
98+
99+
<TextField
100+
label="کد فعال سازی"
101+
id="outlined-margin-dense"
102+
className={classes.textField}
103+
margin="dense"
104+
variant="outlined"
105+
alignItems="center"
106+
justify="center"
107+
/>
108+
</FormControl>
109+
110+
<Grid
111+
container
112+
spacing={0}
113+
direction="column"
114+
alignItems="center"
115+
justify="center"
116+
className={classes.inprow}
117+
>
118+
<Button fullWidth="true" variant="contained" color="primary">
119+
تایید و ورود به سایت
120+
</Button>
121+
</Grid>
122+
123+
<Grid
124+
container
125+
spacing={0}
126+
direction="column"
127+
alignItems="center"
128+
justify="center"
129+
className={classes.inprow}
130+
>
131+
<Button
132+
fullWidth="true"
133+
variant="contained"
134+
color="secondary"
135+
>
136+
ارسال مجدد ایمیل فعال سازی
137+
</Button>
138+
</Grid>
139+
</Paper>
140+
</Grid>
141+
</Grid>
142+
143+
<Grid container spacing={3}></Grid>
144+
<div className="clearfix" />
145+
</div>
146+
</ThemeProvider>
147+
<div className="clearfix" />
148+
</StylesProvider>
149+
);
150+
}

src/pages/EmailVerify/index.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './EmailVerify';

src/pages/SignUpPage/SignUpPage.jsx

+34-46
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ import Validator from "../../react-happy-validator/index";
2626
import { withFormik } from "formik";
2727
import * as Yup from "yup";
2828
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";
2932

3033
const styles = theme => ({
3134
"@global": {
@@ -66,18 +69,6 @@ class SignUpPage extends Component {
6669
};
6770
}
6871

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-
8172
render() {
8273
const {
8374
classes,
@@ -264,45 +255,42 @@ const Form = withFormik({
264255
.required("تکرار کلمه عبور را وارد کنید !")
265256
.oneOf([Yup.ref("password")], "کلمه عبور و تکرار آن مطابقت ندارند !")
266257
}),
267-
258+
268259
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",
272271
headers: {
273272
Accept: "application/json",
274-
"Content-Type": "application/x-www-form-urlencoded"
273+
"Content-Type": "application/json"
275274
},
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"
302280
})
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+
});
306294
}
307295
})(SignUpPage);
308296

0 commit comments

Comments
 (0)