Add account selection functionality to mobile navigation
Added a new type, 'Accounts', and used it to enable account selection from the mobile navigation menu. The 'Accounts' type incorporates the label, value, and image of a given account. This change will improve the app's usability, making it easier for users to navigate different accounts directly from their mobile devices. For custom plans, a null check has been implemented to avoid rendering null values.
This commit is contained in:
@@ -27,6 +27,12 @@ import featureFlagsConfig from '~/config/feature-flags.config';
|
|||||||
import pathsConfig from '~/config/paths.config';
|
import pathsConfig from '~/config/paths.config';
|
||||||
import { getTeamAccountSidebarConfig } from '~/config/team-account-navigation.config';
|
import { getTeamAccountSidebarConfig } from '~/config/team-account-navigation.config';
|
||||||
|
|
||||||
|
type Accounts = Array<{
|
||||||
|
label: string | null;
|
||||||
|
value: string | null;
|
||||||
|
image: string | null;
|
||||||
|
}>;
|
||||||
|
|
||||||
const features = {
|
const features = {
|
||||||
enableTeamAccounts: featureFlagsConfig.enableTeamAccounts,
|
enableTeamAccounts: featureFlagsConfig.enableTeamAccounts,
|
||||||
enableTeamCreation: featureFlagsConfig.enableTeamCreation,
|
enableTeamCreation: featureFlagsConfig.enableTeamCreation,
|
||||||
@@ -35,6 +41,7 @@ const features = {
|
|||||||
export const TeamAccountLayoutMobileNavigation = (
|
export const TeamAccountLayoutMobileNavigation = (
|
||||||
props: React.PropsWithChildren<{
|
props: React.PropsWithChildren<{
|
||||||
account: string;
|
account: string;
|
||||||
|
accounts: Accounts;
|
||||||
}>,
|
}>,
|
||||||
) => {
|
) => {
|
||||||
const signOut = useSignOut();
|
const signOut = useSignOut();
|
||||||
@@ -76,7 +83,7 @@ export const TeamAccountLayoutMobileNavigation = (
|
|||||||
</DropdownMenuTrigger>
|
</DropdownMenuTrigger>
|
||||||
|
|
||||||
<DropdownMenuContent sideOffset={10} className={'w-screen rounded-none'}>
|
<DropdownMenuContent sideOffset={10} className={'w-screen rounded-none'}>
|
||||||
<TeamAccountsModal />
|
<TeamAccountsModal accounts={props.accounts} />
|
||||||
|
|
||||||
{Links}
|
{Links}
|
||||||
|
|
||||||
@@ -130,7 +137,7 @@ function SignOutDropdownItem(
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function TeamAccountsModal() {
|
function TeamAccountsModal(props: { accounts: Accounts }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -157,6 +164,7 @@ function TeamAccountsModal() {
|
|||||||
|
|
||||||
<div className={'py-16'}>
|
<div className={'py-16'}>
|
||||||
<AccountSelector
|
<AccountSelector
|
||||||
|
className={'w-full max-w-full'}
|
||||||
onAccountChange={(value) => {
|
onAccountChange={(value) => {
|
||||||
const path = value
|
const path = value
|
||||||
? pathsConfig.app.accountHome.replace('[account]', value)
|
? pathsConfig.app.accountHome.replace('[account]', value)
|
||||||
@@ -164,7 +172,7 @@ function TeamAccountsModal() {
|
|||||||
|
|
||||||
router.replace(path);
|
router.replace(path);
|
||||||
}}
|
}}
|
||||||
accounts={[]}
|
accounts={props.accounts}
|
||||||
features={features}
|
features={features}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -61,7 +61,10 @@ function TeamWorkspaceLayout({
|
|||||||
<AppLogo />
|
<AppLogo />
|
||||||
|
|
||||||
<div className={'flex space-x-4'}>
|
<div className={'flex space-x-4'}>
|
||||||
<TeamAccountLayoutMobileNavigation account={params.account} />
|
<TeamAccountLayoutMobileNavigation
|
||||||
|
accounts={accounts}
|
||||||
|
account={params.account}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</PageMobileNavigation>
|
</PageMobileNavigation>
|
||||||
|
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ export function PlanPicker(
|
|||||||
return item.interval === selectedInterval;
|
return item.interval === selectedInterval;
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!plan) {
|
if (!plan || plan.custom) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ interface AccountSelectorProps {
|
|||||||
|
|
||||||
selectedAccount?: string;
|
selectedAccount?: string;
|
||||||
collapsed?: boolean;
|
collapsed?: boolean;
|
||||||
|
className?: string;
|
||||||
|
|
||||||
onAccountChange: (value: string | undefined) => void;
|
onAccountChange: (value: string | undefined) => void;
|
||||||
}
|
}
|
||||||
@@ -48,6 +49,7 @@ export function AccountSelector({
|
|||||||
accounts,
|
accounts,
|
||||||
selectedAccount,
|
selectedAccount,
|
||||||
onAccountChange,
|
onAccountChange,
|
||||||
|
className,
|
||||||
features = {
|
features = {
|
||||||
enableTeamCreation: true,
|
enableTeamCreation: true,
|
||||||
},
|
},
|
||||||
@@ -104,6 +106,7 @@ export function AccountSelector({
|
|||||||
'justify-start': !collapsed,
|
'justify-start': !collapsed,
|
||||||
'justify-center': collapsed,
|
'justify-center': collapsed,
|
||||||
},
|
},
|
||||||
|
className,
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<If
|
<If
|
||||||
|
|||||||
Reference in New Issue
Block a user