@@ -5,29 +5,8 @@ import { Icon } from '../../components/icon';
55import { useMessages } from '../../localization' ;
66import type { ProfilePage , ProfilePagesViewProps } from '../profile-pages/profile-pages.view' ;
77import { ProfilePagesView } from '../profile-pages/profile-pages.view' ;
8- import {
9- getAvailableOrganizationProfilePages ,
10- ORGANIZATION_PROFILE_PAGE_ICONS ,
11- resolveOrganizationProfilePages ,
12- } from './organization-profile.layout' ;
13- import type {
14- CustomOrganizationProfilePage ,
15- OrganizationProfilePageId ,
16- OrganizationProfilePages ,
17- } from './organization-profile.types' ;
18-
19- /** What the organization's navigation is built from. */
20- export interface OrganizationProfilePageListOptions {
21- /** The built-in pages. One left undefined is left out of the navigation. */
22- pages : OrganizationProfilePages ;
23- /** Pages of the consumer's own, added to the navigation after the built-ins. */
24- customPages ?: readonly CustomOrganizationProfilePage [ ] ;
25- /**
26- * The order the navigation runs in, by id: a built-in page's id, or a custom page's `path`. Ids
27- * left out keep their default place behind the ones named.
28- */
29- pageOrder ?: readonly ( OrganizationProfilePageId | ( string & { } ) ) [ ] ;
30- }
8+ import { ORGANIZATION_PROFILE_PAGE_ICONS , organizationProfileNavEntries } from './organization-profile.layout' ;
9+ import type { OrganizationProfilePageId , OrganizationProfilePageListOptions } from './organization-profile.types' ;
3110
3211export interface OrganizationProfileViewProps
3312 extends
@@ -59,23 +38,22 @@ export const OrganizationProfileView = React.forwardRef<HTMLDivElement, Organiza
5938
6039/** The organization's navigation, in order: the built-ins it was given content for, then the consumer's pages. */
6140export function organizationProfilePageList (
62- { pages , customPages , pageOrder } : OrganizationProfilePageListOptions ,
41+ options : OrganizationProfilePageListOptions ,
6342 labels : Record < OrganizationProfilePageId , string > ,
6443) : ProfilePage [ ] {
65- return resolveOrganizationProfilePages ( getAvailableOrganizationProfilePages ( pages ) , customPages , pageOrder ) . map (
66- entry =>
67- entry . custom
68- ? { id : entry . id , label : entry . custom . label , icon : entry . custom . icon , content : entry . custom . content }
69- : {
70- id : entry . id ,
71- label : labels [ entry . id ] ,
72- icon : (
73- < Icon
74- glyph = { ORGANIZATION_PROFILE_PAGE_ICONS [ entry . id ] }
75- size = 'sm'
76- />
77- ) ,
78- content : pages [ entry . id ] ,
79- } ,
44+ return organizationProfileNavEntries ( options ) . map ( entry =>
45+ entry . custom
46+ ? { id : entry . id , label : entry . custom . label , icon : entry . custom . icon , content : entry . custom . content }
47+ : {
48+ id : entry . id ,
49+ label : labels [ entry . id ] ,
50+ icon : (
51+ < Icon
52+ glyph = { ORGANIZATION_PROFILE_PAGE_ICONS [ entry . id ] }
53+ size = 'sm'
54+ />
55+ ) ,
56+ content : options . pages [ entry . id ] ,
57+ } ,
8058 ) ;
8159}
0 commit comments