"""Pydantic schemas for the years domain."""
from __future__ import annotations

from datetime import datetime

from pydantic import BaseModel


class YearOut(BaseModel):
    id: int
    year: int
    notes: str = ""
    featured_image_path: str = ""
    is_archived: bool = False
    created_at: datetime | None = None
    planting_count: int | None = None
    plant_count: int | None = None


class YearPlantingRef(BaseModel):
    """A planting within a year (year detail), with v1's per-planting
    group/plant counts."""

    id: int
    name: str
    source: str = ""
    status: str = "planted"
    is_archived: bool = False
    group_count: int
    plant_count: int


class YearDetail(YearOut):
    plantings: list[YearPlantingRef]


class YearCreate(BaseModel):
    year: int
    notes: str = ""


class YearPatch(BaseModel):
    year: int | None = None
    notes: str | None = None


class OkResult(BaseModel):
    ok: bool = True
