Skip to content

feat: bidding hook, contract countdown, dispute resolution portal, reputation reviews grid - #914

Merged
johdanike merged 2 commits into
SwiftChainn:mainfrom
iamthebestofcourse:feat/bidding-hook-countdown-dispute-tests-reputation-grid-839-840-846-847
Sep 30, 2026
Merged

johdanike merged 2 commits into
SwiftChainn:mainfrom
iamthebestofcourse:feat/bidding-hook-countdown-dispute-tests-reputation-grid-839-840-846-847

Conversation

@iamthebestofcourse

Copy link
Copy Markdown

Summary

Closes #839
Closes #840
Closes #846
Closes #847

Implements four assigned issues following this repo's Component -> Hook -> Service layering.

#839: useBidding

  • types/bidding.ts, services/biddingService.ts, hooks/useBidding.ts
  • TanStack Query hook fetching bidding contracts (GET /driver/bidding/contracts) and bid history (GET /driver/bidding/history), submitting bids via a mutation (POST /driver/bidding/bids), and polling bid status every 10s while any bid is pending.

#840: contract expiration countdowns

  • hooks/useContractCountdown.ts, components/driver/BiddingBoard.tsx
  • Live per-contract countdowns with urgency-based coloring (normal/urgent/critical), a one-time "expiring soon" toast per contract, and automatic removal of contracts once 5 minutes past their deadline. The timer uses the Page Visibility API to pause while the tab is hidden and resync immediately on resume, so a background tab doesn't burn CPU ticking a UI nobody can see.

#846: dispute resolution portal + tests

No dispute-resolution UI existed yet in this codebase to write tests against (the acceptance criteria assume DisputeResolutionPortal and useEvidenceUpload already exist), so this PR builds a minimal real implementation first, then tests it:

  • types/disputeResolution.ts, services/disputeResolutionService.ts, hooks/useEvidenceUpload.ts
  • components/escrow/DisputeResolutionPortal.tsx (reason selection -> evidence upload -> review -> submit) and components/escrow/EvidenceMediaDropzone.tsx (drag-and-drop + keyboard-accessible file picker, client-side type/size validation, image compression via the existing imageCompressionService)
  • __tests__/components/escrow/DisputeResolutionPortal.test.tsx and __tests__/hooks/useEvidenceUpload.test.ts: 30 tests, 97-100% statement coverage on the new files (well over the issue's 12-test/85%-coverage bar)

This is deliberately not built on escrow/DisputeForm.tsx / hooks/useDisputeForm.ts / services/escrowService.ts: escrowService.ts imports stellar-sdk, which is not installed in this repo, so that code cannot run in the real app despite its own Jest tests passing (the tests mock the service, so the broken import is never actually loaded). Flagging this as a pre-existing issue; not fixed here since it's unrelated to this PR's scope.

#847: reputation reviews grid

  • types/reputationReview.ts, services/reputationReviewService.ts, hooks/useReputationReviews.ts, components/fleet/ReputationReviewGrid.tsx
  • Filterable grid (rating, date range, verified-only) of driver reviews, with on-chain verification badges and average rating summary.

Also included: ThemeToggle fix (blocking issue for screenshots)

components/ui/ThemeToggle.tsx imported hooks/useTheme.ts, which calls methods (getThemeFromStorage, syncThemeToAPI, etc.) that don't exist on services/themeService.ts, and whose own return shape ({ theme, setTheme }) doesn't even match what ThemeToggle destructures ({ resolvedTheme, toggleTheme }). Since ThemeToggle is rendered from app/layout.tsx, this broke every route in both dev and prod (confirmed pre-existing via a clean checkout of this branch's base commit). Redirected ThemeToggle to import useTheme from the next-themes package instead, matching what components/shared/ThemeProvider.tsx already uses elsewhere in the app. hooks/useTheme.ts and services/themeService.ts themselves are untouched; they're orphaned, dead code and fixing them is out of scope here.

Dependency

Added date-fns (named in #840's "Technical Scope" but not previously installed) for countdown time-difference formatting.

Pre-existing issues found (not fixed, out of scope for this PR)

  • app/page.tsx:178 has an unbalanced JSX tag that fails next build and tsc --noEmit, blocking production builds for the entire repo. Reproduced on a clean checkout of this branch's base commit, unrelated to any file touched here.
  • escrow/DisputeForm.tsx / hooks/useDisputeForm.ts / services/escrowService.ts are broken due to the missing stellar-sdk dependency (see Test: Dispute Resolution Portal and Evidence Dropzone Tests #846 section above).

Test plan

  • npx jest on all new/touched test files: 5 suites, 61 tests passing
  • npx tsc --noEmit: no new errors (only the two pre-existing, unrelated failures noted above)
  • npx eslint on all new/touched files: 0 errors (a few pre-existing-style warnings from an unused-vars rule flagging documentation-only parameter names in function-type signatures, consistent with warnings already present elsewhere in the codebase)
  • Manually rendered all four new components together in a local preview route (screenshot below) and confirmed no runtime errors
  • Confirmed both pre-existing issues above via git stash against a clean checkout, not introduced by this PR

Screenshots

Test suite passing:

tests passing

Components rendered (BiddingBoard, DisputeResolutionPortal, ReputationReviewGrid):

components rendered

…portal, reputation grid

Implements four assigned issues following the Component -> Hook -> Service
layering used elsewhere in the app:

- useBidding (SwiftChainn#839): TanStack Query hook fetching bidding contracts and bid
  history, submitting bids via a mutation, and polling bid status while any
  bid is pending.
- useContractCountdown + BiddingBoard (SwiftChainn#840): per-contract live countdowns
  with urgency-based coloring, a one-time "expiring soon" toast, and
  automatic removal of contracts once past their grace period. The timer
  pauses via the Page Visibility API while the tab is hidden.
- DisputeResolutionPortal, EvidenceMediaDropzone, and useEvidenceUpload
  (SwiftChainn#846): no dispute-resolution UI existed yet in this codebase to write
  tests against, so this adds a minimal real implementation (reason
  selection, evidence upload with image compression, review/submit steps
  backed by a new disputeResolutionService), plus a test suite covering it
  (61 tests total across this batch; DisputeResolutionPortal,
  EvidenceMediaDropzone, and useEvidenceUpload are at 97-100% statement
  coverage).
- ReputationReviewGrid (SwiftChainn#847): filterable grid of driver reviews with
  on-chain verification badges, backed by a new useReputationReviews hook
  and reputationReviewService.

Also fixes components/ui/ThemeToggle.tsx, which imported the app's broken
custom useTheme hook (hooks/useTheme.ts calls methods that don't exist on
services/themeService.ts, and its own return shape doesn't match what
ThemeToggle destructures). That broke app/layout.tsx and therefore every
route, in both dev and prod. Redirected it to next-themes' own useTheme,
which is what components/shared/ThemeProvider.tsx already uses elsewhere
in the app. hooks/useTheme.ts and services/themeService.ts are untouched
and still orphaned, dead code; out of scope here.

Adds date-fns as a dependency for countdown formatting (named in SwiftChainn#840's
technical scope but not previously installed).

Pre-existing, unrelated to this PR: app/page.tsx has an unbalanced JSX tag
at line 178 that fails both `next build` and `tsc --noEmit`, blocking
production builds repo-wide. Reproduced on a clean checkout of this
branch's base commit. escrow/DisputeForm.tsx, hooks/useDisputeForm.ts, and
services/escrowService.ts also remain broken (escrowService.ts imports the
uninstalled stellar-sdk package); the new dispute-resolution code in this
PR does not build on that precedent.

Closes SwiftChainn#839
Closes SwiftChainn#840
Closes SwiftChainn#846
Closes SwiftChainn#847
@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@iamthebestofcourse Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@johdanike
johdanike merged commit d867172 into SwiftChainn:main Sep 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants