fix: update getUserInitials to handle null/undefined inputs and return fallback character
This commit is contained in:
parent
edd8fe8089
commit
f480979020
@ -32,8 +32,10 @@ import { formatDate } from "@/utils/format-date";
|
||||
import { usePermissions } from "@/hooks/usePermissions";
|
||||
|
||||
// Helper function to get user initials
|
||||
const getUserInitials = (firstName: string, lastName: string): string => {
|
||||
return `${firstName[0] || ""}${lastName[0] || ""}`.toUpperCase();
|
||||
const getUserInitials = (firstName: string | null | undefined, lastName: string | null | undefined): string => {
|
||||
const first = (firstName || "").trim().slice(0, 1);
|
||||
const last = (lastName || "").trim().slice(0, 1);
|
||||
return `${first}${last}`.toUpperCase() || "?";
|
||||
};
|
||||
|
||||
// Helper function to get status badge variant
|
||||
|
||||
@ -30,8 +30,10 @@ import { useAppTheme } from "@/hooks/useAppTheme";
|
||||
import { usePermissions } from "@/hooks/usePermissions";
|
||||
|
||||
// Helper function to get user initials
|
||||
const getUserInitials = (firstName: string, lastName: string): string => {
|
||||
return `${firstName[0]}${lastName[0]}`.toUpperCase();
|
||||
const getUserInitials = (firstName: string | null | undefined, lastName: string | null | undefined): string => {
|
||||
const first = (firstName || "").trim().slice(0, 1);
|
||||
const last = (lastName || "").trim().slice(0, 1);
|
||||
return `${first}${last}`.toUpperCase() || "?";
|
||||
};
|
||||
|
||||
// Helper function to get status badge variant
|
||||
|
||||
Loading…
Reference in New Issue
Block a user