Skip to content

Commit 9165f7d

Browse files
committed
feat(ui): add composed UserProfile panels and section components
1 parent 669a561 commit 9165f7d

21 files changed

Lines changed: 725 additions & 0 deletions
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use client';
2+
3+
import { lazy, type ReactNode } from 'react';
4+
5+
import { APIKeysSection } from '../APIKeysSection';
6+
7+
const APIKeysPage = lazy(() =>
8+
import('../../components/UserProfile/APIKeysPage').then(m => ({
9+
default: m.APIKeysPage,
10+
})),
11+
);
12+
13+
export const UserProfileAPIKeysPanel = (): ReactNode => <APIKeysSection page={APIKeysPage} />;
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use client';
2+
3+
import type { PropsWithChildren, ReactNode } from 'react';
4+
5+
import { CardStateProvider, useCardState } from '@/ui/elements/contexts';
6+
import { ProfileCard } from '@/ui/elements/ProfileCard';
7+
8+
import { AccountPage } from '../../components/UserProfile/AccountPage';
9+
import { localizationKeys } from '../../customizables';
10+
import { PageContext } from '../PageContext';
11+
12+
function AccountComposed({ children }: PropsWithChildren): ReactNode {
13+
const card = useCardState();
14+
return (
15+
<ProfileCard.Page>
16+
<ProfileCard.PagePanel
17+
pageId='account'
18+
titleKey={localizationKeys('userProfile.start.headerTitle__account')}
19+
alertContent={card.error}
20+
outerSx={t => ({ gap: t.space.$8, color: t.colors.$colorForeground, isolation: 'isolate' })}
21+
>
22+
{children}
23+
</ProfileCard.PagePanel>
24+
</ProfileCard.Page>
25+
);
26+
}
27+
28+
export function UserProfileAccountPanel({ children }: PropsWithChildren): ReactNode {
29+
if (!children) {
30+
return <AccountPage />;
31+
}
32+
33+
return (
34+
<PageContext.Provider value='account'>
35+
<CardStateProvider>
36+
<AccountComposed>{children}</AccountComposed>
37+
</CardStateProvider>
38+
</PageContext.Provider>
39+
);
40+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { AccountConnectedAccounts as Section } from '../../components/UserProfile/AccountSections';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfileConnectedAccountsSection = createSection('UserProfileConnectedAccountsSection', Section);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { AccountEmails as Section } from '../../components/UserProfile/AccountSections';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfileEmailSection = createSection('UserProfileEmailSection', Section);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { AccountEnterpriseAccounts as Section } from '../../components/UserProfile/AccountSections';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfileEnterpriseAccountsSection = createSection('UserProfileEnterpriseAccountsSection', Section);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { AccountPhone as Section } from '../../components/UserProfile/AccountSections';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfilePhoneSection = createSection('UserProfilePhoneSection', Section);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { UserProfileSection } from '../../components/UserProfile/UserProfileSection';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfileProfileSection = createSection('UserProfileProfileSection', UserProfileSection);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { AccountUsername as Section } from '../../components/UserProfile/AccountSections';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfileUsernameSection = createSection('UserProfileUsernameSection', Section);
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
'use client';
2+
3+
import { AccountWeb3 as Section } from '../../components/UserProfile/AccountSections';
4+
import { createSection } from '../createSection';
5+
6+
export const UserProfileWeb3Section = createSection('UserProfileWeb3Section', Section);
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
'use client';
2+
3+
import { lazy, type ReactNode } from 'react';
4+
5+
import { BillingSection } from '../BillingSection';
6+
7+
const BillingPage = lazy(() =>
8+
import('../../components/UserProfile/BillingPage').then(m => ({
9+
default: m.BillingPage,
10+
})),
11+
);
12+
13+
const PlansPage = lazy(() =>
14+
import('../../components/UserProfile/PlansPage').then(m => ({
15+
default: m.PlansPage,
16+
})),
17+
);
18+
19+
const StatementPage = lazy(() =>
20+
import('../../components/Statements').then(m => ({
21+
default: m.StatementPage,
22+
})),
23+
);
24+
25+
const PaymentAttemptPage = lazy(() =>
26+
import('../../components/PaymentAttempts').then(m => ({
27+
default: m.PaymentAttemptPage,
28+
})),
29+
);
30+
31+
export const UserProfileBillingPanel = (): ReactNode => (
32+
<BillingSection
33+
billing={BillingPage}
34+
plans={PlansPage}
35+
statement={StatementPage}
36+
paymentAttempt={PaymentAttemptPage}
37+
/>
38+
);

0 commit comments

Comments
 (0)