2035f73e7d
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
28 lines
754 B
TypeScript
28 lines
754 B
TypeScript
import { visibleEmail } from "@/shared/account-email";
|
||
import type { AdminUser } from "./types";
|
||
|
||
type RawAdminUser = {
|
||
id: string;
|
||
name: string;
|
||
email: string;
|
||
username?: string | null;
|
||
role?: string | null;
|
||
banned?: boolean | null;
|
||
banReason?: string | null;
|
||
createdAt: Date | string;
|
||
};
|
||
|
||
/** Better Auth kullanıcı kaydını arayüz satırına çevirir (yer tutucu e-posta gizlenir). */
|
||
export function toAdminUser(u: RawAdminUser): AdminUser {
|
||
return {
|
||
id: u.id,
|
||
name: u.name,
|
||
username: u.username ?? "",
|
||
email: visibleEmail(u.email),
|
||
role: u.role === "admin" ? "admin" : "user",
|
||
banned: Boolean(u.banned),
|
||
banReason: u.banReason ?? undefined,
|
||
createdAt: new Date(u.createdAt).toISOString(),
|
||
};
|
||
}
|