Files
myeasycms-v2/apps/web/app/home/[account]/_components/team-account-accounts-selector.tsx
Giancarlo Buomprisco b2c27eb25b Sidebar: make it possible to set the sidebar as collapsed (#72)
* Sidebar: make it possible to set the sidebar as collapsed
2024-10-14 17:31:18 +08:00

45 lines
1011 B
TypeScript

'use client';
import { useRouter } from 'next/navigation';
import { AccountSelector } from '@kit/accounts/account-selector';
import featureFlagsConfig from '~/config/feature-flags.config';
import pathsConfig from '~/config/paths.config';
const features = {
enableTeamCreation: featureFlagsConfig.enableTeamCreation,
};
export function TeamAccountAccountsSelector(params: {
selectedAccount: string;
userId: string;
accounts: Array<{
label: string | null;
value: string | null;
image: string | null;
}>;
collapsed?: boolean;
}) {
const router = useRouter();
return (
<AccountSelector
selectedAccount={params.selectedAccount}
accounts={params.accounts}
userId={params.userId}
collapsed={params.collapsed}
features={features}
onAccountChange={(value) => {
const path = value
? pathsConfig.app.accountHome.replace('[account]', value)
: pathsConfig.app.home;
router.replace(path);
}}
/>
);
}