Showing
7 changed files
with
71 additions
and
60 deletions
1 | import "./App.scss"; | 1 | import "./App.scss"; |
2 | import MainPage from "./pages/MainPage"; | 2 | import MainPage from "./pages/MainPage"; |
3 | import SurveyPageContainer from "./containers/SurveyPageContainer"; | 3 | import SurveyPageContainer from "./containers/SurveyPageContainer"; |
4 | -import ResultPage from "./pages/ResultPage"; | 4 | +import ResultPageContainer from "./containers/ResultPageContainer"; |
5 | import { BrowserRouter, Route, Switch } from "react-router-dom"; | 5 | import { BrowserRouter, Route, Switch } from "react-router-dom"; |
6 | 6 | ||
7 | function App() { | 7 | function App() { |
... | @@ -11,7 +11,7 @@ function App() { | ... | @@ -11,7 +11,7 @@ function App() { |
11 | <Switch> | 11 | <Switch> |
12 | <Route exact path="/" component={MainPage} /> | 12 | <Route exact path="/" component={MainPage} /> |
13 | <Route path="/survey" component={SurveyPageContainer} /> | 13 | <Route path="/survey" component={SurveyPageContainer} /> |
14 | - <Route path="/result" component={ResultPage} /> | 14 | + <Route path="/result" component={ResultPageContainer} /> |
15 | </Switch> | 15 | </Switch> |
16 | </div> | 16 | </div> |
17 | </BrowserRouter> | 17 | </BrowserRouter> | ... | ... |
src/containers/ResultPageContainer.js
0 → 100644
1 | +import React from 'react' | ||
2 | +import { useSelector } from 'react-redux'; | ||
3 | +import ResultPage from '../pages/ResultPage'; | ||
4 | + | ||
5 | +export function ResultPageContainer() { | ||
6 | + const data = useSelector((state) => state.result.data); | ||
7 | + return ( | ||
8 | + <> | ||
9 | + <ResultPage | ||
10 | + result={data} | ||
11 | + /> | ||
12 | + </> | ||
13 | + ) | ||
14 | +} | ||
15 | + | ||
16 | +export default ResultPageContainer; | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | -import React from 'react' | 1 | +import React from 'react'; |
2 | import { useSelector } from 'react-redux'; | 2 | import { useSelector } from 'react-redux'; |
3 | import SurveyPage from '../pages/SurveyPage'; | 3 | import SurveyPage from '../pages/SurveyPage'; |
4 | +// import { createHashHistory } from 'history' | ||
5 | +// const history = createHashHistory(); | ||
4 | 6 | ||
5 | -export function SurveyPageContainer() { | 7 | +export function SurveyPageContainer({history}) { |
6 | const data = useSelector((state) => state.survey.data); | 8 | const data = useSelector((state) => state.survey.data); |
7 | return ( | 9 | return ( |
8 | <> | 10 | <> |
9 | <SurveyPage | 11 | <SurveyPage |
12 | + history={history} | ||
10 | question={data} | 13 | question={data} |
11 | /> | 14 | /> |
12 | </> | 15 | </> | ... | ... |
1 | import React,{useEffect} from 'react'; | 1 | import React,{useEffect} from 'react'; |
2 | -import './MainPage.scss'; | 2 | +import {getQuestionThunk} from '../store/action/survey'; |
3 | +import { useDispatch } from 'react-redux'; | ||
3 | import {Button} from "antd"; | 4 | import {Button} from "antd"; |
4 | -import axios from 'axios'; | ||
5 | import mainImg from "../assets/main-soldier.png"; | 5 | import mainImg from "../assets/main-soldier.png"; |
6 | -import {getSurvey, getSurveySuccess, getSurveyError} from '../store/action/survey'; | 6 | +import styled from 'styled-components'; |
7 | -import { useDispatch } from 'react-redux'; | 7 | + |
8 | +const Container = styled.div` | ||
9 | + display:flex; | ||
10 | + flex-direction: column; | ||
11 | + align-items: center; | ||
12 | +`; | ||
13 | + | ||
14 | +const MainImg = styled.img` | ||
15 | + margin-top: 2rem; | ||
16 | + width: 70rem; | ||
17 | + height: 35rem; | ||
18 | + border-radius: 1rem; | ||
19 | +`; | ||
20 | + | ||
21 | +const MainTitle = styled.div` | ||
22 | + margin-top: 5rem; | ||
23 | + text-align: center; | ||
24 | + font-size: 5rem; | ||
25 | + font-weight: bold; | ||
26 | +`; | ||
27 | + | ||
28 | +const MainDesc = styled.div` | ||
29 | + margin-top: 2rem; | ||
30 | + margin-bottom: 2rem; | ||
31 | + font-size: 1.5rem; | ||
32 | +`; | ||
8 | 33 | ||
9 | 34 | ||
10 | function MainPage({history}){ | 35 | function MainPage({history}){ |
... | @@ -12,35 +37,27 @@ function MainPage({history}){ | ... | @@ -12,35 +37,27 @@ function MainPage({history}){ |
12 | const onClick = () => { | 37 | const onClick = () => { |
13 | history.push('/survey'); | 38 | history.push('/survey'); |
14 | } | 39 | } |
40 | + | ||
15 | useEffect(()=>{ | 41 | useEffect(()=>{ |
16 | - const getApi = async() =>{ | 42 | + dispatch(getQuestionThunk()); |
17 | - dispatch(getSurvey()); | ||
18 | - try{ | ||
19 | - const {data} = await axios.get("getquestions"); | ||
20 | - dispatch(getSurveySuccess(data)); | ||
21 | - }catch(e){ | ||
22 | - dispatch(getSurveyError(e)); | ||
23 | - } | ||
24 | - } | ||
25 | - getApi(); | ||
26 | },[]); | 43 | },[]); |
27 | 44 | ||
28 | return( | 45 | return( |
29 | <> | 46 | <> |
30 | - <div className="main-wrapper"> | 47 | + <Container> |
31 | - <div className="main-title">KHUSAT</div> | 48 | + <MainTitle>KHUSAT</MainTitle> |
32 | - <div className="main-title__desc"> | 49 | + <MainDesc> |
33 | KHUSAT 특별과정, <br></br> | 50 | KHUSAT 특별과정, <br></br> |
34 | 여러분의 보직을 추천드립니다. | 51 | 여러분의 보직을 추천드립니다. |
35 | - </div> | 52 | + </MainDesc> |
36 | <Button | 53 | <Button |
37 | size="large" | 54 | size="large" |
38 | onClick={onClick} | 55 | onClick={onClick} |
39 | color="#536349" | 56 | color="#536349" |
40 | style={{}} | 57 | style={{}} |
41 | > 시작하기</Button> | 58 | > 시작하기</Button> |
42 | - <img className="main-image" src={mainImg}/> | 59 | + <MainImg src={mainImg}/> |
43 | - </div> | 60 | + </Container> |
44 | </> | 61 | </> |
45 | ); | 62 | ); |
46 | } | 63 | } | ... | ... |
src/pages/MainPage.scss
deleted
100644 → 0
1 | -.main-wrapper{ | ||
2 | - display:flex; | ||
3 | - flex-direction: column; | ||
4 | - align-items: center; | ||
5 | - // max-width: 50rem; | ||
6 | -} | ||
7 | - | ||
8 | -.main-image{ | ||
9 | - margin-top: 2rem; | ||
10 | - width: 70rem; | ||
11 | - height: 35rem; | ||
12 | - border-radius: 1rem; | ||
13 | -} | ||
14 | - | ||
15 | -.main-title{ | ||
16 | - margin-top: 5rem; | ||
17 | - text-align: center; | ||
18 | - font-size: 5rem; | ||
19 | - font-weight: bold; | ||
20 | - &__desc{ | ||
21 | - margin-top: 2rem; | ||
22 | - margin-bottom: 2rem; | ||
23 | - font-size: 1.5rem; | ||
24 | - } | ||
25 | -} |
1 | import React from 'react'; | 1 | import React from 'react'; |
2 | -import {useSelector} from 'react-redux'; | ||
3 | import styled from 'styled-components'; | 2 | import styled from 'styled-components'; |
4 | 3 | ||
5 | const Container = styled.div` | 4 | const Container = styled.div` |
... | @@ -24,18 +23,15 @@ const Description = styled.div` | ... | @@ -24,18 +23,15 @@ const Description = styled.div` |
24 | font-size: 1.4rem; | 23 | font-size: 1.4rem; |
25 | `; | 24 | `; |
26 | 25 | ||
27 | -function ResultPage(){ | 26 | +function ResultPage({result}){ |
28 | - const data = useSelector(state=>state.result.data); | ||
29 | - | ||
30 | return( | 27 | return( |
31 | <> | 28 | <> |
32 | - {data ? ( | 29 | + {result && ( |
33 | <Container> | 30 | <Container> |
34 | - <Title>{data.high}</Title> | 31 | + <Title>{result.high}</Title> |
35 | - <Position>{data.low}</Position> | 32 | + <Position>{result.low}</Position> |
36 | - <Description>{data.description}</Description> | 33 | + <Description>{result.description}</Description> |
37 | </Container>) | 34 | </Container>) |
38 | - : <div>로딩중</div> | ||
39 | } | 35 | } |
40 | </> | 36 | </> |
41 | ); | 37 | ); | ... | ... |
1 | import React, { useState, useEffect } from "react"; | 1 | import React, { useState, useEffect } from "react"; |
2 | import Card from "../components/card/Card"; | 2 | import Card from "../components/card/Card"; |
3 | +import {useDispatch} from 'react-redux'; | ||
4 | +import {getResultThunk} from "../store/action/result"; | ||
3 | import ProgressBar from "../components/progressbar/ProgressBar"; | 5 | import ProgressBar from "../components/progressbar/ProgressBar"; |
4 | import "antd/dist/antd.css"; | 6 | import "antd/dist/antd.css"; |
5 | 7 | ||
... | @@ -35,8 +37,10 @@ function SurveyPage({ history, question }) { | ... | @@ -35,8 +37,10 @@ function SurveyPage({ history, question }) { |
35 | const dispatch = useDispatch(); | 37 | const dispatch = useDispatch(); |
36 | 38 | ||
37 | useEffect(()=>{ | 39 | useEffect(()=>{ |
38 | - if(answer.length === 10){ | 40 | + if(answer.length === 10){ // answer state 배열에 10개가 채워지면, |
39 | - dispatch() | 41 | + dispatch(getResultThunk(answer)); |
42 | + history.push('/result'); | ||
43 | + console.log(history); | ||
40 | } | 44 | } |
41 | },[answer]); | 45 | },[answer]); |
42 | 46 | ... | ... |
-
Please register or login to post a comment