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