김대휘

DB 재연결 및 구조수정

...@@ -10,6 +10,7 @@ import TodoCard from "./TodoCard.js"; ...@@ -10,6 +10,7 @@ import TodoCard from "./TodoCard.js";
10 10
11 const useStyles = makeStyles((theme) => ({ 11 const useStyles = makeStyles((theme) => ({
12 root: { 12 root: {
13 + minHeight:"100vh",
13 backgroundColor: "rgba(1,0,0,0.5)" 14 backgroundColor: "rgba(1,0,0,0.5)"
14 }, 15 },
15 container: { 16 container: {
...@@ -18,12 +19,12 @@ const useStyles = makeStyles((theme) => ({ ...@@ -18,12 +19,12 @@ const useStyles = makeStyles((theme) => ({
18 paddingBottom: "1rem", 19 paddingBottom: "1rem",
19 marginLeft: "auto", 20 marginLeft: "auto",
20 marginRight: "auto", 21 marginRight: "auto",
21 - }, 22 + }
22 - item: {},
23 })); 23 }));
24 24
25 export default function BodyLayout() { 25 export default function BodyLayout() {
26 const classes = useStyles(); 26 const classes = useStyles();
27 +
27 const [data, setData] = useState([]); 28 const [data, setData] = useState([]);
28 const [isLoading, setIsLoading] = useState(1); 29 const [isLoading, setIsLoading] = useState(1);
29 30
...@@ -56,7 +57,7 @@ export default function BodyLayout() { ...@@ -56,7 +57,7 @@ export default function BodyLayout() {
56 {data.map((data) => { 57 {data.map((data) => {
57 return ( 58 return (
58 <Grid item xs={6} sm={6} md={3}> 59 <Grid item xs={6} sm={6} md={3}>
59 - <TodoCard data={data} id={data.date}/> 60 + <TodoCard id={data.id} data={data} />
60 </Grid> 61 </Grid>
61 ); 62 );
62 })} 63 })}
......
1 +import React from 'react';
2 +import { makeStyles } from '@material-ui/core/styles';
3 +import Modal from '@material-ui/core/Modal';
4 +
5 +function rand() {
6 + return Math.round(Math.random() * 20) - 10;
7 +}
8 +
9 +function getModalStyle() {
10 + const top = 50 + rand();
11 + const left = 50 + rand();
12 +
13 + return {
14 + top: `${top}%`,
15 + left: `${left}%`,
16 + transform: `translate(-${top}%, -${left}%)`,
17 + };
18 +}
19 +
20 +const useStyles = makeStyles((theme) => ({
21 + paper: {
22 + position: 'absolute',
23 + width: 400,
24 + backgroundColor: theme.palette.background.paper,
25 + border: '2px solid #000',
26 + boxShadow: theme.shadows[5],
27 + padding: theme.spacing(2, 4, 3),
28 + },
29 +}));
30 +
31 +export default function SimpleModal() {
32 + const classes = useStyles();
33 + // getModalStyle is not a pure function, we roll the style only on the first render
34 + const [modalStyle] = React.useState(getModalStyle);
35 + const [open, setOpen] = React.useState(false);
36 +
37 + const handleOpen = () => {
38 + setOpen(true);
39 + };
40 +
41 + const handleClose = () => {
42 + setOpen(false);
43 + };
44 +
45 + const body = (
46 + <div style={modalStyle} className={classes.paper}>
47 + <h2 id="simple-modal-title">Text in a modal</h2>
48 + <p id="simple-modal-description">
49 + Duis mollis, est non commodo luctus, nisi erat porttitor ligula.
50 + </p>
51 + <SimpleModal />
52 + </div>
53 + );
54 +
55 + return (
56 + <div>
57 + <button type="button" onClick={handleOpen}>
58 + Open Modal
59 + </button>
60 + <Modal
61 + open={open}
62 + onClose={handleClose}
63 + aria-labelledby="simple-modal-title"
64 + aria-describedby="simple-modal-description"
65 + >
66 + {body}
67 + </Modal>
68 + </div>
69 + );
70 +}
...@@ -9,7 +9,7 @@ import Icon from "@material-ui/core/Icon"; ...@@ -9,7 +9,7 @@ import Icon from "@material-ui/core/Icon";
9 9
10 const useStyles = makeStyles({ 10 const useStyles = makeStyles({
11 root: { 11 root: {
12 - margin:10 12 + margin: 10,
13 }, 13 },
14 date: { 14 date: {
15 fontSize: 14, 15 fontSize: 14,
...@@ -38,6 +38,12 @@ const useStyles = makeStyles({ ...@@ -38,6 +38,12 @@ const useStyles = makeStyles({
38 export default function TodoCard(props) { 38 export default function TodoCard(props) {
39 const classes = useStyles(); 39 const classes = useStyles();
40 const data = props.data; 40 const data = props.data;
41 + const todo = data.todo.split(",");
42 + const isTrue = "1";
43 + const check = data.ck.split(",").map((ck) => {
44 + return isTrue == ck;
45 + });
46 +
41 return ( 47 return (
42 <Card className={classes.root}> 48 <Card className={classes.root}>
43 <CardContent> 49 <CardContent>
...@@ -52,16 +58,18 @@ export default function TodoCard(props) { ...@@ -52,16 +58,18 @@ export default function TodoCard(props) {
52 <Typography className={classes.title} variant="h6"> 58 <Typography className={classes.title} variant="h6">
53 {data.title} 59 {data.title}
54 </Typography> 60 </Typography>
55 - <Typography className={classes.percent} variant="h6"> 61 +
62 + {/* <Typography className={classes.percent} variant="h6">
56 99% 63 99%
57 - </Typography> 64 + </Typography> */}
58 65
59 - {data.todo.map((todo) => { 66 + {todo.map((item, idx) => {
60 return ( 67 return (
61 <FormControlLabel 68 <FormControlLabel
62 className={classes.checkBox} 69 className={classes.checkBox}
63 control={<Checkbox />} 70 control={<Checkbox />}
64 - label={todo} 71 + checked={check[idx]}
72 + label={item}
65 /> 73 />
66 ); 74 );
67 })} 75 })}
......
1 import React from "react"; 1 import React from "react";
2 -import NavBar from "../components/NavBar.js";
3 -import BodyLayout from "../components/BodyLayout.js";
4 2
5 function App() { 3 function App() {
6 return ( 4 return (
......
1 +const fs = require("fs");
1 const express = require("express"); 2 const express = require("express");
2 const bodyParser = require("body-parser"); 3 const bodyParser = require("body-parser");
3 const app = express(); 4 const app = express();
4 -//const mysql = require('mysql');
5 5
6 const port = process.env.PORT || 5000; 6 const port = process.env.PORT || 5000;
7 7
8 -/*
9 const data = fs.readFileSync('./database.json'); 8 const data = fs.readFileSync('./database.json');
10 const conf = JSON.parse(data); 9 const conf = JSON.parse(data);
10 +const mysql = require('mysql');
11 11
12 const connection = mysql.createConnection({ 12 const connection = mysql.createConnection({
13 host: conf.host, 13 host: conf.host,
...@@ -18,42 +18,17 @@ const connection = mysql.createConnection({ ...@@ -18,42 +18,17 @@ const connection = mysql.createConnection({
18 }); 18 });
19 19
20 connection.connect(); 20 connection.connect();
21 -*/
22 21
23 app.use(bodyParser.json()); 22 app.use(bodyParser.json());
24 app.use(bodyParser.urlencoded({ extended: true })); 23 app.use(bodyParser.urlencoded({ extended: true }));
25 24
26 app.get("/api/cards", (req, res) => { 25 app.get("/api/cards", (req, res) => {
27 - res.send([ 26 + connection.query(
28 - { 27 + 'SELECT * FROM CARDINFO',
29 - date: "2020-99-99", 28 + (err,rows,fields)=>{
30 - name: "daehwi", 29 + res.send(rows);
31 - isPublic: true,
32 - title: "열글자까지가능합니다.",
33 - todo: ["휴대폰하기", "리액트하기", "옾소과제"],
34 - },
35 - {
36 - date: "2020-99-99",
37 - name: "fuck",
38 - isPublic: true,
39 - title: "열글자까지가능합니다.",
40 - todo: ["헬스", "낮잠", "확랜과제"],
41 - },
42 - {
43 - date: "2020-99-99",
44 - name: "talk",
45 - isPublic: true,
46 - title: "열글자까지가능할걸요.",
47 - todo: ["카톡", "라인", "페메","DM"],
48 - },
49 - {
50 - date: "2020-99-99",
51 - name: "성훈정",
52 - isPublic: true,
53 - title: "하나둘셋넷다섯여섯일.",
54 - todo: ["쌍쌍바ㅏ", "비비빅", "메로나"],
55 } 30 }
56 - ]); 31 + )
57 }); 32 });
58 33
59 app.listen(port, () => console.log(`Listening on port ${port}`)); 34 app.listen(port, () => console.log(`Listening on port ${port}`));
......