From 9f761849c2e98f650d089d00aed9df090497ada9 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 27 Oct 2025 03:12:26 +0000 Subject: (최겸) 공지사항 팝업기능 및 다시보지않기 기능 구현(로컬 스토리지 활용) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/notice/service.ts | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) (limited to 'lib/notice/service.ts') diff --git a/lib/notice/service.ts b/lib/notice/service.ts index 9c05b98f..12f2ed2e 100644 --- a/lib/notice/service.ts +++ b/lib/notice/service.ts @@ -21,6 +21,23 @@ import { import type { Notice } from "@/db/schema/notice" +// 페이지별 공지사항 조회 (강제 모달용) +export async function getPageNoticesForModal(pagePath: string): Promise> { + try { + console.log('🔍 Notice Service - 모달용 조회 시작:', { pagePath }) + const result = await getNoticesByPagePath(pagePath) + console.log('📊 Notice Service - 모달용 조회 결과:', { + pagePath, + noticesCount: result.length, + notices: result.map(n => ({ id: n.id, title: n.title, pagePath: n.pagePath })) + }) + return result + } catch (error) { + console.error(`Failed to get notices for modal on page ${pagePath}:`, error) + return [] + } +} + // 간단한 공지사항 목록 조회 (페이지네이션 없이 전체 조회) export async function getNoticeLists(): Promise<{ data: Array }> { try { @@ -33,6 +50,10 @@ export async function getNoticeLists(): Promise<{ data: Array { try { - return await getNoticeById(id) + const result = await getNoticeById(id) + // 유효기간 검증 추가 (현재 시간이 유효기간 내에 있는지 확인) + if (result) { + const currentTime = new Date() + const isValid = (!result.startAt || result.startAt <= currentTime) && + (!result.endAt || result.endAt >= currentTime) + + if (!isValid) { + console.log(`Notice ${id} is not in valid time range`) + return null + } + } + return result } catch (error) { console.error(`Failed to get notice detail for id ${id}:`, error) return null -- cgit v1.2.3