Skip to content

refactor(disputes): deduplicate client/freelancer dispute pages into shared logic #387

Description

@Josue19-08

🔧 Title:

refactor(disputes): deduplicate client/freelancer dispute pages into shared logic

📘 Description

The client and freelancer dispute flows are near-duplicate page pairs, each violating the orchestrator pattern independently:

  • app/disputes/page.tsx + freelancer/disputes/page.tsx — both call listDisputes() directly inline, manage pagination state by hand, and define an identical inline getTabLabel()/LoadingFallback.
  • app/disputes/new/page.tsx + freelancer/disputes/new/page.tsx — both call listOrders()/openDispute() directly inline, duplicate an inline validateForm(), and duplicate a ~185-line inline form.
  • app/disputes/[id]/page.tsx + freelancer/disputes/[id]/page.tsx — both have a fake setTimeout-based comment-submission stub building a DisputeComment object inline, duplicate module-scope formatDate/formatDateTime/toEvidenceUploadItems/InfoRow helpers, and the freelancer version hand-rolls a ~35-line timeline instead of reusing the client version's <DisputeTimeline> component.

✅ Acceptance Criteria

  • A single useDisputeList, useDisputeForm, and useDisputeDetail hook (or equivalent) is shared by both the client and freelancer variants — no duplicated data-fetching/pagination/validation logic between the two
  • formatDate, formatDateTime, toEvidenceUploadItems, InfoRow, getTabLabel, LoadingFallback each exist in exactly one place, imported by both flows
  • freelancer/disputes/[id]/page.tsx uses the existing <DisputeTimeline> component instead of a hand-rolled inline timeline
  • The fake setTimeout comment-submission stub is replaced with a real API call (or, if the backend endpoint doesn't exist yet, filed as its own follow-up issue and linked here — do not ship a fake network call disguised as real in either page)
  • npx tsc --noEmit, npx eslint, npx vitest run, and npm run build all stay clean

🔧 Context AI

📋 Additional Notes

Part of the frontend architecture cleanup milestone, not a Tranche 2 paid deliverable. If the comment-submission backend endpoint doesn't exist, note that as a discovered gap rather than silently leaving the stub in place.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    choreMaintenance / setupfrontendFrontend related

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions