Files
resolutionflow/backend/app/schemas/survey.py
chihlasm 199cf315c6 feat: admin survey responses page with expandable detail and CSV export
- Backend: GET /admin/survey-responses (list with stats, invite join)
- Backend: GET /admin/survey-responses/export (CSV download)
- Frontend: SurveyResponsesPage with expandable row detail
- Two-column Q&A grid with typed answer rendering (chips, ranked lists, quote blocks)
- Stats cards (total responses, this week)
- CSV export button with blob download
- Sidebar nav + route wiring
- Also: updated Q14 from product domain ranking to diagnostic prioritization

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 07:55:49 -05:00

64 lines
1.7 KiB
Python

"""Schemas for FlowPilot survey submission."""
from datetime import datetime
from typing import Any, Optional
from pydantic import BaseModel, Field
class SurveySubmission(BaseModel):
"""Incoming survey response from the public form."""
respondent_name: Optional[str] = Field(None, max_length=255)
responses: dict[str, Any] = Field(
...,
description="Question ID -> answer mapping. Values can be strings, lists, or numbers.",
)
token: Optional[str] = Field(None, description="Invite token for tracking")
class SurveySubmissionResponse(BaseModel):
"""Response after successful submission."""
message: str = "Thank you for your response!"
id: str
class SurveyInviteCreate(BaseModel):
"""Create a new survey invite."""
recipient_name: str = Field(..., min_length=1, max_length=255)
recipient_email: Optional[str] = Field(None, max_length=255)
send_email: bool = False
class SurveyInviteResponse(BaseModel):
"""Invite details returned to admin."""
id: str
token: str
recipient_name: str
recipient_email: Optional[str]
status: str
email_sent: bool
created_at: datetime
completed_at: Optional[datetime]
survey_url: str
class SurveyInviteStatus(BaseModel):
"""Public invite status check — minimal info."""
name: str
status: str
class SurveyResponseDetail(BaseModel):
"""Full survey response returned to admin."""
id: str
respondent_name: Optional[str]
responses: dict[str, Any]
source: str
invite_name: Optional[str]
created_at: datetime
class SurveyResponseListResponse(BaseModel):
"""List of survey responses with summary stats."""
responses: list[SurveyResponseDetail]
total: int
this_week: int