From cb4af81cf385eb8e47bf29afbf8887e5f751bd72 Mon Sep 17 00:00:00 2001 From: javayhu Date: Wed, 19 Mar 2025 09:46:13 +0800 Subject: [PATCH] refactor: streamline user avatar handling across components - Updated the `UserAvatar` component to require a non-optional `image` prop, enhancing type safety. - Simplified the usage of `UserAvatar` in `SidebarUser` and `UserButton` components by removing unnecessary nullish coalescing. - Improved code clarity and consistency in user-related components by ensuring direct access to user properties. --- src/components/dashboard/sidebar-user.tsx | 8 ++++---- src/components/layout/user-button.tsx | 22 ++++++++++------------ src/components/shared/user-avatar.tsx | 4 ++-- src/newsletter/index.ts | 12 ++++++------ 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/src/components/dashboard/sidebar-user.tsx b/src/components/dashboard/sidebar-user.tsx index aaae019..c392530 100644 --- a/src/components/dashboard/sidebar-user.tsx +++ b/src/components/dashboard/sidebar-user.tsx @@ -93,8 +93,8 @@ export function SidebarUser() { data-[state=open]:text-sidebar-accent-foreground" > @@ -118,8 +118,8 @@ export function SidebarUser() {
diff --git a/src/components/layout/user-button.tsx b/src/components/layout/user-button.tsx index d24d512..fe74211 100644 --- a/src/components/layout/user-button.tsx +++ b/src/components/layout/user-button.tsx @@ -62,8 +62,8 @@ export function UserButton({ user }: UserButtonProps) { setOpen(true)}> @@ -78,19 +78,17 @@ export function UserButton({ user }: UserButtonProps) {
- {user?.name &&

+

{user.name} -

} - {user?.email && ( -

- {user?.email} -

- )} +

+

+ {user.email} +

@@ -142,7 +140,7 @@ export function UserButton({ user }: UserButtonProps) { diff --git a/src/components/shared/user-avatar.tsx b/src/components/shared/user-avatar.tsx index 7ef2772..c8fd746 100644 --- a/src/components/shared/user-avatar.tsx +++ b/src/components/shared/user-avatar.tsx @@ -4,7 +4,7 @@ import { User2Icon } from 'lucide-react'; interface UserAvatarProps extends AvatarProps { name: string; - image?: string; + image: string | null | undefined; } /** @@ -21,7 +21,7 @@ export function UserAvatar({ name, image, ...props }: UserAvatarProps) { {name} diff --git a/src/newsletter/index.ts b/src/newsletter/index.ts index 42ba0d6..f00fdb2 100644 --- a/src/newsletter/index.ts +++ b/src/newsletter/index.ts @@ -1,19 +1,19 @@ import { ResendNewsletterProvider } from './provider/resend'; import { - CheckSubscribeStatusProps, NewsletterConfig, NewsletterProvider, - SubscribeNewsletterP, - UnsubscribeNewsletterProps + SubscribeNewsletterParams, + UnsubscribeNewsletterParams, + CheckSubscribeStatusParams } from './types'; // Re-export types for convenience export type { NewsletterProvider, NewsletterConfig, - SubscribeNewsletterP as SubscribeNewsletterProps, - UnsubscribeNewsletterProps, - CheckSubscribeStatusProps + SubscribeNewsletterParams, + UnsubscribeNewsletterParams, + CheckSubscribeStatusParams }; // Export provider implementation