This commit dates the transition from a global user session to individual account handling based on user ID. The transition was made across several components, notably the account settings, icons, and selector. This change improves performance by reducing unnecessary requests and ensures more accurate data handling. The commit also includes some cleanups and minor fixes spread across different components.
43 lines
976 B
TypeScript
43 lines
976 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;
|
|
}>;
|
|
}) {
|
|
const router = useRouter();
|
|
|
|
return (
|
|
<AccountSelector
|
|
selectedAccount={params.selectedAccount}
|
|
accounts={params.accounts}
|
|
userId={params.userId}
|
|
collapsed={false}
|
|
features={features}
|
|
onAccountChange={(value) => {
|
|
const path = value
|
|
? pathsConfig.app.accountHome.replace('[account]', value)
|
|
: pathsConfig.app.home;
|
|
|
|
router.replace(path);
|
|
}}
|
|
/>
|
|
);
|
|
}
|