import { z } from 'zod/v4';

export const CreateUserSchema = z.object({
  keycloakId: z.string().min(1),
  displayName: z.string().min(1).max(100).trim(),
  email: z.email(),
  householdIds: z.array(z.string()).default([]),
  defaultHouseholdId: z.string().optional(),
});

export const UpdateUserSchema = CreateUserSchema.partial().omit({ keycloakId: true });

export const UserResponseSchema = z.object({
  _id: z.string(),
  keycloakId: z.string(),
  displayName: z.string(),
  email: z.string(),
  householdIds: z.array(z.string()),
  defaultHouseholdId: z.string().nullable(),
  createdAt: z.string(),
  updatedAt: z.string(),
});

export type CreateUserInput = z.infer<typeof CreateUserSchema>;
export type UpdateUserInput = z.infer<typeof UpdateUserSchema>;
export type UserResponse = z.infer<typeof UserResponseSchema>;
