"""
Demo Accounts API - Public demo account information (ATOMIC READ)
"""

from fastapi import APIRouter
from typing import List
import structlog

from app.api.schemas import DemoAccountInfo
from app.core import settings
from shared.routing import RouteBuilder

router = APIRouter(tags=["demo-accounts"])
logger = structlog.get_logger()

route_builder = RouteBuilder('demo')


@router.get(
    route_builder.build_base_route("accounts", include_tenant_prefix=False),
    response_model=List[DemoAccountInfo]
)
async def get_demo_accounts():
    """Get public demo account information (ATOMIC READ)"""
    accounts = []

    for account_type, config in settings.DEMO_ACCOUNTS.items():
        accounts.append({
            "account_type": account_type,
            "name": config["name"],
            "email": config["email"],
            "password": "DemoSanPablo2024!" if "sanpablo" in config["email"] else "DemoLaEspiga2024!",
            "description": (
                "Panadería individual que produce todo localmente"
                if account_type == "professional"
                else "Punto de venta con obrador central"
            ),
            "features": (
                ["Gestión de Producción", "Recetas", "Inventario", "Ventas", "Previsión de Demanda"]
                if account_type == "professional"
                else ["Gestión de Proveedores", "Pedidos", "Inventario", "Ventas", "Previsión de Demanda"]
            ),
            "business_model": (
                "Producción Local" if account_type == "professional" else "Obrador Central + Punto de Venta"
            )
        })

    return accounts
