|
1 | 1 | import { useOrganization } from '@clerk/shared/react'; |
2 | 2 |
|
3 | | -import { Header } from '@/ui/elements/Header'; |
4 | 3 | import { OrganizationPreview } from '@/ui/elements/OrganizationPreview'; |
5 | 4 | import { ProfileCard } from '@/ui/elements/ProfileCard'; |
6 | 5 | import { ProfileSection } from '@/ui/elements/Section'; |
7 | 6 |
|
8 | 7 | import { Protect, useProtect } from '../../common'; |
9 | 8 | import { useEnvironment } from '../../contexts'; |
10 | | -import { Col, descriptors, localizationKeys, Text } from '../../customizables'; |
| 9 | +import { Col, localizationKeys, Text } from '../../customizables'; |
11 | 10 | import { Action } from '../../elements/Action'; |
12 | 11 | import { useActionContext } from '../../elements/Action/ActionRoot'; |
13 | 12 | import { DeleteOrganizationForm, LeaveOrganizationForm } from './ActionConfirmationPage'; |
@@ -58,34 +57,28 @@ const DeleteOrganizationScreen = () => { |
58 | 57 | export const OrganizationGeneralPage = () => { |
59 | 58 | return ( |
60 | 59 | <ProfileCard.Page> |
61 | | - <Col |
62 | | - elementDescriptor={descriptors.page} |
63 | | - sx={t => ({ gap: t.space.$8 })} |
| 60 | + <ProfileCard.PagePanel |
| 61 | + pageId='organizationGeneral' |
| 62 | + titleKey={localizationKeys('organizationProfile.start.headerTitle__general')} |
64 | 63 | > |
65 | | - <Col |
66 | | - elementDescriptor={descriptors.profilePage} |
67 | | - elementId={descriptors.profilePage.setId('organizationGeneral')} |
68 | | - > |
69 | | - <Header.Root> |
70 | | - <Header.Title |
71 | | - localizationKey={localizationKeys('organizationProfile.start.headerTitle__general')} |
72 | | - sx={t => ({ marginBottom: t.space.$4 })} |
73 | | - textVariant='h2' |
74 | | - /> |
75 | | - </Header.Root> |
76 | | - <OrganizationProfileSection /> |
77 | | - <Protect permission='org:sys_domains:read'> |
78 | | - <OrganizationDomainsSection /> |
79 | | - </Protect> |
80 | | - <OrganizationLeaveSection /> |
81 | | - <OrganizationDeleteSection /> |
82 | | - </Col> |
83 | | - </Col> |
| 64 | + <OrganizationProfileSection /> |
| 65 | + <Protect permission='org:sys_domains:read'> |
| 66 | + <OrganizationDomainsSection /> |
| 67 | + </Protect> |
| 68 | + <OrganizationLeaveSection /> |
| 69 | + <OrganizationDeleteSection /> |
| 70 | + </ProfileCard.PagePanel> |
84 | 71 | </ProfileCard.Page> |
85 | 72 | ); |
86 | 73 | }; |
87 | 74 |
|
88 | | -const OrganizationProfileSection = () => { |
| 75 | +/** |
| 76 | + * Renders the organization profile section (name, logo) with inline edit when the user has |
| 77 | + * `org:sys_profile:manage`. |
| 78 | + * |
| 79 | + * @returns The profile section, or `null` when no organization is active. |
| 80 | + */ |
| 81 | +export const OrganizationProfileSection = (): JSX.Element | null => { |
89 | 82 | const { organization } = useOrganization(); |
90 | 83 |
|
91 | 84 | if (!organization) { |
@@ -134,7 +127,13 @@ const OrganizationProfileSection = () => { |
134 | 127 | ); |
135 | 128 | }; |
136 | 129 |
|
137 | | -const OrganizationDomainsSection = () => { |
| 130 | +/** |
| 131 | + * Renders the verified-domains section. |
| 132 | + * |
| 133 | + * @returns The domains section, or `null` when domains are disabled, no organization is active, or |
| 134 | + * there are no domains and the user cannot add any. |
| 135 | + */ |
| 136 | +export const OrganizationDomainsSection = (): JSX.Element | null => { |
138 | 137 | const { organizationSettings } = useEnvironment(); |
139 | 138 | const { organization, domains } = useOrganization({ domains: { infinite: true } }); |
140 | 139 | const canManageDomains = useProtect({ permission: 'org:sys_domains:manage' }); |
@@ -190,7 +189,12 @@ const OrganizationDomainsSection = () => { |
190 | 189 | ); |
191 | 190 | }; |
192 | 191 |
|
193 | | -const OrganizationLeaveSection = () => { |
| 192 | +/** |
| 193 | + * Renders the "leave organization" action in the danger section. |
| 194 | + * |
| 195 | + * @returns The leave-organization section, or `null` when no organization is active. |
| 196 | + */ |
| 197 | +export const OrganizationLeaveSection = (): JSX.Element | null => { |
194 | 198 | const { organization } = useOrganization(); |
195 | 199 |
|
196 | 200 | if (!organization) { |
@@ -236,7 +240,13 @@ const OrganizationLeaveSection = () => { |
236 | 240 | ); |
237 | 241 | }; |
238 | 242 |
|
239 | | -const OrganizationDeleteSection = () => { |
| 243 | +/** |
| 244 | + * Renders the "delete organization" action in the danger section. |
| 245 | + * |
| 246 | + * @returns The delete-organization section, or `null` when no organization is active, the user |
| 247 | + * lacks `org:sys_profile:delete`, or admin delete is disabled. |
| 248 | + */ |
| 249 | +export const OrganizationDeleteSection = (): JSX.Element | null => { |
240 | 250 | const { organization } = useOrganization(); |
241 | 251 | const canDeleteOrganization = useProtect({ permission: 'org:sys_profile:delete' }); |
242 | 252 |
|
|
0 commit comments