Skip to content

Feat/admin fetch all filters - #25

Merged
laithanhhung merged 11 commits into
devfrom
feat/admin-fetch-all-filters
Jul 24, 2026
Merged

Feat/admin fetch all filters#25
laithanhhung merged 11 commits into
devfrom
feat/admin-fetch-all-filters

Conversation

@laithanhhung

@laithanhhung laithanhhung commented Jul 24, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • New Features

    • Added hub manager assignment through the hubs administration screen.
    • Added order-group search, auto-batch preview/results, and cancellation with optional reasons.
    • Added server-side pagination and filtering across admin lists, including products, markets, users, and delivery zones.
    • Added cascading product category filters and improved location selection controls.
    • Added date and time pickers for analytics and platform settings.
  • Improvements

    • Updated admin layouts, responsive grids, sorting, pagination controls, and assignment workflows.
    • Removed standalone hub staff and platform settings navigation pages; settings are now accessed through dialogs.

laithanhhung and others added 11 commits July 24, 2026 18:16
- Add fetchAllOffset / fetchAllCursor helpers that page an admin list to
  completion (backend caps pageSize at 100). Cursor loop stops when the
  backend returns no nextCursor, so it never regresses or spins.
- Apply to products, market-products, hubs, vehicles, hub-manager and
  market-agent user pickers, and restaurant credit statements/transactions
  — all previously capped at the first 100 rows.
- Products list: replace the single category filter with a parent → child
  cascade (child narrows by parent; picking a child auto-fills the parent),
  matching the create/edit dialog.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
- Fix market-agent assignment never showing: the GET market-assignments
  body wraps the ids as { userId, marketIds: [...] }, which the generic
  list parser missed (always []). Parse marketIds/markets/assignments
  explicitly, tolerating string or object entries.
- Market-agent user list is fetched in full without a pageSize param;
  setMarketAgent takes the previous agent from the row instead of
  re-scanning every agent (cuts the N+1 request storm).
- Even column widths; fixed pricing/details columns so the header lines
  up with the rows. Agent cell truncates the email with an ellipsis.
- LocationPicker: optional queryControl + searchLabelKey — the market
  address seeds the map search, so the address is entered once (drives
  geocoding) instead of twice. Detail/create forms redesigned compact.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Material buttons default to inline-flex, so the long agent email
overflowed its cell. Force the agent button to display:flex and let the
label span flex-shrink + truncate so it ellipsises within the column.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Tailwind truncate classes weren't taking inside the Material button, so
the email still overflowed. Add explicit width-constraining CSS on the
button and an .agent-label rule (min-width:0 + overflow/ellipsis/nowrap),
independent of the button's internal structure.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Rework the order-groups console around the documented contract (§4.2):

- Auto-batch: validate targetDate client-side (optional yyyy-MM-dd) and
  disable submit until valid, mirroring the backend rule; label the
  submit as preview vs apply; warn on force/apply.
- Render the run result as UI — created/batched/skipped tiles, the
  batches list (market, zone, order count) and skipped orders with a
  localized reason — instead of dumping raw JSON.
- Explain failures: VALIDATION_ERROR marks the date field,
  AUTO_BATCH_ALREADY_RUNNING / 409 shows a "busy" banner, everything
  else an error banner, all via readApiError + describeApiError.
- Table gains a status pill and a Created column; cancel opens a dialog
  with an optional reason; agent assign stays required-only.
- Type the auto-batch result (AdminAutoBatchResult) end to end.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Backend list responses carry a `pagination: { total, page, pageSize }`
block, which the old total-only extractor missed. Add extractPagination()
and teach extractTotal to look inside `pagination`. The admin
server-paginated lists — order groups, users, restaurants, audit logs —
sync their paginator's page/size/total from what the backend echoes back.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Load one page of products at a time from the backend (page/pageSize),
pushing search and category filtering to the server (`search`/`category`,
`includeInactive:false`) and tracking the paginator from the returned
`pagination` block — instead of fetching every page up front and
filtering/paging on the client. Sorting reorders the loaded page.

Pickers that still need the whole catalog (add-product-to-market) use a
new productOptions() that pages to completion.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The admin checkboxes (order-groups dry-run/force, settings, hub-staff)
had no color, so they rendered in the indigo accent palette. Set
color="primary" so they match FreshFlow's green brand, like the auth
and checkout checkboxes already do.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Material tints an unselected checkbox's hover/focus ripple with a dark
on-surface colour — a heavy grey circle. Tint the state layer and click
ripple of primary checkboxes with the brand primary so hover reads smooth
and matches the checked state.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Move platform settings into a dialog from order groups, align hubs/resource-crud with the markets inventory layout (manager assign, address+map detail), remove hub staff routing, and wire shared page/pageSize across admin tables. Dashboard date range uses Material datepicker; MatTimepicker formats are fixed in app config.

Co-authored-by: Cursor <cursoragent@cursor.com>
BE has no offset pagination for these master-data lists — load once and paginate in the table instead of calling listPage per MatPaginator change.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kody-ai

kody-ai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Code Review Could Not Complete ⚠️

The review failed before suggestions could be generated.

Reason: The configured API key (google_gemini) is out of credits or has hit its billing limit. Top up the account or adjust the plan.

After fixing the issue, comment @kody review on this PR to re-run the review.

Kody Guide: Usage and Configuration
Interacting with Kody
  • Request a Review: Ask Kody to review your PR manually by adding a comment with the @kody start-review command at the root of your PR.

  • Validate Business Logic: Ask Kody to validate your code against business rules by adding a comment with the @kody -v business-logic command.

  • Provide Feedback: Help Kody learn and improve by reacting to its comments with a 👍 for helpful suggestions or a 👎 if improvements are needed.

Current Kody Configuration
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug
Performance
Security
Business Logic

Access your configuration settings here.

@laithanhhung
laithanhhung merged commit d09889e into dev Jul 24, 2026
1 of 3 checks passed
@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: efa6ce3c-e147-4a32-88ee-90f01dc0c128

📥 Commits

Reviewing files that changed from the base of the PR and between 28ac251 and 0bacde8.

⛔ Files ignored due to path filters (4)
  • src/contract/generated/apis/CategoriesApi.ts is excluded by !**/generated/**
  • src/contract/generated/apis/DeliveryZonesApi.ts is excluded by !**/generated/**
  • src/contract/generated/apis/MarketsApi.ts is excluded by !**/generated/**
  • src/contract/generated/apis/UnitsApi.ts is excluded by !**/generated/**
📒 Files selected for processing (37)
  • public/i18n/en.json
  • public/i18n/vi.json
  • src/app/app.config.ts
  • src/app/core/api/envelope.ts
  • src/app/core/maps/location-picker.component.ts
  • src/app/core/navigation/navigation.data.ts
  • src/app/modules/admin/admin.routes.ts
  • src/app/modules/admin/admin.service.ts
  • src/app/modules/admin/admin.types.ts
  • src/app/modules/admin/analytics/analytics-dashboard.component.html
  • src/app/modules/admin/analytics/analytics-dashboard.component.ts
  • src/app/modules/admin/catalog/catalog-admin.service.ts
  • src/app/modules/admin/catalog/market-products.component.ts
  • src/app/modules/admin/catalog/markets.component.html
  • src/app/modules/admin/catalog/markets.component.ts
  • src/app/modules/admin/catalog/products.component.html
  • src/app/modules/admin/catalog/products.component.ts
  • src/app/modules/admin/logistics/delivery-zones.component.ts
  • src/app/modules/admin/logistics/hub-staff.component.html
  • src/app/modules/admin/logistics/hub-staff.component.ts
  • src/app/modules/admin/logistics/hubs.component.ts
  • src/app/modules/admin/logistics/logistics-admin.service.ts
  • src/app/modules/admin/order-groups/order-groups.component.html
  • src/app/modules/admin/order-groups/order-groups.component.ts
  • src/app/modules/admin/restaurants/restaurants-admin.component.html
  • src/app/modules/admin/restaurants/restaurants-admin.component.ts
  • src/app/modules/admin/settings/settings.component.html
  • src/app/modules/admin/settings/settings.component.ts
  • src/app/modules/admin/shared/admin-pagination.ts
  • src/app/modules/admin/shared/resource-crud.component.html
  • src/app/modules/admin/shared/resource-crud.component.ts
  • src/app/modules/admin/shared/resource-crud.types.ts
  • src/app/modules/admin/users/users-list.component.html
  • src/app/modules/admin/users/users-list.component.ts
  • src/app/modules/cart/checkout.component.scss
  • src/contract/openapi.json
  • src/styles/styles.scss

📝 Walkthrough

Walkthrough

Admin APIs and CRUD screens now support shared pagination, cursor/offset aggregation, assignment dialogs, combined location fields, typed auto-batching, cancellation dialogs, and updated settings and analytics forms.

Changes

Admin foundation

Layer / File(s) Summary
Pagination and envelope helpers
src/app/core/api/envelope.ts, src/app/modules/admin/shared/admin-pagination.ts, src/contract/openapi.json
Adds pagination extraction, cursor/offset fetch-all helpers, page conversions, and paginated API contracts.
Reusable CRUD and location controls
src/app/core/maps/location-picker.component.ts, src/app/modules/admin/shared/*, src/styles/styles.scss
Adds server-paged CRUD resources, assign-user dialogs, configurable location search binding, composite field layouts, and assignment button styling.

Catalog and logistics

Layer / File(s) Summary
Catalog pagination and filtering
src/app/modules/admin/catalog/catalog-admin.service.ts, src/app/modules/admin/catalog/products.component.*, src/app/modules/admin/catalog/markets.component.*
Moves products and markets to typed server-side paging, cascading category filters, and bulk option loading.
Logistics assignments and listings
src/app/modules/admin/logistics/*.ts, src/app/modules/admin/admin.routes.ts, src/app/core/navigation/navigation.data.ts
Adds hub-manager assignment and paginated logistics retrieval while removing hub-staff navigation and APIs.

Admin workflows

Layer / File(s) Summary
Admin service contracts
src/app/modules/admin/admin.service.ts, src/app/modules/admin/admin.types.ts
Adds pagination metadata, resilient assignment parsing, cursor retrieval, and typed auto-batch results.
Order-group batching and cancellation
src/app/modules/admin/order-groups/*, public/i18n/*.json
Adds search, agent assignment, auto-batch dialogs/results, target-date validation, and batch-cancellation confirmation.
Settings, analytics, and list screens
src/app/modules/admin/settings/*, src/app/modules/admin/analytics/*, src/app/modules/admin/users/*, src/app/modules/admin/restaurants/*
Combines settings into a dialog form, adds time/date pickers, and standardizes pagination handling across admin screens.

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

Possibly related PRs

Poem

A rabbit sorts pages, one hop at a time,
Batches bloom neatly in admin’s design.
Maps find their places, managers appear,
Settings save softly, with dates crystal-clear.
“Thump!” says the bunny—“the workflows now shine!”

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/admin-fetch-all-filters

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.

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.

1 participant