1- import type { OrganizationEnrollmentMode } from '@clerk/types' ;
1+ import type { OrganizationDomainResource , OrganizationEnrollmentMode } from '@clerk/types' ;
22
3+ import { CalloutWithAction } from '../../common' ;
34import { useCoreOrganization , useEnvironment } from '../../contexts' ;
4- import { Col , Flex , localizationKeys , Spinner } from '../../customizables' ;
5+ import type { LocalizationKey } from '../../customizables' ;
6+ import { Col , Flex , localizationKeys , Spinner , Text } from '../../customizables' ;
57import {
68 ContentPage ,
79 Form ,
@@ -16,11 +18,39 @@ import {
1618 withCardStateProvider ,
1719} from '../../elements' ;
1820import { useFetch , useNavigateToFlowStart } from '../../hooks' ;
21+ import { InformationCircle } from '../../icons' ;
1922import { useRouter } from '../../router' ;
2023import { handleError , useFormControl } from '../../utils' ;
2124import { LinkButtonWithDescription } from '../UserProfile/LinkButtonWithDescription' ;
2225import { OrganizationProfileBreadcrumbs } from './OrganizationProfileNavbar' ;
2326
27+ const useCalloutLabel = (
28+ domain : OrganizationDomainResource | null ,
29+ {
30+ infoLabel : infoLabelKey ,
31+ } : {
32+ infoLabel : LocalizationKey ;
33+ } ,
34+ ) => {
35+ const totalInvitations = domain ?. totalPendingInvitations || 0 ;
36+ const totalSuggestions = domain ?. totalPendingSuggestions || 0 ;
37+ const totalPending = totalSuggestions + totalInvitations ;
38+
39+ if ( totalPending === 0 ) {
40+ return [ ] as string [ ] ;
41+ }
42+
43+ return [
44+ infoLabelKey ,
45+ localizationKeys ( `organizationProfile.verifiedDomainPage.enrollmentTab.calloutInvitationCountLabel` , {
46+ count : totalInvitations ,
47+ } ) ,
48+ localizationKeys ( `organizationProfile.verifiedDomainPage.enrollmentTab.calloutSuggestionCountLabel` , {
49+ count : totalInvitations ,
50+ } ) ,
51+ ] ;
52+ } ;
53+
2454export const VerifiedDomainPage = withCardStateProvider ( ( ) => {
2555 const card = useCardState ( ) ;
2656 const { organizationSettings } = useEnvironment ( ) ;
@@ -30,6 +60,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
3060 infinite : true ,
3161 } ,
3262 } ) ;
63+
3364 const { navigateToFlowStart } = useNavigateToFlowStart ( ) ;
3465 const { params, navigate, queryParams } = useRouter ( ) ;
3566 const mode = ( queryParams . mode || 'edit' ) as 'select' | 'edit' ;
@@ -104,6 +135,14 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
104135 domain : domain ?. name ,
105136 } ) ;
106137
138+ const calloutLabel = useCalloutLabel ( domain , {
139+ infoLabel : localizationKeys ( `organizationProfile.verifiedDomainPage.enrollmentTab.calloutInfoLabel` ) ,
140+ } ) ;
141+
142+ const dangerCalloutLabel = useCalloutLabel ( domain , {
143+ infoLabel : localizationKeys ( `organizationProfile.verifiedDomainPage.dangerTab.calloutInfoLabel` ) ,
144+ } ) ;
145+
107146 const updateEnrollmentMode = async ( ) => {
108147 if ( ! domain || ! organization ) {
109148 return ;
@@ -149,6 +188,7 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
149188 if ( ! ( domain . verification && domain . verification . status === 'verified' ) ) {
150189 void navigateToFlowStart ( ) ;
151190 }
191+
152192 return (
153193 < ContentPage
154194 headerTitle = { domain . name }
@@ -175,6 +215,24 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
175215 direction = { 'col' }
176216 gap = { 4 }
177217 >
218+ { calloutLabel . length > 0 && (
219+ < CalloutWithAction icon = { InformationCircle } >
220+ { calloutLabel . map ( ( label , index ) => (
221+ < Text
222+ key = { index }
223+ as = { 'span' }
224+ sx = { [
225+ t => ( {
226+ lineHeight : t . lineHeights . $short ,
227+ color : 'inherit' ,
228+ display : 'block' ,
229+ } ) ,
230+ ] }
231+ localizationKey = { label }
232+ />
233+ ) ) }
234+ </ CalloutWithAction >
235+ ) }
178236 < Header . Root >
179237 < Header . Subtitle
180238 localizationKey = { localizationKeys ( 'organizationProfile.verifiedDomainPage.enrollmentTab.subtitle' ) }
@@ -207,22 +265,42 @@ export const VerifiedDomainPage = withCardStateProvider(() => {
207265 { allowsEdit && (
208266 < TabPanel
209267 direction = { 'col' }
210- sx = { [
211- { width : '100%' } ,
212- t => ( {
213- padding : `${ t . space . $none } ${ t . space . $4 } ` ,
214- } ) ,
215- ] }
268+ gap = { 4 }
269+ sx = { { width : '100%' } }
216270 >
217- < LinkButtonWithDescription
218- title = { localizationKeys ( 'organizationProfile.verifiedDomainPage.dangerTab.removeDomainTitle' ) }
219- subtitle = { localizationKeys ( 'organizationProfile.verifiedDomainPage.dangerTab.removeDomainSubtitle' ) }
220- actionLabel = { localizationKeys (
221- 'organizationProfile.verifiedDomainPage.dangerTab.removeDomainActionLabel__remove' ,
222- ) }
223- colorScheme = 'danger'
224- onClick = { ( ) => navigate ( `../../domain/${ domain . id } /remove` ) }
225- />
271+ { dangerCalloutLabel . length > 0 && (
272+ < CalloutWithAction icon = { InformationCircle } >
273+ { dangerCalloutLabel . map ( ( label , index ) => (
274+ < Text
275+ key = { index }
276+ as = { 'span' }
277+ sx = { [
278+ t => ( {
279+ lineHeight : t . lineHeights . $short ,
280+ color : 'inherit' ,
281+ display : 'block' ,
282+ } ) ,
283+ ] }
284+ localizationKey = { label }
285+ />
286+ ) ) }
287+ </ CalloutWithAction >
288+ ) }
289+ < Col
290+ sx = { t => ( {
291+ padding : `${ t . space . $none } ${ t . space . $4 } ` ,
292+ } ) }
293+ >
294+ < LinkButtonWithDescription
295+ title = { localizationKeys ( 'organizationProfile.verifiedDomainPage.dangerTab.removeDomainTitle' ) }
296+ subtitle = { localizationKeys ( 'organizationProfile.verifiedDomainPage.dangerTab.removeDomainSubtitle' ) }
297+ actionLabel = { localizationKeys (
298+ 'organizationProfile.verifiedDomainPage.dangerTab.removeDomainActionLabel__remove' ,
299+ ) }
300+ colorScheme = 'danger'
301+ onClick = { ( ) => navigate ( `../../domain/${ domain . id } /remove` ) }
302+ />
303+ </ Col >
226304 </ TabPanel >
227305 ) }
228306 </ TabPanels >
0 commit comments