Showing
9 changed files
with
13 additions
and
84 deletions
... | @@ -4,6 +4,9 @@ const router = express.Router(); | ... | @@ -4,6 +4,9 @@ const router = express.Router(); |
4 | 4 | ||
5 | router.post('/',(req,res)=>{ | 5 | router.post('/',(req,res)=>{ |
6 | console.log(req.body); | 6 | console.log(req.body); |
7 | + return res.status(200).json({ | ||
8 | + success: true | ||
9 | + }); | ||
7 | }); | 10 | }); |
8 | 11 | ||
9 | router.get('/',(req,res)=>{ | 12 | router.get('/',(req,res)=>{ | ... | ... |
turnel_FE/src/_actions/types.js
deleted
100644 → 0
1 | -import Axios from 'axios'; | ||
2 | -import { LOGIN_USER, REGISTER_USER } from './types'; | ||
3 | - | ||
4 | -export function loginUser(dataToSubmit) { | ||
5 | - | ||
6 | - const request = Axios.post('/api/login', dataToSubmit) | ||
7 | - .then( response => response.data ) | ||
8 | - return { | ||
9 | - type: LOGIN_USER, | ||
10 | - payload: request | ||
11 | - } | ||
12 | -} | ||
13 | - | ||
14 | -export function registerUser(dataToSubmit) { | ||
15 | - | ||
16 | - const request = Axios.post('/api/register', dataToSubmit) | ||
17 | - .then( response => response.data ) | ||
18 | - return { | ||
19 | - type: REGISTER_USER, | ||
20 | - payload: request | ||
21 | - } | ||
22 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
turnel_FE/src/_reducers/index.js
deleted
100644 → 0
1 | -import { | ||
2 | - LOGIN_USER, REGISTER_USER | ||
3 | -} from '../_actions/types'; | ||
4 | - | ||
5 | -export default function (state = {}, action) { | ||
6 | - switch (action.type) { | ||
7 | - case LOGIN_USER: | ||
8 | - return { ...state, loginSuccess: action.payload } | ||
9 | - break; | ||
10 | - case REGISTER_USER: | ||
11 | - return {...state, register: action.payload} | ||
12 | - break; | ||
13 | - default: | ||
14 | - return state; | ||
15 | - } | ||
16 | -} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -2,11 +2,8 @@ import React, {useState} from "react"; | ... | @@ -2,11 +2,8 @@ import React, {useState} from "react"; |
2 | import "../style/LoginPage.scss"; | 2 | import "../style/LoginPage.scss"; |
3 | import { Icon, Input } from "semantic-ui-react" | 3 | import { Icon, Input } from "semantic-ui-react" |
4 | import { useNavigate } from "react-router-dom"; | 4 | import { useNavigate } from "react-router-dom"; |
5 | -import {useDispatch} from "react-redux"; | ||
6 | -import { loginUser } from '../../../_actions/user_action' | ||
7 | 5 | ||
8 | function LoginPage(props) { | 6 | function LoginPage(props) { |
9 | - const dispatch = useDispatch(); | ||
10 | const navigate = useNavigate(); | 7 | const navigate = useNavigate(); |
11 | 8 | ||
12 | const [Id, setId] = useState(""); | 9 | const [Id, setId] = useState(""); |
... | @@ -26,15 +23,7 @@ function LoginPage(props) { | ... | @@ -26,15 +23,7 @@ function LoginPage(props) { |
26 | email: Id, | 23 | email: Id, |
27 | password: Password | 24 | password: Password |
28 | } | 25 | } |
29 | - dispatch(loginUser(body)) | 26 | + |
30 | - .then(response => { | ||
31 | - if (response.payload.loginSuccess) { | ||
32 | - props.history.push('/main') | ||
33 | - } | ||
34 | - else{ | ||
35 | - alert('Error') | ||
36 | - } | ||
37 | - }) | ||
38 | 27 | ||
39 | }; | 28 | }; |
40 | 29 | ... | ... |
1 | import React, {useState} from "react"; | 1 | import React, {useState} from "react"; |
2 | import "../style/RegisterPage.scss"; | 2 | import "../style/RegisterPage.scss"; |
3 | import { Button, Icon, Input } from "semantic-ui-react"; | 3 | import { Button, Icon, Input } from "semantic-ui-react"; |
4 | -import {useDispatch} from "react-redux"; | 4 | +import Axios from 'axios' |
5 | -import { registerUser } from '../../../_actions/user_action' | ||
6 | 5 | ||
7 | -function RegisterPage(props) { | 6 | +function RegisterPage() { |
8 | - const dispatch = useDispatch(); | ||
9 | const [Id, setId] = useState(""); | 7 | const [Id, setId] = useState(""); |
10 | const [Password, setPassword] = useState(""); | 8 | const [Password, setPassword] = useState(""); |
11 | const [PasswordCheck,setPasswordCheck] = useState(""); | 9 | const [PasswordCheck,setPasswordCheck] = useState(""); |
... | @@ -37,14 +35,7 @@ function RegisterPage(props) { | ... | @@ -37,14 +35,7 @@ function RegisterPage(props) { |
37 | password: Password, | 35 | password: Password, |
38 | personality: Personality | 36 | personality: Personality |
39 | } | 37 | } |
40 | - dispatch(registerUser(body)) | 38 | + |
41 | - .then(response => { | ||
42 | - if (response.payload.success) { | ||
43 | - props.history.push('/login') | ||
44 | - } else { | ||
45 | - alert('Failed to sign up') | ||
46 | - } | ||
47 | - }) | ||
48 | } | 39 | } |
49 | return ( | 40 | return ( |
50 | <div id="Register"> | 41 | <div id="Register"> | ... | ... |
... | @@ -4,19 +4,11 @@ import {Provider} from "react-redux"; | ... | @@ -4,19 +4,11 @@ import {Provider} from "react-redux"; |
4 | import './index.css'; | 4 | import './index.css'; |
5 | import App from './App'; | 5 | import App from './App'; |
6 | import 'semantic-ui-css/semantic.min.css' | 6 | import 'semantic-ui-css/semantic.min.css' |
7 | -import {applyMiddleware, createStore} from "redux"; | ||
8 | -import promiseMiddleware from 'redux-promise-middleware' | ||
9 | -import ReduxThunk from 'redux-thunk' | ||
10 | -import Reducer from './_reducers'; | ||
11 | 7 | ||
12 | -const createStoreWithMiddleWare = applyMiddleware(promiseMiddleware, ReduxThunk)(createStore) | ||
13 | ReactDOM.render( | 8 | ReactDOM.render( |
14 | - <Provider store={createStoreWithMiddleWare(Reducer, | 9 | + |
15 | - window.__REDUX_DEVTOOLS_EXTENSION__ && | 10 | + <App />, |
16 | - window.__REDUX_DEVTOOLS_EXTENSION__() | 11 | + |
17 | - )}> | ||
18 | - <App /> | ||
19 | - </Provider>, | ||
20 | document.getElementById('root') | 12 | document.getElementById('root') |
21 | ); | 13 | ); |
22 | 14 | ... | ... |
-
Please register or login to post a comment