diff --git a/src/pages/master/tag/component/DetailTag.jsx b/src/pages/master/tag/component/DetailTag.jsx index 6ec67fc..96f86f0 100644 --- a/src/pages/master/tag/component/DetailTag.jsx +++ b/src/pages/master/tag/component/DetailTag.jsx @@ -1,5 +1,5 @@ import React, { useEffect, useState } from 'react'; -import { Modal, Input, Typography, Switch, Button, ConfigProvider, Divider, Select } from 'antd'; +import { Modal, Input, Typography, Switch, Button, ConfigProvider, Select, Checkbox } from 'antd'; import { NotifAlert, NotifOk } from '../../../../components/Global/ToastNotif'; import { createTag, updateTag, getAllTag } from '../../../../api/master-tag'; import { getAllDevice } from '../../../../api/master-device'; @@ -34,6 +34,7 @@ const DetailTag = (props) => { lim_high: '', lim_high_crash: '', device_id: null, + description: '', sub_section_id: null, }; @@ -147,10 +148,8 @@ const DetailTag = (props) => { payload.unit = formData.unit.trim(); } - // Add device_id only if it's selected - if (formData.device_id) { - payload.device_id = parseInt(formData.device_id); - } + // Add device_id - backend requires this field even if null + payload.device_id = formData.device_id ? parseInt(formData.device_id) : null; // Add limit fields only if they have values if (formData.lim_low_crash !== '' && formData.lim_low_crash !== null) { @@ -166,10 +165,8 @@ const DetailTag = (props) => { payload.lim_high_crash = parseFloat(formData.lim_high_crash); } - // Add sub_section_id only if it's selected - if (formData.sub_section_id) { - payload.sub_section_id = parseInt(formData.sub_section_id); - } + // Add sub_section_id - backend requires this field even if null + payload.sub_section_id = formData.sub_section_id ? parseInt(formData.sub_section_id) : null; try { const response = @@ -234,24 +231,24 @@ const DetailTag = (props) => { }); }; - const handleAlarmToggle = (checked) => { + const handleAlarmToggle = (e) => { setformData({ ...formData, - is_alarm: checked, + is_alarm: e.target.checked, }); }; - const handleReportToggle = (checked) => { + const handleReportToggle = (e) => { setformData({ ...formData, - is_report: checked, + is_report: e.target.checked, }); }; - const handleHistoryToggle = (checked) => { + const handleHistoryToggle = (e) => { setformData({ ...formData, - is_history: checked, + is_history: e.target.checked, }); }; @@ -336,7 +333,7 @@ const DetailTag = (props) => { } Tag`} open={props.showModal} onCancel={handleCancel} - width={800} + width={1000} footer={[ { - {/* Alarm, Report, dan History dalam satu baris */} + {/* Tag Code dan Alarm, Report dan History */}
- {/* Alarm Toggle */} + {/* Tag Code - Auto Increment & Read Only */}
-
- Alarm - * -
-
Tag Code + -
- -
-
- {formData.is_alarm === true ? 'Yes' : 'No'} -
+ /> +
+ {/* Alarm Checkbox */} +
+ Alarm +
+
- {/* Report Toggle */} + {/* Report Checkbox */}
-
- Report - * -
-
-
- -
-
- {formData.is_report === true ? 'Yes' : 'No'} -
+ Report +
+
- {/* History Toggle */} + {/* History Checkbox */}
+ History
- History - * -
-
-
- -
-
- {formData.is_history === true ? 'Yes' : 'No'} -
+
- - {/* Tag Code - Auto Increment & Read Only */} -
- Tag Code - -
{/* Tag Number dan Tag Name dalam satu baris */}
{
- {/* Limit Low Crash dan Limit Low dalam satu baris */} + {/* Semua Limit dalam satu baris */}
{/* Limit Low Crash */} @@ -720,17 +656,6 @@ const DetailTag = (props) => { step="any" />
-
-
- {/* Limit High dan Limit High Crash dalam satu baris */} -
-
{/* Limit High */}
Limit High @@ -759,6 +684,18 @@ const DetailTag = (props) => {
+ {/* Description */} +
+ Description + +
)} diff --git a/src/pages/master/tag/component/ListTag.jsx b/src/pages/master/tag/component/ListTag.jsx index 2451e71..c9c41ed 100644 --- a/src/pages/master/tag/component/ListTag.jsx +++ b/src/pages/master/tag/component/ListTag.jsx @@ -44,12 +44,14 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [ dataIndex: 'data_type', key: 'data_type', width: '10%', + render: (text) => text || '-', }, { title: 'Unit', dataIndex: 'unit', key: 'unit', width: '8%', + render: (text) => text || '-', }, { title: 'Sub Section', @@ -63,6 +65,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [ dataIndex: 'device_name', key: 'device_name', width: '12%', + render: (text) => text || '-', }, { title: 'Status',