"""Student report form (Phase 7).

Server-side validation for the "Report Listing" modal. The reason choices are
sourced from :data:`app.moderation.services.REPORT_REASON_OPTIONS` so the form
and the service stay in sync.
"""

from __future__ import annotations

from flask_wtf import FlaskForm
from wtforms import SelectField, SubmitField, TextAreaField
from wtforms.validators import DataRequired, Length, Optional

from app.moderation.services import REPORT_REASON_OPTIONS


class ReportForm(FlaskForm):
    """Report an inappropriate listing."""

    reason = SelectField(
        "Reason",
        choices=REPORT_REASON_OPTIONS,
        validators=[DataRequired(message="Please choose a reason.")],
    )
    description = TextAreaField(
        "Details (optional)",
        validators=[Optional(), Length(max=1000, message="Keep details under 1000 characters.")],
        render_kw={"rows": 4, "placeholder": "Add any context that helps our moderators."},
    )
    submit = SubmitField("Submit report")
