Skip to content

Pick reservation dates in a Vue component - #1165

Merged
KrzysztofPajak merged 5 commits into
developfrom
feature/reservation-picker-vue
Dec 1, 2026
Merged

KrzysztofPajak merged 5 commits into
developfrom
feature/reservation-picker-vue

Conversation

@KrzysztofPajak

@KrzysztofPajak KrzysztofPajak commented Dec 1, 2026 •

Copy link
Copy Markdown
Member

Type: feature

Issue

The storefront picked reservation dates with window.Reservation (theme/common.js): three Pikaday instances with wrong parse functions (day and month swapped, month not zero-based), disableDayFn evaluated before the AJAX data arrived, arrays growing through concat, alert(error) and a fixed MM/DD/YYYY format. The quick view called it with hardcoded URLs and an English message. It also could not use what R12 (#1164) offers: the last end date one resource can take.

Solution

  • New <reservation-picker> component (vueapp/src/views/reservation-picker.js + .css) used by the product page and the quick view, fed by GET Product/ReservationAvailability:
    • day product: one range; after a start date only the end dates up to its last reachable end date are offered (IncBothDate allows a one-day range). Reads a year from the month shown and reads on from a start whose run reaches the end of the read;
    • hour/minute product: a date, then its free slots; the parameter dropdown filters them (the parameter is shown next to the time when no filter is chosen). Day products show no parameter dropdown: the cart books a range on one resource whatever its parameter, so it filtered nothing before either;
    • month and dates in the store's culture (CultureInfo.CurrentCulture), first day Monday as before; labels from the JSON island;
    • editing a cart item (product page updatecartitemid or the cart's quick view) opens on the item's dates/slot and passes shoppingCartItemId, so the item keeps its own slots;
    • after an add to cart the picker asks again what is free (grand:reservation-booked event). refreshreservation is now sent for day products too, since R6 a range in the cart holds its slots;
    • the price is re-read through productdetails_attributechange when a range is complete, scoped to the quick view when the picker is in it.
  • UX: a range previews its end under the pointer; Start/End fields show the weekday and outline the one the next click fills; free days bold, today underlined; an hour product opens on its first date with slots, slots are buttons (with the parameter under the time when no filter is set), and up to 6 parameters are a switch with "All" (Common.All) instead of a dropdown with an empty option. Labels reuse Products.ReservationStartDate/EndDate, no new resources.
  • Islands: the product page picker is its own vue-island="reservationInfo"; the quick view modal declares reservationQuickView. One reservationInfo view registers each payload under the name it carries.
  • The cart and the attribute change parse yyyy-MM-dd only (ParseReservationDates), no fallback for MM/dd/yyyy.
  • Removed: window.Reservation, behaviours/reservation-info.js, the quick view's initReservationQV, the ReservationFullDate/Year/Month fields, Pikaday (package, CSS, window.Pikaday), ProductController.GetDatesForMonth and the availableToCustomerId parameter of GetProductReservationsByProductId that only it used.
  • Theme.Modern has no reservation views of its own. Theme.Nordic's product page uses the shared partial; its CSS selectors for the old #reservationDatepicker and parameter label now target the new markup.
  • Bundles rebuilt (npm run build).

Breaking changes

  • ProductController.GetDatesForMonth is removed; use Product/ReservationAvailability.
  • reservationDatepickerFrom / reservationDatepickerTo are read as yyyy-MM-dd only. A custom theme or client posting MM/dd/yyyy gets no dates.
  • window.Reservation and window.Pikaday no longer exist.
  • IProductReservationService.GetProductReservationsByProductId lost its last optional parameter availableToCustomerId.

Testing

Unit: Grand.Web.Tests (712), Grand.Business.Catalog.Tests (1187), Grand.Business.Checkout.Tests (1168), Grand.Web.Admin.Tests (2199) pass. The visibility tests of the removed endpoint (catalog manager preview, availability window) moved to the ReservationAvailability tests; new ReservationDatesTests cover the ISO parsing. eslint src clean.

E2E on the shared reservations DB (Theme.Nordic, dark and light mode):

  1. Tent (day, IncBothDate=false): start Wed 12/09 offers ends up to 12/24 only (Tent 1; 24–26 Dec have no slots); range 12/09–12/24 posts ISO dates, price 15 × 24.65 = 369.75; add to cart → the cart stores 12/09–12/24 at store midnight, and the calendar drops the Wednesdays 9, 16, 23 (Tent 2 has none).
  2. Cart → edit the tent item: the quick view opens on 12/09–12/24 with the item's own Wednesdays free; change to 12/10–12/15 → cart shows the new dates, 5 × 24.65 = 123.25.
  3. Climbing wall (hour): Sundays and 24–27 Dec disabled, slots 09:00–16:00 store time; Beginner filter keeps the chosen date and halves the slots; add 10:00 → it disappears from the list.
  4. Quick view of the e-bike (day, IncBothDate=true) from the tent page: 12/14–12/14 allowed; 12/14–12/16 → quick view price 3 × 41.65 = 124.95, the page price behind it unchanged.

Also fixed here (found while testing and in review):

  • Shortening an edited range left the dropped days held until the hold expired: ProductReservationService.TryHold returned early when every slot of the new range was already freshly held by the item, so it never released the others (seen: item edited from 12/09–12/24 to 12/10–12/15, Tent 1 kept 12/09–12/23). The early return now also requires that the item holds nothing outside its choice. New test TryHold_RangeShortenedWithinAFreshHold_ReleasesTheDroppedDays (fails without the fix). E2E: after the same edit only 12/10–12/14 stay held.
  • Quick view attribute change threw for non-simple products (Cannot read properties of undefined (reading 'ProductPrice') in wwwroot/theme/script/app.js): every type other than simple was looked up among AssociatedProducts. Now only a grouped product's associated product is priced that way, any other type prices itself. E2E: e-bike quick view, ticking "Pannier bags" moves the price 41.65 → 46.75, no console error.
  • Picker (review): resetting the parameter when the quick view changes product fired the parameter watcher, whose refresh cleared the edited cart item's dates/slot — the parameter now refreshes on the select's change only (E2E: pick a parameter in a quick view, close, edit the cart's hour item → its slot is still selected). A read answered after a refresh no longer counts as failed, so it leaves the newer read's month mark alone.

The product page and the quick view render one <reservation-picker> fed by
ReservationAvailability: a day product picks a range limited to the last end
date one resource can take, an hour product a date and a slot, the parameter
filtering the slots. Dates are shown in the store's culture and posted as
yyyy-MM-dd, the only format the cart reads now.

window.Reservation, Pikaday and GetDatesForMonth are gone, with the
availableToCustomerId filter only that endpoint used. After an add to cart
the picker asks again what is free, for day products too.
Copilot AI balanced review requested due to automatic review settings December 1, 2026 16:05

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Active reservation-picker bugs prevent retries after failed availability requests, clear saved selections when editing cart items, and leave preserved dates without refreshed slots after filter changes.

3 open issues
2 files not reviewed
  • src/Web/Grand.Web/vueapp/package-lock.json: Generated file
  • src/Web/Grand.Web/wwwroot/bundles/libs.css: Generated file
What changed in this PR

Replaces the storefront’s Pikaday reservation controls with a shared Vue component that uses the range-aware availability API introduced in #1164.

Changes:

  • Adds localized date-range and time-slot selection for product pages and quick views, including cart-item editing and availability refresh.
  • Standardizes submitted dates on yyyy-MM-dd and removes the legacy calendar endpoint, scripts, and Pikaday dependency.
  • Updates reservation tests and Nordic styling for the new picker.

Review used the supplied diffs; the repository snapshot was unavailable, and no verification commands ran.

File Description
src/​Web/​Grand.Web/​wwwroot/​theme/​script/​app.js Removes legacy quick-view reservation initialization.
src/​Web/​Grand.Web/​vueapp/​src/​views/​reservation-picker.js Adds the shared reservation picker and availability handling.
src/​Web/​Grand.Web/​vueapp/​src/​views/​reservation-picker.css Styles the calendar, ranges, and slots.
src/​Web/​Grand.Web/​vueapp/​src/​theme/​common.js Removes the legacy reservation implementation.
src/​Web/​Grand.Web/​vueapp/​src/​theme/​axios-cart.js Dispatches reservation refresh events after booking.
src/​Web/​Grand.Web/​vueapp/​src/​main.js Registers the picker and removes Pikaday imports and globals.
src/​Web/​Grand.Web/​vueapp/​src/​behaviours/​reservation-info.js Deletes the legacy picker bootstrap.
src/​Web/​Grand.Web/​vueapp/​src/​behaviours/​quick-view-modal.js Removes the legacy reservation modal hook.
src/​Web/​Grand.Web/​vueapp/​package.json Removes the Pikaday dependency.
src/​Web/​Grand.Web/​vueapp/​package-lock.json Removes Pikaday’s locked package entry.
src/​Web/​Grand.Web/​Views/​Shared/​Partials/​QuickView/​ReservationInfo.cshtml Uses the shared picker in quick views.
src/​Web/​Grand.Web/​Views/​Shared/​Partials/​ProductQuickView.cshtml Supplies quick-view picker routes, culture, and labels.
src/​Web/​Grand.Web/​Views/​Product/​Partials/​ReservationInfo.cshtml Hosts the product-page picker and its data island.
src/​Web/​Grand.Web/​Extensions/​MappingExtensions.cs Parses reservation dates strictly as ISO dates.
src/​Web/​Grand.Web/​Controllers/​ProductController.cs Removes GetDatesForMonth.
src/​Web/​Grand.Web/​Controllers/​ActionCartController.cs Requests availability refresh for day reservations too.
src/​Tests/​Grand.Web.Tests/​Extensions/​ReservationDatesTests.cs Tests accepted and rejected date formats.
src/​Tests/​Grand.Web.Tests/​Controllers/​ProductControllerReservationDatesTests.cs Removes tests for the retired endpoint.
src/​Tests/​Grand.Web.Tests/​Controllers/​ProductControllerReservationAvailabilityTests.cs Adds preview and availability-window coverage.
src/​Tests/​Grand.Business.Checkout.Tests/​Commands/​Handlers/​Orders/​PlaceOrderCommandHandlerTests.cs Updates verification for the simplified service signature.
src/​Tests/​Grand.Business.Catalog.Tests/​Services/​Products/​ProductReservationServiceTests.cs Removes coverage for the deleted customer-filter parameter.
src/​Plugins/​Theme.Nordic/​Content/​css/​product.css Targets the new picker markup.
src/​Modules/​Grand.Module.Installer/​Services/​InstallDataProducts.Outdoor.cs Updates a comment to name the replacement endpoint.
src/​Business/​Grand.Business.Core/​Interfaces/​Catalog/​Products/​IProductReservationService.cs Removes the obsolete optional customer-filter parameter.
src/​Business/​Grand.Business.Catalog/​Services/​Products/​ProductReservationService.cs Removes the corresponding legacy query filter.

Review effort: Balanced

Comment on lines +156 to +158
parameter() {
this.refresh()
},
lastEndDates: {}, readTo: {}, readRanges: [], slots: {}, readMonths: {},
start: null, end: null, reservationId: null
})
this.read()
Comment on lines +243 to +244
const range = { from, to: addDays(from, DAYS_READ) }
this.readRanges.push(range)
support added 4 commits December 1, 2026 17:18
TryHold returned early when every slot of the item's new choice was already
freshly held by it, so a range edited to fewer days kept holding the days it
dropped until the hold expired. The early return now also requires that the
item holds nothing outside its choice.
Every type other than simple was looked up among the associated products,
which only a grouped product has, so a reservation or auction product with
attributes threw in the quick view and its price never changed.
Resetting the parameter for another product fired the parameter watcher, whose
refresh cleared the dates or slot of the cart item being edited; the parameter
now refreshes on the select's change only. A read answered after a refresh no
longer counts as failed, so it leaves the newer read's month mark alone.
A range previews where it would end under the pointer, and the start and end
fields show their weekday and which one the next click fills. Free days read
bold, today is underlined. An hour product opens on its first date with slots,
the slots are buttons, and a few parameters are a switch with "All" instead
of a dropdown with an empty option. No new resources.
@KrzysztofPajak
KrzysztofPajak merged commit e366a80 into develop Dec 1, 2026
8 of 9 checks passed
@KrzysztofPajak
KrzysztofPajak deleted the feature/reservation-picker-vue branch December 1, 2026 16:41
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