Add player bug reports and profile identity features

This commit is contained in:
2026-10-08 18:27:20 +05:00
parent 36e8d11eb4
commit 0b08672f4a
51 changed files with 3938 additions and 45 deletions

View File

@@ -0,0 +1,46 @@
import { z } from "zod";
export const defaultGlowColor = "#ffe6a1";
export const glowColorSchema = z
.string()
.regex(/^#[a-fA-F0-9]{6}$/, "Choose a valid glow color")
.transform((color) => color.toLowerCase());
export const prefixIcons = [
"star",
"crown",
"heart",
"flame",
"gem",
"trophy",
"sparkles",
] as const;
export type PrefixIcon = (typeof prefixIcons)[number];
export const customPrefixSchema = z
.string()
.trim()
.min(1)
.max(24)
.refine(
(value) =>
!/[\u0000-\u001f\u007f-\u009f\u202a-\u202e\u2066-\u2069<>]/u.test(value),
"Use a prefix of 1–24 characters without hidden controls or markup",
);
export const prefixUpdateSchema = z
.object({ prefix: customPrefixSchema.nullable(), icon: z.enum(prefixIcons) })
.strict();
export type ProfileAppearance = {
name_glow?: boolean;
glow_color?: string;
role?: string;
bug_finder?: boolean;
custom_prefix?: string | null;
custom_prefix_icon?: string;
};
export const appearanceColumns =
"name_glow,glow_color,role,bug_finder,custom_prefix,custom_prefix_icon" as const;
export type BadgeUser = ProfileAppearance & {
id: string;
display_name: string;
};
export function glowColor(value?: string) {
return glowColorSchema.safeParse(value).data ?? defaultGlowColor;
}