Skip to content

Commit

Permalink
feat(web): team member limit nudge
Browse files Browse the repository at this point in the history
  • Loading branch information
ChmaraX committed Oct 15, 2024
1 parent 7624e94 commit 390c1d7
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 38 deletions.
52 changes: 23 additions & 29 deletions apps/web/src/ee/clerk/components/CustomOrganizationProfile.tsx
Original file line number Diff line number Diff line change
@@ -1,44 +1,38 @@
import { OrganizationProfile } from '@clerk/clerk-react';
import { FC } from 'react';
import { OrganizationProfile, useOrganization } from '@clerk/clerk-react';
import { OrganizationProfileTheme } from '@clerk/types';
import { ROUTES } from '../../../constants/routes';

// Hides OrganizationProfile sidebar + makes it fit the parent container
const OrganizationProfileAppearance = {
elements: {
pageScrollBox: {
padding: 0,
},
cardBox: {
display: 'block',
width: '100%',
height: '100%',
boxShadow: 'none',
},
navbar: {
display: 'none',
},
rootBox: {
width: '100%',
},
},
};

interface CustomOrganizationProfileProps {
// Hacky workaround to embed organization profile in user profile page
export const CustomOrganizationProfile = ({
appearance,
firstItem,
}: {
appearance: OrganizationProfileTheme;
firstItem: 'general' | 'members';
}
}) => {
const { organization } = useOrganization();

// Hacky workaround to embed organization profile in user profile page
export const CustomOrganizationProfile: FC<CustomOrganizationProfileProps> = ({ firstItem }) => {
if (firstItem === 'general') {
return (
<OrganizationProfile appearance={OrganizationProfileAppearance}>
<OrganizationProfile
appearance={appearance}
// @ts-ignore
__unstable_manageBillingUrl={ROUTES.MANAGE_ACCOUNT_BILLING}
__unstable_manageBillingMembersLimit={organization?.maxAllowedMemberships}
>
<OrganizationProfile.Page label="general" />
<OrganizationProfile.Page label="members" />
</OrganizationProfile>
);
}

return (
<OrganizationProfile appearance={OrganizationProfileAppearance}>
<OrganizationProfile
appearance={appearance}
// @ts-ignore
__unstable_manageBillingUrl={ROUTES.MANAGE_ACCOUNT_BILLING}
__unstable_manageBillingMembersLimit={organization?.maxAllowedMemberships}
>
<OrganizationProfile.Page label="members" />
<OrganizationProfile.Page label="general" />
</OrganizationProfile>
Expand Down
13 changes: 4 additions & 9 deletions apps/web/src/ee/clerk/pages/ManageAccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import {
} from '@novu/novui/icons';
import { FeatureFlagsKeysEnum } from '@novu/shared';
import { useNavigate, useParams } from 'react-router-dom';
import { Title } from '@novu/novui';
import { MANAGE_ACCOUNT_ROUTE_SEGMENTS, ROUTES } from '../../../constants/routes';
import { useFeatureFlag } from '../../../hooks/useFeatureFlag';
import { BrandingPage } from '../../../pages/brand/BrandingPage';
import { BillingPage } from '../../billing/pages/BillingPage';
import { Title } from '@novu/novui';
import {
billingTitle,
clerkComponentAppearance,
Expand All @@ -24,6 +24,7 @@ import {
tabsStyles,
titleTab,
} from './ManageAccountPage.styles';
import { CustomOrganizationProfile } from '../components/CustomOrganizationProfile';

export default function ManageAccountPage() {
const navigate = useNavigate();
Expand Down Expand Up @@ -108,16 +109,10 @@ export default function ManageAccountPage() {
</UserProfile>
</Tabs.Panel>
<Tabs.Panel value={MANAGE_ACCOUNT_ROUTE_SEGMENTS.ORGANIZATION}>
<OrganizationProfile appearance={clerkComponentAppearance}>
<OrganizationProfile.Page label="general" />
<OrganizationProfile.Page label="members" />
</OrganizationProfile>
<CustomOrganizationProfile appearance={clerkComponentAppearance} firstItem="general" />
</Tabs.Panel>
<Tabs.Panel value={MANAGE_ACCOUNT_ROUTE_SEGMENTS.TEAM_MEMBERS}>
<OrganizationProfile appearance={clerkComponentAppearance}>
<OrganizationProfile.Page label="members" />
<OrganizationProfile.Page label="general" />
</OrganizationProfile>
<CustomOrganizationProfile appearance={clerkComponentAppearance} firstItem="members" />
</Tabs.Panel>
{!isV2Enabled && (
<Tabs.Panel value={MANAGE_ACCOUNT_ROUTE_SEGMENTS.BRANDING}>
Expand Down

0 comments on commit 390c1d7

Please sign in to comment.