Showing
2 changed files
with
45 additions
and
18 deletions
... | @@ -22,6 +22,12 @@ const useStyles = makeStyles((theme) => ({ | ... | @@ -22,6 +22,12 @@ const useStyles = makeStyles((theme) => ({ |
22 | marginLeft: "auto", | 22 | marginLeft: "auto", |
23 | marginRight: "auto", | 23 | marginRight: "auto", |
24 | }, | 24 | }, |
25 | + date: { | ||
26 | + width: "100%", | ||
27 | + paddingLeft: "1rem", | ||
28 | + paddingTop: "1rem", | ||
29 | + color: "white", | ||
30 | + }, | ||
25 | })); | 31 | })); |
26 | 32 | ||
27 | export default function BodyLayout() { | 33 | export default function BodyLayout() { |
... | @@ -40,6 +46,7 @@ export default function BodyLayout() { | ... | @@ -40,6 +46,7 @@ export default function BodyLayout() { |
40 | callApi() | 46 | callApi() |
41 | .then((res) => { | 47 | .then((res) => { |
42 | setData(res); | 48 | setData(res); |
49 | + console.log(res); | ||
43 | setIsLoading(0); | 50 | setIsLoading(0); |
44 | }) | 51 | }) |
45 | .catch((err) => console.log(err)); | 52 | .catch((err) => console.log(err)); |
... | @@ -53,28 +60,45 @@ export default function BodyLayout() { | ... | @@ -53,28 +60,45 @@ export default function BodyLayout() { |
53 | <Container className={classes.container} maxwidth="md"> | 60 | <Container className={classes.container} maxwidth="md"> |
54 | <Grid className={classes.item} container> | 61 | <Grid className={classes.item} container> |
55 | {data.map((card, idx) => { | 62 | {data.map((card, idx) => { |
56 | - if (idx===0 || card.date !== data[idx - 1].date) { | 63 | + let isVisible = card.isPublic; |
64 | + let showDate = null; | ||
65 | + const isMine = card.name === "aa"; ////data.name과 session name 비교 로그인 구현하고 수정 | ||
66 | + | ||
67 | + | ||
68 | + if (idx === 0 || card.date !== data[idx - 1].date) { | ||
69 | + showDate=( | ||
70 | + <Typography variant="h4" className={classes.date}> | ||
71 | + {card.date} | ||
72 | + </Typography> | ||
73 | + ); | ||
74 | + } | ||
75 | + | ||
76 | + if (isMine) { | ||
77 | + isVisible = 1; | ||
78 | + } | ||
79 | + | ||
80 | + if (isVisible === 1) { | ||
57 | return ( | 81 | return ( |
58 | <> | 82 | <> |
59 | - <Typography variant="h4" style={{width:"100%", color:"white"}}>{card.date}</Typography> | 83 | + {showDate} |
60 | <Grid item xs={6} sm={6} md={3}> | 84 | <Grid item xs={6} sm={6} md={3}> |
61 | - <TodoCard key={card.id} data={card} /> | 85 | + <TodoCard |
86 | + key={card.id} | ||
87 | + data={card} | ||
88 | + isVisible={isVisible} | ||
89 | + isMine={isMine} | ||
90 | + /> | ||
62 | </Grid> | 91 | </Grid> |
63 | </> | 92 | </> |
64 | ); | 93 | ); |
65 | } else { | 94 | } else { |
66 | - return ( | 95 | + return <>{ showDate }</>; |
67 | - <Grid item xs={6} sm={6} md={3}> | ||
68 | - <TodoCard key={card.id} data={card} /> | ||
69 | - </Grid> | ||
70 | - ); | ||
71 | } | 96 | } |
72 | })} | 97 | })} |
73 | 98 | ||
74 | {/* <Grid item xs={6} sm={6} md={3}> | 99 | {/* <Grid item xs={6} sm={6} md={3}> |
75 | <Icon style={{ fontSize: 60 }}>add_circle</Icon> | 100 | <Icon style={{ fontSize: 60 }}>add_circle</Icon> |
76 | </Grid> */} | 101 | </Grid> */} |
77 | - | ||
78 | </Grid> | 102 | </Grid> |
79 | </Container> | 103 | </Container> |
80 | </div> | 104 | </div> | ... | ... |
... | @@ -35,15 +35,22 @@ const useStyles = makeStyles({ | ... | @@ -35,15 +35,22 @@ const useStyles = makeStyles({ |
35 | }, | 35 | }, |
36 | }); | 36 | }); |
37 | 37 | ||
38 | -export default function TodoCard(props) { | 38 | +export default function TodoCard({ data, isMine, isVisible }) { |
39 | const classes = useStyles(); | 39 | const classes = useStyles(); |
40 | - const data = props.data; | ||
41 | const todo = data.todo.split(","); | 40 | const todo = data.todo.split(","); |
42 | - const isTrue = "1"; | ||
43 | const check = data.ck.split(",").map((ck) => { | 41 | const check = data.ck.split(",").map((ck) => { |
44 | - return isTrue === ck; | 42 | + return parseInt(ck); |
45 | }); | 43 | }); |
46 | 44 | ||
45 | + let settingButton = null; | ||
46 | + | ||
47 | + if (isMine) { | ||
48 | + settingButton = ( | ||
49 | + <Icon className={classes.icon} color="primary"> | ||
50 | + settings | ||
51 | + </Icon> | ||
52 | + ); | ||
53 | + } | ||
47 | return ( | 54 | return ( |
48 | <Card className={classes.root}> | 55 | <Card className={classes.root}> |
49 | <CardContent> | 56 | <CardContent> |
... | @@ -51,18 +58,14 @@ export default function TodoCard(props) { | ... | @@ -51,18 +58,14 @@ export default function TodoCard(props) { |
51 | {data.date} · {data.name} | 58 | {data.date} · {data.name} |
52 | </Typography> | 59 | </Typography> |
53 | 60 | ||
54 | - <Icon className={classes.icon} color="primary"> | 61 | + {settingButton} |
55 | - settings | ||
56 | - </Icon> | ||
57 | 62 | ||
58 | <Typography className={classes.title} variant="h6"> | 63 | <Typography className={classes.title} variant="h6"> |
59 | {data.title} | 64 | {data.title} |
60 | </Typography> | 65 | </Typography> |
61 | - | ||
62 | {/* <Typography className={classes.percent} variant="h6"> | 66 | {/* <Typography className={classes.percent} variant="h6"> |
63 | 99% | 67 | 99% |
64 | </Typography> */} | 68 | </Typography> */} |
65 | - | ||
66 | {todo.map((item, idx) => { | 69 | {todo.map((item, idx) => { |
67 | return ( | 70 | return ( |
68 | <FormControlLabel | 71 | <FormControlLabel | ... | ... |
-
Please register or login to post a comment