From df239e99032117c71f86cd74fa31929371b298a6 Mon Sep 17 00:00:00 2001 From: giancarlo Date: Mon, 15 Apr 2024 19:07:59 +0800 Subject: [PATCH] Update user authentication and refactor UI components Refactored the user authentication method in the dashboard from getSession to getUser, and updated its related variables accordingly. UI components have also been modified, which includes streamlining the importation of the 'cn' function and exporting the 'Stepper' function directly. Lastly, the 'Stepper' function is now included in the package.json for the UI component package. --- apps/web/app/(dashboard)/home/_components/home-sidebar.tsx | 7 ++----- apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts | 4 ++-- packages/ui/package.json | 3 ++- packages/ui/src/makerkit/stepper.tsx | 6 ++---- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx b/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx index 79cc6536a..551e3a4c8 100644 --- a/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx +++ b/apps/web/app/(dashboard)/home/_components/home-sidebar.tsx @@ -16,7 +16,7 @@ import { loadUserWorkspace } from '../_lib/load-user-workspace'; export function HomeSidebar() { const collapsed = getSidebarCollapsed(); - const { accounts, session } = use(loadUserWorkspace()); + const { accounts, user } = use(loadUserWorkspace()); return ( @@ -38,10 +38,7 @@ export function HomeSidebar() {
- +
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 d80924b9b..f5fb2199e 100644 --- a/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts +++ b/apps/web/app/(dashboard)/home/_lib/load-user-workspace.ts @@ -10,11 +10,11 @@ export const loadUserWorkspace = cache(async () => { const loadAccounts = featureFlagsConfig.enableTeamAccounts; const accounts = loadAccounts ? await loadUserAccounts(client) : []; - const { data } = await client.auth.getSession(); + const { data } = await client.auth.getUser(); return { accounts, - session: data.session, + user: data.user, }; }); diff --git a/packages/ui/package.json b/packages/ui/package.json index 66a1d5a70..beb8d4b95 100644 --- a/packages/ui/package.json +++ b/packages/ui/package.json @@ -124,7 +124,8 @@ "./profile-avatar": "./src/makerkit/profile-avatar.tsx", "./mode-toggle": "./src/makerkit/mode-toggle.tsx", "./enhanced-data-table": "./src/makerkit/data-table.tsx", - "./language-selector": "./src/makerkit/language-selector.tsx" + "./language-selector": "./src/makerkit/language-selector.tsx", + "./stepper": "./src/makerkit/stepper.tsx" }, "typesVersions": { "*": { diff --git a/packages/ui/src/makerkit/stepper.tsx b/packages/ui/src/makerkit/stepper.tsx index 278e8101f..f94c233ca 100644 --- a/packages/ui/src/makerkit/stepper.tsx +++ b/packages/ui/src/makerkit/stepper.tsx @@ -4,7 +4,7 @@ import { Fragment, useCallback } from 'react'; import { cva } from 'class-variance-authority'; -import { cn } from '../utils/cn'; +import { cn } from '../utils'; import { If } from './if'; import { Trans } from './trans'; @@ -20,7 +20,7 @@ const classNameBuilder = getClassNameBuilder(); * - currentStep {number} - The index of the currently active step. * - variant {string} (optional) - The variant of the stepper component (default: 'default'). **/ -function Stepper(props: { +export function Stepper(props: { steps: string[]; currentStep: number; variant?: Variant; @@ -78,8 +78,6 @@ function Stepper(props: { ); } -export default Stepper; - function getClassNameBuilder() { return cva(``, { variants: {