import { z } from 'zod'

export const loginSchema = z.object({
  email: z.string().email('Ungültige E-Mail-Adresse'),
  password: z.string().min(1, 'Passwort erforderlich'),
})

export const PROJECT_MODES = ['EINSATZ', 'UEBUNG'] as const
export type ProjectMode = (typeof PROJECT_MODES)[number]

export const projectSchema = z.object({
  title: z.string().min(1, 'Titel erforderlich').max(200, 'Titel zu lang'),
  mode: z.enum(PROJECT_MODES).optional(),
  exerciseEvaluation: z.string().max(10000).optional(),
  location: z.string().optional(),
  description: z.string().optional(),
  einsatzleiter: z.string().optional(),
  journalfuehrer: z.string().optional(),
  mapCenter: z.object({
    lng: z.number(),
    lat: z.number(),
  }).optional(),
  mapZoom: z.number().min(1).max(22).optional(),
})

export const featureSchema = z.object({
  type: z.string(),
  geometry: z.object({
    type: z.string(),
    coordinates: z.any(),
  }),
  properties: z.record(z.any()).optional(),
})

export const iconUploadSchema = z.object({
  name: z.string().min(1, 'Name erforderlich').max(100, 'Name zu lang'),
  categoryId: z.string().uuid('Ungültige Kategorie'),
})

export type LoginInput = z.infer<typeof loginSchema>
export type ProjectInput = z.infer<typeof projectSchema>
export type FeatureInput = z.infer<typeof featureSchema>
export type IconUploadInput = z.infer<typeof iconUploadSchema>
