diff --git a/src/components/Notification/NotificationItem.tsx b/src/components/Notification/NotificationItem.tsx index e965ba1..9b81483 100644 --- a/src/components/Notification/NotificationItem.tsx +++ b/src/components/Notification/NotificationItem.tsx @@ -6,6 +6,7 @@ import {NotificationDTO} from '../../hooks/queries/notification/useGetNotificati import {usePatchNotification} from '../../hooks/mutations/notification/usePatchNotification'; import {useQueryClient} from '@tanstack/react-query'; import {NOTIFICATION_KEYS} from '../../hooks/queries/QueryKeys'; +import {formatDate, getCategoryName} from '../../utils/pushUtils'; interface NotificationItemProps { item: NotificationDTO; @@ -46,12 +47,14 @@ export default function NotificationItem({item}: NotificationItemProps) { ]} onPress={handleOnPress}> - {item.type} + {getCategoryName(item.type)} {!item.isChecked && } - {item.title} - {item.createdAt} + + {item.title} {item.body} + + {formatDate(item.createdAt)} ); } diff --git a/src/components/ResultSwiper/ResultItem/ResultItem.style.ts b/src/components/ResultSwiper/ResultItem/ResultItem.style.ts index cfd2b22..e34db06 100644 --- a/src/components/ResultSwiper/ResultItem/ResultItem.style.ts +++ b/src/components/ResultSwiper/ResultItem/ResultItem.style.ts @@ -30,6 +30,7 @@ const styles = StyleSheet.create({ ...flexBox('row', 'flex-start', 'center'), gap: 10, flex: 1, + paddingEnd: 20, }, boxItemWSpace: {...flexBox('row', 'space-between'), width: '100%'}, text: { diff --git a/src/screens/Detail/Detail.tsx b/src/screens/Detail/Detail.tsx index 7721699..27e27dc 100644 --- a/src/screens/Detail/Detail.tsx +++ b/src/screens/Detail/Detail.tsx @@ -57,7 +57,11 @@ export default function Detail({navigation, route}: DetailProps) { queryClient.invalidateQueries({ queryKey: LOCATION_KEYS.detail(String(id)), }); + queryClient.invalidateQueries({ + queryKey: CATEGORY_KEYS.lists(), + }); + navigation.pop(); bottomSheetRef.current?.close(); }, onError: e => { diff --git a/src/utils/pushUtils.ts b/src/utils/pushUtils.ts index 9d79bc5..0a651c6 100644 --- a/src/utils/pushUtils.ts +++ b/src/utils/pushUtils.ts @@ -137,3 +137,43 @@ export function parseNotificationData(data: string | object | undefined) { console.error(e); } } + +/** + * 카테고리 타입 별 이름 변환해 주는 함수 + * @param type + */ +export function getCategoryName(type: string) { + if (type === 'userLocation') return '날짜 추천 받고 여행 떠나기'; + else if (type === 'category') return '카테고리 리마인드'; + else type; +} + +/** + * ISO Date를 포맷팅해 주는 함수 + * @param isoString + */ +export function formatDate(isoString: string): string { + try { + const date = new Date(isoString); + + if (isNaN(date.getTime())) throw new Error('Invalid date'); + + const today = new Date(); + const isToday = + date.getFullYear() === today.getFullYear() && + date.getMonth() === today.getMonth() && + date.getDate() === today.getDate(); + + if (isToday) { + return '오늘'; + } + + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, '0'); + const day = String(date.getDate()).padStart(2, '0'); + + return `${year}.${month}.${day}`; + } catch (error) { + return isoString; + } +}