From 8627cdaf1ff147cc8a920e8aa175e8327bb1f584 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Mon, 15 Apr 2024 17:46:11 +0800 Subject: [PATCH] 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. --- .../home-sidebar-account-selector.tsx | 1 - .../home/_components/home-sidebar.tsx | 13 +- .../home/_lib/load-user-workspace.ts | 4 +- apps/web/package.json | 2 +- packages/billing/gateway/package.json | 2 +- packages/features/accounts/package.json | 2 +- .../src/components/account-selector.tsx | 116 ++++++++---------- packages/features/admin/package.json | 2 +- packages/features/auth/package.json | 2 +- packages/features/team-accounts/package.json | 2 +- packages/next/package.json | 2 +- packages/supabase/package.json | 2 +- packages/ui/package.json | 2 +- 13 files changed, 78 insertions(+), 74 deletions(-) diff --git a/apps/web/app/(dashboard)/home/_components/home-sidebar-account-selector.tsx b/apps/web/app/(dashboard)/home/_components/home-sidebar-account-selector.tsx index 18516bb0b..79fb71eaa 100644 --- a/apps/web/app/(dashboard)/home/_components/home-sidebar-account-selector.tsx +++ b/apps/web/app/(dashboard)/home/_components/home-sidebar-account-selector.tsx @@ -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, }; diff --git a/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx b/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx index 9e26a796f..79cc6536a 100644 --- a/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx +++ b/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx @@ -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 ( - + } + > + + diff --git a/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts b/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts index 512730295..d80924b9b 100644 --- a/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts +++ b/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts @@ -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 { diff --git a/apps/web/package.json b/apps/web/package.json index b0f455e96..5cff5b8fe 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -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", diff --git a/packages/billing/gateway/package.json b/packages/billing/gateway/package.json index fc3225d52..32ac92604 100644 --- a/packages/billing/gateway/package.json +++ b/packages/billing/gateway/package.json @@ -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", diff --git a/packages/features/accounts/package.json b/packages/features/accounts/package.json index f79eb62fa..03fdd10fd 100644 --- a/packages/features/accounts/package.json +++ b/packages/features/accounts/package.json @@ -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", diff --git a/packages/features/accounts/src/components/account-selector.tsx b/packages/features/accounts/src/components/account-selector.tsx index e7f97e08e..2e6b764e0 100644 --- a/packages/features/accounts/src/components/account-selector.tsx +++ b/packages/features/accounts/src/components/account-selector.tsx @@ -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,66 +170,64 @@ export function AccountSelector({ - - 0}> - - } - > - {(accounts ?? []).map((account) => ( - { - setValue(currentValue === value ? '' : currentValue); - setOpen(false); + 0}> + + } + > + {(accounts ?? []).map((account) => ( + { + setValue(currentValue === value ? '' : currentValue); + setOpen(false); - if (onAccountChange) { - onAccountChange(currentValue); - } - }} - > -
- - + if (onAccountChange) { + onAccountChange(currentValue); + } + }} + > +
+ + - - {account.label ? account.label[0] : ''} - - + + {account.label ? account.label[0] : ''} + + - - {account.label} - -
+ + {account.label} + +
- -
- ))} -
-
+ +
+ ))} +
diff --git a/packages/features/admin/package.json b/packages/features/admin/package.json index 239ab7f38..69888adf7 100644 --- a/packages/features/admin/package.json +++ b/packages/features/admin/package.json @@ -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" diff --git a/packages/features/auth/package.json b/packages/features/auth/package.json index 1826ad867..8327a7648 100644 --- a/packages/features/auth/package.json +++ b/packages/features/auth/package.json @@ -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", diff --git a/packages/features/team-accounts/package.json b/packages/features/team-accounts/package.json index c8118b0ca..a64a6034f 100644 --- a/packages/features/team-accounts/package.json +++ b/packages/features/team-accounts/package.json @@ -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", diff --git a/packages/next/package.json b/packages/next/package.json index a4855b48e..423cffba2 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -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": { diff --git a/packages/supabase/package.json b/packages/supabase/package.json index ddfcbfbf6..a2c241d11 100644 --- a/packages/supabase/package.json +++ b/packages/supabase/package.json @@ -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" }, diff --git a/packages/ui/package.json b/packages/ui/package.json index 482dc4a27..66a1d5a70 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -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",