Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2_open_source_sw_development_Han
/
Jaksimsamil
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
송용우
2020-06-22 09:33:16 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
699244b1b529050488cecc31427b437abdb49f5b
699244b1
1 parent
6f6deb25
Update BJIDForm
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
218 additions
and
12 deletions
jaksimsamil-page/src/components/setting/BJIDForm.js
jaksimsamil-page/src/components/setting/SettingForm.js
jaksimsamil-page/src/containers/setting/SettingContainer.js
jaksimsamil-page/src/lib/api/profile.js
jaksimsamil-page/src/modules/auth.js
jaksimsamil-page/src/modules/index.js
jaksimsamil-page/src/modules/profile.js
jaksimsamil-page/src/pages/SettingPage.js
jaksimsamil-page/src/components/setting/BJIDForm.js
0 → 100644
View file @
699244b
import
React
from
'react'
;
import
styled
from
'styled-components'
;
import
Button
from
'../common/Button'
;
import
palette
from
'../../lib/styles/palette'
;
const
BJIDFormBlock
=
styled
.
div
`
width: 100%;
border-top: 1px solid
${
palette
.
gray
[
2
]}
;
padding-top: 2rem;
h4 {
color:
${
palette
.
gray
[
8
]}
;
margin-top: 0;
margin-bottom: 0.5rem;
}
`
;
const
BJIDForm
=
({
onChange
,
onBJIDSubmit
,
profile
})
=>
{
return
(
<
BJIDFormBlock
>
<
h4
>
백준
아이디
<
/h4
>
<
input
name
=
"userBJID"
onChange
=
{
onChange
}
value
=
{
profile
.
userBJID
}
placeholder
=
"백준 아이디"
/>
<
button
type
=
"submit"
onSubmit
=
{
onBJIDSubmit
}
>
등록
<
/button
>
<
/BJIDFormBlock
>
);
};
export
default
BJIDForm
;
jaksimsamil-page/src/components/setting/SettingForm.js
0 → 100644
View file @
699244b
import
React
from
'react'
;
import
styled
from
'styled-components'
;
import
Button
from
'../common/Button'
;
import
palette
from
'../../lib/styles/palette'
;
import
BJIDForm
from
'./BJIDForm'
;
const
SettingFormBlock
=
styled
.
div
`
h3 {
margin: 0;
color:
${
palette
.
gray
[
8
]}
;
margin-bottom: 1rem;
}
background:
${
palette
.
gray
[
2
]}
;
margin: 0 auto;
display: flex;
flex-direction: column;
`
;
const
StyledInput
=
styled
.
input
`
font-size: 1rem;
border: none;
border-bottom: 1px solid
${
palette
.
gray
[
5
]}
;
padding-bottom: 0.5rem;
outline: none;
&:focus {
color: $oc-teal-7;
border-bottom: 1px solid
${
palette
.
gray
[
7
]}
;
}
& + & {
margin-top: 1rem;
}
`
;
const
SectionContainer
=
styled
.
div
`
display: flex;
`
;
const
SettingForm
=
({
onChange
,
onBJIDSubmit
,
profile
})
=>
{
console
.
log
(
profile
);
return
(
<
SettingFormBlock
>
<
SectionContainer
>
<
h3
>
{
profile
.
username
}
<
/h3
>
<
p
>
입력
<
/p
>
<
/SectionContainer
>
<
SectionContainer
>
<
BJIDForm
profile
=
{
profile
}
onChange
=
{
onChange
}
onBJIDSubmit
=
{
onBJIDSubmit
}
/
>
<
/SectionContainer
>
<
SectionContainer
>
<
h3
>
친구
<
/h3
>
<
StyledInput
name
=
"BJID"
placeholder
=
"친구 아이디"
/>
<
Button
>
추가
<
/Button
>
<
/SectionContainer
>
<
h3
>
친구
리스트
<
/h3
>
<
/SettingFormBlock
>
);
};
export
default
SettingForm
;
jaksimsamil-page/src/containers/setting/SettingContainer.js
0 → 100644
View file @
699244b
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
useDispatch
,
useSelector
}
from
'react-redux'
;
import
{
withRouter
}
from
'react-router-dom'
;
import
{
changeField
,
setBJID
}
from
'../../modules/profile'
;
import
SettingForm
from
'../../components/setting/SettingForm'
;
const
SettingContainer
=
({
history
})
=>
{
const
dispatch
=
useDispatch
();
const
[
error
,
setError
]
=
useState
(
null
);
const
{
user
,
profile
}
=
useSelector
(({
user
,
profile
})
=>
({
user
:
user
.
user
,
profile
:
profile
,
}));
const
onChange
=
(
e
)
=>
{
const
{
value
,
name
}
=
e
.
target
;
dispatch
(
changeField
({
key
:
name
,
value
:
value
,
}),
);
};
const
onBJIDSubmit
=
(
e
)
=>
{
e
.
preventDefault
();
let
username
=
profile
.
username
;
let
userBJID
=
profile
.
userBJID
;
dispatch
(
setBJID
({
username
,
userBJID
}));
};
useEffect
(()
=>
{
//Do Init Form
console
.
log
(
profile
);
},
[
dispatch
]);
return
(
<
SettingForm
type
=
"setting"
onChange
=
{
onChange
}
onBJIDSubmit
=
{
onBJIDSubmit
}
profile
=
{
profile
}
><
/SettingForm
>
);
};
export
default
withRouter
(
SettingContainer
);
jaksimsamil-page/src/lib/api/profile.js
0 → 100644
View file @
699244b
import
client
from
'./client'
;
export
const
setBJID
=
({
username
,
BJID
})
=>
client
.
post
(
'api/profile/setprofile'
,
{
username
,
BJID
});
jaksimsamil-page/src/modules/auth.js
View file @
699244b
...
...
@@ -5,19 +5,19 @@ import createRequestSaga, {
createRequestActionTypes
,
}
from
'../lib/createRequestSaga'
;
import
*
as
authAPI
from
'../lib/api/auth'
;
const
CHAGE_FIELD
=
'auth/CHANGE_FIELD'
;
const
CHA
N
GE_FIELD
=
'auth/CHANGE_FIELD'
;
const
INITIALIZE_FORM
=
'auth/INITIALIZE_FORM'
;
const
REGISTER
=
'auth/REGISTER'
;
const
REGISTER_SUCCESS
=
'auth/REGISTER_SUCCESS'
;
const
REGISTER_FAILURE
=
'auth/REGISTER_FAILURE'
;
const
[
REGISTER
,
REGISTER_SUCCESS
,
REGISTER_FAILURE
]
=
createRequestActionTypes
(
'auth/REGISTER'
,
)
;
const
LOGIN
=
'auth/LOGIN'
;
const
LOGIN_SUCCESS
=
'auth/LOGIN_SUCCESS'
;
const
LOGIN_FAILURE
=
'auth/LOGIN_FAILURE'
;
const
[
LOGIN
,
LOGIN_SUCCESS
,
LOGIN_FAILURE
]
=
createRequestActionTypes
(
'auth/REGISTER'
,
)
;
export
const
changeField
=
createAction
(
CHAGE_FIELD
,
CHA
N
GE_FIELD
,
({
form
,
key
,
value
})
=>
({
form
,
key
,
...
...
@@ -59,7 +59,7 @@ export function* authSaga() {
const
auth
=
handleActions
(
{
[
CHAGE_FIELD
]:
(
state
,
{
payload
:
{
form
,
key
,
value
}
})
=>
[
CHA
N
GE_FIELD
]:
(
state
,
{
payload
:
{
form
,
key
,
value
}
})
=>
produce
(
state
,
(
draft
)
=>
{
draft
[
form
][
key
]
=
value
;
}),
...
...
jaksimsamil-page/src/modules/index.js
View file @
699244b
...
...
@@ -3,15 +3,17 @@ import { all } from 'redux-saga/effects';
import
auth
,
{
authSaga
}
from
'./auth'
;
import
loading
from
'./loading'
;
import
user
,
{
userSaga
}
from
'./user'
;
import
profile
,
{
profileSaga
}
from
'./profile'
;
const
rootReducer
=
combineReducers
({
auth
,
loading
,
user
,
profile
,
});
export
function
*
rootSaga
()
{
yield
all
([
authSaga
(),
userSaga
()]);
yield
all
([
authSaga
(),
userSaga
()
,
profileSaga
()
]);
}
export
default
rootReducer
;
...
...
jaksimsamil-page/src/modules/profile.js
0 → 100644
View file @
699244b
import
{
createAction
,
handleActions
}
from
'redux-actions'
;
import
createRequestSaga
,
{
createRequestActionTypes
,
}
from
'../lib/createRequestSaga'
;
import
produce
from
'immer'
;
import
*
as
profileAPI
from
'../lib/api/profile'
;
import
{
takeLatest
}
from
'redux-saga/effects'
;
const
INITIALIZE
=
'profile/INITIALIZE'
;
const
CHANGE_FIELD
=
'profile/CHANGE_FIELD'
;
const
[
SET_BJID
,
SET_BJID_SUCCESS
,
SET_BJID_FAILURE
]
=
createRequestActionTypes
(
'profile/SET_BJID'
,
);
export
const
setBJID
=
createAction
(
SET_BJID
,
({
username
,
BJID
})
=>
({
username
,
BJID
,
}));
export
const
changeField
=
createAction
(
CHANGE_FIELD
,
({
key
,
value
})
=>
({
key
,
value
,
}));
const
initialState
=
{
username
:
''
,
userBJID
:
''
,
solvedBJ
:
''
,
friendList
:
[],
BJIDError
:
''
,
};
const
setBJIDSaga
=
createRequestSaga
(
SET_BJID
,
profileAPI
.
setBJID
);
export
function
*
profileSaga
()
{
yield
takeLatest
(
SET_BJID
,
setBJIDSaga
);
}
export
default
handleActions
(
{
[
INITIALIZE
]:
(
state
)
=>
initialState
,
[
CHANGE_FIELD
]:
(
state
,
{
payload
:
{
key
,
value
}
})
=>
produce
(
state
,
(
draft
)
=>
{
draft
[
key
]
=
value
;
}),
[
SET_BJID_SUCCESS
]:
(
state
,
{
payload
:
BJID
})
=>
({
...
state
,
BJID
,
BJIDError
:
null
,
}),
[
SET_BJID_FAILURE
]:
(
state
,
{
payload
:
error
})
=>
({
...
state
,
BJIDError
:
error
,
}),
},
initialState
,
);
jaksimsamil-page/src/pages/SettingPage.js
View file @
699244b
import
React
from
'react'
;
import
HeaderContainer
from
'../containers/common/HeaderContainer'
;
import
Button
from
'../components/common/Button'
;
import
SettingForm
from
'../components/setting/SettingForm'
;
import
SettingContainer
from
'../containers/setting/SettingContainer'
;
const
SettingPage
=
()
=>
{
return
(
<
div
>
<
HeaderContainer
/>
<
Button
>
setting
<
/Button
>
<
SettingContainer
><
/SettingContainer
>
<
/div
>
);
};
...
...
Please
register
or
login
to post a comment