"""Public beta signup endpoint — no auth required."""

import logging
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel, EmailStr
from app.core.email import EmailService

logger = logging.getLogger(__name__)

router = APIRouter(prefix="/beta-signup", tags=["beta"])


class BetaSignupRequest(BaseModel):
    email: EmailStr


class BetaSignupResponse(BaseModel):
    success: bool
    message: str


@router.post("", response_model=BetaSignupResponse)
async def beta_signup(data: BetaSignupRequest):
    """Collect beta interest — sends notification to beta@resolutionflow.com."""
    sent = await EmailService.send_beta_signup_notification(data.email)
    if not sent:
        logger.warning("Beta signup recorded (email delivery skipped): %s", data.email)
    return BetaSignupResponse(
        success=True,
        message="Thanks! We'll be in touch with beta access details.",
    )
