Skip to content

Commit 8e41cef

Browse files
committed
1 parent 2d34a18 commit 8e41cef

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/lib/utils.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,13 @@ import { twMerge } from "tailwind-merge"
44
export function cn(...inputs: ClassValue[]) {
55
return twMerge(clsx(inputs))
66
}
7+
8+
export const getInitials = (name: string | undefined): string => {
9+
if (!name) return ""
10+
return name
11+
.split(" ")
12+
.filter(Boolean)
13+
.slice(0, 2)
14+
.map((word) => word[0].toUpperCase())
15+
.join("")
16+
}

src/pages/quotes/QuotePage.tsx

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,13 @@ import {
1313
adminUpdateQuoteMutation,
1414
} from "@/generated/client/@tanstack/react-query.gen"
1515
import { activateKeyset } from "@/generated/client/sdk.gen"
16-
import { cn } from "@/lib/utils"
16+
import { cn, getInitials } from "@/lib/utils"
1717
import { formatDate, humanReadableDuration } from "@/utils/dates"
1818

1919
import { formatNumber, truncateString } from "@/utils/strings"
2020
import { useMutation, useQueryClient, useSuspenseQuery } from "@tanstack/react-query"
2121
import { getDeterministicColor } from "@/utils/dev"
2222

23-
// Utility functions for deterministic avatars
24-
function getInitials(name?: string): string {
25-
if (!name) return "?"
26-
const words = name.trim().split(/\s+/)
27-
if (words.length === 1) {
28-
return words[0].substring(0, 2).toUpperCase()
29-
}
30-
return (words[0][0] + words[words.length - 1][0]).toUpperCase()
31-
}
32-
3323
import { LoaderIcon } from "lucide-react"
3424
import { Suspense, useMemo, useState } from "react"
3525
import { Link, useParams } from "react-router"
@@ -464,7 +454,7 @@ export function ParticipantsOverviewCard({
464454
}
465455

466456
function AnonPublicAvatar({ value, tooltip }: { value?: AnonPublicData; tooltip?: React.ReactNode }) {
467-
const initials = "?" // getInitials(value?.node_id?.slice(-8)) // Use last 8 chars of node_id
457+
const initials = "?"
468458
const backgroundColor = getDeterministicColor(value?.node_id)
469459

470460
const avatar = (

0 commit comments

Comments
 (0)