@@ -29,71 +29,63 @@ import {
29
29
SyncOutlined ,
30
30
ArrowLeftOutlined
31
31
} from "@ant-design/icons" ;
32
- import { getEnvironmentById } from './services/environments.service' ;
33
32
import AppsList from './components/AppsList' ;
34
- import { Workspace } from './types/workspace.types' ;
35
- import { Environment } from './types/environment.types' ;
36
- import { App } from './types/app.types' ;
33
+ import { useEnvironmentContext } from "./context/EnvironmentContext" ;
34
+ import { useWorkspace } from "./hooks/useWorkspace" ;
35
+
36
+
37
37
38
38
const { Title, Text } = Typography ;
39
39
const { TabPane } = Tabs ;
40
40
41
41
42
42
const WorkspaceDetail : React . FC = ( ) => {
43
+
43
44
// Get parameters from URL
44
- const { environmentId, workspaceId } = useParams < {
45
- environmentId : string ;
45
+ const { environmentId, workspaceId } = useParams < {
46
46
workspaceId : string ;
47
+ environmentId : string ;
47
48
} > ( ) ;
48
-
49
49
const {
50
50
environment,
51
+ loading : envLoading ,
52
+ error : envError ,
53
+ refresh : refreshEnvironment ,
54
+ } = useEnvironmentContext ( ) ;
55
+
56
+ const {
51
57
workspace,
52
- apps,
53
- appsLoading,
54
- appsError,
55
- refreshApps,
56
- appStats,
57
- dataSources,
58
- dataSourcesLoading,
59
- dataSourcesError,
60
- refreshDataSources,
61
- dataSourceStats,
62
- isLoading,
63
- hasError
64
- } = useWorkspaceDetail ( environmentId , workspaceId ) ;
58
+ loading : workspaceLoading ,
59
+ error : workspaceError ,
60
+ refresh : refreshWorkspace
61
+ } = useWorkspace ( environment , workspaceId ) ;
62
+
63
+
65
64
66
- // Handle loading/error states
67
- if ( isLoading ) {
68
- return < Spin /> ;
65
+ if ( envLoading || workspaceLoading ) {
66
+ return (
67
+ < div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , height : '100%' , padding : '50px' } } >
68
+ < Spin size = "large" tip = "Loading workspace details..." />
69
+ </ div >
70
+ ) ;
71
+ }
72
+
73
+ if ( envError || workspaceError || ! environment || ! workspace ) {
74
+ return (
75
+ < Alert
76
+ message = "Error loading workspace details"
77
+ description = { envError || workspaceError || "Workspace not found." }
78
+ type = "error"
79
+ showIcon
80
+ style = { { margin : '24px' } }
81
+ action = {
82
+ < Button type = "primary" onClick = { ( ) => history . push ( `/home/settings/environments/${ environmentId } ` ) } >
83
+ Back to Environment
84
+ </ Button >
85
+ }
86
+ />
87
+ ) ;
69
88
}
70
-
71
- // Handle loading/error states
72
- if ( isLoading ) {
73
- return (
74
- < div style = { { display : 'flex' , justifyContent : 'center' , alignItems : 'center' , height : '100%' , padding : '50px' } } >
75
- < Spin size = "large" tip = "Loading workspace details..." />
76
- </ div >
77
- ) ;
78
- }
79
-
80
- // Handle error state
81
- if ( hasError || ! environment || ! workspace ) {
82
- return (
83
- < Alert
84
- message = "Error loading workspace details"
85
- description = "Could not load the workspace or environment data. Please try again."
86
- type = "error"
87
- showIcon
88
- style = { { margin : '24px' } }
89
- action = {
90
- < Button type = "primary" onClick = { ( ) => history . push ( `/home/settings/environments/${ environmentId } ` ) } >
91
- Back to Environment
92
- </ Button >
93
- }
94
- />
95
- ) ;
96
- }
97
89
98
90
return (
99
91
< div className = "workspace-detail-container" style = { { padding : '24px' } } >
0 commit comments