diff --git a/src/pages/notification/component/ListNotification.jsx b/src/pages/notification/component/ListNotification.jsx index 4fe046e..3fc11c8 100644 --- a/src/pages/notification/component/ListNotification.jsx +++ b/src/pages/notification/component/ListNotification.jsx @@ -694,9 +694,9 @@ const ListNotification = memo(function ListNotification(props) { Plant Subsection
{selectedNotification.subsection}
- Time + Date & Time -
{selectedNotification.timestamp.split(' ')[1]} WIB
+
{selectedNotification.timestamp}
{ // Extract nested data const errorCodeData = apiData.error_code; // Get active solution (is_active: true) - const activeSolution = errorCodeData?.solution?.find(sol => sol.is_active) || errorCodeData?.solution?.[0] || {}; + const activeSolution = + errorCodeData?.solution?.find((sol) => sol.is_active) || errorCodeData?.solution?.[0] || {}; return { id: `notification-${apiData.notification_error_id}-0`, @@ -46,13 +36,15 @@ const transformNotificationData = (apiData) => { title: errorCodeData?.error_code_name || 'Unknown Error', issue: errorCodeData?.error_code || 'Unknown Error', description: apiData.message_error_issue || 'No details available', - timestamp: apiData.created_at ? new Date(apiData.created_at).toLocaleString('id-ID', { - day: '2-digit', - month: '2-digit', - year: 'numeric', - hour: '2-digit', - minute: '2-digit', - }) + ' WIB' : 'N/A', + timestamp: apiData.created_at + ? new Date(apiData.created_at).toLocaleString('id-ID', { + day: '2-digit', + month: '2-digit', + year: 'numeric', + hour: '2-digit', + minute: '2-digit', + }) + ' WIB' + : 'N/A', location: apiData.plant_sub_section_name || 'Location not specified', details: apiData.message_error_issue || 'No details available', isRead: apiData.is_read || false, @@ -67,15 +59,20 @@ const transformNotificationData = (apiData) => { spareparts: errorCodeData?.spareparts || [], solution: { ...activeSolution, - path_document: activeSolution.path_document ? activeSolution.path_document.replace('/detail-notification/pdf/', '/notification-detail/pdf/') : activeSolution.path_document + path_document: activeSolution.path_document + ? activeSolution.path_document.replace( + '/detail-notification/pdf/', + '/notification-detail/pdf/' + ) + : activeSolution.path_document, }, // Include the active solution data with fixed URL error_code: errorCodeData, device_info: { device_code: apiData.device_code, device_name: apiData.device_name, device_location: apiData.device_location, - brand_name: apiData.brand_name - } + brand_name: apiData.brand_name, + }, }; }; @@ -145,7 +142,6 @@ const NotificationDetailTab = () => { } else { throw new Error('Notification not found'); } - } catch (err) { setError(err.message); console.error('Error fetching notification detail:', err); @@ -159,7 +155,14 @@ const NotificationDetailTab = () => { if (loading) { return ( - + ); @@ -167,12 +170,23 @@ const NotificationDetailTab = () => { if (error || !notification) { return ( - + navigate('/notification')}>Back to List} + extra={ + + } /> ); @@ -184,12 +198,18 @@ const NotificationDetailTab = () => { -
+
- - -
+
Error Notification Detail @@ -216,22 +245,53 @@ const NotificationDetailTab = () => { {/* Kolom Kiri: Data Kompresor */} - - + + -
+
+ +
{notification.title} -
{notification.issue}
+
+ + {notification.issue} + +
Plant Subsection
{notification.location}
- Time -
{notification.timestamp.split(' ')[1]} WIB
+ + Date & Time + +
{notification.timestamp}
@@ -239,13 +299,44 @@ const NotificationDetailTab = () => { {/* Kolom Tengah: Informasi Teknis */} - - -
Error Channel
{notification.error_chanel || 'N/A'}
-
Device Code
{notification.device_info?.device_code || 'N/A'}
-
Device Name
{notification.device_info?.device_name || 'N/A'}
-
Device Location
{notification.device_info?.device_location || 'N/A'}
-
Brand
{notification.device_info?.brand_name || 'N/A'}
+ + +
+ Error Channel +
{notification.error_chanel || 'N/A'}
+
+
+ Device Code +
+ {notification.device_info?.device_code || 'N/A'} +
+
+
+ Device Name +
+ {notification.device_info?.device_name || 'N/A'} +
+
+
+ Device Location +
+ {notification.device_info?.device_location || 'N/A'} +
+
+
+ Brand +
+ {notification.device_info?.brand_name || 'N/A'} +
+
@@ -257,45 +348,181 @@ const NotificationDetailTab = () => {
- Handling Guideline - Spare Part - Log Activity + + + + + + Handling Guideline + + + + + + + + + + Spare Part + + + + + + + + + + Log Activity + + + + - - - {notification.error_code?.solution && notification.error_code.solution.length > 0 ? ( + + + {notification.error_code?.solution && + notification.error_code.solution.length > 0 ? ( <> {notification.error_code.solution - .filter(sol => sol.is_active) // Hanya tampilkan solusi yang aktif + .filter((sol) => sol.is_active) // Hanya tampilkan solusi yang aktif .map((sol, index) => ( -
+
{sol.path_document ? ( - PDF}> -
+ + PDF + + } + > +
- {sol.file_upload_name || 'Solution Document.pdf'} - lihat disini + + {' '} + {sol.file_upload_name || + 'Solution Document.pdf'} + + + lihat disini +
) : null} - {sol.type_solution === 'text' && sol.text_solution ? ( - {sol.type_solution.toUpperCase()}}> + {sol.type_solution === 'text' && + sol.text_solution ? ( + + {sol.type_solution.toUpperCase()} + + } + >
- {sol.solution_name}: -
{sol.text_solution}
+ + {sol.solution_name}: + +
+ {sol.text_solution} +
) : null}
- )) - } + ))} ) : ( -
+
Tidak ada dokumen solusi tersedia
)} @@ -303,39 +530,98 @@ const NotificationDetailTab = () => { - - - {notification.spareparts && notification.spareparts.length > 0 ? ( + + + {notification.spareparts && + notification.spareparts.length > 0 ? ( notification.spareparts.map((sparepart, index) => ( - + - -
- + +
+
- + {sparepart.sparepart_stok} - - {sparepart.sparepart_name} - - {sparepart.sparepart_description || 'Deskripsi tidak tersedia'} + + + {sparepart.sparepart_name} + + + {sparepart.sparepart_description || + 'Deskripsi tidak tersedia'} -
- Kode: {sparepart.sparepart_code} | Qty: {sparepart.sparepart_qty} | Unit: {sparepart.sparepart_unit} +
+ Kode: {sparepart.sparepart_code}{' '} + | Qty: {sparepart.sparepart_qty}{' '} + | Unit:{' '} + {sparepart.sparepart_unit}
@@ -343,7 +629,13 @@ const NotificationDetailTab = () => { )) ) : ( -
+
Tidak ada spare parts terkait
)} @@ -351,63 +643,67 @@ const NotificationDetailTab = () => { - - - + - - {isAddingLog && ( - <> - - Add New Log / Update Progress - - - - )} - - - - {logHistoryData.map((log) => ( - - {log.addedBy.name}:{' '} - {log.description} - - - {log.timestamp} - + {isAddingLog && ( + <> + + Add New Log / Update Progress + + + + )} + + - ))} - - - + {logHistoryData.map((log) => ( + + + {log.addedBy.name}:{' '} + {log.description} + + + {log.timestamp} + + + ))} + + + @@ -422,4 +718,4 @@ const NotificationDetailTab = () => { ); }; -export default NotificationDetailTab; \ No newline at end of file +export default NotificationDetailTab;