"""Public contact endpoints — no authentication required."""
from fastapi import APIRouter, Depends
from sqlalchemy.orm import Session

from app.core.database import get_db
from app.schemas.public_contact import (
    PublicContactInfoResponse,
    PublicContactRequest,
    PublicContactResponse,
)
from app.services.support_contact_service import contact_info, process_contact_enquiry

router = APIRouter()


@router.get("/info", response_model=PublicContactInfoResponse)
def get_contact_info():
    """CNP Solutions contact channels for help pages and marketing."""
    return PublicContactInfoResponse(**contact_info())


@router.post("/contact", response_model=PublicContactResponse)
def submit_contact_enquiry(
    payload: PublicContactRequest,
    db: Session = Depends(get_db),
):
    """
    Log a support/sales enquiry and return WhatsApp + email deep links.
    When WhatsApp Business API is configured, also notifies the CNP support line.
    """
    result = process_contact_enquiry(db, payload.model_dump())
    return PublicContactResponse(**result)
