diff --git a/src/pages/master/tag/component/DetailTag.jsx b/src/pages/master/tag/component/DetailTag.jsx
index 6d8bbda..0ff5a25 100644
--- a/src/pages/master/tag/component/DetailTag.jsx
+++ b/src/pages/master/tag/component/DetailTag.jsx
@@ -188,6 +188,7 @@ const DetailTag = (props) => {
const params = new URLSearchParams({ limit: 1000 });
const response = await getAllDevice(params);
if (response && response.data && response.data.data) {
+ console.log('Loaded devices:', response.data.data); // Debug
setDeviceList(response.data.data);
}
} catch (error) {
@@ -305,82 +306,7 @@ const DetailTag = (props) => {
/>
)}
-
- Tag Name
- *
-
-
-
- Tag Number
- *
-
-
-
- Data Type
- *
-
-
-
- Unit
- *
-
-
-
- Device Code
- *
-
-
- Device Name
-
-
- {/* Device ID hidden - value dari dropdown */}
-
+ {/* Status dipindah ke atas Tag Name */}
Status
@@ -408,6 +334,91 @@ const DetailTag = (props) => {
+
+ Tag Name
+ *
+
+
+
+ Tag Number
+ *
+
+
+
+ Data Type
+ *
+
+
+
+ Unit
+ *
+
+
+
+ Device Code
+ *
+
+
+
+ Device Name
+
+
+ {/* Device ID hidden - value dari dropdown */}
+
)}
diff --git a/src/pages/master/tag/component/ListTag.jsx b/src/pages/master/tag/component/ListTag.jsx
index 8bc207b..7f9fdb3 100644
--- a/src/pages/master/tag/component/ListTag.jsx
+++ b/src/pages/master/tag/component/ListTag.jsx
@@ -115,7 +115,15 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
const ListTag = memo(function ListTag(props) {
const [trigerFilter, setTrigerFilter] = useState(false);
- const defaultFilter = { search: '' };
+ const defaultFilter = {
+ criteria: '', // Global search (OR condition)
+ name: '',
+ code: '',
+ data: '',
+ unit: '',
+ device: '',
+ subsection: '',
+ };
const [formDataFilter, setFormDataFilter] = useState(defaultFilter);
const [searchValue, setSearchValue] = useState('');
@@ -132,18 +140,19 @@ const ListTag = memo(function ListTag(props) {
}
}, [props.actionMode]);
- useEffect(() => {
- // Memicu filter setiap kali formDataFilter berubah
- doFilter();
- }, [formDataFilter]);
-
const doFilter = () => {
setTrigerFilter((prev) => !prev);
};
- const handleSearch = (value) => {
- setSearchValue(value);
- setFormDataFilter({ search: value });
+ const handleSearch = () => {
+ setFormDataFilter((prev) => ({ ...prev, criteria: searchValue }));
+ doFilter();
+ };
+
+ const handleSearchClear = () => {
+ setSearchValue('');
+ setFormDataFilter((prev) => ({ ...prev, criteria: '' }));
+ doFilter();
};
const showPreviewModal = (param) => {
props.setSelectedData(param);
@@ -210,11 +219,16 @@ const ListTag = memo(function ListTag(props) {
placeholder="Search tag by code, name, or type..."
value={searchValue}
onChange={(e) => {
- const { value } = e.target;
+ const value = e.target.value;
setSearchValue(value);
+ // Auto search when clearing by backspace/delete
+ if (value === '') {
+ handleSearchClear();
+ }
}}
onSearch={handleSearch}
allowClear
+ onClear={handleSearchClear}
enterButton={