Skip to content

Commit a900b8e

Browse files
committed
Refactor VsumTabs component to simplify state management
- Removed loadingId state and associated logic for improved clarity. - Eliminated derived states activeEdit and activeDetails as they are no longer needed, streamlining the component's functionality.
1 parent 393ad26 commit a900b8e

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/components/ui/VsumTabs.tsx

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ interface VsumTabsProps {
1111

1212
export const VsumTabs: React.FC<VsumTabsProps> = ({ openVsums, activeVsumId, onActivate, onClose }) => {
1313
const [detailsById, setDetailsById] = useState<Record<number, VsumDetails | undefined>>({});
14-
const [loadingId, setLoadingId] = useState<number | null>(null);
1514
const [error, setError] = useState<string>('');
1615
const [edits, setEdits] = useState<Record<number, { name: string; metaModelIds: number[] }>>({});
1716
const [saving, setSaving] = useState(false);
@@ -61,8 +60,7 @@ export const VsumTabs: React.FC<VsumTabsProps> = ({ openVsums, activeVsumId, onA
6160
}
6261
}, [activeVsumId, detailsById]);
6362

64-
const activeEdit = activeVsumId ? edits[activeVsumId] : undefined;
65-
const activeDetails = activeVsumId ? detailsById[activeVsumId] : undefined;
63+
// Derived states no longer needed: activeEdit, activeDetails
6664

6765
const saveById = async (id: number, override?: { name?: string; metaModelIds?: number[] }) => {
6866
const edit = edits[id];
@@ -93,16 +91,13 @@ export const VsumTabs: React.FC<VsumTabsProps> = ({ openVsums, activeVsumId, onA
9391
const ensureDetails = async (id: number) => {
9492
if (detailsById[id]) return detailsById[id];
9593
try {
96-
setLoadingId(id);
9794
const res = await apiService.getVsumDetails(id);
9895
setDetailsById(prev => ({ ...prev, [id]: res.data }));
9996
setEdits(prev => ({ ...prev, [id]: { name: res.data.name, metaModelIds: (res.data.metaModels || []).map(m => m.id) } }));
10097
return res.data;
10198
} catch (e) {
10299
setError(e instanceof Error ? e.message : 'Failed to load vSUM details');
103100
return undefined;
104-
} finally {
105-
setLoadingId(null);
106101
}
107102
};
108103

0 commit comments

Comments
 (0)