Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김대휘
/
Do-gether
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
1
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김대휘
2020-06-04 02:46:14 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3ec97c3f8d9f0b9a1ee920a13259ee55767bafb9
3ec97c3f
1 parent
e0135f65
Api test
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
70 additions
and
36 deletions
client/package.json
client/src/App.js
client/src/components/BodyLayout.js
client/src/components/TodoCard.js
client/src/index.js
package.json
server.js
client/package.json
View file @
3ec97c3
...
...
@@ -32,5 +32,6 @@
"last 1 firefox version"
,
"last 1 safari version"
]
}
},
"proxy"
:
"http://localhost:5000/"
}
...
...
client/src/App.js
View file @
3ec97c3
import
React
from
"react"
;
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
NavBar
from
"./components/NavBar.js"
;
import
BodyLayout
from
"./components/BodyLayout.js"
;
...
...
client/src/components/BodyLayout.js
View file @
3ec97c3
import
React
from
"react"
;
import
React
,
{
useState
,
useEffect
}
from
"react"
;
import
{
makeStyles
}
from
"@material-ui/core/styles"
;
import
Container
from
"@material-ui/core/Container"
;
import
Grid
from
"@material-ui/core/Grid"
;
...
...
@@ -6,14 +7,6 @@ import Icon from "@material-ui/core/Icon";
import
TodoCard
from
"./TodoCard.js"
;
const
data
=
{
date
:
"2020-99-99"
,
name
:
"daehwi"
,
isPublic
:
true
,
title
:
"열글자까지가능합니다."
,
todo
:
[
"응가하기"
,
"똥싸기"
,
"변누기"
],
};
const
useStyles
=
makeStyles
((
theme
)
=>
({
root
:
{
flexGrow
:
1
,
...
...
@@ -27,19 +20,42 @@ const useStyles = makeStyles((theme) => ({
},
}));
export
default
function
CenteredGrid
()
{
const
callApi
=
async
()
=>
{
const
response
=
await
fetch
(
"/api/cards"
);
const
body
=
await
response
.
json
();
return
body
;
};
export
default
function
BodyLayout
()
{
const
classes
=
useStyles
();
const
[
data
,
setData
]
=
useState
([]);
return
(
<
Container
className
=
{
classes
.
root
}
maxwidth
=
"sm"
>
<
Grid
className
=
{
classes
.
item
}
container
spacing
=
{
3
}
>
<
Grid
item
xs
=
"6"
sm
=
"6"
md
=
"3"
>
<
TodoCard
data
=
{
data
}
/
>
<
/Grid
>
<
Grid
item
xs
=
"6"
sm
=
"6"
md
=
"3"
alignItems
=
"center"
>
<
Icon
style
=
{{
fontSize
:
60
}}
>
add_circle
<
/Icon
>
useEffect
(()
=>
{
callApi
()
.
then
((
res
)
=>
setData
(
res
))
.
catch
((
err
)
=>
console
.
log
(
err
));
});
if
(
!
data
)
{
return
<
p
>
ㄱㄷㄱㄷ
<
/p>
;
}
else
{
console
.
log
(
123
);
console
.
log
(
data
);
return
(
<
Container
className
=
{
classes
.
root
}
maxwidth
=
"sm"
>
<
Grid
className
=
{
classes
.
item
}
container
spacing
=
{
3
}
>
{
data
.
map
((
data
)
=>
{
return
(
<
Grid
item
xs
=
"6"
sm
=
"6"
md
=
"3"
>
<
TodoCard
data
=
{
data
}
/
>
<
/Grid
>
);
})}
<
Grid
item
xs
=
"6"
sm
=
"6"
md
=
"3"
>
<
Icon
style
=
{{
fontSize
:
60
}}
>
add_circle
<
/Icon
>
<
/Grid
>
<
/Grid
>
<
/
Grid
>
<
/Container
>
);
<
/
Container
>
);
}
}
...
...
client/src/components/TodoCard.js
View file @
3ec97c3
...
...
@@ -37,6 +37,7 @@ const useStyles = makeStyles({
export
default
function
TodoCard
(
props
)
{
const
classes
=
useStyles
();
const
data
=
props
.
data
;
console
.
log
(
data
);
return
(
<
Card
className
=
{
classes
.
root
}
>
<
CardContent
>
...
...
client/src/index.js
View file @
3ec97c3
...
...
@@ -2,9 +2,4 @@ import React from "react";
import
ReactDOM
from
"react-dom"
;
import
App
from
"./App"
;
ReactDOM
.
render
(
<
React
.
StrictMode
>
<
App
/>
<
/React.StrictMode>
,
document
.
getElementById
(
"root"
)
);
ReactDOM
.
render
(
<
App
/>
,
document
.
getElementById
(
"root"
));
...
...
package.json
View file @
3ec97c3
...
...
@@ -12,6 +12,5 @@
},
"devDependencies"
:
{
"concurrently"
:
"^4.0.1"
},
"proxy"
:
"http://localhost:5000/"
}
}
...
...
server.js
View file @
3ec97c3
const
express
=
require
(
'express'
);
const
bodyParser
=
require
(
'body-parser'
);
const
express
=
require
(
"express"
);
const
bodyParser
=
require
(
"body-parser"
);
const
app
=
express
();
const
port
=
process
.
env
.
PORT
||
5000
;
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
app
.
get
(
'/api/hello'
,
(
req
,
res
)
=>
{
res
.
send
({
message
:
'Hello Express!'
});
app
.
get
(
"/api/cards"
,
(
req
,
res
)
=>
{
res
.
send
([
{
date
:
"2020-99-99"
,
name
:
"daehwi"
,
isPublic
:
true
,
title
:
"열글자까지가능합니다."
,
todo
:
[
"응가하기"
,
"똥싸기"
,
"변누기"
],
},
{
date
:
"2020-99-99"
,
name
:
"fuck"
,
isPublic
:
true
,
title
:
"열글자까지가능합니다."
,
todo
:
[
"응가하다말기"
,
"똥싸기"
,
"변누기"
],
},
{
date
:
"2020-99-99"
,
name
:
"성훈"
,
isPublic
:
true
,
title
:
"열글자까지가능할걸요."
,
todo
:
[
"응가하면서폰보기"
,
"똥싸기"
,
"변누기"
],
},
]);
});
app
.
listen
(
port
,
()
=>
console
.
log
(
`Listening on port
${
port
}
`
));
\ No newline at end of file
app
.
listen
(
port
,
()
=>
console
.
log
(
`Listening on port
${
port
}
`
));
...
...
Please
register
or
login
to post a comment