);
}
export function CheckAvailBadge({ status, value }: { status: AvailStatus; value?: string }) {
if (!value || status === "idle")
return 입력 후 자동 확인;
if (status === "checking")
return (
중복 확인 중…
);
if (status === "available")
return (
사용 가능
);
if (status === "taken")
return (
이미 사용 중
);
if (status === "reserved")
return (
예약어 (사용 불가)
);
return (
형식 오류
);
}
/** TextInput 의 status prop 과 매핑 */
export function availToInputStatus(a: AvailStatus): TextInputStatus | undefined {
if (a === "available") return "ok";
if (a === "taken" || a === "reserved" || a === "invalid") return "err";
return undefined;
}
export function genPassword(length = 12): string {
const chars = "ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz23456789@#$";
const arr = new Uint32Array(length);
if (typeof window !== "undefined" && window.crypto) {
window.crypto.getRandomValues(arr);
}
let out = "";
for (let i = 0; i < length; i++) {
out += chars[arr[i] % chars.length];
}
return out;
}