refactor: update notification handling to prioritize active solutions and improve data extraction
This commit is contained in:
@@ -47,28 +47,29 @@ 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',
|
||||
issue: item.error_code_name || 'Unknown Error',
|
||||
description: `${item.error_code} - ${item.error_code_name}`,
|
||||
title: item.error_code?.error_code_name || item.device_name || 'Unknown Error',
|
||||
issue: item.error_code || item.error_code_name || 'Unknown Error',
|
||||
description: `${item.error_code} - ${item.error_code_name || ''}`,
|
||||
timestamp:
|
||||
new Date(item.created_at).toLocaleString('id-ID', {
|
||||
item.created_at ? new Date(item.created_at).toLocaleString('id-ID', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}) + ' WIB',
|
||||
location: item.device_location || 'Location not specified',
|
||||
}) + ' WIB' : 'N/A',
|
||||
location: item.plant_sub_section_name || item.device_location || 'Location not specified',
|
||||
details: item.message_error_issue || 'No details available',
|
||||
link: `/verification-sparepart/${item.notification_error_id}`, // Dummy URL untuk verifikasi spare part
|
||||
subsection: item.solution_name || 'N/A',
|
||||
subsection: item.plant_sub_section_name || 'N/A',
|
||||
isRead: item.is_read,
|
||||
status: item.is_read ? 'Resolved' : item.is_delivered ? 'Delivered' : 'Pending',
|
||||
tag: item.error_code,
|
||||
errorCode: item.error_code,
|
||||
solutionName: item.solution_name,
|
||||
typeSolution: item.type_solution,
|
||||
pathSolution: item.path_solution,
|
||||
solutionName: item.error_code?.solution?.[0]?.solution_name || 'N/A',
|
||||
typeSolution: item.error_code?.solution?.[0]?.type_solution || 'N/A',
|
||||
pathSolution: item.error_code?.solution?.[0]?.path_document || item.error_code?.solution?.[0]?.path_solution || 'N/A',
|
||||
error_code: item.error_code,
|
||||
}));
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user