Skip to content

feat: add My Orders profile screen - #465

Open
CherryCIC wants to merge 2 commits into
mainfrom
agent/451-my-orders
Open

feat: add My Orders profile screen#465
CherryCIC wants to merge 2 commits into
mainfrom
agent/451-my-orders

Conversation

@CherryCIC

@CherryCIC CherryCIC commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

In summary:

image
  • Added the My Orders Profile subpage with loading, empty, error, refresh and order-list states.
  • Used the existing authenticated API client with the Swagger-documented GET /api/order/my-orders route.
  • Enriched unique products with bounded concurrency and safe partial-failure fallbacks.
  • Preserved monetary values as integer minor units and formatted item prices using the order currency.
  • Centralised delivery-status labels with a neutral fallback for unknown states.
  • Kept the existing bottom navigation visible with Profile selected, including visual and system back handling.
  • Removed the like badge and count following the latest product decision, superseding that detail in the original issue brief.

Scope

Frontend only. No backend, Firestore or Swagger changes are included.

Validation

  • 39 focused endpoint, repository, view-model, widget and navigation tests passed.
  • Targeted Flutter analysis passed with no issues.
  • The staged diff was checked for whitespace errors and contains only My Orders work.

Closes #451

Summary by CodeRabbit

  • New Features
    • Added a “My Orders” experience accessible from the Profile section.
    • Orders now display product details, pricing, delivery status, images, and charity information.
    • Added loading, empty, error, retry, and pull-to-refresh states.
    • Added responsive order cards with accessibility support and safe fallbacks for unavailable details.
  • Bug Fixes
    • Improved navigation and back-button handling when returning from My Orders.
  • Tests
    • Added coverage for order loading, navigation, formatting, enrichment, error handling, and responsive layouts.

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4a3f5b26-bd20-4fd4-8a7d-e2a023e98644

📥 Commits

Reviewing files that changed from the base of the PR and between 3f4fd13 and 075f87e.

📒 Files selected for processing (5)
  • lib/core/config/app_strings.dart
  • lib/core/services/network/api_endpoints.dart
  • lib/core/utils/dependency.dart
  • lib/features/profile/profile_page.dart
  • test/home_orders_navigation_test.dart
🚧 Files skipped from review as they are similar to previous changes (5)
  • lib/core/services/network/api_endpoints.dart
  • lib/features/profile/profile_page.dart
  • lib/core/config/app_strings.dart
  • lib/core/utils/dependency.dart
  • test/home_orders_navigation_test.dart

📝 Walkthrough

Walkthrough

Adds a complete My Orders feature: API contracts, order parsing and enrichment, asynchronous state management, order list/card UI, profile navigation integration, and coverage for data, widget, and navigation behavior.

Changes

My Orders flow

Layer / File(s) Summary
Order contracts and formatting
lib/core/config/app_strings.dart, lib/core/services/network/api_endpoints.dart, lib/features/orders/models/order_summary.dart, lib/features/orders/order_currency_formatter.dart, test/api_endpoints_test.dart
Adds My Orders strings, authenticated order and product endpoints, normalized OrderSummary parsing, currency formatting, and route contract tests.
Order fetching and state management
lib/features/orders/orders_repository.dart, lib/features/orders/orders_view_model.dart, lib/core/utils/dependency.dart, test/orders_repository_test.dart, test/orders_view_model_test.dart
Fetches orders, enriches them with charity and product data, registers repository/view-model dependencies, manages loading and refresh state, and tests malformed data, concurrency, failures, stale requests, and disposal.
Orders page and card presentation
lib/features/orders/orders_page.dart, lib/features/orders/widgets/order_card.dart, test/orders_widgets_test.dart
Adds loading, failure, empty, refresh, and list states with responsive order cards, image/logo fallbacks, status labels, accessibility semantics, and widget coverage.
Profile entry and navigation lifecycle
lib/features/profile/profile_page.dart, lib/features/home/home_page.dart, test/home_orders_navigation_test.dart
Connects the profile shortcut to My Orders and manages overlay display, back handling, tab changes, profile preservation, and navigation reset behavior.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ProfilePage
  participant HomePage
  participant MyOrdersPage
  participant OrdersViewModel
  participant OrdersRepository
  participant ApiService

  ProfilePage->>HomePage: onOrdersPressed()
  HomePage->>MyOrdersPage: display orders overlay
  MyOrdersPage->>OrdersViewModel: loadOrders()
  OrdersViewModel->>OrdersRepository: fetchOrders()
  OrdersRepository->>ApiService: fetch orders, charities, and products
  ApiService-->>OrdersRepository: return API data
  OrdersRepository-->>OrdersViewModel: return enriched orders
  OrdersViewModel-->>MyOrdersPage: notify state update
Loading

Possibly related PRs

  • Cherry-CIC/MVP#443: Updates the feature-flagged profile shortcut area that this PR wires to My Orders.
  • Cherry-CIC/MVP#458: Touches shared profile shortcut/navigation plumbing and app strings for a separate Liked Items flow.

Suggested labels: UI, MVP, Frontend

Suggested reviewers: zodiac1, taiwo2

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Issue #451 also requires product like count, which this PR omits from the My Orders order cards. Add the like badge/count to My Orders, or update #451 if that requirement was intentionally dropped.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding the My Orders profile screen.
Out of Scope Changes check ✅ Passed The changes appear focused on the My Orders feature and its supporting wiring, tests, and UI behavior.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/451-my-orders

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CherryCIC CherryCIC self-assigned this Jul 24, 2026
@CherryCIC CherryCIC added this to the User Profile milestone Jul 24, 2026
@CherryCIC
CherryCIC marked this pull request as ready for review July 24, 2026 12:45
@CherryCIC
CherryCIC requested review from MattGoodwin0 and removed request for JaseElder and MattGoodwin0 July 24, 2026 12:45

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (2)
lib/features/orders/orders_page.dart (1)

25-35: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Reload when the provided view-model instance changes.

context.read does not update when the ancestor OrdersViewModel is replaced. Consumer<OrdersViewModel> will rebuild with the new instance, but this state keeps the old _viewModel and _hasInitialised, so that new uninitialized instance never calls loadOrders(). Schedule loadOrders() when the referenced instance identity changes, rather than only once per state lifetime.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/features/orders/orders_page.dart` around lines 25 - 35, Update
didChangeDependencies in the orders page to detect when
context.read<OrdersViewModel>() returns a different instance, reset the
initialization tracking for that new view model, and schedule that instance’s
loadOrders() after the frame. Preserve the mounted check and avoid reloading
when the same OrdersViewModel instance remains provided.
lib/features/orders/orders_repository.dart (1)

41-44: 🚀 Performance & Scalability | 🔵 Trivial | ⚡ Quick win

Consider parallelizing the two independent enrichment fetches.

_fetchCharityLogos() and _fetchProducts(...) have no data dependency on each other, but they run sequentially, adding an extra round-trip of latency to the orders load path. Starting the charity fetch before awaiting products lets them overlap.

♻️ Proposed overlap of independent fetches
-      final charityLogos = await _fetchCharityLogos();
-      final products = await _fetchProducts(
-        orders.map((order) => order.productId).where((productId) => productId.isNotEmpty).toSet(),
-      );
+      final charityLogosFuture = _fetchCharityLogos();
+      final products = await _fetchProducts(
+        orders.map((order) => order.productId).where((productId) => productId.isNotEmpty).toSet(),
+      );
+      final charityLogos = await charityLogosFuture;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/features/orders/orders_repository.dart` around lines 41 - 44, Update the
orders loading flow around _fetchCharityLogos and _fetchProducts to start both
independent asynchronous fetches before awaiting either result, allowing the
network requests to overlap. Preserve the existing product ID filtering and
ensure both resolved values remain available for subsequent enrichment.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@lib/features/orders/order_currency_formatter.dart`:
- Around line 6-15: Update formatItemPrice in
lib/features/orders/order_currency_formatter.dart (lines 6-15) to accept
normalized nonblank order.currency values, removing the GBP-only guard while
retaining the null minor-unit check and passing the currency to
formatMinorUnits. Update the EUR assertion in test/orders_widgets_test.dart
(lines 76-83) to expect the formatted ISO-code value.

In `@test/orders_widgets_test.dart`:
- Around line 76-83: Update the test “does not label a GBP product price as
another currency” to use a valid EUR minor-unit price and assert the expected
formatted order-currency value, such as “EUR 4.00”, instead of expecting null.
Preserve the test’s focus on ensuring a EUR price is not mislabeled as GBP.

---

Nitpick comments:
In `@lib/features/orders/orders_page.dart`:
- Around line 25-35: Update didChangeDependencies in the orders page to detect
when context.read<OrdersViewModel>() returns a different instance, reset the
initialization tracking for that new view model, and schedule that instance’s
loadOrders() after the frame. Preserve the mounted check and avoid reloading
when the same OrdersViewModel instance remains provided.

In `@lib/features/orders/orders_repository.dart`:
- Around line 41-44: Update the orders loading flow around _fetchCharityLogos
and _fetchProducts to start both independent asynchronous fetches before
awaiting either result, allowing the network requests to overlap. Preserve the
existing product ID filtering and ensure both resolved values remain available
for subsequent enrichment.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 12155a7f-82b6-4c62-a96d-3fea6d76a1bd

📥 Commits

Reviewing files that changed from the base of the PR and between 1ff77ea and 3f4fd13.

📒 Files selected for processing (17)
  • lib/core/config/app_strings.dart
  • lib/core/services/network/api_endpoints.dart
  • lib/core/utils/dependency.dart
  • lib/features/home/home_page.dart
  • lib/features/orders/models/order_summary.dart
  • lib/features/orders/order_currency_formatter.dart
  • lib/features/orders/orders_page.dart
  • lib/features/orders/orders_repository.dart
  • lib/features/orders/orders_view_model.dart
  • lib/features/orders/widgets/order_card.dart
  • lib/features/profile/profile_page.dart
  • lib/features/profile/widgets/user_order_details.dart
  • test/api_endpoints_test.dart
  • test/home_orders_navigation_test.dart
  • test/orders_repository_test.dart
  • test/orders_view_model_test.dart
  • test/orders_widgets_test.dart

Comment on lines +6 to +15
static String? formatItemPrice(OrderSummary order) {
final minorUnits = order.itemPriceMinor;
if (minorUnits == null || order.currency != 'GBP') {
return null;
}

return formatMinorUnits(
minorUnits: minorUnits,
currency: order.currency,
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Honor the order currency rather than treating non-GBP prices as unavailable.

  • lib/features/orders/order_currency_formatter.dart#L6-L15: accept normalized nonblank currencies and format their minor-unit amount through formatMinorUnits.
  • test/orders_widgets_test.dart#L76-L83: change the EUR assertion to the formatted ISO-code value so the regression is covered.
📍 Affects 2 files
  • lib/features/orders/order_currency_formatter.dart#L6-L15 (this comment)
  • test/orders_widgets_test.dart#L76-L83
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@lib/features/orders/order_currency_formatter.dart` around lines 6 - 15,
Update formatItemPrice in lib/features/orders/order_currency_formatter.dart
(lines 6-15) to accept normalized nonblank order.currency values, removing the
GBP-only guard while retaining the null minor-unit check and passing the
currency to formatMinorUnits. Update the EUR assertion in
test/orders_widgets_test.dart (lines 76-83) to expect the formatted ISO-code
value.

Comment on lines +76 to +83
test('does not label a GBP product price as another currency', () {
expect(
OrderCurrencyFormatter.formatItemPrice(
_order(currency: 'EUR'),
),
isNull,
);
});

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Do not lock the non-GBP price regression into the test.

A valid EUR minor-unit price should assert its formatted order-currency value (for example, EUR 4.00), not null.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/orders_widgets_test.dart` around lines 76 - 83, Update the test “does
not label a GBP product price as another currency” to use a valid EUR minor-unit
price and assert the expected formatted order-currency value, such as “EUR
4.00”, instead of expecting null. Preserve the test’s focus on ensuring a EUR
price is not mislabeled as GBP.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement My Orders profile screen

1 participant