From c8a72edbda9c94e7582ec332d827137aa2e09da8 Mon Sep 17 00:00:00 2001 From: Lee Soobeom Date: Fri, 1 Jul 2022 16:16:20 +0900 Subject: [PATCH] =?UTF-8?q?post=20=ED=8C=8C=EC=9D=BC=20=EB=B6=84=EB=A6=AC,?= =?UTF-8?q?=20=EA=B5=AC=EC=A1=B0=EB=B6=84=ED=95=B4=20Type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/Pages/post.tsx | 26 ++++++++++++++++++++++++++ frontend/src/pages/board.tsx | 30 ++++++++++++++++-------------- 2 files changed, 42 insertions(+), 14 deletions(-) create mode 100644 frontend/src/Pages/post.tsx diff --git a/frontend/src/Pages/post.tsx b/frontend/src/Pages/post.tsx new file mode 100644 index 0000000..3390174 --- /dev/null +++ b/frontend/src/Pages/post.tsx @@ -0,0 +1,26 @@ +import React, { useState } from "react"; + +export interface PostType { + id: string; + title: string; + date: string; + click: number; +} + +type Props = { + post: PostType; +} + +export default function Post({ post }: Props) { + const [count, setCount] = useState(0); + + return ( +
+
+ +
{/*title */} +
{post.date}
+
{count}
+
+ ); +} \ No newline at end of file diff --git a/frontend/src/pages/board.tsx b/frontend/src/pages/board.tsx index 87863d4..90e12db 100644 --- a/frontend/src/pages/board.tsx +++ b/frontend/src/pages/board.tsx @@ -1,15 +1,20 @@ import React, {useState} from "react"; +import Post, { PostType } from "./post"; function range(start:number, end:number) { return (new Array(end - start + 1)).fill(undefined).map((_, i) => i + start); } +const fakes = [{id: "a", title:'부산남자의 서울여행', date:'2022-06-30', click: 0},{id: "b", title:'바다!바다!바다!', date:'2022-08-01',click:0}, {id: "c", title:'Jeju-island', date:'2022-9-10',click:0}, {id: "d", title:'마! 부싼 가봤나!', date:'2022-9-22', click:0}, {id: "e", title:'Daegu', date:'2022-10-1', click:0}, {id: "f", title:'강원도 감자는 맛있다.', date:'2022-12-12',click:0},{id: "g", title:'여행가고싶다...',date:'2022-12-25',click:0}]; + +interface Posts { + posts: PostType[]; +} + export default function BoardPage() { - const ords = range(0,4); //[0,1,2,3,4]; - const [count, setCount] = useState(0); - const fakes = [['Seoul', '2022-06-30', '0'], ['Jeju', '2022-9-10', '1'], ['Busan', '2022-9-22', '2'], ['Daegu', '2022-10-1', '3'], ['Incheon', '2022-12-12','4'],]; - + const [posts, setPosts] = useState(fakes); + return (
@@ -21,22 +26,19 @@ export default function BoardPage() {
-
-
+
+
+
{/* Link */} +
+
-
No.
Title
Date
Clicks
- {ords.map((ord, index) => ( -
-
{ord + 1}
-
{/*title */} -
{fakes[ord][1]}
-
{count}
-
+ {posts.map((post) => ( + ))}
-- GitLab