better-chatbot / src /app /api /admin /validations.ts
Bot
Initial commit for HF Spaces
05c5ed5
Raw
History Blame Contribute Delete
795 Bytes
import { z } from "zod";
import { USER_ROLES, UserRoleNames } from "app-types/roles";
import { ActionState } from "lib/action-utils";
import { BasicUserWithLastLogin } from "app-types/user";
export const UpdateUserRoleSchema = z.object({
userId: z.uuid("Invalid user ID"),
role: z
.enum(Object.values(USER_ROLES) as [UserRoleNames, ...UserRoleNames[]])
.optional(),
});
export const UpdateUserBanStatusSchema = z.object({
userId: z.uuid("Invalid user ID"),
banned: z.enum(["true", "false"]).transform((value) => value === "true"),
banReason: z.string().optional(),
});
export type UpdateUserRoleActionState = ActionState & {
user?: BasicUserWithLastLogin | null;
};
export type UpdateUserBanStatusActionState = ActionState & {
user?: BasicUserWithLastLogin | null;
};