@happychef/algorithm 1.0.3 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -69,10 +69,11 @@ function timeHasGiftcard(data, dateStr, timeStr, giftcard) {
69
69
  * @param {string} dateStr - The date string in "YYYY-MM-DD" format.
70
70
  * @param {Array} reservations - An array of reservation objects.
71
71
  * @param {number} guests - The number of guests for the reservation.
72
+ * @param {Array} blockedSlots - Optional array of blocked time slots to exclude.
72
73
  * @param {string|null} selectedGiftcard - The selected giftcard (if any).
73
74
  * @returns {boolean} - Returns true if the date passes all checks to be available.
74
75
  */
75
- function isDateAvailableWithTableCheck(data, dateStr, reservations, guests, selectedGiftcard) {
76
+ function isDateAvailableWithTableCheck(data, dateStr, reservations, guests, blockedSlots = [], selectedGiftcard = null) {
76
77
  // 0) Optionally filter by selected menu item's date range (only when normalOpeningTimes = false)
77
78
  const currentItem = typeof window !== 'undefined' ? window.currentReservationTicketItem : null;
78
79
  if (
@@ -112,7 +113,7 @@ function isDateAvailableWithTableCheck(data, dateStr, reservations, guests, sele
112
113
  console.log(`Table assignment is ${isTableAssignmentEnabled ? 'ENABLED' : 'DISABLED'} for date ${dateStr}`);
113
114
 
114
115
  // 1) First, do the standard day-level checks (including simple giftcard check).
115
- const basicDateAvailable = isDateAvailable(data, dateStr, reservations, guests, selectedGiftcard);
116
+ const basicDateAvailable = isDateAvailable(data, dateStr, reservations, guests, blockedSlots, selectedGiftcard);
116
117
  if (!basicDateAvailable) {
117
118
  console.log(`Date ${dateStr} fails basic availability check`);
118
119
  return false;
@@ -126,7 +127,7 @@ function isDateAvailableWithTableCheck(data, dateStr, reservations, guests, sele
126
127
 
127
128
  // 2) Get all available timeblocks for this date
128
129
  console.log(`Getting available timeblocks for ${dateStr}`);
129
- const availableTimeblocks = getAvailableTimeblocks(data, dateStr, reservations, guests);
130
+ const availableTimeblocks = getAvailableTimeblocks(data, dateStr, reservations, guests, blockedSlots, selectedGiftcard);
130
131
  console.log(`Found ${Object.keys(availableTimeblocks).length} available timeblocks before table check`);
131
132
 
132
133
  // If no timeblocks are available at all, exit early
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@happychef/algorithm",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Restaurant and reservation algorithm utilities",
5
5
  "main": "index.js",
6
6
  "author": "happy chef",