import { z } from "zod";

export const TRIP_CATEGORIES = ["unterkunft", "essen", "transport", "aktivitaeten", "sonstiges"] as const;
export type TripCategory = (typeof TRIP_CATEGORIES)[number];

export const createTripSchema = z.object({
  name: z.string().min(1).max(100),
  destination: z.string().max(200).optional(),
  budget: z.number().positive(),
  startDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
  endDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
});

export const updateTripSchema = createTripSchema.partial();

export const createTripExpenseSchema = z.object({
  label: z.string().min(1).max(200),
  amount: z.number().positive(),
  category: z.enum(TRIP_CATEGORIES).default("sonstiges"),
  paidBy: z.string().min(1),
  date: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
  note: z.string().max(500).optional(),
});

export const updateTripExpenseSchema = createTripExpenseSchema.partial();

export type CreateTripInput = z.infer<typeof createTripSchema>;
export type UpdateTripInput = z.infer<typeof updateTripSchema>;
export type CreateTripExpenseInput = z.infer<typeof createTripExpenseSchema>;
export type UpdateTripExpenseInput = z.infer<typeof updateTripExpenseSchema>;
