1
1
import { useEffect } from 'react' ;
2
2
import { useNavigate , useParams } from 'react-router-dom' ;
3
3
4
+ import { useObjectMetadata } from '@/metadata/hooks/useObjectMetadata' ;
4
5
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer' ;
5
6
import { SettingsObjectFormSection } from '@/settings/data-model/components/SettingsObjectFormSection' ;
6
- import { activeObjectItems } from '@/settings/data-model/constants/mockObjects' ;
7
7
import { SettingsObjectIconSection } from '@/settings/data-model/object-edit/SettingsObjectIconSection' ;
8
8
import { AppPath } from '@/types/AppPath' ;
9
9
import { IconArchive , IconSettings } from '@/ui/display/icon' ;
@@ -15,14 +15,16 @@ import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
15
15
16
16
export const SettingsObjectEdit = ( ) => {
17
17
const navigate = useNavigate ( ) ;
18
+
18
19
const { pluralObjectName = '' } = useParams ( ) ;
19
- const activeObject = activeObjectItems . find (
20
- ( activeObject ) => activeObject . name . toLowerCase ( ) === pluralObjectName ,
20
+ const { activeObjects } = useObjectMetadata ( ) ;
21
+ const activeObject = activeObjects . find (
22
+ ( activeObject ) => activeObject . namePlural === pluralObjectName ,
21
23
) ;
22
24
23
25
useEffect ( ( ) => {
24
- if ( ! activeObject ) navigate ( AppPath . NotFound ) ;
25
- } , [ activeObject , navigate ] ) ;
26
+ if ( activeObjects . length && ! activeObject ) navigate ( AppPath . NotFound ) ;
27
+ } , [ activeObject , activeObjects . length , navigate ] ) ;
26
28
27
29
return (
28
30
< SubMenuTopBarContainer Icon = { IconSettings } title = "Settings" >
@@ -31,7 +33,7 @@ export const SettingsObjectEdit = () => {
31
33
links = { [
32
34
{ children : 'Objects' , href : '/settings/objects' } ,
33
35
{
34
- children : activeObject ?. name ?? '' ,
36
+ children : activeObject ?. labelPlural ?? '' ,
35
37
href : `/settings/objects/${ pluralObjectName } ` ,
36
38
} ,
37
39
{ children : 'Edit' } ,
@@ -40,16 +42,15 @@ export const SettingsObjectEdit = () => {
40
42
{ activeObject && (
41
43
< >
42
44
< SettingsObjectIconSection
43
- disabled = { activeObject . type === 'standard' }
44
- Icon = { activeObject . Icon }
45
- iconKey = { activeObject . Icon . name }
46
- label = { activeObject . name }
45
+ disabled = { ! activeObject . isCustom }
46
+ iconKey = { activeObject . icon ?? undefined }
47
+ label = { activeObject . labelPlural }
47
48
/>
48
49
< SettingsObjectFormSection
49
- disabled = { activeObject . type === 'standard' }
50
- singularName = { activeObject . singularName }
51
- pluralName = { activeObject . name }
52
- description = { activeObject . description }
50
+ disabled = { ! activeObject . isCustom }
51
+ singularName = { activeObject . labelSingular }
52
+ pluralName = { activeObject . labelPlural }
53
+ description = { activeObject . description ?? undefined }
53
54
/>
54
55
</ >
55
56
) }
0 commit comments