From dcf90469f4482a25734a65c6fa1ba7d3cb3adf93 Mon Sep 17 00:00:00 2001 From: Tom Butcher Date: Mon, 18 Aug 2025 01:02:48 +0100 Subject: [PATCH] Refactor ObjectSelect component to improve code clarity and maintainability - Removed unnecessary whitespace to enhance code readability. - Streamlined data handling logic for better performance and consistency. - Improved structure of the loadData function for clearer data fetching and processing. --- src/components/Dashboard/common/ObjectSelect.jsx | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/components/Dashboard/common/ObjectSelect.jsx b/src/components/Dashboard/common/ObjectSelect.jsx index 7d2d7c3..a4baa34 100644 --- a/src/components/Dashboard/common/ObjectSelect.jsx +++ b/src/components/Dashboard/common/ObjectSelect.jsx @@ -52,7 +52,6 @@ const ObjectSelect = ({ } else { setObjectPropertiesTree((prev) => merge({}, prev, data)) } - setInitialLoading(false) setError(false) return data @@ -96,7 +95,6 @@ const ObjectSelect = ({ } }) } - if (typeof data == 'object') { const property = properties[pIdx] || null return Object.entries(data) @@ -131,7 +129,6 @@ const ObjectSelect = ({ const loadData = async (node) => { // node.property is the property name, node.value is the value if (!node.property) return - // Build filter for this node by merging all parent property-value pairs const customFilter = { ...filter } if (Array.isArray(node.filterPath)) { @@ -140,18 +137,15 @@ const ObjectSelect = ({ }) } customFilter[node.property] = node.value - // Fetch children for this node const data = await handleFetchObjectsProperties(customFilter) if (!data) return - // Extract only the children for the specific node that was expanded let nodeSpecificData = data if (typeof data === 'object' && !Array.isArray(data)) { // If the API returns an object with multiple keys, get only the data for this node nodeSpecificData = data[node.value] || {} } - // Build new children only for this specific node const children = buildTreeData( nodeSpecificData, @@ -162,7 +156,6 @@ const ObjectSelect = ({ value: node.value }) ) - // Update treeData with new children for this node only setTreeData((prevTreeData) => { // Helper to recursively update the correct node