Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김원진
/
khusat-front
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-12-04 23:10:42 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0f1ae81882ef143b410759cda28c1e4b73aef5e5
0f1ae818
1 parent
77a07d7f
[REFACTOR] Container를 이용한 모듈화 및 전체 기능 구현 리팩토링
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
71 additions
and
60 deletions
src/App.js
src/containers/ResultPageContainer.js
src/containers/SurveyPageContainer.js
src/pages/MainPage.js
src/pages/MainPage.scss
src/pages/ResultPage.js
src/pages/SurveyPage.js
src/App.js
View file @
0f1ae81
import
"./App.scss"
;
import
MainPage
from
"./pages/MainPage"
;
import
SurveyPageContainer
from
"./containers/SurveyPageContainer"
;
import
ResultPage
from
"./pages/ResultPage
"
;
import
ResultPage
Container
from
"./containers/ResultPageContainer
"
;
import
{
BrowserRouter
,
Route
,
Switch
}
from
"react-router-dom"
;
function
App
()
{
...
...
@@ -11,7 +11,7 @@ function App() {
<
Switch
>
<
Route
exact
path
=
"/"
component
=
{
MainPage
}
/
>
<
Route
path
=
"/survey"
component
=
{
SurveyPageContainer
}
/
>
<
Route
path
=
"/result"
component
=
{
ResultPage
}
/
>
<
Route
path
=
"/result"
component
=
{
ResultPage
Container
}
/
>
<
/Switch
>
<
/div
>
<
/BrowserRouter
>
...
...
src/containers/ResultPageContainer.js
0 → 100644
View file @
0f1ae81
import
React
from
'react'
import
{
useSelector
}
from
'react-redux'
;
import
ResultPage
from
'../pages/ResultPage'
;
export
function
ResultPageContainer
()
{
const
data
=
useSelector
((
state
)
=>
state
.
result
.
data
);
return
(
<>
<
ResultPage
result
=
{
data
}
/
>
<
/
>
)
}
export
default
ResultPageContainer
;
\ No newline at end of file
src/containers/SurveyPageContainer.js
View file @
0f1ae81
import
React
from
'react'
import
React
from
'react'
;
import
{
useSelector
}
from
'react-redux'
;
import
SurveyPage
from
'../pages/SurveyPage'
;
// import { createHashHistory } from 'history'
// const history = createHashHistory();
export
function
SurveyPageContainer
()
{
export
function
SurveyPageContainer
(
{
history
}
)
{
const
data
=
useSelector
((
state
)
=>
state
.
survey
.
data
);
return
(
<>
<
SurveyPage
history
=
{
history
}
question
=
{
data
}
/
>
<
/
>
...
...
src/pages/MainPage.js
View file @
0f1ae81
import
React
,{
useEffect
}
from
'react'
;
import
'./MainPage.scss'
;
import
{
getQuestionThunk
}
from
'../store/action/survey'
;
import
{
useDispatch
}
from
'react-redux'
;
import
{
Button
}
from
"antd"
;
import
axios
from
'axios'
;
import
mainImg
from
"../assets/main-soldier.png"
;
import
{
getSurvey
,
getSurveySuccess
,
getSurveyError
}
from
'../store/action/survey'
;
import
{
useDispatch
}
from
'react-redux'
;
import
styled
from
'styled-components'
;
const
Container
=
styled
.
div
`
display:flex;
flex-direction: column;
align-items: center;
`
;
const
MainImg
=
styled
.
img
`
margin-top: 2rem;
width: 70rem;
height: 35rem;
border-radius: 1rem;
`
;
const
MainTitle
=
styled
.
div
`
margin-top: 5rem;
text-align: center;
font-size: 5rem;
font-weight: bold;
`
;
const
MainDesc
=
styled
.
div
`
margin-top: 2rem;
margin-bottom: 2rem;
font-size: 1.5rem;
`
;
function
MainPage
({
history
}){
...
...
@@ -12,35 +37,27 @@ function MainPage({history}){
const
onClick
=
()
=>
{
history
.
push
(
'/survey'
);
}
useEffect
(()
=>
{
const
getApi
=
async
()
=>
{
dispatch
(
getSurvey
());
try
{
const
{
data
}
=
await
axios
.
get
(
"getquestions"
);
dispatch
(
getSurveySuccess
(
data
));
}
catch
(
e
){
dispatch
(
getSurveyError
(
e
));
}
}
getApi
();
dispatch
(
getQuestionThunk
());
},[]);
return
(
<>
<
div
className
=
"main-wrapper"
>
<
div
className
=
"main-title"
>
KHUSAT
<
/div
>
<
div
className
=
"main-title__desc"
>
<
Container
>
<
MainTitle
>
KHUSAT
<
/MainTitle
>
<
MainDesc
>
KHUSAT
특별과정
,
<
br
><
/br
>
여러분의
보직을
추천드립니다
.
<
/
div
>
<
/
MainDesc
>
<
Button
size
=
"large"
onClick
=
{
onClick
}
color
=
"#536349"
style
=
{{}}
>
시작하기
<
/Button
>
<
img
className
=
"main-image"
src
=
{
mainImg
}
/
>
<
/
div
>
<
MainImg
src
=
{
mainImg
}
/
>
<
/
Container
>
<
/
>
);
}
...
...
src/pages/MainPage.scss
deleted
100644 → 0
View file @
77a07d7
.main-wrapper
{
display
:flex
;
flex-direction
:
column
;
align-items
:
center
;
// max-width: 50rem;
}
.main-image
{
margin-top
:
2rem
;
width
:
70rem
;
height
:
35rem
;
border-radius
:
1rem
;
}
.main-title
{
margin-top
:
5rem
;
text-align
:
center
;
font-size
:
5rem
;
font-weight
:
bold
;
&
__desc
{
margin-top
:
2rem
;
margin-bottom
:
2rem
;
font-size
:
1
.5rem
;
}
}
src/pages/ResultPage.js
View file @
0f1ae81
import
React
from
'react'
;
import
{
useSelector
}
from
'react-redux'
;
import
styled
from
'styled-components'
;
const
Container
=
styled
.
div
`
...
...
@@ -24,18 +23,15 @@ const Description = styled.div`
font-size: 1.4rem;
`
;
function
ResultPage
(){
const
data
=
useSelector
(
state
=>
state
.
result
.
data
);
function
ResultPage
({
result
}){
return
(
<>
{
data
?
(
{
result
&&
(
<
Container
>
<
Title
>
{
data
.
high
}
<
/Title
>
<
Position
>
{
data
.
low
}
<
/Position
>
<
Description
>
{
data
.
description
}
<
/Description
>
<
Title
>
{
result
.
high
}
<
/Title
>
<
Position
>
{
result
.
low
}
<
/Position
>
<
Description
>
{
result
.
description
}
<
/Description
>
<
/Container>
)
:
<
div
>
로딩중
<
/div
>
}
<
/
>
);
...
...
src/pages/SurveyPage.js
View file @
0f1ae81
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
Card
from
"../components/card/Card"
;
import
{
useDispatch
}
from
'react-redux'
;
import
{
getResultThunk
}
from
"../store/action/result"
;
import
ProgressBar
from
"../components/progressbar/ProgressBar"
;
import
"antd/dist/antd.css"
;
...
...
@@ -35,8 +37,10 @@ function SurveyPage({ history, question }) {
const
dispatch
=
useDispatch
();
useEffect
(()
=>
{
if
(
answer
.
length
===
10
){
dispatch
()
if
(
answer
.
length
===
10
){
// answer state 배열에 10개가 채워지면,
dispatch
(
getResultThunk
(
answer
));
history
.
push
(
'/result'
);
console
.
log
(
history
);
}
},[
answer
]);
...
...
Please
register
or
login
to post a comment