@@ -42,8 +42,8 @@ export function AdminLayout() {
42
42
43
43
const [ config ] = useState < TabDefinition < TabModel > [ ] > ( ( ) => [
44
44
{
45
- mapToUiState : ( _ , path ) => ( {
46
- id : path ,
45
+ mapToUiModel : ( key ) => ( {
46
+ id : key ,
47
47
title : "Dashboard" ,
48
48
content : < Outlet /> ,
49
49
isClosable : true ,
@@ -52,8 +52,8 @@ export function AdminLayout() {
52
52
insertAt : theBeginning ,
53
53
} ,
54
54
{
55
- mapToUiState : ( _ , path ) => ( {
56
- id : path ,
55
+ mapToUiModel : ( key ) => ( {
56
+ id : key ,
57
57
title : "Categories" ,
58
58
content : < Outlet /> ,
59
59
isClosable : true ,
@@ -62,8 +62,8 @@ export function AdminLayout() {
62
62
insertAt : theBeginning ,
63
63
} ,
64
64
{
65
- mapToUiState : ( _ , path ) => ( {
66
- id : path ,
65
+ mapToUiModel : ( key ) => ( {
66
+ id : key ,
67
67
title : "Products" ,
68
68
content : < Outlet /> ,
69
69
isClosable : true ,
@@ -72,8 +72,8 @@ export function AdminLayout() {
72
72
insertAt : theBeginning ,
73
73
} ,
74
74
{
75
- mapToUiState : ( _ , path ) => ( {
76
- id : path ,
75
+ mapToUiModel : ( key ) => ( {
76
+ id : key ,
77
77
title : "Suppliers" ,
78
78
content : < Outlet /> ,
79
79
isClosable : true ,
@@ -83,24 +83,19 @@ export function AdminLayout() {
83
83
} ,
84
84
] ) ;
85
85
86
- const { tabs, activeTab , setActivePath } = useRouterTabs ( {
86
+ const { tabs, setTabs , activeTabKey , setActiveTabKey } = useRouterTabs ( {
87
87
router,
88
88
config,
89
89
paths,
90
- undefinedPath : homeRoute ,
90
+ undefinedKeyPath : homeRoute ,
91
91
onPathsChange : setPaths ,
92
+ getUiModelKey : ( model ) => model . id ,
92
93
} ) ;
93
94
94
95
useEffect ( ( ) => {
95
96
return persistTabs ( paths ) ;
96
97
} , [ paths , persistTabs ] ) ;
97
98
98
- const activeTabId = activeTab ?. id ;
99
-
100
- const setTabs = ( tabs : TabModel [ ] ) => {
101
- setPaths ( tabs . map ( ( tab ) => tab . id ) ) ;
102
- } ;
103
-
104
99
return (
105
100
< div css = { layoutStyles } >
106
101
< header css = { headerStyles } > John Doe</ header >
@@ -111,11 +106,11 @@ export function AdminLayout() {
111
106
< Tabs
112
107
tabs = { tabs }
113
108
onTabsChange = { setTabs }
114
- initialActiveTabId = { activeTabId }
109
+ initialActiveTabId = { activeTabKey }
115
110
initialTabs = { tabs }
116
111
hasControlledActiveTabId
117
- activeTabId = { activeTabId }
118
- onActiveTabIdChange = { setActivePath }
112
+ activeTabId = { activeTabKey }
113
+ onActiveTabIdChange = { setActiveTabKey }
119
114
/>
120
115
</ div >
121
116
</ div >
0 commit comments