Files
myeasycms-v2/apps/web/app/home/[account]/_components/team-account-accounts-selector.tsx
2024-04-30 22:16:38 +07:00

40 lines
928 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;
accounts: Array<{
label: string | null;
value: string | null;
image: string | null;
}>;
}) {
const router = useRouter();
return (
<AccountSelector
selectedAccount={params.selectedAccount}
accounts={params.accounts}
collapsed={false}
features={features}
onAccountChange={(value) => {
const path = value
? pathsConfig.app.accountHome.replace('[account]', value)
: pathsConfig.app.home;
router.replace(path);
}}
/>
);
}