From 978e020305befccb7902fd7893f126c303341b0b Mon Sep 17 00:00:00 2001 From: Rafiafrzl Date: Mon, 22 Dec 2025 20:49:48 +0700 Subject: [PATCH] feat: update notification data transformation and enhance user history display --- .../component/ListNotification.jsx | 3 +- .../IndexNotificationDetail.jsx | 111 +++++++++++++++--- 2 files changed, 96 insertions(+), 18 deletions(-) diff --git a/src/pages/notification/component/ListNotification.jsx b/src/pages/notification/component/ListNotification.jsx index 96cba0f..a959cd9 100644 --- a/src/pages/notification/component/ListNotification.jsx +++ b/src/pages/notification/component/ListNotification.jsx @@ -47,7 +47,7 @@ const transformNotificationData = (apiData) => { return apiData.map((item, index) => ({ id: `notification-${item.notification_error_id}-${index}`, // Unique key prefix with array index type: item.is_read ? 'resolved' : item.is_delivered ? 'warning' : 'critical', - title: item.device_name || 'Unknown Device', + title: item.error_code_name || 'Unknown Error', issue: item.error_code || item.error_code_name || 'Unknown Error', description: `${item.error_code} - ${item.error_code_name || ''}`, timestamp: item.created_at @@ -324,7 +324,6 @@ const ListNotification = memo(function ListNotification(props) { borderColor: notification.isRead ? '#f0f0f0' : '#d6e4ff', cursor: 'pointer', }} - onClick={() => handleMarkAsRead(notification.id)} >
{ }; }; +// Dummy data baru untuk user history +const getDummyUsers = (notification) => { + if (!notification) return []; + return [ + { + id: '1', + name: 'John Doe', + phone: '081234567890', + status: 'delivered', + }, + { + id: '2', + name: 'Jane Smith', + phone: '082345678901', + status: 'sent', + }, + { + id: '3', + name: 'Bob Johnson', + phone: '083456789012', + status: 'failed', + }, + { + id: '4', + name: 'Alice Brown', + phone: '084567890123', + status: 'delivered', + }, + ]; +}; + +const getStatusTag = (status) => { + switch (status) { + case 'delivered': + return } color="success">Delivered; + case 'sent': + return } color="processing">Sent; + case 'failed': + return Failed; + default: + return {status}; + } +}; + const getIconAndColor = (type) => { switch (type) { case 'critical': @@ -262,14 +309,6 @@ const NotificationDetailTab = () => { Back to notification list - - -
{ - {/* Kolom Kanan: Log History */} + {/* Kolom Kanan: User History */} - + +
+ + {getDummyUsers(notification).map((user) => ( + + + + + } /> +
+ {user.name} +
+ + {user.phone} +
+
+
+ + + + {getStatusTag(user.status)} + + + +
+
+ ))} +
+
+
@@ -432,6 +510,7 @@ const NotificationDetailTab = () => { setModalContent('user')} >