# @File: backend/routers/bizmail_public.py
# @Desc: Public (anonymous) Bizmail360 endpoints — the pricing page only
#        needs the list of active plans. Keeping this on a separate router
#        means no auth dependency is introduced and the frontend can fetch
#        it before login.
from __future__ import annotations

from typing import List

from core.database import get_db
from fastapi import APIRouter, Depends
from schemas.bizmail import BizmailPlanOut
from services.bizmail.plans import list_plans
from sqlalchemy.ext.asyncio import AsyncSession

router = APIRouter(prefix="/api/v1/public/bizmail", tags=["bizmail-public"])


@router.get("/plans", response_model=List[BizmailPlanOut])
async def public_list_plans(db: AsyncSession = Depends(get_db)):
    """Return all active Bizmail360 plans for the /bizmail360/pricing page."""
    plans = await list_plans(db, include_inactive=False)
    return [BizmailPlanOut.model_validate(p) for p in plans]