Skip to content

Nuria Lopez - #14

Open
nurialrivas wants to merge 8 commits into
MewsSystems:mainfrom
nurialrivas:main
Open

Nuria Lopez#14
nurialrivas wants to merge 8 commits into
MewsSystems:mainfrom
nurialrivas:main

Conversation

@nurialrivas

@nurialrivas nurialrivas commented Apr 19, 2026

Copy link
Copy Markdown

Nuria Lopez

  • RE#001# Completed

  • RE#002# Completed

  • RE#003# Completed

Task Report

While the commit history reflects the order in which I approached the tasks, it's not an accurate reflection of the time spent working on them due to time breaks between tasks. The actual productive time spent solving the 3 tasks was 3-4 hours, excluding initial set up, plus an extra hour investigating and applying the Copilot suggestions that made sense.

The majority of the time went to tasks RE#001 and RE#003, around 2.5 hours between the two of them. After commiting RE#002, around half an hour was used for polishing both RE#001 and RE#002.
Due to the time constrains, some important parts of the development process were not included, such us tests, performance improvements, fine-grained error handling, date mismatches or better user experience.

Notes

React development was done with the assistance of AIs. While I do have some past experience developing in React, it's been some years since I last touched it, and given that it's constantly and quickly evolving, it would have been impossible to properly get myself up to date in the time given for the challenge.

Nuria Lopez added 7 commits April 17, 2026 21:05
* Block, in the date picker, the dates already booked to prevent the new customer from selecting them
* Add double check in the backend booking endpoint, if received dates collide with another reservation of that room the endpoint returns a 400.
* Created endpoint to return all the reservations for a given room.
- API
    + Added FluenValidations package to validate api requests
    + Added Reservation validator
    * Updated ReservationRepository to actually save the reservations in the DB
    + New endpoint in GuestController to allow adding guests through the API
        * Updated DB table to include a column for the surname
        * Updated query to incude the surname
- UI
    * Updated bookRoom function in api to actually call the backend API
        + Added error handling logic to display the actual messages when the response status code is 400
    + Added error toast
    * Updated ReservationPage to use the error toast when the response is not successful.
*
* Block, in the date picker, the dates already booked to prevent the new customer from selecting them
* Add double check in the backend booking endpoint, if received dates collide with another reservation of that room the endpoint returns a 400.
* Created endpoint to return all the reservations for a given room.
- API
    * Check date collision in a DB transaction rather than by making 2 DB calls in the controller
     + Create new exception to throw when the previous collision happens
    * Ammend return type of endpoints that return a list.
    * Remove unnecessary null checks in ReservationRepository

- UI
    * Always use formatted room number in ReservationPage
    * Memoize isDateBlocked function
- API
    + Added endpoint in ReservationController to retrieve upcoming reservations
    * Replaced Console.WriteLine with ILogger methods
    + Implemented authorisation and authentication in StaffController using Claims
    * Configured Cookie authentication in Program
    * Fixed some typos and messages from previous commits.

-UI
    + Added functions to retrieve upcoming reservations to the Reservations api
    + Created staff page to display upcoming reservations
    + Created Staff api to handle login
Copilot AI review requested due to automatic review settings April 19, 2026 22:17

Copilot AI 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.

Pull request overview

This PR expands the reservation system with staff authentication + a staff dashboard, implements real reservation booking with overlap detection, and improves the UI booking flow with error toasts and date blocking.

Changes:

  • Add staff login (cookie auth) and a /staff dashboard showing upcoming reservations.
  • Implement reservation creation against the API, plus endpoints for upcoming/room reservations and client-side date blocking.
  • Add FluentValidation-based reservation validation and introduce guest surname persistence.

Reviewed changes

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

Show a summary per file
File Description
ui/src/utils/toasts.tsx Adds an error-toast hook for displaying booking failures.
ui/src/components/ErrorToast.tsx Introduces an error toast component consistent with existing toast styling.
ui/src/reservations/api.ts Implements booking POST + adds queries for upcoming/room reservations.
ui/src/reservations/ReservationPage.tsx Handles booking success/failure with success/error toasts and passes reservations to the modal.
ui/src/reservations/BookingDetailsModal.tsx Blocks already-reserved dates using fetched room reservations.
ui/src/staff/api.ts Adds staff login + auth check hooks.
ui/src/staff/StaffLoginModal.tsx Adds a login modal that triggers staff auth + navigation.
ui/src/staff/StaffDashboardPage.tsx Adds a staff-only page to view upcoming reservations.
ui/src/router.tsx Registers the new /staff route.
ui/src/LandingPage.tsx Replaces placeholder login with the real staff login modal trigger.
ui/package-lock.json Bumps UI package version.
api/api.csproj Adds FluentValidation + auto-validation packages.
api/Program.cs Wires up FluentValidation and cookie authentication/authorization.
api/Controllers/StaffController.cs Implements staff login and an authorized auth-check endpoint.
api/Controllers/ReservationController.cs Adds endpoints for upcoming/room reservations and improves logging/conflict handling.
api/Controllers/GuestController.cs Adds guest creation endpoint.
api/Repositories/ReservationRepository.cs Implements reservation creation with overlap check + adds upcoming/room queries.
api/Repositories/GuestRepository.cs Updates guest insert to include surname.
api/Models/Validators/ReservationValidator.cs Adds FluentValidation rules for reservations.
api/Models/Errors/ReservationConflictException.cs Adds a dedicated exception for reservation overlaps.
api/Utils/GuidTypeHandler.cs Adds a Dapper type handler for GUIDs stored as strings.
api/Db/Setup.cs Updates DB schema to include guest surname column.
api/.gitignore Ignores additional local/dev artifacts.
Files not reviewed (1)
  • ui/package-lock.json: Language not supported

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

{
RuleFor(r => r.Start)
.NotEmpty()
.GreaterThan(DateTime.UtcNow.Date)
Console.WriteLine("An error occured when trying to book a reservation:");
Console.WriteLine(ex.ToString());

Logger.LogError(ex, "An error occured when trying to book a reservation");
Comment on lines +33 to +38
catch (Exception ex)
{
Console.WriteLine("An error occured when trying to register a new guest:");
Console.WriteLine(ex.ToString());

return BadRequest("Invalid guest data");
Comment on lines +80 to +82
_db.Open();
using var transaction = _db.BeginTransaction();
try
Comment thread ui/src/reservations/api.ts Outdated
Comment on lines +41 to +49
if (error instanceof HTTPError && error.response.status === 400) {
const body = await error.response.json<unknown>();
if (body && typeof body === "object" && "errors" in body) {
const messages = Object.values(body.errors as Record<string, string[]>).flat();
throw new BookingError(messages);
}
if (typeof body === "string") {
throw new BookingError([body]);
}
return _db.QuerySingleAsync<Guest>(
"INSERT INTO Guests(Email, Name) Values(@Email, @Name) RETURNING *",
"INSERT INTO Guests(Email, Name, Surname) Values(@Email, @Name, @Surname) RETURNING *",
newGuest
Comment thread api/Controllers/GuestController.cs Outdated
}
catch (Exception ex)
{
Console.WriteLine("An error occured when trying to register a new guest:");
Comment thread api/Program.cs
{
options.Cookie.Name = "access";
options.Cookie.HttpOnly = true;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
Comment thread api/Db/Setup.cs
Comment on lines 22 to 27
$@"
CREATE TABLE IF NOT EXISTS Guests (
{nameof(Guest.Email)} TEXT PRIMARY KEY NOT NULL,
{nameof(Guest.Name)} TEXT NOT NULL
{nameof(Guest.Name)} TEXT NOT NULL,
{nameof(Guest.Surname)} TEXT NOT NULL
);
- API
    * Fixed typos
    * Replaced Console.Writelilne with ILogger
    * Use dynamic comparisson in ReservationValidator (I applied the change because the outcome will be the same, but it should not be necessary according to the FluentValidation repo)
    * Registered all repositories and DB as Scoped to prevent headaches.

- UI
    * Expand error handling
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.

2 participants