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 + + + )}