From 3ee98da51cc5b04c7ff6317b2a800847625b21a7 Mon Sep 17 00:00:00 2001 From: peachpetal Date: Mon, 12 Jan 2026 14:01:29 +0900 Subject: [PATCH] =?UTF-8?q?fix(users):=20=EC=95=8C=EB=A6=BC=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=20=EC=BF=BC=EB=A6=AC=ED=82=A4=20=EB=B0=8F=20=ED=95=84?= =?UTF-8?q?=EB=93=9C=EB=AA=85=20=EB=B6=88=EC=9D=BC=EC=B9=98=20=ED=95=B4?= =?UTF-8?q?=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/auction-notification-toggle.tsx | 1 + .../api/use-notification.ts | 39 +++++++++++-------- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/src/entities/notification/ui/auction-notification-toggle.tsx b/src/entities/notification/ui/auction-notification-toggle.tsx index 921d07bc..3a942ea8 100644 --- a/src/entities/notification/ui/auction-notification-toggle.tsx +++ b/src/entities/notification/ui/auction-notification-toggle.tsx @@ -62,6 +62,7 @@ export default function AuctionNotificationToggle({ auctionId }: AuctionNotifica onSuccess: async () => { showToast.success("알림 설정이 저장되었습니다."); await qc.invalidateQueries({ queryKey: auctionNotificationSettingsKey(auctionId) }); + await qc.invalidateQueries({ queryKey: ["user", "notifications"] }); setOpenChange(false); }, onError: (_err, _vars, ctx) => { diff --git a/src/features/notification-preference/api/use-notification.ts b/src/features/notification-preference/api/use-notification.ts index 0b4c3447..2982f7dd 100644 --- a/src/features/notification-preference/api/use-notification.ts +++ b/src/features/notification-preference/api/use-notification.ts @@ -14,13 +14,20 @@ import { import type { NotificationPreferenceItemType } from "../model/types"; -interface NotificationInfo { +interface NotificationInfoDTO { alertStart: boolean; alertEnd: boolean; alertPrice: boolean; triggerPrice: number; } +interface NotificationSettingsType { + auctionStart: boolean; + auctionEnd: boolean; + priceReached: boolean; + price: number; +} + interface NotificationSliceItem { status: string; auctionId: number; @@ -28,7 +35,7 @@ interface NotificationSliceItem { auctionImageUrl: string; startPrice: number; startedAt: string; - notificationInfo: NotificationInfo; + notificationInfo: NotificationInfoDTO; currentPrice?: number; endPrice?: number; discountPercent?: number; @@ -49,13 +56,6 @@ interface NotificationSettingResponse { price: number; } -interface UpdateNotificationRequest { - auctionStart: boolean; - auctionEnd: boolean; - priceReached: boolean; - price: number; -} - export const notificationKeys = { all: ["user", "notifications"] as const, list: () => [...notificationKeys.all, "list"] as const, @@ -77,12 +77,11 @@ const mapStatusToTradeStatus = (status: string): UserTradeStatusType => { } }; -const generateKeywords = (info: NotificationInfo): string[] => { +const generateKeywords = (info: NotificationSettingsType): string[] => { const keywords: string[] = []; - if (info.alertStart) keywords.push("경매 시작"); - if (info.alertPrice && info.triggerPrice > 0) - keywords.push(`${info.triggerPrice.toLocaleString()}원 도달`); - if (info.alertEnd) keywords.push("경매 종료"); + if (info.auctionStart) keywords.push("경매 시작"); + if (info.priceReached && info.price > 0) keywords.push(`${info.price.toLocaleString()}원 도달`); + if (info.auctionEnd) keywords.push("경매 종료"); return keywords; }; @@ -111,6 +110,13 @@ const fetchNotifications = async ( .map((item) => { const finalPrice = item.endPrice || item.currentPrice || item.startPrice; + const settings: NotificationSettingsType = { + auctionStart: item.notificationInfo.alertStart, + auctionEnd: item.notificationInfo.alertEnd, + priceReached: item.notificationInfo.alertPrice, + price: item.notificationInfo.triggerPrice, + }; + return { id: String(item.auctionId), status: mapStatusToTradeStatus(item.status), @@ -120,7 +126,7 @@ const fetchNotifications = async ( discountRate: item.discountPercent, date: item.startedAt, imageUrl: item.auctionImageUrl, - keywords: generateKeywords(item.notificationInfo), + keywords: generateKeywords(settings), }; }); @@ -160,7 +166,7 @@ export function useNotificationSettings(auctionId: number) { export function useUpdateNotificationSettings() { const queryClient = useQueryClient(); return useMutation({ - mutationFn: ({ auctionId, data }: { auctionId: number; data: UpdateNotificationRequest }) => + mutationFn: ({ auctionId, data }: { auctionId: number; data: NotificationSettingsType }) => httpClient(API_ENDPOINTS.auctionNotificationSetting(auctionId), { method: "PUT", body: data, @@ -177,6 +183,7 @@ export function useUpdateNotificationSettings() { onSuccess: (_, vars) => { queryClient.invalidateQueries({ queryKey: notificationKeys.settings(vars.auctionId) }); queryClient.invalidateQueries({ queryKey: notificationKeys.list() }); + queryClient.invalidateQueries({ queryKey: ["auctionNotificationSettings", vars.auctionId] }); }, }); }