송용우

Update Material Design

This diff could not be displayed because it is too large.
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
3 "version": "0.1.0", 3 "version": "0.1.0",
4 "private": true, 4 "private": true,
5 "dependencies": { 5 "dependencies": {
6 + "@material-ui/core": "^4.10.2",
6 "@testing-library/jest-dom": "^4.2.4", 7 "@testing-library/jest-dom": "^4.2.4",
7 "@testing-library/react": "^9.3.2", 8 "@testing-library/react": "^9.3.2",
8 "@testing-library/user-event": "^7.1.2", 9 "@testing-library/user-event": "^7.1.2",
......
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Paper from '@material-ui/core/Paper';
4 +import Grid from '@material-ui/core/Grid';
5 +import palette from '../../lib/styles/palette';
6 +const useStyles = makeStyles((theme) => ({
7 + root: {
8 + flexGrow: 1,
9 + background: palette.gray[2],
10 + },
11 + paper: {
12 + padding: theme.spacing(2),
13 + textAlign: 'center',
14 + color: theme.palette.text.secondary,
15 + },
16 +}));
17 +const HomeForm = () => {
18 + const classes = useStyles();
19 + return (
20 + <div className={classes.root}>
21 + <Grid container spacing={3}>
22 + <Grid item xs={12}>
23 + <Paper className={classes.paper}>xs=12</Paper>
24 + </Grid>
25 + <Grid item xs={6}>
26 + <Paper className={classes.paper}>xs=6</Paper>
27 + </Grid>
28 + <Grid item xs={6}>
29 + <Paper className={classes.paper}>xs=6</Paper>
30 + </Grid>
31 + <Grid item xs={3}>
32 + <Paper className={classes.paper}>xs=3</Paper>
33 + </Grid>
34 + <Grid item xs={3}>
35 + <Paper className={classes.paper}>xs=3</Paper>
36 + </Grid>
37 + <Grid item xs={3}>
38 + <Paper className={classes.paper}>xs=3</Paper>
39 + </Grid>
40 + <Grid item xs={3}>
41 + <Paper className={classes.paper}>xs=3</Paper>
42 + </Grid>
43 + </Grid>
44 + </div>
45 + );
46 +};
47 +
48 +export default HomeForm;
1 import React from 'react'; 1 import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
2 import styled from 'styled-components'; 3 import styled from 'styled-components';
3 -import Button from '../common/Button';
4 import palette from '../../lib/styles/palette'; 4 import palette from '../../lib/styles/palette';
5 +import Button from '@material-ui/core/Button';
6 +import TextField from '@material-ui/core/TextField';
5 const BJIDFormBlock = styled.div` 7 const BJIDFormBlock = styled.div`
6 width: 100%; 8 width: 100%;
7 - border-top: 1px solid ${palette.gray[2]};
8 padding-top: 2rem; 9 padding-top: 2rem;
9 h4 { 10 h4 {
10 color: ${palette.gray[8]}; 11 color: ${palette.gray[8]};
...@@ -13,21 +14,35 @@ const BJIDFormBlock = styled.div` ...@@ -13,21 +14,35 @@ const BJIDFormBlock = styled.div`
13 } 14 }
14 `; 15 `;
15 16
17 +const useStyles = makeStyles((theme) => ({
18 + root: {
19 + '& > *': {
20 + margin: theme.spacing(1),
21 + },
22 + },
23 +}));
24 +
16 const BJIDForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => { 25 const BJIDForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => {
26 + const classes = useStyles();
17 return ( 27 return (
18 - <BJIDFormBlock> 28 + <div>
19 - <h4>백준 아이디</h4>
20 <form onSubmit={onBJIDSubmit}> 29 <form onSubmit={onBJIDSubmit}>
21 - <input 30 + <TextField
22 name="userBJID" 31 name="userBJID"
23 onChange={onChange} 32 onChange={onChange}
24 value={profile.userBJID} 33 value={profile.userBJID}
25 placeholder="백준 아이디" 34 placeholder="백준 아이디"
35 + id="standard-basic"
36 + label="백준 아이디"
26 /> 37 />
27 - <button type="submit">등록</button> 38 + <Button variant="outlined" type="submit">
39 + 등록
40 + </Button>
28 </form> 41 </form>
29 - <button onClick={onSyncBJIDSubmit}>동기화</button> 42 + <Button variant="outlined" onClick={onSyncBJIDSubmit}>
30 - </BJIDFormBlock> 43 + 동기화
44 + </Button>
45 + </div>
31 ); 46 );
32 }; 47 };
33 export default BJIDForm; 48 export default BJIDForm;
......
...@@ -3,6 +3,9 @@ import styled from 'styled-components'; ...@@ -3,6 +3,9 @@ import styled from 'styled-components';
3 import Button from '../common/Button'; 3 import Button from '../common/Button';
4 import palette from '../../lib/styles/palette'; 4 import palette from '../../lib/styles/palette';
5 import BJIDForm from './BJIDForm'; 5 import BJIDForm from './BJIDForm';
6 +import { makeStyles } from '@material-ui/core/styles';
7 +import Paper from '@material-ui/core/Paper';
8 +import Grid from '@material-ui/core/Grid';
6 9
7 const SettingFormBlock = styled.div` 10 const SettingFormBlock = styled.div`
8 h3 { 11 h3 {
...@@ -33,30 +36,40 @@ const SectionContainer = styled.div` ...@@ -33,30 +36,40 @@ const SectionContainer = styled.div`
33 display: flex; 36 display: flex;
34 `; 37 `;
35 38
39 +const useStyles = makeStyles((theme) => ({
40 + root: {
41 + flexGrow: 1,
42 + background: palette.gray[2],
43 + },
44 + paper: {
45 + margin: 'auto',
46 + textAlign: 'center',
47 + padding: 30,
48 + },
49 +}));
50 +
36 const SettingForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => { 51 const SettingForm = ({ onChange, onBJIDSubmit, profile, onSyncBJIDSubmit }) => {
52 + const classes = useStyles();
37 return ( 53 return (
38 - <SettingFormBlock> 54 + <div className={classes.root}>
39 - <SectionContainer> 55 + <Grid container spacing={3}>
56 + <Grid item xs={12}>
57 + <Paper className={classes.paper}>
40 <h3>{profile.username}</h3> 58 <h3>{profile.username}</h3>
41 - <p>입력</p> 59 + </Paper>
42 - </SectionContainer> 60 + </Grid>
43 - 61 + <Grid container item xs={12}>
44 - <SectionContainer> 62 + <Paper className={classes.paper} elevation={3}>
45 <BJIDForm 63 <BJIDForm
46 profile={profile} 64 profile={profile}
47 onChange={onChange} 65 onChange={onChange}
48 onBJIDSubmit={onBJIDSubmit} 66 onBJIDSubmit={onBJIDSubmit}
49 onSyncBJIDSubmit={onSyncBJIDSubmit} 67 onSyncBJIDSubmit={onSyncBJIDSubmit}
50 /> 68 />
51 - </SectionContainer> 69 + </Paper>
52 - 70 + </Grid>
53 - <SectionContainer> 71 + </Grid>
54 - <h3>친구</h3> 72 + </div>
55 - <StyledInput name="BJID" placeholder="친구 아이디" />
56 - <Button>추가</Button>
57 - </SectionContainer>
58 - <h3>친구 리스트</h3>
59 - </SettingFormBlock>
60 ); 73 );
61 }; 74 };
62 75
......
1 +import React, { useEffect, useState } from 'react';
2 +import { useDispatch, useSelector } from 'react-redux';
3 +import { withRouter } from 'react-router-dom';
4 +import HomeForm from '../../components/home/HomeForm';
5 +const HomeContainer = ({ histroy }) => {
6 + const dispatch = useDispatch();
7 + const [isLogin, setLogin] = useState(false);
8 + const { user, profile } = useSelector(({ user, profile }) => ({
9 + user: user.user,
10 + profile: profile,
11 + }));
12 +
13 + useEffect(() => {
14 + if (user) {
15 + setLogin(true);
16 + }
17 + });
18 + return <HomeForm />;
19 +};
20 +export default withRouter(HomeContainer);
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
9 initializeProfile, 9 initializeProfile,
10 } from '../../modules/profile'; 10 } from '../../modules/profile';
11 import SettingForm from '../../components/setting/SettingForm'; 11 import SettingForm from '../../components/setting/SettingForm';
12 -import { sync } from '../../../node_modules/fast-glob/index'; 12 +
13 const SettingContainer = ({ history }) => { 13 const SettingContainer = ({ history }) => {
14 const dispatch = useDispatch(); 14 const dispatch = useDispatch();
15 const { user, profile } = useSelector(({ user, profile }) => ({ 15 const { user, profile } = useSelector(({ user, profile }) => ({
...@@ -42,12 +42,17 @@ const SettingContainer = ({ history }) => { ...@@ -42,12 +42,17 @@ const SettingContainer = ({ history }) => {
42 }; 42 };
43 43
44 useEffect(() => { 44 useEffect(() => {
45 + if (!user) {
46 + alert('로그인이 필요합니다 ');
47 + history.push('/');
48 + } else {
45 let username = user.username; 49 let username = user.username;
46 dispatch(getPROFILE({ username })); 50 dispatch(getPROFILE({ username }));
47 return () => { 51 return () => {
48 dispatch(initializeProfile()); 52 dispatch(initializeProfile());
49 }; 53 };
50 - }, [dispatch, user]); 54 + }
55 + }, [dispatch, user, history]);
51 56
52 return ( 57 return (
53 <SettingForm 58 <SettingForm
......
1 +/*
2 +1. 날짜 순 정렬
3 +2. 현재 날짜와의 차이
4 +3. 최근 일주일간 푼 문제 수
5 +4. 추천 문제
6 +*/
7 +exports.analyzeBJ = function (solvedBJ) {
8 + console.log(solvedBJ);
9 +};
1 import React from 'react'; 1 import React from 'react';
2 import HeaderContainer from '../containers/common/HeaderContainer'; 2 import HeaderContainer from '../containers/common/HeaderContainer';
3 -import Button from '../components/common/Button'; 3 +import HomeContainer from '../containers/home/HomeContainer';
4 4
5 const HomePage = () => { 5 const HomePage = () => {
6 return ( 6 return (
7 <div> 7 <div>
8 <HeaderContainer /> 8 <HeaderContainer />
9 - <Button>home</Button> 9 + <HomeContainer />
10 </div> 10 </div>
11 ); 11 );
12 }; 12 };
......