forked from JustOneBite/job-front
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b147fff
commit 4dd0664
Showing
4 changed files
with
82 additions
and
25 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
'use client' | ||
import React from 'react'; | ||
import styles from "./listItem.module.css"; | ||
import Link from "next/link"; | ||
import { useState , useEffect } from 'react'; | ||
|
||
// 게시물 데이터 예시 (실제 데이터는 서버에서 가져와야됨) | ||
|
||
|
||
|
||
const listItem = () => { | ||
const [posts , setPosts] = useState([]); | ||
|
||
|
||
useEffect(()=>{ | ||
const fetchPosts = async() => { | ||
const res = await fetch('/api/posts'); | ||
const data = await res.json(); | ||
console.log(data) | ||
if(res.ok){ | ||
setPosts(data.posts || []) | ||
|
||
}else{ | ||
console.error('서버오류',res.message) | ||
} | ||
} | ||
|
||
fetchPosts(); | ||
},[]); | ||
|
||
|
||
|
||
return ( | ||
<div className={styles.postList}> | ||
{posts.map((post, index) => ( | ||
<div key={post.id} className={styles.navbar}> | ||
<div className={styles.navbarItem}>{index + 1}</div> {/* 번호는 인덱스에 1을 더해서 표시 */} | ||
<div className={styles.navbarItem}>{post.category}</div> | ||
<Link | ||
href={{ | ||
pathname: "/studentService/edit", | ||
query: { postId: post.id, title: post.title }, | ||
}} | ||
> | ||
<div className={styles.navbarItem} style={{ cursor: "pointer", color: "blue" }}> | ||
{post.title} | ||
</div> | ||
</Link> | ||
<div className={styles.navbarItem}>{post.author}</div> | ||
<div className={styles.navbarItem}>{post.date}</div> | ||
<div className={styles.navbarItem}>{post.status ? '처리완료' : '답변대기'}</div> | ||
</div> | ||
))} | ||
</div> | ||
); | ||
}; | ||
|
||
export default listItem; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters