From 6b6b621c745351e6a911eee18580c196b33e64e4 Mon Sep 17 00:00:00 2001 From: ChanLee_KR Date: Sat, 13 Jul 2024 18:53:16 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=ED=85=8C=EB=A7=88=20=EB=B3=80=EA=B2=BD?= =?UTF-8?q?=20=EC=8B=9C=20toast=20ui=20=EC=B6=94=EA=B0=80=20(#ATR-537)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/entities/theme/model/useThemeSetting.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/apps/service/src/entities/theme/model/useThemeSetting.ts b/apps/service/src/entities/theme/model/useThemeSetting.ts index e504ff1b..13d1e6c7 100644 --- a/apps/service/src/entities/theme/model/useThemeSetting.ts +++ b/apps/service/src/entities/theme/model/useThemeSetting.ts @@ -1,7 +1,9 @@ 'use client' import { useCallback, useEffect, useState } from 'react' +import { toast } from 'react-toastify' import { RealTheme, Theme } from './type' +import { THEME_NAME } from '../constant' function getCurrentTheme(): Theme { if (typeof window === 'undefined') { @@ -40,10 +42,16 @@ export default function useThemeSetting() { setLightTheme() }, [currentTheme]) - const setTheme = useCallback((theme: Theme) => { - setCurrentTheme(theme) - localStorage.setItem('theme', theme) - }, []) + const setTheme = useCallback( + (theme: Theme) => { + setCurrentTheme(theme) + localStorage.setItem('theme', theme) + if (theme !== currentTheme) { + toast.success(`테마가 변경되었어요 (${THEME_NAME[theme]})`) + } + }, + [currentTheme], + ) return { currentTheme, realTheme, setTheme } }