Showing
3 changed files
with
28 additions
and
18 deletions
... | @@ -3,15 +3,17 @@ import React, { useState, useEffect } from "react"; | ... | @@ -3,15 +3,17 @@ import React, { useState, useEffect } from "react"; |
3 | import { makeStyles } from "@material-ui/core/styles"; | 3 | import { makeStyles } from "@material-ui/core/styles"; |
4 | import Container from "@material-ui/core/Container"; | 4 | import Container from "@material-ui/core/Container"; |
5 | import Grid from "@material-ui/core/Grid"; | 5 | import Grid from "@material-ui/core/Grid"; |
6 | +import Typography from "@material-ui/core/Typography"; | ||
7 | + | ||
6 | import Icon from "@material-ui/core/Icon"; | 8 | import Icon from "@material-ui/core/Icon"; |
7 | -import CircularProgress from "@material-ui/core/CircularProgress"; | 9 | +// import CircularProgress from "@material-ui/core/CircularProgress"; |
8 | 10 | ||
9 | import TodoCard from "./TodoCard.js"; | 11 | import TodoCard from "./TodoCard.js"; |
10 | 12 | ||
11 | const useStyles = makeStyles((theme) => ({ | 13 | const useStyles = makeStyles((theme) => ({ |
12 | root: { | 14 | root: { |
13 | - minHeight:"100vh", | 15 | + minHeight: "100vh", |
14 | - backgroundColor: "rgba(1,0,0,0.5)" | 16 | + backgroundColor: "rgba(0,0,0,0.5)", |
15 | }, | 17 | }, |
16 | container: { | 18 | container: { |
17 | flexGrow: 1, | 19 | flexGrow: 1, |
... | @@ -19,7 +21,7 @@ const useStyles = makeStyles((theme) => ({ | ... | @@ -19,7 +21,7 @@ const useStyles = makeStyles((theme) => ({ |
19 | paddingBottom: "1rem", | 21 | paddingBottom: "1rem", |
20 | marginLeft: "auto", | 22 | marginLeft: "auto", |
21 | marginRight: "auto", | 23 | marginRight: "auto", |
22 | - } | 24 | + }, |
23 | })); | 25 | })); |
24 | 26 | ||
25 | export default function BodyLayout() { | 27 | export default function BodyLayout() { |
... | @@ -31,7 +33,7 @@ export default function BodyLayout() { | ... | @@ -31,7 +33,7 @@ export default function BodyLayout() { |
31 | const callApi = async () => { | 33 | const callApi = async () => { |
32 | const response = await fetch("/api/cards"); | 34 | const response = await fetch("/api/cards"); |
33 | const body = await response.json(); | 35 | const body = await response.json(); |
34 | - return body; | 36 | + return body.reverse(); |
35 | }; | 37 | }; |
36 | 38 | ||
37 | useEffect(() => { | 39 | useEffect(() => { |
... | @@ -44,27 +46,35 @@ export default function BodyLayout() { | ... | @@ -44,27 +46,35 @@ export default function BodyLayout() { |
44 | }, []); | 46 | }, []); |
45 | 47 | ||
46 | if (isLoading) { | 48 | if (isLoading) { |
47 | - return ( | 49 | + return <></>; |
48 | - <> | ||
49 | - <CircularProgress /> | ||
50 | - </> | ||
51 | - ); | ||
52 | } else { | 50 | } else { |
53 | return ( | 51 | return ( |
54 | <div className={classes.root}> | 52 | <div className={classes.root}> |
55 | <Container className={classes.container} maxwidth="md"> | 53 | <Container className={classes.container} maxwidth="md"> |
56 | <Grid className={classes.item} container> | 54 | <Grid className={classes.item} container> |
57 | - {data.map((data) => { | 55 | + {data.map((card, idx) => { |
56 | + if (idx===0 || card.date !== data[idx - 1].date) { | ||
58 | return ( | 57 | return ( |
58 | + <> | ||
59 | + <Typography variant="h4" style={{width:"100%", color:"white"}}>{card.date}</Typography> | ||
59 | <Grid item xs={6} sm={6} md={3}> | 60 | <Grid item xs={6} sm={6} md={3}> |
60 | - <TodoCard id={data.id} data={data} /> | 61 | + <TodoCard key={card.id} data={card} /> |
61 | </Grid> | 62 | </Grid> |
63 | + </> | ||
62 | ); | 64 | ); |
63 | - })} | 65 | + } else { |
64 | - <hr width="100%" height="19%" color="white" /> | 66 | + return ( |
65 | <Grid item xs={6} sm={6} md={3}> | 67 | <Grid item xs={6} sm={6} md={3}> |
66 | - <Icon style={{ fontSize: 60 }}>add_circle</Icon> | 68 | + <TodoCard key={card.id} data={card} /> |
67 | </Grid> | 69 | </Grid> |
70 | + ); | ||
71 | + } | ||
72 | + })} | ||
73 | + | ||
74 | + {/* <Grid item xs={6} sm={6} md={3}> | ||
75 | + <Icon style={{ fontSize: 60 }}>add_circle</Icon> | ||
76 | + </Grid> */} | ||
77 | + | ||
68 | </Grid> | 78 | </Grid> |
69 | </Container> | 79 | </Container> |
70 | </div> | 80 | </div> | ... | ... |
... | @@ -33,9 +33,9 @@ export default function ButtonAppBar() { | ... | @@ -33,9 +33,9 @@ export default function ButtonAppBar() { |
33 | <MenuIcon /> | 33 | <MenuIcon /> |
34 | </IconButton> | 34 | </IconButton> |
35 | <Typography variant="h6" className={classes.title}> | 35 | <Typography variant="h6" className={classes.title}> |
36 | - Fuck | 36 | + Do-gether |
37 | </Typography> | 37 | </Typography> |
38 | - <Button color="inherit">Login</Button> | 38 | + <Button color="inherit">Logout</Button> |
39 | </Toolbar> | 39 | </Toolbar> |
40 | </AppBar> | 40 | </AppBar> |
41 | </div> | 41 | </div> | ... | ... |
... | @@ -41,7 +41,7 @@ export default function TodoCard(props) { | ... | @@ -41,7 +41,7 @@ export default function TodoCard(props) { |
41 | const todo = data.todo.split(","); | 41 | const todo = data.todo.split(","); |
42 | const isTrue = "1"; | 42 | const isTrue = "1"; |
43 | const check = data.ck.split(",").map((ck) => { | 43 | const check = data.ck.split(",").map((ck) => { |
44 | - return isTrue == ck; | 44 | + return isTrue === ck; |
45 | }); | 45 | }); |
46 | 46 | ||
47 | return ( | 47 | return ( | ... | ... |
-
Please register or login to post a comment