From b2c7303258c44f6970cdba96e2b25e59b206c148 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EC=9D=B4=EC=9C=A0=EC=A7=84?= Date: Mon, 6 Apr 2026 17:10:34 +0900 Subject: [PATCH] =?UTF-8?q?refactor(useNoticeModal):=20=EB=A7=8C=EB=A3=8C?= =?UTF-8?q?=20=EC=8B=9C=EC=A0=90=20=EA=B4=80=EB=A6=AC=EB=A5=BC=20=EC=9C=84?= =?UTF-8?q?=ED=95=9C=20expireDate=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../games/SnackGame/game/hook/useNoticeModal.tsx | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/pages/games/SnackGame/game/hook/useNoticeModal.tsx b/src/pages/games/SnackGame/game/hook/useNoticeModal.tsx index 1a949a0..6157d3f 100644 --- a/src/pages/games/SnackGame/game/hook/useNoticeModal.tsx +++ b/src/pages/games/SnackGame/game/hook/useNoticeModal.tsx @@ -6,8 +6,10 @@ import ImageWithFallback from '@components/ImageWithFallback/ImageWithFallback'; import { KEY_LAST_NOTICE_INFO } from '@constants/localStorage.constant'; import useModal from '@hooks/useModal'; -// notice_YYYYMMDD_keyword(_version) -const CURRENT_ID = 'notice_20250710_bomb'; +const NOTICE_CONFIG = { + id: 'notice_2025-07-10_bomb', + expireDate: '2025-07-17T23:59:59+09:00', +} as const; const Notice = () => { const { closeModal } = useModal(); @@ -18,7 +20,7 @@ const Notice = () => { localStorage.setItem( KEY_LAST_NOTICE_INFO, JSON.stringify({ - id: CURRENT_ID, + id: NOTICE_CONFIG.id, hideUntil: new Date(Date.now() + ONE_DAY), }), ); @@ -63,14 +65,19 @@ const Notice = () => { export const useNoticeModal = () => { const { openModal } = useModal(); + const isNoticeExpired = () => { + return new Date() > new Date(NOTICE_CONFIG.expireDate); + }; + const isNoticeHidden = () => { const lastNotice = localStorage.getItem(KEY_LAST_NOTICE_INFO); const { id, hideUntil } = lastNotice ? JSON.parse(lastNotice) : {}; - return id === CURRENT_ID && new Date(hideUntil) > new Date(); + return id === NOTICE_CONFIG.id && new Date(hideUntil) > new Date(); }; const openNoticeModal = () => { + if (isNoticeExpired()) return; if (isNoticeHidden()) return; openModal({