Skip to content

Booking confirmed#84

Closed
Kathify wants to merge 6 commits into
mainfrom
booking-confirmed
Closed

Booking confirmed#84
Kathify wants to merge 6 commits into
mainfrom
booking-confirmed

Conversation

@Kathify

@Kathify Kathify commented Jan 14, 2026

Copy link
Copy Markdown

Summary by CodeRabbit

  • New Features

    • Added visual feedback for booking operations with color-coded status messages and confirmation alerts showing reservation details.
  • Bug Fixes

    • Enhanced booking validation to require essential fields (first name, last name, date, time) before processing.
  • Refactor

    • Simplified controller flow and added automatic form reset after successful bookings.
  • Chores

    • Removed the Customer data model, affecting how customer information is stored and validated.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Jan 14, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

Deletes the Customer entity class from src/main/java/backend/entities/Customer.java and updates BookingController to add required-field validation, colorized status feedback, a confirmation Alert on success, and UI cleanup after booking.

Changes

Cohort / File(s) Summary
Entity Layer
src/main/java/backend/entities/Customer.java
Removed entire public Customer entity class (file deleted).
Booking UI Controller
src/main/java/frontend/controller/BookingController.java
Simplified SpinnerValueFactory initialization; added required-field checks (first name, last name, date, start time); set statusLabel text/color for errors and success; show confirmation Alert with booking details; reset/clear input fields and controls after successful booking; update exception handling to display errors in statusLabel.

Sequence Diagram(s)

(Skipped)

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Possibly related PRs

  • Service #63 — PR that modifies multiple backend components (CustomerFactory, CustomerRepo, CustomerService, BookingFactory) that reference the removed Customer entity.
  • Factories and service #56 — Adds BookingFactory.createBooking which accepts a Customer parameter and thus depends on the deleted Customer class.
  • Entities/relations #21 — Updates entity relationships (e.g., Booking) in ways that likely reference or assume the Customer entity removed here.

Poem

🐰
I hop and nibble through the code,
A class departed from the road.
Forms now check and labels gleam,
Alerts applaud the booking dream.
I twirl my ears — hooray, clean mode! 🥕

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Booking confirmed' is vague and does not clearly summarize the main changes in the pull request, which include deleting the Customer entity and enhancing the BookingController with validation and user feedback features. Use a more specific title that describes the primary technical changes, such as 'Remove Customer entity and enhance booking confirmation UI' or 'Add booking confirmation dialog and validation improvements'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ef7d6bd and 9964c30.

📒 Files selected for processing (1)
  • src/main/java/backend/entities/Customer.java
💤 Files with no reviewable changes (1)
  • src/main/java/backend/entities/Customer.java

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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 and usage tips.

@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: 1

🤖 Fix all issues with AI agents
In `@src/main/java/frontend/controller/BookingController.java`:
- Around line 76-78: The call dialogPane.lookup(".content.label") can return
null and cause a NullPointerException when setStyle() is invoked; update the
code around DialogPane dialogPane = alert.getDialogPane() to capture the lookup
result into a variable (e.g., Node contentLabel =
dialogPane.lookup(".content.label")), check contentLabel for null before calling
setStyle(), and only call setStyle() when contentLabel is non-null (optionally
log or ignore when null) to avoid the NPE.
🧹 Nitpick comments (3)
src/main/java/frontend/controller/BookingController.java (3)

43-48: Consider using isBlank() instead of isEmpty() for text validation.

isEmpty() returns false for whitespace-only strings like " ", which would pass validation but likely isn't intended. Using isBlank() (Java 11+) or getText().trim().isEmpty() would catch this edge case.

Suggested improvement
-            if (firstNameField.getText().isEmpty() || lastNameField.getText().isEmpty() ||
+            if (firstNameField.getText().isBlank() || lastNameField.getText().isBlank() ||
                     date == null || startTime == null) {

86-86: Inconsistent spinner default value.

The spinner is initialized with a default value of 2 in initialize() (line 31), but after a successful booking, it's reset to 1. Consider using the same default value for consistency.

Suggested fix
-            guestsSpinner.getValueFactory().setValue(1);
+            guestsSpinner.getValueFactory().setValue(2);

90-93: Consider user-friendly error messages.

Displaying raw exception messages (e.getMessage()) may expose internal details or show technical jargon to end users. For production, consider mapping exceptions to user-friendly messages while logging the full details for debugging.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a754c61 and 89dc2a8.

📒 Files selected for processing (2)
  • src/main/java/backend/entities/Customer.java
  • src/main/java/frontend/controller/BookingController.java
💤 Files with no reviewable changes (1)
  • src/main/java/backend/entities/Customer.java
🔇 Additional comments (1)
src/main/java/frontend/controller/BookingController.java (1)

29-35: LGTM!

The condensed spinner initialization is cleaner, and the time range setup (12:00-20:00) is appropriate for restaurant booking hours.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread src/main/java/frontend/controller/BookingController.java Outdated

@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

🤖 Fix all issues with AI agents
In `@src/main/java/frontend/controller/BookingController.java`:
- Line 31: The guests spinner default is inconsistent: it’s initialized with
SpinnerValueFactory.IntegerSpinnerValueFactory(1, 8, 2) (default 2) but later
reset to 1 after booking; update one side so both use the same default (pick
either default 1 or 2) — locate the initialization of guestsSpinner (where
SpinnerValueFactory.IntegerSpinnerValueFactory is used) and the post-booking
reset (the code that sets the spinner value after booking, e.g.,
guestsSpinner.getValueFactory().setValue(...) or a new ValueFactory) and make
them match (set the reset to the same default as the initial factory or change
the initial factory default to the reset value).
- Around line 52-74: BookingController uses restaurant from
RestaurantHandler.getCurrentRestaurant() without checking for null before
calling bookingService.bookTable(...) and restaurant.getName(), which can cause
NPEs; add a null check for restaurant at the start of the booking flow (before
calling bookTable and before referencing restaurant.getName()), and if null, set
statusLabel to an error message (red) and show an Alert with a clear message to
select a restaurant, then return early so bookTable and subsequent uses of
restaurant are never called.
🧹 Nitpick comments (1)
src/main/java/frontend/controller/BookingController.java (1)

93-96: Consider sanitizing exception messages for user display.

Displaying e.getMessage() directly could expose internal error details. If the BookingService throws exceptions with technical messages, consider providing a user-friendly fallback message.

Optional: User-friendly error handling
         } catch (Exception e) {
-            statusLabel.setText(e.getMessage());
+            String userMessage = e.getMessage() != null ? e.getMessage() : "An error occurred. Please try again.";
+            statusLabel.setText(userMessage);
             statusLabel.setStyle("-fx-text-fill: red;");
         }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89dc2a8 and ef7d6bd.

📒 Files selected for processing (1)
  • src/main/java/frontend/controller/BookingController.java
🔇 Additional comments (3)
src/main/java/frontend/controller/BookingController.java (3)

43-48: LGTM on validation logic.

The required field validation covers the essential booking information. Phone and email appear to be intentionally optional, which is acceptable for the booking flow.


85-91: LGTM on form cleanup.

The form reset logic correctly clears all fields after the confirmation alert is shown, ensuring the alert displays the booking details before clearing.


77-81: Good null-check fix.

The null check addresses the previous NPE concern. The CSS selector .content.label correctly targets a DialogPane content label element that has both the content and label style classes. This is the proper selector syntax for an element with multiple classes.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 8, 2)
);

guestsSpinner.setValueFactory(new SpinnerValueFactory.IntegerSpinnerValueFactory(1, 8, 2));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Inconsistent spinner default values.

The spinner is initialized with a default of 2 guests (line 31), but after booking it resets to 1 (line 89). Consider using a consistent default value.

Proposed fix to use consistent default value
-        guestsSpinner.getValueFactory().setValue(1);
+        guestsSpinner.getValueFactory().setValue(2);

Also applies to: 89-89

🤖 Prompt for AI Agents
In `@src/main/java/frontend/controller/BookingController.java` at line 31, The
guests spinner default is inconsistent: it’s initialized with
SpinnerValueFactory.IntegerSpinnerValueFactory(1, 8, 2) (default 2) but later
reset to 1 after booking; update one side so both use the same default (pick
either default 1 or 2) — locate the initialization of guestsSpinner (where
SpinnerValueFactory.IntegerSpinnerValueFactory is used) and the post-booking
reset (the code that sets the spinner value after booking, e.g.,
guestsSpinner.getValueFactory().setValue(...) or a new ValueFactory) and make
them match (set the reset to the same default as the initial factory or change
the initial factory default to the reset value).

Comment on lines 52 to +74
Booking booking = bookingService.bookTable(
restaurant,
firstNameField.getText(),
lastNameField.getText(),
emailField.getText(),
phoneField.getText(),
guestsSpinner.getValue(),
startTime,
endTime,
date
restaurant,
firstNameField.getText(),
lastNameField.getText(),
emailField.getText(),
phoneField.getText(),
guestsSpinner.getValue(),
startTime,
endTime,
date
);

statusLabel.setText(
"Booking confirmed! ID: " + booking.getId()
statusLabel.setText("Booking confirmed! ID: " + booking.getId());
statusLabel.setStyle("-fx-text-fill: green;");

Alert alert = new Alert(Alert.AlertType.INFORMATION);
alert.setTitle("Booking confirmed");
alert.setHeaderText(null);
alert.setContentText(
"Booking confirmed for " + firstNameField.getText() + " " + lastNameField.getText() + "\n" +
"Restaurant: " + restaurant.getName() + "\n" +
"Date & Time: " + date + " at " + startTime + "\n" +
"Guests: " + guestsSpinner.getValue()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Potential NullPointerException if restaurant is null.

restaurant is initialized from RestaurantHandler.getCurrentRestaurant() at line 16 and used without a null check. If no restaurant is selected, restaurant.getName() at line 72 (and the booking call at line 52) will throw an NPE.

Proposed fix to add null check in validation
-            if (firstNameField.getText().isEmpty() || lastNameField.getText().isEmpty() ||
-                    date == null || startTime == null) {
+            if (restaurant == null || firstNameField.getText().isEmpty() || lastNameField.getText().isEmpty() ||
+                    date == null || startTime == null) {
                 statusLabel.setText("Please fill in all required fields");
                 statusLabel.setStyle("-fx-text-fill: red;");
                 return;
             }
🤖 Prompt for AI Agents
In `@src/main/java/frontend/controller/BookingController.java` around lines 52 -
74, BookingController uses restaurant from
RestaurantHandler.getCurrentRestaurant() without checking for null before
calling bookingService.bookTable(...) and restaurant.getName(), which can cause
NPEs; add a null check for restaurant at the start of the booking flow (before
calling bookTable and before referencing restaurant.getName()), and if null, set
statusLabel to an error message (red) and show an Alert with a clear message to
select a restaurant, then return early so bookTable and subsequent uses of
restaurant are never called.

@Kathify Kathify closed this Jan 14, 2026
@Kathify
Kathify deleted the booking-confirmed branch January 14, 2026 21:06
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