Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건희
/
OSSW_Weather_Briefing
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김건희
2022-05-23 16:56:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
d075eab2f6cf8165725b724213d8964ee555abd4
d075eab2
1 parent
0ac6cf61
[Update] Register Redux Setting
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
41 deletions
weather_briefing/src/component/views/RegisterPage/RegisterPage.js
weather_briefing/src/index.js
weather_briefing/src/modules/Index.js
weather_briefing/src/modules/user.js
weather_briefing/src/setupProxy.js
weather_briefing/src/component/views/RegisterPage/RegisterPage.js
View file @
d075eab
import
React
,
{
useCallback
,
useState
}
from
"react"
;
import
{
useDispatch
}
from
"react-redux"
;
import
{
register
}
from
"../../../modules/user"
;
import
"../style/RegisterPage.scss"
import
{
register
}
from
"../../../modules/user.js"
;
import
"../style/RegisterPage.scss"
;
import
{
useDispatch
,
useSelector
}
from
"react-redux"
;
import
{
useNavigate
}
from
"react-router-dom"
;
function
RegisterPage
(
props
)
{
const
dispatch
=
useDispatch
();
const
naviagte
=
useNavigate
();
const
registerResult
=
useSelector
(
state
=>
state
.
user
.
registerSuccess
);
const
[
Name
,
setName
]
=
useState
(
""
);
const
[
Sex
,
setSex
]
=
useState
(
""
);
...
...
@@ -98,20 +102,20 @@ function RegisterPage(props) {
id
:
Id
,
password
:
Password
,
gender
:
Sex
,
};
dispatch
(
register
(
UserData
));
if
(
registerResult
)
{
alert
(
'회원가입에 성공하였습니다.'
);
naviagte
(
'/login'
);
}
else
{
alert
(
'회원가입에 실패하였습니다.'
);
}
};
dispatch
(
register
(
UserData
)
.
then
(
res
=>
{
if
(
res
.
payload
.
success
)
{
props
.
history
.
push
(
'/login'
);
}
else
{
alert
(
res
.
payload
.
error
);
}
})
);
}
},
[
checkIdError
,
checkNameError
,
checkPasswordError
,
checkRegisterError
,
checkSexError
,
Password
,
PasswordCheck
,
Sex
]);
},
[
checkIdError
,
checkNameError
,
checkPasswordError
,
checkRegisterError
,
checkSexError
,
Password
,
PasswordCheck
,
Sex
,
dispatch
,
registerResult
]);
return
(
<
div
id
=
"body"
>
...
...
weather_briefing/src/index.js
View file @
d075eab
...
...
@@ -14,12 +14,10 @@ const store = createStore(rootReducer, composeWithDevTools());
const
root
=
ReactDOM
.
createRoot
(
document
.
getElementById
(
'root'
));
root
.
render
(
<
Provider
store
=
{
store
}
>
<
React
.
StrictMode
>
<
BrowserRouter
>
<
App
/>
<
/BrowserRouter
>
<
/React.StrictMode
>
<
/Provider
>
<
BrowserRouter
>
<
App
/>
<
/BrowserRouter
>
<
/Provider>
,
);
// If you want to start measuring performance in your app, pass a function
...
...
weather_briefing/src/modules/Index.js
View file @
d075eab
import
{
combineReducers
}
from
"redux"
;
import
user
from
"./user"
;
import
user
from
"./user
.js
"
;
const
rootReducer
=
combineReducers
({
user
,
...
...
weather_briefing/src/modules/user.js
View file @
d075eab
import
axios
from
'axios'
;
const
REGISTER
=
'user/REGISTER'
;
const
LOGIN
=
'user/LOGIN'
const
InitialState
=
{
logged
:
false
,
name
:
'test'
,
id
:
'test123'
,
password
:
'test1111~'
,
gender
:
'1'
,
};
const
LOGIN
=
'user/LOGIN'
;
export
function
register
(
data
)
{
const
req
=
axios
.
post
(
'http://localhost:4000/register'
,
data
)
const
req
=
axios
.
post
(
'http://localhost:4000/
api/
register'
,
data
)
.
then
(
res
=>
res
.
data
);
return
{
type
:
REGISTER
,
payload
:
req
,
}
}
;
}
export
function
login
(
data
)
{
const
req
=
axios
.
post
(
'http://localhost:4000/login'
,
data
)
const
req
=
axios
.
post
(
'http://localhost:4000/
api/
login'
,
data
)
.
then
(
res
=>
res
.
date
);
return
{
type
:
LOGIN
,
payload
:
req
,
}
}
;
}
export
default
function
(
state
=
{},
action
)
{
switch
(
action
.
type
)
{
case
REGISTER
:
return
{...
state
,
success
:
action
.
payload
};
break
;
return
{
...
state
,
registerSuccess
:
action
.
payload
};
case
LOGIN
:
return
{...
state
,
loginSuccess
:
action
.
payload
};
break
;
return
{
...
state
,
loginSuccess
:
action
.
payload
};
default
:
return
state
;
}
};
\ No newline at end of file
}
\ No newline at end of file
...
...
weather_briefing/src/setupProxy.js
View file @
d075eab
...
...
@@ -2,7 +2,7 @@ const { createProxyMiddleware } = require("http-proxy-middleware");
module
.
exports
=
function
(
app
)
{
app
.
use
(
createProxyMiddleware
(
'/'
,
{
createProxyMiddleware
(
'/
api
'
,
{
target
:
'http://localhost:4000'
,
//접속하려는 서버의 루트 URL
changeOrigin
:
true
})
...
...
Please
register
or
login
to post a comment