Skip to content

Commit aa32bbc

Browse files
authored
feat(clerk-js,localizations,shared,ui): Add support for Banned badge (#8261)
1 parent c54e3df commit aa32bbc

7 files changed

Lines changed: 25 additions & 1 deletion

File tree

.changeset/wet-mangos-stop.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
'@clerk/localizations': minor
3+
'@clerk/clerk-js': minor
4+
'@clerk/shared': minor
5+
'@clerk/ui': minor
6+
---
7+
8+
Add support for rendering the Banned badge in the organization members list.

packages/clerk-js/src/core/resources/PublicUserData.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class PublicUserData implements IPublicUserData {
1212
identifier!: string;
1313
userId?: string;
1414
username?: string;
15+
banned?: boolean;
1516

1617
constructor(data: PublicUserDataJSON | PublicUserDataJSONSnapshot) {
1718
this.fromJSON(data);
@@ -26,6 +27,7 @@ export class PublicUserData implements IPublicUserData {
2627
this.identifier = data.identifier || '';
2728
this.userId = data.user_id;
2829
this.username = data.username;
30+
this.banned = data.banned ?? undefined;
2931
}
3032

3133
return this;
@@ -40,6 +42,7 @@ export class PublicUserData implements IPublicUserData {
4042
identifier: this.identifier,
4143
user_id: this.userId,
4244
username: this.username,
45+
banned: this.banned,
4346
};
4447
}
4548
}

packages/localizations/src/en-US.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ export const enUS: LocalizationResource = {
6363
badge__upcomingPlan: 'Upcoming',
6464
badge__userDevice: 'User device',
6565
badge__you: 'You',
66+
badge__banned: 'Banned',
6667
billing: {
6768
addPaymentMethod__label: 'Add payment method',
6869
alwaysFree: 'Always free',

packages/shared/src/types/json.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,7 @@ export interface PublicUserDataJSON {
321321
identifier: string;
322322
user_id?: string;
323323
username?: string;
324+
banned?: boolean;
324325
}
325326

326327
export interface SessionWithActivitiesJSON extends Omit<SessionJSON, 'user'> {

packages/shared/src/types/localization.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ export type __internal_LocalizationResource = {
152152
badge__unverified: LocalizationValue;
153153
badge__requiresAction: LocalizationValue;
154154
badge__you: LocalizationValue;
155+
badge__banned: LocalizationValue;
155156
badge__freeTrial: LocalizationValue;
156157
badge__currentPlan: LocalizationValue;
157158
badge__upcomingPlan: LocalizationValue;

packages/shared/src/types/session.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,7 @@ export interface PublicUserData {
336336
identifier: string;
337337
userId?: string;
338338
username?: string;
339+
banned?: boolean;
339340
}
340341

341342
/**

packages/ui/src/components/OrganizationProfile/ActiveMembersList.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ const MemberRow = (props: {
9595
user={membership.publicUserData}
9696
subtitle={membership.publicUserData?.identifier}
9797
subtitleProps={{ variant: 'caption' }}
98-
badge={isCurrentUser && <Badge localizationKey={localizationKeys('badge__you')} />}
98+
badge={
99+
isCurrentUser ? (
100+
<Badge localizationKey={localizationKeys('badge__you')} />
101+
) : membership.publicUserData?.banned ? (
102+
<Badge
103+
colorScheme='danger'
104+
localizationKey={localizationKeys('badge__banned')}
105+
/>
106+
) : undefined
107+
}
99108
/>
100109
</Td>
101110
<Td>

0 commit comments

Comments
 (0)