import { z } from "zod";
import { isoDateString, nullableIntIdFromForm } from "./common";

export const CreateProjectSchema = z.object({
  name: z.string().min(1, "Zadejte název projektu"),
  customer_id: nullableIntIdFromForm.optional(),
  responsible_user_id: nullableIntIdFromForm.optional(),
  status: z.string().optional().default("aktivni"),
  start_date: isoDateString.nullish(),
  end_date: isoDateString.nullish(),
  notes: z.string().nullish(),
});

export const UpdateProjectSchema = z.object({
  name: z.string().nullish(),
  status: z.string().optional(),
  notes: z.string().nullish(),
  customer_id: nullableIntIdFromForm.optional(),
  responsible_user_id: nullableIntIdFromForm.optional(),
  quotation_id: nullableIntIdFromForm.optional(),
  order_id: nullableIntIdFromForm.optional(),
  start_date: isoDateString.nullish(),
  end_date: isoDateString.nullish(),
});

export const CreateProjectNoteSchema = z.object({
  content: z.string().nullish(),
});

export type CreateProjectInput = z.infer<typeof CreateProjectSchema>;
export type UpdateProjectInput = z.infer<typeof UpdateProjectSchema>;
export type CreateProjectNoteInput = z.infer<typeof CreateProjectNoteSchema>;
