Dev: Display Host Contact Information Form Progress
๐งฉ Overview
This issue focuses on showing dynamic status icons (โโ complete, โ partial, โฏ incomplete) to indicate the completion state of the Contact Info section in the Host Profile. The backend evaluates the user's submitted data and returns a status that the frontend uses to render the correct icon.
More Info
This form is part of the Host Profile intake. Users can select a preferred contact method ("Email" or "Text") and optionally fill out a phone number.
The UI displays a status icon based on backend logic:
- โโ Complete: All required fields are valid based on context (e.g., email chosen, phone not needed)
- โ Partial: At least one field is filled, but not enough to count as complete
- โฏ Incomplete: No relevant data provided
Example: If the user chooses "Email" as their preferred method but does not provide a phone number, the status should still show โโ because phone is not required in that context.
๐ Scope of Work
- Make
phone_numberoptional in schema and DB - Evaluate contact info completion based on conditional rules
- Return correct status (
complete,partial, orincomplete) - Status should drive icon logic on the frontend
- Prevent duplicate
contact_infoentries (update existing if sameuser_id)
๐ง Engineering Tasks
Steps to Implement:
-
[x] Make
phone_numberoptional inContactInfoCreateschema -
[x] Update Alembic migration to make
phone_numbernullable in DB -
[x] Modify
crud.pyto update existing contact info -
[x] Update
determine_status()inroutes.py:- โโ If
preferred_method == "Email"โphone_numbernot required for complete - โโ If
preferred_method == "Text"โphone_numberis required for complete - โ One of the fields present but not enough to meet full rules โ partial
- โฏ Neither field provided โ incomplete
- โโ If
โ Acceptance Criteria
- [x] Submitting contact info with only email (preferred_method=email) is valid
- [x] Submitting contact info with phone (preferred_method=phone) requires phone_number with 10+ digits
- [x] Backend replaces existing entry if user already has a contact_info row
- [x] Backend
/completion-statusreturns correct status based on inputs - [x] Frontend shows โโ if contact info is "complete", โ if partial, โฏ if incomplete
- [x] Status icons are clearly visible and emphasized in UI
๐ Dependencies
- Frontend must implement logic to map
completion-statusto appropriate status icons
๐ฆ Technical Notes
- Backend: FastAPI, SQLAlchemy, Pydantic
- Used
Optional[str]forphone_numberin Pydantic schema - Status is computed dynamically using
determine_status()in route - Backend logic ensures only one row per user in
contact_infotable - Frontend updates icon based on backend status: โโ / โ / โฏ
- POST
/contact-infoacts as upsert - GET
/completion-status/{user_id}returns{ "Contact Information": "complete" | "partial" | "incomplete" }
๐งช Testing Strategy
All validation can be covered by manual testing:
-
โ Submit form with:
- Preferred method: email only โ โโ complete
- Preferred method: phone + valid number โ โโ complete
- Preferred method: phone + short/invalid number โ โ partial
- No input at all โ โฏ incomplete
-
โ Observe status icons update correctly in UI
-
โ Reload form and ensure saved data is preserved
-
โ Resubmit form to test replacement (edit + save again)
-
โ Check backend DB only contains one row per user
๐ฉ Risks / Considerations
- Risk: If backend logic doesn't perfectly match frontend icon mapping, users could be misled
- Consideration: Validation rules must remain synchronized between frontend and backend
๐งต Related Issues
- #720
- #919
Action Items
- [X] Update issue with current Engineering Issue Template format
- [X] Come up with a solution
- [ ] Discuss with Dev Lead & Dev PM
- [ ] Share proposal with Product and Design
๐ Resources
Attachments/Screenshots (If Applicable):
- N/A
#500 covers this
Reached out to Dev Lead for discussion.