From 7eabb2c7c89583887655218b62d1b60137085a0a Mon Sep 17 00:00:00 2001 From: Rafiafrzl Date: Fri, 24 Oct 2025 14:53:02 +0700 Subject: [PATCH 1/5] fix description field --- src/pages/master/tag/component/DetailTag.jsx | 35 ++++++++++++-------- src/pages/master/tag/component/ListTag.jsx | 15 ++++++--- 2 files changed, 33 insertions(+), 17 deletions(-) diff --git a/src/pages/master/tag/component/DetailTag.jsx b/src/pages/master/tag/component/DetailTag.jsx index 96f86f0..63322e3 100644 --- a/src/pages/master/tag/component/DetailTag.jsx +++ b/src/pages/master/tag/component/DetailTag.jsx @@ -34,9 +34,9 @@ const DetailTag = (props) => { lim_high: '', lim_high_crash: '', device_id: null, - description: '', + tag_description: '', - sub_section_id: null, + plant_sub_section_id: null, }; const [formData, setformData] = useState(defaultData); @@ -148,8 +148,15 @@ const DetailTag = (props) => { payload.unit = formData.unit.trim(); } - // Add device_id - backend requires this field even if null - payload.device_id = formData.device_id ? parseInt(formData.device_id) : null; + // Add tag_description only if it has a value + if (formData.tag_description && formData.tag_description.trim() !== '') { + payload.tag_description = formData.tag_description.trim(); + } + + // Add device_id only if it has a value + if (formData.device_id) { + payload.device_id = parseInt(formData.device_id); + } // Add limit fields only if they have values if (formData.lim_low_crash !== '' && formData.lim_low_crash !== null) { @@ -165,8 +172,10 @@ const DetailTag = (props) => { payload.lim_high_crash = parseFloat(formData.lim_high_crash); } - // 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; + // Add plant_sub_section_id only if it has a value + if (formData.plant_sub_section_id) { + payload.plant_sub_section_id = parseInt(formData.plant_sub_section_id); + } try { const response = @@ -510,9 +519,9 @@ const DetailTag = (props) => { @@ -688,8 +697,8 @@ const DetailTag = (props) => {
Description [ title: 'Data Type', dataIndex: 'data_type', key: 'data_type', - width: '10%', + width: '8%', render: (text) => text || '-', }, { @@ -55,9 +55,9 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [ }, { title: 'Sub Section', - dataIndex: 'sub_section_name', - key: 'sub_section_name', - width: '12%', + dataIndex: 'plant_sub_section_name', + key: 'plant_sub_section_name', + width: '10%', render: (text) => text || '-', }, { @@ -67,6 +67,13 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [ width: '12%', render: (text) => text || '-', }, + { + title: 'Description', + dataIndex: 'tag_description', + key: 'tag_description', + width: '12%', + render: (text) => text || '-', + }, { title: 'Status', dataIndex: 'is_active', From c3fadb93828e3e3ca3084bae3aba0e26107f6161 Mon Sep 17 00:00:00 2001 From: Vinix Date: Fri, 24 Oct 2025 15:42:29 +0700 Subject: [PATCH 2/5] fix: plant sub section --- .../component/DetailPlantSection.jsx | 81 ++++++++++++++++--- .../component/ListPlantSection.jsx | 59 ++++++++++---- 2 files changed, 110 insertions(+), 30 deletions(-) diff --git a/src/pages/master/plantSection/component/DetailPlantSection.jsx b/src/pages/master/plantSection/component/DetailPlantSection.jsx index 75be3ef..5515df4 100644 --- a/src/pages/master/plantSection/component/DetailPlantSection.jsx +++ b/src/pages/master/plantSection/component/DetailPlantSection.jsx @@ -10,20 +10,41 @@ const DetailPlantSection = (props) => { const [confirmLoading, setConfirmLoading] = useState(false); const defaultData = { - sub_section_id: '', - sub_section_code: '', - sub_section_name: '', + plant_sub_section_id: '', + plant_sub_section_code: '', + plant_sub_section_name: '', + table_name_value: '', // Fix field name + plant_sub_section_description: '', is_active: true, }; const [formData, setFormData] = useState(defaultData); const handleInputChange = (e) => { - const { name, value } = e.target; - setFormData({ - ...formData, - [name]: value, - }); + // Handle different input types + let name, value; + + if (e && e.target) { + // Standard input + name = e.target.name; + value = e.target.value; + } else if (e && e.type === 'change') { + // Switch or other components + name = e.name || e.target?.name; + value = e.value !== undefined ? e.value : e.checked; + } else { + // Fallback + return; + } + + console.log(`📝 Input change: ${name} = ${value}`); + + if (name) { + setFormData(prev => ({ + ...prev, + [name]: value, + })); + } }; const handleCancel = () => { @@ -36,7 +57,7 @@ const DetailPlantSection = (props) => { // Daftar aturan validasi const validationRules = [ - { field: 'sub_section_name', label: 'Plant Sub Section Name', required: true }, + { field: 'plant_sub_section_name', label: 'Plant Sub Section Name', required: true }, ]; if ( @@ -52,14 +73,20 @@ const DetailPlantSection = (props) => { return; try { + console.log("💾 Current formData before save:", formData); + const payload = { + plant_sub_section_name: formData.plant_sub_section_name, + plant_sub_section_description: formData.plant_sub_section_description, + table_name_value: formData.table_name_value, // Fix field name is_active: formData.is_active, - sub_section_name: formData.sub_section_name, }; + console.log("📤 Payload to be sent:", payload); + const response = props.actionMode === 'edit' - ? await updatePlantSection(formData.sub_section_id, payload) + ? await updatePlantSection(formData.plant_sub_section_id, payload) : await createPlantSection(payload); if (response && (response.statusCode === 200 || response.statusCode === 201)) { @@ -98,9 +125,17 @@ const DetailPlantSection = (props) => { }; useEffect(() => { + console.log("🔄 Modal state changed:", { + showModal: props.showModal, + actionMode: props.actionMode, + selectedData: props.selectedData + }); + if (props.selectedData) { + console.log("📋 Setting form data from selectedData:", props.selectedData); setFormData(props.selectedData); } else { + console.log("📋 Resetting to default data"); setFormData(defaultData); } }, [props.showModal, props.selectedData, props.actionMode]); @@ -195,13 +230,33 @@ const DetailPlantSection = (props) => { Plant Sub Section Name *
+
+ Table Name Value + +
+
+ Description + +
)} diff --git a/src/pages/master/plantSection/component/ListPlantSection.jsx b/src/pages/master/plantSection/component/ListPlantSection.jsx index 863525a..9ff8d4c 100644 --- a/src/pages/master/plantSection/component/ListPlantSection.jsx +++ b/src/pages/master/plantSection/component/ListPlantSection.jsx @@ -14,25 +14,47 @@ import TableList from '../../../../components/Global/TableList'; const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [ { - title: 'Section Code', - dataIndex: 'sub_section_code', - key: 'sub_section_code', - width: '20%', + title: 'No', + key: 'no', + width: '5%', + align: 'center', + render: (_, __, index) => index + 1, + }, + { + title: 'Plant Sub Section Code', + dataIndex: 'plant_sub_section_code', + key: 'plant_sub_section_code', + width: '15%', + align: 'center', }, { title: 'Plant Sub Section Name', - dataIndex: 'sub_section_name', - key: 'sub_section_name', - width: '40%', + dataIndex: 'plant_sub_section_name', + key: 'plant_sub_section_name', + width: '25%', + }, + { + title: 'Table Name Value', + dataIndex: 'table_name_value', + key: 'table_name_value', + width: '20%', + render: (text) => text || '-', + }, + { + title: 'Description', + dataIndex: 'plant_sub_section_description', + key: 'plant_sub_section_description', + width: '20%', + render: (text) => text || '-', }, { title: 'Status', dataIndex: 'is_active', key: 'is_active', - width: '15%', + width: '10%', align: 'center', render: (status) => ( - + {status ? 'Active' : 'Inactive'} ), @@ -46,22 +68,25 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [