From 90419b5d1578ba03e69dab8a0aa8df3488df65a0 Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Mon, 18 May 2026 11:27:49 +0800 Subject: [PATCH] feat: tambah fitur tandai terbaca per notifikasi dan ekstrak styles - Tambah fungsi handleMarkOneRead untuk tandai satu notifikasi terbaca tanpa navigasi - Tambah tombol "Tandai dibaca" pada tiap notifikasi yang belum terbaca - Buat notification.styles.ts dengan 8 class styles untuk notification screen - Daftarkan NotificationStyles ke constants/styles/index.ts --- app/(application)/notification.tsx | 57 ++++++++++++++----------- constants/styles/index.ts | 2 + constants/styles/notification.styles.ts | 29 +++++++++++++ 3 files changed, 64 insertions(+), 24 deletions(-) create mode 100644 constants/styles/notification.styles.ts diff --git a/app/(application)/notification.tsx b/app/(application)/notification.tsx index 03aa940..2bb50a9 100644 --- a/app/(application)/notification.tsx +++ b/app/(application)/notification.tsx @@ -136,6 +136,17 @@ export default function Notification() { } } + async function handleMarkOneRead(id: string) { + try { + const hasil = await decryptToken(String(token?.current)) + await apiReadOneNotification({ user: hasil, id: id }) + await queryClient.invalidateQueries({ queryKey: ['notifications'] }) + dispatch(setUpdateNotification(!updateNotification)) + } catch (error) { + console.error(error) + } + } + return ( setShowConfirm(false)} /> - + + {isLoading ? ( [0, 1, 2, 3, 4].map((_, i) => ) ) : flatData.length === 0 ? ( @@ -203,11 +215,11 @@ export default function Notification() { renderItem={({ item }) => { if (item._type === 'header') { return ( - - + + {item.date} - + ) } @@ -217,37 +229,20 @@ export default function Notification() { return ( handleReadNotification(item.id, item.category, item.idContent)} - style={({ pressed }) => [{ - flexDirection: 'row', - alignItems: 'center', - borderRadius: 10, - borderWidth: 1, + style={({ pressed }) => [Styles.notifItemRow, { borderColor: colors.icon + '20', backgroundColor: pressed ? colors.icon + '10' : item.isRead ? colors.icon + '10' : colors.card, - paddingHorizontal: 12, - paddingVertical: 10, - marginBottom: 6, }]} > - {/* Colored icon */} - + - {/* Content */} - + + {!item.isRead && ( + { + e.stopPropagation() + handleMarkOneRead(item.id) + }} + hitSlop={8} + style={({ pressed }) => ({ opacity: pressed ? 0.5 : 1, flexShrink: 0 })} + > + + Tandai dibaca + + + )}