# app/modules/loyalty/schemas/category.py
"""Pydantic schemas for transaction categories."""

from datetime import datetime

from pydantic import BaseModel, ConfigDict, Field


class CategoryCreate(BaseModel):
    """Schema for creating a transaction category."""

    name: str = Field(..., min_length=1, max_length=100)
    name_translations: dict[str, str] | None = Field(
        None,
        description='Translations keyed by language: {"en": "Men", "fr": "Hommes"}',
    )
    display_order: int = Field(default=0, ge=0)


class CategoryUpdate(BaseModel):
    """Schema for updating a transaction category."""

    name: str | None = Field(None, min_length=1, max_length=100)
    name_translations: dict[str, str] | None = None
    display_order: int | None = Field(None, ge=0)
    is_active: bool | None = None


class CategoryResponse(BaseModel):
    """Schema for transaction category response."""

    model_config = ConfigDict(from_attributes=True)

    id: int
    store_id: int
    name: str
    name_translations: dict[str, str] | None = None
    display_order: int
    is_active: bool
    created_at: datetime
    updated_at: datetime


class CategoryListResponse(BaseModel):
    """Schema for listing categories."""

    categories: list[CategoryResponse]
    total: int
