feat: frontend draft
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
import type { ContactDTO, MessageIdDTO, SerializedId } from "@shared/dto";
|
||||
|
||||
export { cn } from "cn";
|
||||
|
||||
export function getId(id?: string | SerializedId | MessageIdDTO | null) {
|
||||
if (!id) return "";
|
||||
return typeof id === "string" ? id : (id._serialized ?? "");
|
||||
}
|
||||
|
||||
export function getInitial(name?: string | null) {
|
||||
return (
|
||||
name
|
||||
?.split(" ")
|
||||
.map((i) => i[0])
|
||||
.slice(0, 2)
|
||||
.join("") || ""
|
||||
);
|
||||
}
|
||||
|
||||
export function getFormattedName(
|
||||
name: string | SerializedId | ContactDTO | null | undefined,
|
||||
): string {
|
||||
if (!name) return "";
|
||||
return typeof name === "string"
|
||||
? name
|
||||
: typeof name.formattedName === "string"
|
||||
? name.formattedName
|
||||
: "user" in name
|
||||
? name.user || ""
|
||||
: "";
|
||||
}
|
||||
Reference in New Issue
Block a user