Showing
6 changed files
with
92 additions
and
11 deletions
... | @@ -3282,6 +3282,27 @@ | ... | @@ -3282,6 +3282,27 @@ |
3282 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz", | 3282 | "resolved": "https://registry.npmjs.org/axe-core/-/axe-core-4.4.2.tgz", |
3283 | "integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA==" | 3283 | "integrity": "sha512-LVAaGp/wkkgYJcjmHsoKx4juT1aQvJyPcW09MLCjVTh3V2cc6PnyempiLMNH5iMdfIX/zdbjUx2KDjMLCTdPeA==" |
3284 | }, | 3284 | }, |
3285 | + "axios": { | ||
3286 | + "version": "0.27.2", | ||
3287 | + "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", | ||
3288 | + "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", | ||
3289 | + "requires": { | ||
3290 | + "follow-redirects": "^1.14.9", | ||
3291 | + "form-data": "^4.0.0" | ||
3292 | + }, | ||
3293 | + "dependencies": { | ||
3294 | + "form-data": { | ||
3295 | + "version": "4.0.0", | ||
3296 | + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", | ||
3297 | + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", | ||
3298 | + "requires": { | ||
3299 | + "asynckit": "^0.4.0", | ||
3300 | + "combined-stream": "^1.0.8", | ||
3301 | + "mime-types": "^2.1.12" | ||
3302 | + } | ||
3303 | + } | ||
3304 | + } | ||
3305 | + }, | ||
3285 | "axobject-query": { | 3306 | "axobject-query": { |
3286 | "version": "2.2.0", | 3307 | "version": "2.2.0", |
3287 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", | 3308 | "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-2.2.0.tgz", |
... | @@ -10346,9 +10367,9 @@ | ... | @@ -10346,9 +10367,9 @@ |
10346 | } | 10367 | } |
10347 | }, | 10368 | }, |
10348 | "redux": { | 10369 | "redux": { |
10349 | - "version": "4.2.0", | 10370 | + "version": "4.1.2", |
10350 | - "resolved": "https://registry.npmjs.org/redux/-/redux-4.2.0.tgz", | 10371 | + "resolved": "https://registry.npmjs.org/redux/-/redux-4.1.2.tgz", |
10351 | - "integrity": "sha512-oSBmcKKIuIR4ME29/AeNUnl5L+hvBq7OaJWzaptTQJAntaPvxIJqfnjbaEiCzzaIz+XmVILfqAM3Ob0aXLPfjA==", | 10372 | + "integrity": "sha512-SH8PglcebESbd/shgf6mii6EIoRM0zrQyjcuQ+ojmfxjTtE0z9Y8pa62iA/OJ58qjP6j27uyW4kUF4jl/jd6sw==", |
10352 | "requires": { | 10373 | "requires": { |
10353 | "@babel/runtime": "^7.9.2" | 10374 | "@babel/runtime": "^7.9.2" |
10354 | } | 10375 | } | ... | ... |
... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
6 | "@testing-library/jest-dom": "^5.16.4", | 6 | "@testing-library/jest-dom": "^5.16.4", |
7 | "@testing-library/react": "^13.2.0", | 7 | "@testing-library/react": "^13.2.0", |
8 | "@testing-library/user-event": "^13.5.0", | 8 | "@testing-library/user-event": "^13.5.0", |
9 | + "axios": "^0.27.2", | ||
9 | "cors": "^2.8.5", | 10 | "cors": "^2.8.5", |
10 | "express": "^4.18.1", | 11 | "express": "^4.18.1", |
11 | "http-proxy-middleware": "^2.0.6", | 12 | "http-proxy-middleware": "^2.0.6", |
... | @@ -16,7 +17,7 @@ | ... | @@ -16,7 +17,7 @@ |
16 | "react-redux": "^8.0.1", | 17 | "react-redux": "^8.0.1", |
17 | "react-router-dom": "^6.3.0", | 18 | "react-router-dom": "^6.3.0", |
18 | "react-scripts": "5.0.1", | 19 | "react-scripts": "5.0.1", |
19 | - "redux": "^4.2.0", | 20 | + "redux": "^4.1.2", |
20 | "web-vitals": "^2.1.4" | 21 | "web-vitals": "^2.1.4" |
21 | }, | 22 | }, |
22 | "scripts": { | 23 | "scripts": { | ... | ... |
1 | import React, { useCallback, useState } from "react"; | 1 | import React, { useCallback, useState } from "react"; |
2 | +import { useDispatch } from "react-redux"; | ||
3 | +import { register } from "../../../modules/user"; | ||
2 | import "../style/RegisterPage.scss" | 4 | import "../style/RegisterPage.scss" |
3 | 5 | ||
4 | function RegisterPage(props) { | 6 | function RegisterPage(props) { |
7 | + const dispatch = useDispatch(); | ||
5 | 8 | ||
6 | const [Name, setName] = useState(""); | 9 | const [Name, setName] = useState(""); |
7 | const [Sex, setSex] = useState(""); | 10 | const [Sex, setSex] = useState(""); |
... | @@ -94,8 +97,18 @@ function RegisterPage(props) { | ... | @@ -94,8 +97,18 @@ function RegisterPage(props) { |
94 | name: Name, | 97 | name: Name, |
95 | id: Id, | 98 | id: Id, |
96 | password: Password, | 99 | password: Password, |
97 | - sex: Sex, | 100 | + gender: Sex, |
98 | - }; | 101 | + } |
102 | + | ||
103 | + dispatch(register(UserData) | ||
104 | + .then(res => { | ||
105 | + if (res.payload.success) { | ||
106 | + props.history.push('/login'); | ||
107 | + } else { | ||
108 | + alert(res.payload.error); | ||
109 | + } | ||
110 | + }) | ||
111 | + ); | ||
99 | } | 112 | } |
100 | 113 | ||
101 | }, [checkIdError, checkNameError, checkPasswordError, checkRegisterError, checkSexError, Password, PasswordCheck, Sex]); | 114 | }, [checkIdError, checkNameError, checkPasswordError, checkRegisterError, checkSexError, Password, PasswordCheck, Sex]); | ... | ... |
... | @@ -2,16 +2,24 @@ import React from 'react'; | ... | @@ -2,16 +2,24 @@ import React from 'react'; |
2 | import ReactDOM from 'react-dom/client'; | 2 | import ReactDOM from 'react-dom/client'; |
3 | import './index.css'; | 3 | import './index.css'; |
4 | import App from './App'; | 4 | import App from './App'; |
5 | +import { Provider } from 'react-redux'; | ||
6 | +import { createStore } from 'redux'; | ||
5 | import reportWebVitals from './reportWebVitals'; | 7 | import reportWebVitals from './reportWebVitals'; |
6 | import { BrowserRouter } from 'react-router-dom'; | 8 | import { BrowserRouter } from 'react-router-dom'; |
9 | +import rootReducer from './modules/Index'; | ||
10 | +import { composeWithDevTools } from 'redux-devtools-extension'; | ||
11 | + | ||
12 | +const store = createStore(rootReducer, composeWithDevTools()); | ||
7 | 13 | ||
8 | const root = ReactDOM.createRoot(document.getElementById('root')); | 14 | const root = ReactDOM.createRoot(document.getElementById('root')); |
9 | root.render( | 15 | root.render( |
10 | - <React.StrictMode> | 16 | + <Provider store={store}> |
11 | - <BrowserRouter> | 17 | + <React.StrictMode> |
12 | - <App /> | 18 | + <BrowserRouter> |
13 | - </BrowserRouter> | 19 | + <App /> |
14 | - </React.StrictMode> | 20 | + </BrowserRouter> |
21 | + </React.StrictMode> | ||
22 | + </Provider> | ||
15 | ); | 23 | ); |
16 | 24 | ||
17 | // If you want to start measuring performance in your app, pass a function | 25 | // If you want to start measuring performance in your app, pass a function | ... | ... |
weather_briefing/src/modules/Index.js
0 → 100644
weather_briefing/src/modules/user.js
0 → 100644
1 | +import axios from 'axios'; | ||
2 | + | ||
3 | +const REGISTER = 'user/REGISTER'; | ||
4 | + | ||
5 | +const InitialState = { | ||
6 | + name: 'test', | ||
7 | + id: 'test123', | ||
8 | + password: 'test1111~', | ||
9 | + gender: '1', | ||
10 | +}; | ||
11 | + | ||
12 | +export function register(data) { | ||
13 | + const req = axios.post('http://localhost:4000/register', data) | ||
14 | + .then(res => res.data); | ||
15 | + | ||
16 | + return { | ||
17 | + type: REGISTER, | ||
18 | + payload: req, | ||
19 | + } | ||
20 | +}; | ||
21 | + | ||
22 | +export default function (state = InitialState, action) { | ||
23 | + switch (action.type) { | ||
24 | + case REGISTER: | ||
25 | + return {...state, register: action.payload}; | ||
26 | + break; | ||
27 | + default: | ||
28 | + return state; | ||
29 | + } | ||
30 | +}; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment