'use client' import { useEffect, useState } from "react"; import NoticeModal from "@/app/components/ModelNotice"; import { MilkdownViewer } from "@/app/components/MilkdownViewer"; import { MilkdownProvider } from "@milkdown/react"; import { Crepe } from "@milkdown/crepe"; import { useRef } from "react"; export default function Page() { const crepeRef = useRef(null!); const [noticeList, setNoticeList] = useState<{ id: string; title: string; pubDate: Date; content: string; tag: string; }[]>([]); const [currentNotice, setCurrentNotice] = useState<{ id: string; title: string; content: string; tag:string pubDate: Date; }>({ id: "", tag: "", title: "", content: "", pubDate: new Date("0"), }); const [isNoticeModalOpen, setIsNoticeModalOpen] = useState(false); const openHandler = (id: string) => { const notice = noticeList.find((notice) => notice.id === id); if (notice) { setCurrentNotice({ id: notice.id, title: notice.title, content: notice.content, tag: notice.tag, pubDate: notice.pubDate, }); } setIsNoticeModalOpen(true); } const fetchNotices = async () => { const response = await fetch('/api/notice'); const data = await response.json(); setNoticeList(data); } useEffect(() => { fetchNotices(); }, []); return (
{noticeList.length === 0 ? (
게시글이 없습니다.
) : ( noticeList.map((notice) => (
openHandler(notice.id)} > {/* 여기 min-w-0 추가해서 자식을 제한함 부모와 이 위치 관계 다시 확인 */}
{ notice.tag === "중요" && (
중요
) }
{notice.title}
{notice.pubDate.toLocaleString('ko-KR', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false })}
)) )}
setIsNoticeModalOpen(false)}>

{currentNotice.title}

{currentNotice.pubDate.toLocaleString('ko-KR', { year: 'numeric', month: '2-digit', day: '2-digit', hour: '2-digit', minute: '2-digit', hour12: false, })}

); }