refactor: consolidate duplicated helpers and envelope types #121
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "refactor/mapps-140-consolidate-helpers"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
One canonical implementation per concept, removing the copy-paste drift seedbed flagged in the too-many-cooks audit.
Move
urlencoding_minimaltosrc/utils/url.rsand import it in all five former copies (company_picker, contacts, audit_log, knowledge_base, contracts).Add one shared client decode envelope
crate::utils::Paginated<T>(with#[serde(default)]meta) and delete the divergent per-page / per-module re-declarations:modules/audit::Paginated,modules/sla::SlaPaginated, and the genericPaginated<T>in dashboard, projects, time, assets, knowledge_base, tickets, contracts, and billing, plus the namedPaginatedTickets.datausesdefault = "Vec::new"so the envelope stays generic over non-Defaultrow types.Add
UserRole::parse_role(&str) -> UserRoleas the single canonical role parser and route theauth_callbacksite through it, dropping its partial inline match that omitted super_admin/dispatcher/sales.Change
AuthContext::has_role(anduse_require_role) to takeUserRoleinstead of a stringly comparison, matchingAuthState::has_role.Rename the three domain-specific
humanize_statusfunctions tohumanize_ticket_status,humanize_tenant_status, andhumanize_contract_statusso they no longer share a name that invites drift.Extract
ticket_status_badge(&str) -> BadgeVariantintocomponents::tableand route the dashboard, ticket-list, and portal ticket tables through it; the canonical mapping includes theclosedarm the divergent copies missed.Remove the private
CompanyAddressincontactsin favor of the moduleAddress, restoring access to itsformatted/is_emptyhelpers.Define
default_trueonce incrate::utilsand point every#[serde(default = "...")]at it, deleting the five model-local copies and the onboarding copy.Add
month_nametocrate::utils::datetimeand import it in the calendar and timesheet pages.Add a real
PortalUserMenu(avatar dropdown with Account Settings + Logout) toPortalLayout, which previously showed a bare icon with no way to sign out.#MAPPS-140
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com