Files
myeasycms-v2/apps/web/app/(dashboard)/home/_components/home-sidebar-account-selector.tsx
giancarlo 8627cdaf1f Update 'next' package version and refactor user account handling
This commit updates the 'next' package from version 14.2.0 to 14.2.1 across various modules. It also refactors the code for user account handling to make it controlled by an enableTeamAccounts flag in the featureFlagsConfig, essentially allowing the enabling or disabling of the 'team accounts' feature according to the specified flag.
2024-04-15 17:46:11 +08:00

39 lines
867 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 HomeSidebarAccountSelector(props: {
accounts: Array<{
label: string | null;
value: string | null;
image: string | null;
}>;
collapsed: boolean;
}) {
const router = useRouter();
return (
<AccountSelector
collapsed={props.collapsed}
accounts={props.accounts}
features={features}
onAccountChange={(value) => {
if (value) {
const path = pathsConfig.app.accountHome.replace('[account]', value);
router.replace(path);
}
}}
/>
);
}