> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: getTimeSlots(reservationLocationId: string, date: Date, partySize: number, options: GetTimeSlotsOptions)

# Method package: wixTableReservationsV2

# Method menu location: wixTableReservationsV2 --> timeSlots --> getTimeSlots

# Method Link: https://dev.wix.com/docs/velo/apis/wix-table-reservations-v2/time-slots/get-time-slots.md

# Method Description:

Returns a list of time slots at a given restaurant on a given `date`, and their availability for a given `partySize`.

Without passing optional parameters, the list will contain a single time slot at the given `date`.
Use `slotsBefore` and `slotsAfter` to get additional time slots before and after the given `date`.

If you do not provide a `duration`, the duration will be calculated automatically based on the reservation location's configuration.
The reservation location's settings used to determine the duration are its `defaultTurnoverTime` and `turnoverTimeRules`. These specify how much time should be allotted for a reservation of a party of a given size.

The `startDate`s of time slots in the response are 15 minutes apart regardless of the `duration` provided.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Get time slots for a given date,location, and party size (page code) @description:

```javascript
import { timeSlots } from 'wix-table-reservations-v2';

/* Sample reservationLocationId value: 'fab8cc1f-31cf-462f-b5bb-392594624bf2'
 * Sample date value: new Date("2023-12-29T12:30:00Z")
 * Sample partySize value: 2
 */

timeSlots.getTimeSlots(reservationLocationId, new Date(date), partySize)
  .then((retrievedSlots) => {
    const firstStartDate = retrievedSlots.items[0].startDate;
    const firstStatus = retrievedSlots.items[0].status;

    console.log('Success! Retrieved the following time slots:', retrievedSlots);
    return retrievedSlots;
  })
  .catch((error) => {
    console.error(error);
    // Handle the error
  });

/* Promise resolves to:
 * {
 *   "timeSlots": [
 *     {
 *       "startDate": "2023-12-29T10:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T10:15:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T10:30:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T10:45:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *   },
 *     {
 *       "startDate": "2023-12-29T11:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T11:15:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T11:30:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T11:45:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:00:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:15:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:30:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:45:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:00:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:15:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:30:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:45:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:15:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:30:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:45:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T15:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     }
 *   ]
 * }
 */

```

## Get time slots with options (page code) 

```javascript
import { timeSlots } from 'wix-table-reservations-v2';

/* Sample reservationLocationId value: 'fab8cc1f-31cf-462f-b5bb-392594624bf2'
 * Sample date value: new Date("2023-12-29T12:30:00Z")
 * Sample partySize value: 2
 * 
 * Sample options value: 
 * {
 *   "duration": 5,
 *   "slotsAfter": 1,
 *   "slotsBefore": 0
 * }
 */

timeSlots.getTimeSlots(reservationLocationId, new Date(date), partySize)
  .then((retrievedSlots) => {
    const firstStartDate = retrievedSlots.items[0].startDate;
    const firstStatus = retrievedSlots.items[0].status;

    console.log('Success! Retrieved the following time slots:', retrievedSlots);
    return retrievedSlots;
  })
  .catch((error) => {
    console.error(error);
    // Handle the error
  });

/* Promise resolves to:
* {
*   "timeSlots": [
*     {
*       "startDate": "2023-12-29T12:30:00.000Z",
*       "duration": 5,
*       "status": "UNAVAILABLE",
*       "tableCombinations": [],
*       "manualApproval": false
*     },
*     {
*       "startDate": "2023-12-29T12:45:00.000Z",
*       "duration": 5,
*       "status": "UNAVAILABLE",
*       "tableCombinations": [],
*       "manualApproval": false
*     }
*   ]
* }
*/

```

## Get time slots for a given date,location, and party size (backend) @description:

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { timeSlots } from 'wix-table-reservations-v2';

/* Sample reservationLocationId value: 'fab8cc1f-31cf-462f-b5bb-392594624bf2'
 * Sample date value: new Date("2023-12-29T12:30:00Z")
 * Sample partySize value: 2
 */

export const myGetTimeSlotsFunction = webMethod(Permissions.Anyone, async (options) => {
  try {
    const retrievedSlots = await timeSlots.getTimeSlots(reservationLocationId, new Date(date), partySize)

    const firstStartDate = retrievedSlots.items[0].startDate;
    const firstStatus = retrievedSlots.items[0].status;

    console.log('Success! Retrieved the following time slots:', retrievedSlots);
    return retrievedSlots;
  } catch (error) {
    console.error(error);
    // Handle the error
  }

});

/* Promise resolves to:
 * {
 *   "timeSlots": [
 *     {
 *       "startDate": "2023-12-29T10:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T10:15:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T10:30:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T10:45:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *   },
 *     {
 *       "startDate": "2023-12-29T11:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T11:15:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T11:30:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T11:45:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:00:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:15:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:30:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T12:45:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:00:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:15:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:30:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T13:45:00.000Z",
 *       "duration": 90,
 *       "status": "UNAVAILABLE",
 *       "tableCombinations": [],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:15:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:30:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T14:45:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     },
 *     {
 *       "startDate": "2023-12-29T15:00:00.000Z",
 *       "duration": 90,
 *       "status": "AVAILABLE",
 *       "tableCombinations": [
 *         {
 *           "tableIds": [
 *             "1ed802ae-708f-4da6-9177-54c3df5d3dd5"
 *           ]
 *         }
 *       ],
 *       "manualApproval": false
 *     }
 *   ]
 * }
 */
```

## Create a held reservation with a given time, location, and party size. 

```javascript
/* This example requires the following elements:
 * A dropdown element named `locationDropdown`.
 * A dropdown element named `partySizeDropdown`.
 * A dropdown element named `timeSlotDropdown`.
 * A button named `confirmButton`.
 * A text element named `heldReservationNotification`.
 */

/**********************************************
 * Backend code - reservationLocations.web.js *
 **********************************************/

import { Permissions, webMethod } from 'wix-web-module';
import { locations } from 'wix-business-tools.v2';
import { elevate } from 'wix-auth';

export const getRestaurantLocation = webMethod(Permissions.Anyone, async (location_id) => {
  const elevatedGetLocation = elevate(locations.getLocation);

  try {
     const result = await elevatedGetLocation(location_id);
     return result;
   } catch (error) {
     console.error(error);
     // Handle the error
   }
});

/*************
 * Page code *
 *************/

import { reservationLocations } from 'wix-table-reservations.v2';
import { reservations } from 'wix-table-reservations.v2';
import { timeSlots } from 'wix-table-reservations.v2';

import { getRestaurantLocation } from 'backend/reservationLocations.web';

$w.onReady(async function () {
  $w('#timeSlotDropdown').hide();
  $w('#partySizeDropdown').hide();
  $w('#confirmButton').hide();
  $w('#heldReservationNotification').hide();

  //Get the list of reservation locations
  const myReservationLocationList = await (async () => {
    try {
      let fullListObject = await reservationLocations.listReservationLocations();
      return fullListObject.reservationLocations;
    } catch (error) {
     console.error(error);
     // Handle the error
   }
  })();

  //Create an array to hold names and values for our locations dropdown list
  let locationDropdownOptions = [];
  for (const object in myReservationLocationList){
    //Use the _id stored in the reservation location's location object to get the location's name from the `locations` service
    const locationObject = await getRestaurantLocation(myReservationLocationList[object].location._id);
    locationDropdownOptions.push({
      "label": locationObject.name, 
      "value": myReservationLocationList[object]._id
    })	
  }
  //Populate our dropdown list with the array
  $w("#locationDropdown").options = locationDropdownOptions;

  //Create an array to hold numbers and values for our party size dropdown list
  let partySizeDropdownOptions = [];
  for (let i = 1; i<10; i++){
    partySizeDropdownOptions.push({
      "label": String(i), 
      "value": String(i)
    })	
  }
  //Populate our dropdown list with the array
  $w("#partySizeDropdown").options = partySizeDropdownOptions;

  $w('#locationDropdown').onChange( (event) => {
    if ($w('#locationDropdown').value) {
      $w('#partySizeDropdown').show();
      $w('#timeSlotDropdown').hide()
      $w('#confirmButton').hide();
    }
  });

  $w('#partySizeDropdown').onChange( async (event) => {
    if ($w('#locationDropdown').value) {
      $w('#timeSlotDropdown').show()
      $w('#confirmButton').hide();

      const timeSlotDetails = {
        "reservationLocationId": $w('#locationDropdown').value, 
        "date": new Date(),
        "partySize": parseInt($w('#partySizeDropdown').value)
      };

      const timeSlotOptions = {
        "duration": 30,
	"slotsAfter": 8,
	"slotsBefore": 0
      };

      //Get the list of time slots according to the details and options above
      const availableTimeSlots = await (async () => {
        try {
          let fullListObject = await timeSlots.getTimeSlots(timeSlotDetails.reservationLocationId, timeSlotDetails.date, timeSlotDetails.partySize, timeSlotOptions);
          return fullListObject.timeSlots;
        } catch (error) {
          console.error(error);
          // Handle the error
        }
      })();

      //Create an array to hold numbers and values for our time slot dropdown list
      let timeSlotDropdownOptions = [];
      for (const timeSlot in availableTimeSlots){
        if(availableTimeSlots[timeSlot].status == "AVAILABLE"){
          timeSlotDropdownOptions.push({
            "label": String(availableTimeSlots[timeSlot].startDate), 
            "value": String(availableTimeSlots[timeSlot].startDate)
          })
        }	
      }
      //Populate our dropdown list with the array
      $w("#timeSlotDropdown").options = timeSlotDropdownOptions;
    }
  });

  $w('#timeSlotDropdown').onChange( async (event) => {
    if ($w('#timeSlotDropdown').value) {
      $w('#confirmButton').show();
    }
  });

  $w('#confirmButton').onClick( async (event) => {
    //Get the list of time slots according to the details and options above
    
    const createdHeldReservation = await (async () => {
      try {
        const reservationDetails = {
          "reservationLocationId": $w('#locationDropdown').value, 
          "startDate": new Date($w("#timeSlotDropdown").value),
          "partySize": parseInt($w('#partySizeDropdown').value)
        };

        return await reservations.createHeldReservation(reservationDetails);
      } catch (error) {
        console.error(error);
        // Handle the error
      }
    })();

    if(createdHeldReservation){
      $w('#heldReservationNotification').text = "Held reservation created successfully."
      $w('#heldReservationNotification').show();
    }
  });
});

```

---