feat: add My Orders profile screen - #465
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (5)
🚧 Files skipped from review as they are similar to previous changes (5)
📝 WalkthroughWalkthroughAdds 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. ChangesMy Orders flow
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
Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
lib/features/orders/orders_page.dart (1)
25-35: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winReload when the provided view-model instance changes.
context.readdoes not update when the ancestorOrdersViewModelis replaced.Consumer<OrdersViewModel>will rebuild with the new instance, but this state keeps the old_viewModeland_hasInitialised, so that new uninitialized instance never callsloadOrders(). ScheduleloadOrders()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 winConsider 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
📒 Files selected for processing (17)
lib/core/config/app_strings.dartlib/core/services/network/api_endpoints.dartlib/core/utils/dependency.dartlib/features/home/home_page.dartlib/features/orders/models/order_summary.dartlib/features/orders/order_currency_formatter.dartlib/features/orders/orders_page.dartlib/features/orders/orders_repository.dartlib/features/orders/orders_view_model.dartlib/features/orders/widgets/order_card.dartlib/features/profile/profile_page.dartlib/features/profile/widgets/user_order_details.darttest/api_endpoints_test.darttest/home_orders_navigation_test.darttest/orders_repository_test.darttest/orders_view_model_test.darttest/orders_widgets_test.dart
| static String? formatItemPrice(OrderSummary order) { | ||
| final minorUnits = order.itemPriceMinor; | ||
| if (minorUnits == null || order.currency != 'GBP') { | ||
| return null; | ||
| } | ||
|
|
||
| return formatMinorUnits( | ||
| minorUnits: minorUnits, | ||
| currency: order.currency, | ||
| ); |
There was a problem hiding this comment.
🎯 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 throughformatMinorUnits.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.
| test('does not label a GBP product price as another currency', () { | ||
| expect( | ||
| OrderCurrencyFormatter.formatItemPrice( | ||
| _order(currency: 'EUR'), | ||
| ), | ||
| isNull, | ||
| ); | ||
| }); |
There was a problem hiding this comment.
🎯 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.
In summary:
GET /api/order/my-ordersroute.Scope
Frontend only. No backend, Firestore or Swagger changes are included.
Validation
Closes #451
Summary by CodeRabbit