Skip to content

fix(orders): align order status lifecycle between backend and frontend#190

Open
ArshVermaGit wants to merge 3 commits into
rdodiya:gssoc_developfrom
ArshVermaGit:gssoc_develop
Open

fix(orders): align order status lifecycle between backend and frontend#190
ArshVermaGit wants to merge 3 commits into
rdodiya:gssoc_developfrom
ArshVermaGit:gssoc_develop

Conversation

@ArshVermaGit
Copy link
Copy Markdown

Resolves #188

Description

This PR resolves a latent integration bug where the backend OrderStatus enum values were completely mismatched with the hardcoded lowercase status strings used on the frontend admin dashboard (e.g., cooking vs PREPARING, missing BILLED enum).

Once API integration is enabled, these mismatches would cause deserialization failures on status updates and component crashes on the order grid due to undefined status styling properties.


Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • Refactor (code change that improves structure without changing behavior)
  • New feature
  • Breaking change
  • Documentation update only

Key Changes

1. Backend Alignment

  • OrderStatus.java (Canonical): Added BILLED("Billed") to support the final billing stage before completion.
  • OrderStatus.java (Duplicate): Aligned the duplicate enum under the order.entity package to match the canonical one and marked it @Deprecated to prevent future misuse.
  • OrderServiceImpl.java: Added OrderStatus.BILLED to the list of active statuses in getActiveOrdersByBranch so billed orders awaiting payment remain visible on the dashboard.

2. Frontend Status Alignment

  • OrderCard.jsx & OrdersGrid.jsx:
    • Aligned all status config and mock data keys to use uppercase enum values matching the database representations (PENDING, PREPARING, READY, BILLED, COMPLETED).
    • Added styling and config for all 8 statuses including new styles/icons for CONFIRMED, SERVED, and CANCELLED.
    • Implemented a defaultStatus fallback to gracefully handle unknown statuses without crashing.
    • Corrected the commented-out API path to point to the secure endpoint (/secure/api/v1/orders/...) and corrected the HTTP method to PATCH.
  • LiveOrders.jsx (Dashboard): Updated dashboard feeds, mock status records, and badge helper to align with the new uppercase schema.
  • Orders.jsx & StatusLegend.jsx:
    • Updated filter tabs to use uppercase identifiers.
    • Added a dedicated filter for Cancelled orders.
    • Rebranded CookingPreparing to match the backend displayName.

3. Documentation

  • ProjectDetails.md: Updated the order lifecycle flowchart to reflect the actual agreed-upon flow:
    Pending → Confirmed → Preparing → Ready → Served → Billed → Completed

Verification & Test Plan

  • Verified all status transitions match the exact uppercase names defined in the JPA entities
  • Verified the dashboard Live Orders feed correctly maps all status colors
  • Grepped the entire codebase to confirm no lowercase status strings (cooking, billed, etc.) remain in any config map or filter
  • Tested locally — frontend compiles without errors, no undefined crashes on the order grid
  • Follows branch naming convention (fix/...) from CONTRIBUTING.md
  • Commit message follows conventional commits format
  • No unrelated files changed

… Add BILLED status to backend OrderStatus enum - Add BILLED to active order statuses list in OrderServiceImpl - Align all frontend status keys to uppercase backend enum values - Add support for CONFIRMED, SERVED, and CANCELLED statuses on the frontend - Update mock fallback data, dashboard components, and StatusLegend config - Fix commented API paths to target correct secure API endpoints - Deprecate duplicate OrderStatus enum in entity package - Update ProjectDetails.md order lifecycle documentation
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR aligns the order status lifecycle across the Java backend and the admin frontend by introducing the missing BILLED backend status and updating the frontend to use uppercase status identifiers compatible with EnumType.STRING, plus adding safer UI fallbacks.

Changes:

  • Backend: add BILLED to OrderStatus and include it in “active orders” retrieval; deprecate the duplicate enum under order.entity.
  • Frontend: replace lowercase status strings with uppercase enum-aligned values across dashboard components; add status styling coverage and an unknown-status fallback to avoid UI crashes.
  • Docs: update the documented order lifecycle flow and payment-flow wording to match the intended status progression.

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
RestroHub/src/main/java/com/restroly/qrmenu/order/service/impl/OrderServiceImpl.java Adds BILLED to the active-status list used by the active orders endpoint.
RestroHub/src/main/java/com/restroly/qrmenu/order/entity/OrderStatus.java Deprecates and aligns the duplicate enum to the canonical status set.
RestroHub/src/main/java/com/restroly/qrmenu/common/enums/OrderStatus.java Adds BILLED("Billed") to the canonical backend enum.
RestroHub-FrontEnd/src/components/admin/orders/Orders.jsx Updates filter tab IDs to uppercase enum values and adds a Cancelled filter.
RestroHub-FrontEnd/src/components/admin/orders/orderComponents/StatusLegend.jsx Updates legend labels (Cooking → Preparing) and adds legend entries for Completed/Cancelled.
RestroHub-FrontEnd/src/components/admin/orders/orderComponents/OrdersGrid.jsx Updates mock statuses to uppercase; updates commented API path; adjusts completed-status handling.
RestroHub-FrontEnd/src/components/admin/orders/orderComponents/OrderCard.jsx Updates status/action configs to uppercase enum values, adds more statuses, and adds a default fallback status.
RestroHub-FrontEnd/src/components/admin/dashboard/cards/LiveOrders.jsx Updates status badge config and fallback feed data to uppercase enum values.
ProjectDetails.md Updates the lifecycle diagram and payment-flow text to reference BILLED.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rdodiya
Copy link
Copy Markdown
Owner

rdodiya commented May 24, 2026

Hi @ArshVermaGit ,
Please review the suggestion points and update the necessary code changes and update the PR

ArshVermaGit and others added 2 commits May 24, 2026 19:19
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@ArshVermaGit
Copy link
Copy Markdown
Author

Hi @rdodiya ! The necessary code changes have been made. Please review the PR and merge it under GSSoC. Thanks!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Order status values are mismatched between backend enum and frontend — will break when API integration is enabled

3 participants