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.
This commit is contained in:
giancarlo
2024-04-15 17:46:11 +08:00
parent 81e662e63d
commit 8627cdaf1f
13 changed files with 78 additions and 74 deletions

View File

@@ -8,7 +8,6 @@ import featureFlagsConfig from '~/config/feature-flags.config';
import pathsConfig from '~/config/paths.config';
const features = {
enableTeamAccounts: featureFlagsConfig.enableTeamAccounts,
enableTeamCreation: featureFlagsConfig.enableTeamCreation,
};

View File

@@ -2,8 +2,11 @@ import { use } from 'react';
import { cookies } from 'next/headers';
import { If } from '@kit/ui/if';
import { Sidebar, SidebarContent, SidebarNavigation } from '@kit/ui/sidebar';
import { AppLogo } from '~/components/app-logo';
import featuresFlagConfig from '~/config/feature-flags.config';
import { personalAccountSidebarConfig } from '~/config/personal-account-sidebar.config';
// home imports
@@ -18,7 +21,15 @@ export function HomeSidebar() {
return (
<Sidebar collapsed={collapsed}>
<SidebarContent className={'my-4'}>
<HomeSidebarAccountSelector collapsed={collapsed} accounts={accounts} />
<If
condition={featuresFlagConfig.enableTeamAccounts}
fallback={<AppLogo className={'py-2'} />}
>
<HomeSidebarAccountSelector
collapsed={collapsed}
accounts={accounts}
/>
</If>
</SidebarContent>
<SidebarContent className={`h-[calc(100%-160px)] overflow-y-auto`}>

View File

@@ -2,12 +2,14 @@ import { cache } from 'react';
import { getSupabaseServerComponentClient } from '@kit/supabase/server-component-client';
import featureFlagsConfig from '~/config/feature-flags.config';
import { Database } from '~/lib/database.types';
export const loadUserWorkspace = cache(async () => {
const client = getSupabaseServerComponentClient();
const loadAccounts = featureFlagsConfig.enableTeamAccounts;
const accounts = await loadUserAccounts(client);
const accounts = loadAccounts ? await loadUserAccounts(client) : [];
const { data } = await client.auth.getSession();
return {

View File

@@ -60,7 +60,7 @@
"i18next": "^23.11.1",
"i18next-resources-to-backend": "^1.2.1",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"next-sitemap": "^4.2.3",
"next-themes": "0.3.0",
"react": "18.2.0",

View File

@@ -46,7 +46,7 @@
"@types/react": "^18.2.77",
"date-fns": "^3.6.0",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react": "18.2.0",
"react-hook-form": "^7.51.3",
"react-i18next": "^14.1.0",

View File

@@ -36,7 +36,7 @@
"@types/react": "^18.2.77",
"@types/react-dom": "^18.2.25",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"next-themes": "0.3.0",
"react": "18.2.0",
"react-dom": "18.2.0",

View File

@@ -33,7 +33,6 @@ interface AccountSelectorProps {
}>;
features: {
enableTeamAccounts: boolean;
enableTeamCreation: boolean;
};
@@ -50,7 +49,6 @@ export function AccountSelector({
selectedAccount,
onAccountChange,
features = {
enableTeamAccounts: true,
enableTeamCreation: true,
},
collapsed = false,
@@ -80,10 +78,6 @@ export function AccountSelector({
);
};
if (!features.enableTeamAccounts) {
return null;
}
const selected = accounts.find((account) => account.value === value);
const pictureUrl = personalData.data?.picture_url;
@@ -176,7 +170,6 @@ export function AccountSelector({
<CommandSeparator />
<If condition={features.enableTeamAccounts}>
<If condition={accounts.length > 0}>
<CommandGroup
heading={
@@ -236,7 +229,6 @@ export function AccountSelector({
))}
</CommandGroup>
</If>
</If>
</CommandList>
</Command>

View File

@@ -40,7 +40,7 @@
"@tanstack/react-table": "^8.16.0",
"@types/react": "^18.2.77",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react": "18.2.0",
"react-hook-form": "^7.51.3",
"zod": "^3.22.4"

View File

@@ -32,7 +32,7 @@
"@tanstack/react-query": "5.29.0",
"@types/react": "^18.2.77",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react-hook-form": "^7.51.3",
"react-i18next": "^14.1.0",
"sonner": "^1.4.41",

View File

@@ -37,7 +37,7 @@
"class-variance-authority": "^0.7.0",
"date-fns": "^3.6.0",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.51.3",

View File

@@ -28,7 +28,7 @@
"@kit/tailwind-config": "workspace:*",
"@kit/tsconfig": "workspace:*",
"@supabase/supabase-js": "^2.42.3",
"next": "14.2.0",
"next": "14.2.1",
"zod": "^3.22.4"
},
"eslintConfig": {

View File

@@ -32,7 +32,7 @@
"@supabase/supabase-js": "^2.42.3",
"@tanstack/react-query": "5.29.0",
"@types/react": "^18.2.77",
"next": "14.2.0",
"next": "14.2.1",
"react": "18.2.0",
"zod": "^3.22.4"
},

View File

@@ -59,7 +59,7 @@
"date-fns": "^3.6.0",
"eslint": "^8.57.0",
"lucide-react": "^0.367.0",
"next": "14.2.0",
"next": "14.2.1",
"next-themes": "0.3.0",
"prettier": "^3.2.5",
"react-day-picker": "^8.10.0",