이준호

update: 리드미 업데이트

1 -# Getting Started with Create React App 1 +# 👨‍✈️ KHUSAT
2 2
3 -This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 3 +---
4 4
5 -## Available Scripts 5 +**KHUSAT : 성격 유형 테스트로 알아보는 병과 추천 테스트**
6 6
7 -In the project directory, you can run: 7 +요즘 SNS에 MBTI를 시작으로 많은 유형의 성격 유형 테스트가 있습니다!
8 8
9 -### `yarn start` 9 +꽃으로 알아보는, 스낵으로 알아보는, 등등... 저희는 좀 특별하답니다 👏
10 10
11 -Runs the app in the development mode.\ 11 +20대 남자면 꼭 가야만 하는 군대, 어떤 보직이 알맞을지 미리 추천해 드리겠습니다.
12 -Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
13 12
14 -The page will reload if you make edits.\ 13 +(이미지 추가하기)
15 -You will also see any lint errors in the console.
16 14
17 -### `yarn test` 15 +## 🔖 프로그램 구조
18 16
19 -Launches the test runner in the interactive watch mode.\ 17 +---
20 -See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
21 18
22 -### `yarn build` 19 +`KHUSAT-FRONT`
23 20
24 -Builds the app for production to the `build` folder.\ 21 +- `components` : 재사용이 가능한 component들을 모아놓았습니다.
25 -It correctly bundles React in production mode and optimizes the build for the best performance. 22 +- `pages` : 기능별 화면을 모아놓은 라우팅 페이지들 입니다.
23 +- `store` : 상태관리를 위한 redux store 입니다.
26 24
27 -The build is minified and the filenames include the hashes.\ 25 +`KHUSAT-SERVER`
28 -Your app is ready to be deployed!
29 26
30 -See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 27 +## 🌏 개발환경 및 사용 언어
31 28
32 -### `yarn eject` 29 +---
33 30
34 -**Note: this is a one-way operation. Once you `eject`, you can’t go back!** 31 +`KHUSAT-FRONT`
35 32
36 -If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 33 +- Visual Studio Code
34 +- React.js
35 +- Redux, Redux-thunk(redux middleware)
37 36
38 -Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 37 +🌟**dependency**
39 38
40 -You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 39 +- sass
40 +- antd
41 +- axios
42 +- react-router-dom
41 43
42 -## Learn More 44 +`KHUSAT-SERVER`
43 45
44 -You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 46 +## 🔎 사용 방법
45 47
46 -To learn React, check out the [React documentation](https://reactjs.org/). 48 +---
47 49
48 -### Code Splitting 50 +**(배포 이전) Local에서 동작하는 방법을 소개합니다.**
49 51
50 -This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 52 +1. repository clone 하기
53 + > 원하는 디렉토리에서 khusat-front 를 클론해옵니다.
51 54
52 -### Analyzing the Bundle Size 55 + ```jsx
56 + git clone http://khuhub.khu.ac.kr/khusat/khusat-front.git
57 + ```
53 58
54 -This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 59 +2. package 파일 설치하기
60 + > 빌드를 위한 패키지 모듈들을 설치합니다. (yarn을 추천합니다)
55 61
56 -### Making a Progressive Web App 62 + ```jsx
63 + yarn // yarn 만 입력합니다.
64 + npm install // npm 사용시 npm install을 입력합니다.
65 + ```
57 66
58 -This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 67 +3. application 실행하기
68 + > `yarn start` 로 실행 후 [`localhost:3000`](http://localhost:3000) 으로 접속하여 테스트 할 수 있습니다!
59 69
60 -### Advanced Configuration 70 + ```jsx
71 + yarn start
72 + https://localhost:3000
73 + ```
61 74
62 -This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 75 +## 👥 구성원 소개
63 76
64 -### Deployment 77 +> KHUSAT의 개발자들 입니다.
65 78
66 -This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 79 +|🙋[이준호](https://github.com/juno7803)|🙋[박기홍](https://github.com/kyhong222)|
80 +|:------:|:-----:|
81 +|![이준호사진]()|![박기홍사진]()|
82 +|프론트 개발자|서버 개발자|
67 83
68 -### `yarn build` fails to minify 84 +## © License
69 -
70 -This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)
...\ No newline at end of file ...\ No newline at end of file
......
1 -import React from 'react'; 1 +import React, { useEffect } from 'react';
2 import './Card.scss'; 2 import './Card.scss';
3 3
4 function Card({question,answer,setAnswer,curIdx,setCurIdx}){ 4 function Card({question,answer,setAnswer,curIdx,setCurIdx}){
......
1 -import React,{useState} from 'react'; 1 +import React,{useEffect, useState} from 'react';
2 import './MainPage.scss'; 2 import './MainPage.scss';
3 import ProgressBar from "../components/progressbar/ProgressBar"; 3 import ProgressBar from "../components/progressbar/ProgressBar";
4 import {Button} from "antd"; 4 import {Button} from "antd";
5 +import axios from 'axios';
5 import mainImg from "../assets/main-soldier.png"; 6 import mainImg from "../assets/main-soldier.png";
7 +import {getSurvey,getSurveySuccess,getSurveyError} from '../store/action/survey';
6 8
7 function MainPage({history}){ 9 function MainPage({history}){
8 //const [percent,setPercent] = useState(0); 10 //const [percent,setPercent] = useState(0);
9 const onClick = () => { 11 const onClick = () => {
10 history.push('/survey'); 12 history.push('/survey');
11 } 13 }
14 + useEffect(()=>{
15 + // const getApi = async() =>{
16 + // dispatch(getSurvey());
17 + // try{
18 + // const {data} = await axios.get("getquestions");
19 + // setQuestion(data);
20 + // dispatch(getSurveySuccess(data));
21 + // }catch(e){
22 + // dispatch(getSurveyError(e));
23 + // }
24 + // }
25 + // getApi();
26 + const getApi = async()=>{
27 + const {data} = await axios.get("getquestions");
28 + localStorage.setItem('question',JSON.stringify(data));
29 + }
30 + getApi();
31 +
32 + },[]);
12 33
13 return( 34 return(
14 <> 35 <>
...@@ -23,6 +44,7 @@ function MainPage({history}){ ...@@ -23,6 +44,7 @@ function MainPage({history}){
23 size="large" 44 size="large"
24 onClick={onClick} 45 onClick={onClick}
25 color="#536349" 46 color="#536349"
47 + style={{}}
26 > 시작하기</Button> 48 > 시작하기</Button>
27 <img className="main-image" src={mainImg}/> 49 <img className="main-image" src={mainImg}/>
28 </div> 50 </div>
......
...@@ -2,20 +2,25 @@ import React from 'react'; ...@@ -2,20 +2,25 @@ import React from 'react';
2 import {useSelector} from 'react-redux'; 2 import {useSelector} from 'react-redux';
3 import './ResultPage.scss'; 3 import './ResultPage.scss';
4 4
5 +
5 function ResultPage(){ 6 function ResultPage(){
6 const data = useSelector(state=>state.result.data); 7 const data = useSelector(state=>state.result.data);
7 8
8 return( 9 return(
9 <div className="container"> 10 <div className="container">
10 - {data && ( 11 + {data ? (
11 <div className="result"> 12 <div className="result">
12 <div className="result__title">{data.high}</div> 13 <div className="result__title">{data.high}</div>
13 <div className="result__position">{data.low}</div> 14 <div className="result__position">{data.low}</div>
14 <div className="result__desc">{data.description}</div> 15 <div className="result__desc">{data.description}</div>
15 - <div><img src={data.image}/></div> 16 + {/* <div><img src={"/Users/ijunho/Desktop/JUNHO/khusat-front/src/assets/db"+data.image.split("khusat_DB")[1]}/></div> */}
16 - </div> 17 + {/* {console.log(data.image.split("khusat_DB")[1])} */}
17 - )} 18 + {/* <div><img src={"../../assets/db"+data.image.split("khusat_DB")[1]}/></div> */}
18 - 19 + {/* /Users/daydream/Desktop/khusat_server/khusat_DB : 47*/}
20 + {/* `${(data.image).substring(47,data.image.length)}/Users/ijunho/desktop/junho/khusat-front/src/assets/db` */}
21 + </div>)
22 + : <div>로딩중</div>
23 + }
19 </div> 24 </div>
20 ); 25 );
21 } 26 }
......
...@@ -5,27 +5,50 @@ import axios from 'axios'; ...@@ -5,27 +5,50 @@ import axios from 'axios';
5 import "./SurveyPage.scss"; 5 import "./SurveyPage.scss";
6 import 'antd/dist/antd.css' 6 import 'antd/dist/antd.css'
7 // import redux 7 // import redux
8 -import {useDispatch} from 'react-redux'; 8 +import {useDispatch,useSelector} from 'react-redux';
9 import {getResult,getResultSuccess,getResultError} from '../store/action/result'; 9 import {getResult,getResultSuccess,getResultError} from '../store/action/result';
10 +import {getSurvey,getSurveySuccess,getSurveyError} from '../store/action/survey';
11 +import ResultPage from "./ResultPage";
12 +// import styled,{css} from 'styled-components';
13 +
14 +// const Slider = styled.div`
15 +// border: 1px solid gray;
16 +// width: 30rem;
17 +// display: flex;
18 +// align-items: center;
19 +// margin: 0 auto;
20 +// transform: translateX(${-30}rem);
21 +// transition: 0.5s
22 +// overflow: hidden;
23 +// `;
10 24
11 function SurveyPage({history}) { 25 function SurveyPage({history}) {
12 const [curIdx, setCurIdx] = useState(0); 26 const [curIdx, setCurIdx] = useState(0);
13 - const [question, setQuestion] = useState([]); 27 + const [question, setQuestion] = useState(JSON.parse(localStorage.getItem('question')||'{}'));
14 const [answer, setAnswer] = useState([]); 28 const [answer, setAnswer] = useState([]);
15 const dispatch = useDispatch(); 29 const dispatch = useDispatch();
16 30
17 - useEffect(()=>{ 31 + const data = useSelector(state=>state.survey.data);
18 - const getApi = async() =>{ 32 + // useEffect(()=>{
19 - const {data} = await axios.get("getquestions"); 33 + // const getApi = async() =>{
20 - setQuestion(data); 34 + // dispatch(getSurvey());
21 - } 35 + // try{
22 - getApi(); 36 + // const {data} = await axios.get("getquestions");
23 - },[]); 37 + // setQuestion(data);
38 + // dispatch(getSurveySuccess(data));
39 + // }catch(e){
40 + // dispatch(getSurveyError(e));
41 + // }
42 + // }
43 + // getApi();
44 + // },[]);
24 45
25 useEffect(()=>{ 46 useEffect(()=>{
47 + console.log(curIdx);
26 if(curIdx === 10){ 48 if(curIdx === 10){
49 + // setCurIdx(curIdx-1);
27 const postApi = async ()=>{ 50 const postApi = async ()=>{
28 - dispatch(getResult); 51 + dispatch(getResult());
29 try{ 52 try{
30 const {data} = await axios.post("submit", answer); 53 const {data} = await axios.post("submit", answer);
31 console.log(data); 54 console.log(data);
...@@ -41,29 +64,40 @@ function SurveyPage({history}) { ...@@ -41,29 +64,40 @@ function SurveyPage({history}) {
41 64
42 return ( 65 return (
43 <div className="container"> 66 <div className="container">
44 - <div className="container__progress"> 67 + <div className="container__progress"></div>
45 - <ProgressBar percent={curIdx*10} />
46 - </div>
47 <div className="slider"> 68 <div className="slider">
48 - {question && question.map((question,index) => ( 69 + {
49 - <div className="slider__wrapper"> 70 + curIdx === 11? history.push('/result') :(<Card
50 - <Card 71 + question={question[curIdx]}
51 - key={question.num}
52 - question={question}
53 answer={answer} 72 answer={answer}
54 setAnswer={setAnswer} 73 setAnswer={setAnswer}
55 curIdx={curIdx} 74 curIdx={curIdx}
56 setCurIdx={setCurIdx} 75 setCurIdx={setCurIdx}
57 - style={{ 76 + />)
58 - transform: `translateX(${(-30)*curIdx}rem)`, 77 + }
59 - transition: "0.5s",
60 - }}
61 - />
62 - </div>
63 - ))}
64 </div> 78 </div>
65 </div> 79 </div>
66 ); 80 );
67 } 81 }
68 82
69 export default SurveyPage; 83 export default SurveyPage;
84 +
85 +// {/* <Slider> */}
86 +// {question && question.map((question,index) => (
87 +// <div className="slider__wrapper">
88 +// {/* <ProgressBar percent={curIdx*10} /> */}
89 +// <Card
90 +// key={question.num}
91 +// question={question}
92 +// answer={answer}
93 +// setAnswer={setAnswer}
94 +// curIdx={curIdx}
95 +// setCurIdx={setCurIdx}
96 +// style={{
97 +// transform: `translate3d(${(-30)*curIdx}rem,0,0)`,
98 +// transition: "0.5s",
99 +// }}
100 +// />
101 +// </div>
102 +// ))}
103 +// {/* </Slider> */}
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -11,15 +11,14 @@ ...@@ -11,15 +11,14 @@
11 } 11 }
12 12
13 .slider{ 13 .slider{
14 - border: 1px solid gray; 14 + // border: 1px solid gray;
15 width: 30rem; 15 width: 30rem;
16 display: flex; 16 display: flex;
17 align-items: center; 17 align-items: center;
18 - margin: 0; 18 + margin: 0 auto;
19 overflow: hidden; 19 overflow: hidden;
20 20
21 &__wrapper{ 21 &__wrapper{
22 - border: 1px solid red;
23 width: 30rem; 22 width: 30rem;
24 } 23 }
25 &__desc{ 24 &__desc{
...@@ -29,4 +28,12 @@ ...@@ -29,4 +28,12 @@
29 } 28 }
30 } 29 }
31 30
32 -// swiper 31 +// .slider__wrapper{
32 +// // border: 1px solid red;
33 +// width: 30rem;
34 +// }
35 +// .slider__desc{
36 +// font-size: 2rem;
37 +// font-weight: bold;
38 +// margin-bottom: 2rem;
39 +// }
...\ No newline at end of file ...\ No newline at end of file
......
1 +// action
2 +const GET_SURVEY = 'GET_SURVEY';
3 +const GET_SURVEY_SUCCESS = 'GET_SURVEY_SUCCESS';
4 +const GET_SURVEY_ERROR = 'GET_SURVEY_ERROR';
5 +
6 +// action creators
7 +export const getSurvey = () => ({type:GET_SURVEY});
8 +export const getSurveySuccess = (data) => ({type: GET_SURVEY_SUCCESS, payload: data});
9 +export const getSurveyError = (e) => ({type: GET_SURVEY_ERROR, payload: e});
10 +
11 +const initialState = {
12 + loading: true,
13 + data: null,
14 + error: null
15 +}
16 +
17 +function survey(
18 + state = initialState,
19 + action
20 +){
21 + switch(action.type){
22 + case GET_SURVEY: {
23 + return{
24 + loading: true,
25 + data: null,
26 + error: null
27 + }
28 + }
29 + case GET_SURVEY_SUCCESS:{
30 + return{
31 + loading: false,
32 + data: action.payload,
33 + error: null
34 + }
35 + }
36 + case GET_SURVEY_ERROR:{
37 + return{
38 + loading: false,
39 + data: null,
40 + error: action.payload
41 + }
42 + }
43 + default:
44 + return state;
45 + }
46 +}
47 +
48 +export default survey;
...\ No newline at end of file ...\ No newline at end of file
1 import {combineReducers} from 'redux'; 1 import {combineReducers} from 'redux';
2 import result from "./action/result"; 2 import result from "./action/result";
3 +import survey from "./action/survey";
3 4
4 const rootReducer = combineReducers({ 5 const rootReducer = combineReducers({
5 result, 6 result,
7 + survey
6 }) 8 })
7 9
8 export default rootReducer; 10 export default rootReducer;
...\ No newline at end of file ...\ No newline at end of file
......