Reorder contacts in Attik mobile by role order

Objective

  • On inspection detail in Attik mobile, the Contacts section should list people in the same order inspectors see on Attik web—driven by each role’s configured order (e.g. Clients → Client’s Agent → Listing Agent), not by how rows were added or synced into inspection.people.
  • Align mobile with existing company contact-role settings so field staff can scan contacts in a predictable, role-based order.

Background

  • Product feedback (Christopher Scott): under Contacts on mobile, users expect contacts top-to-bottom as Clients, then Client’s Agent, then Listing Agent.
  • The requirement is that display order matches the order field on populated roles in the people array—the same sort key companies configure under contact roles.
  • Attik web already sorts inspection people by _roleId.order (with a high fallback when order is missing) in PeopleBox before rendering.
  • Attik mobile currently passes inspection.people through unchanged; ContactsList maps the array in API/storage order, so Listing Agent or other roles can appear above Client or Client’s Agent even when role settings say otherwise.
  • The inspection API already returns order on populated people._roleId; mobile types omit it but the value is available at runtime when people is populated.

Scope

Backend

  • Contact roles define order on contactRolesSchema (attik-backend/src/models/contactRolesSchema.ts, default 9999).
  • Inspection reads with populate: people include role order via people._roleId select in attik-backend/src/routes/inspection.ts (name, icon, description, portalPermissions, order). Aggregation population in attik-backend/src/util/functions/aggregation/inspectionPopulation.ts merges full role objects into people—no change required unless mobile populate paths differ.

Frontend (reference behavior)

  • attik-frontend/src/components/ui/PeopleBox.tsx is the parity target: roleDisplayOrder reads Number(role.order) with fallback 9999, comparePeopleForDisplay sorts people before grouping by role. Mobile should behave consistently with this pattern; exact reuse vs. local helper is a dev choice.

Mobile

  • Inspection detail in attik-mobile/app/(app)/inspection/[id].tsx builds people from inspection?.people and renders <ContactsList people={people} /> with no sort.
  • attik-mobile/components/inspection/ContactsList.tsx maps people in array order.
  • attik-mobile/types/index.tsContactRole currently has _id, name, type only; extending types for order may be needed for clarity.
  • attik-mobile/hooks/useInspectionDetails.ts and useInspections.ts request populated people—data should include order when populated.
  • Also in scope: the deduped uniquePeople list and client-portal dropdown options in [id].tsx are built from the same unsorted people loop; sorting for the Contacts section should keep portal option order aligned with the visible contact list.
  • Out of scope unless discovered in QA: changing company role order values in settings; reordering rows inside inspection.people on the server.

Decision needed

  • Whether to sort in ContactsList only vs. a shared sorted people memo in [id].tsx (portal dropdown and any other consumers).
  • Tie-break when two people share the same role order (web uses contact id string compare after role order).

References

  • Mobile: attik-mobile/app/(app)/inspection/[id].tsx, attik-mobile/components/inspection/ContactsList.tsx
  • Web parity: attik-frontend/src/components/ui/PeopleBox.tsx
  • API populate: attik-backend/src/routes/inspection.ts, attik-backend/src/models/contactRolesSchema.ts

Please authenticate to join the conversation.

Upvoters
Status

Planned

Board
🏠

Main App

Date

2 days ago

Author

Linear

Subscribe to post

Get notified by email when there are changes.