Skip to content

Commit

Permalink
[#224] feat: 팝업공지사항 API 연동
Browse files Browse the repository at this point in the history
  • Loading branch information
tnqkr3494 committed Jan 17, 2025
1 parent c8b14e9 commit 477c1b1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
10 changes: 9 additions & 1 deletion src/app/(root)/dashboard/(overview)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,18 @@ import AnnounceCard from '@/components/dashboard/card/announceCard';
import RouletteCard from '@/components/dashboard/card/rouletteCard';
import ReservationList from '@/components/studyroom/studyRoomBoard';
import NoticeModal from '@/components/common/noticeModal';
import { fetchExtended } from '@/utils/fetchExtended';
import { Notice } from '@/lib/definitions';
// import ClassicCard from '@/components/dashboard/card/classicCard';

export default async function DashBoard() {
const CourseData = await getCourseAttendance();
const noticeData = await fetchExtended<Notice>('http://dev.api.segam.org:3000/v1/notice/popup', {
cache: 'no-store',
next: {
tags: ['noticePopUp'],
},
}).then((response) => response.body);
const { title, description, iconName, link } = calAnnounceData(CourseData);

return (
Expand Down Expand Up @@ -47,7 +55,7 @@ export default async function DashBoard() {
{/* <ClassicCard /> */}
<RouletteCard />
</div>
<NoticeModal />
<NoticeModal noticeData={noticeData} />
</main>
);
}
7 changes: 4 additions & 3 deletions src/components/common/noticeModal.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
'use client';

import useModal from '@/hooks/useModal';
import { Notice } from '@/lib/definitions';
import Button from './button/button';

export default function NoticeModal() {
export default function NoticeModal({ noticeData }: { noticeData: Notice }) {
const { noticeModal } = useModal();

const handleClick = () => {
noticeModal({
title: '공지사항제목',
content: `아래부터 공지사항 내용입니다 아래부터 공지사항 내용입니다 아래부터 공지사항 내용입니다`,
title: noticeData.title,
content: noticeData.content,
onClick: () => {
console.log('모달 확인 버튼 클릭');
},
Expand Down
9 changes: 9 additions & 0 deletions src/lib/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,12 @@ export type Category = {
categoryName: string;
books: Option[];
};

export type Notice = {
id: number;
title: string;
content: string;
isPopup: boolean;
createdAt: string;
deletedAt: string | null;
};

0 comments on commit 477c1b1

Please sign in to comment.