@@ -14,21 +14,28 @@ import {
1414
1515import type { NotificationPreferenceItemType } from "../model/types" ;
1616
17- interface NotificationInfo {
17+ interface NotificationInfoDTO {
1818 alertStart : boolean ;
1919 alertEnd : boolean ;
2020 alertPrice : boolean ;
2121 triggerPrice : number ;
2222}
2323
24+ interface NotificationSettingsType {
25+ auctionStart : boolean ;
26+ auctionEnd : boolean ;
27+ priceReached : boolean ;
28+ price : number ;
29+ }
30+
2431interface NotificationSliceItem {
2532 status : string ;
2633 auctionId : number ;
2734 title : string ;
2835 auctionImageUrl : string ;
2936 startPrice : number ;
3037 startedAt : string ;
31- notificationInfo : NotificationInfo ;
38+ notificationInfo : NotificationInfoDTO ;
3239 currentPrice ?: number ;
3340 endPrice ?: number ;
3441 discountPercent ?: number ;
@@ -49,13 +56,6 @@ interface NotificationSettingResponse {
4956 price : number ;
5057}
5158
52- interface UpdateNotificationRequest {
53- auctionStart : boolean ;
54- auctionEnd : boolean ;
55- priceReached : boolean ;
56- price : number ;
57- }
58-
5959export const notificationKeys = {
6060 all : [ "user" , "notifications" ] as const ,
6161 list : ( ) => [ ...notificationKeys . all , "list" ] as const ,
@@ -77,12 +77,11 @@ const mapStatusToTradeStatus = (status: string): UserTradeStatusType => {
7777 }
7878} ;
7979
80- const generateKeywords = ( info : NotificationInfo ) : string [ ] => {
80+ const generateKeywords = ( info : NotificationSettingsType ) : string [ ] => {
8181 const keywords : string [ ] = [ ] ;
82- if ( info . alertStart ) keywords . push ( "경매 시작" ) ;
83- if ( info . alertPrice && info . triggerPrice > 0 )
84- keywords . push ( `${ info . triggerPrice . toLocaleString ( ) } 원 도달` ) ;
85- if ( info . alertEnd ) keywords . push ( "경매 종료" ) ;
82+ if ( info . auctionStart ) keywords . push ( "경매 시작" ) ;
83+ if ( info . priceReached && info . price > 0 ) keywords . push ( `${ info . price . toLocaleString ( ) } 원 도달` ) ;
84+ if ( info . auctionEnd ) keywords . push ( "경매 종료" ) ;
8685 return keywords ;
8786} ;
8887
@@ -111,6 +110,13 @@ const fetchNotifications = async (
111110 . map ( ( item ) => {
112111 const finalPrice = item . endPrice || item . currentPrice || item . startPrice ;
113112
113+ const settings : NotificationSettingsType = {
114+ auctionStart : item . notificationInfo . alertStart ,
115+ auctionEnd : item . notificationInfo . alertEnd ,
116+ priceReached : item . notificationInfo . alertPrice ,
117+ price : item . notificationInfo . triggerPrice ,
118+ } ;
119+
114120 return {
115121 id : String ( item . auctionId ) ,
116122 status : mapStatusToTradeStatus ( item . status ) ,
@@ -120,7 +126,7 @@ const fetchNotifications = async (
120126 discountRate : item . discountPercent ,
121127 date : item . startedAt ,
122128 imageUrl : item . auctionImageUrl ,
123- keywords : generateKeywords ( item . notificationInfo ) ,
129+ keywords : generateKeywords ( settings ) ,
124130 } ;
125131 } ) ;
126132
@@ -160,7 +166,7 @@ export function useNotificationSettings(auctionId: number) {
160166export function useUpdateNotificationSettings ( ) {
161167 const queryClient = useQueryClient ( ) ;
162168 return useMutation ( {
163- mutationFn : ( { auctionId, data } : { auctionId : number ; data : UpdateNotificationRequest } ) =>
169+ mutationFn : ( { auctionId, data } : { auctionId : number ; data : NotificationSettingsType } ) =>
164170 httpClient ( API_ENDPOINTS . auctionNotificationSetting ( auctionId ) , {
165171 method : "PUT" ,
166172 body : data ,
@@ -177,6 +183,7 @@ export function useUpdateNotificationSettings() {
177183 onSuccess : ( _ , vars ) => {
178184 queryClient . invalidateQueries ( { queryKey : notificationKeys . settings ( vars . auctionId ) } ) ;
179185 queryClient . invalidateQueries ( { queryKey : notificationKeys . list ( ) } ) ;
186+ queryClient . invalidateQueries ( { queryKey : [ "auctionNotificationSettings" , vars . auctionId ] } ) ;
180187 } ,
181188 } ) ;
182189}
0 commit comments