This is the frontend application for the Periodic Tables project, a restaurant reservation management system. This project was developed using React and communicates with a backend API to manage reservations and tables for a fine dining restaurant.
- JSX
- React.js
- Axios
-
Clone the repository:
git clone https://github.com/yourusername/periodic-tables-frontend.git
-
Navigate to the project directory:
cd periodic-tables-frontend
-
Install the dependencies:
npm install
-
Create a
.env
file and set theREACT_APP_API_BASE_URL
to point to your backend API. -
Start the development server:
npm start
The application provides an interface for managing restaurant reservations and tables. Users can create, view, update, and cancel reservations, as well as manage table statuses.
Fetches a list of reservations based on the provided query parameters.
Parameters:
params
(Object): Query parameters for listing reservations.signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any[]>
: The list of reservations.
Fetches a list of all tables.
Parameters:
signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any[]>
: The list of tables.
Marks a table as finished.
Parameters:
table_id
(number): The ID of the table to mark as finished.signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any>
: The response data.
Updates the status of a reservation.
Parameters:
reservation_id
(number): The ID of the reservation to update.status
(string): The new status of the reservation.signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any>
: The response data.
Retrieves a reservation by its ID.
Parameters:
reservation_id
(number): The ID of the reservation to retrieve.signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any>
: The reservation data.
Updates a reservation.
Parameters:
reservation_id
(number): The ID of the reservation to update.data
(Object): The updated reservation data.signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any>
: The response data.
Cancels a reservation.
Parameters:
reservation_id
(number): The ID of the reservation to cancel.signal
(AbortSignal): Optional abort signal to cancel the request.
Returns:
Promise<any>
: The response data.
A custom hook to parse URL query parameters.
Usage Example:
const query = useQuery();
const date = query.get("date");
Returns:
URLSearchParams
: The URLSearchParams instance.
Formats the reservation_date
property of a reservation.
Parameters:
reservations
(Object|Object[]): A reservation or an array of reservations.
Returns:
Object|Object[]
: The formatted reservation(s).
Formats the reservation_time
property of a reservation.
Parameters:
reservations
(Object|Object[]): A reservation or an array of reservations.
Returns:
Object|Object[]
: The formatted reservation(s).
Validates the reservation date.
Parameters:
date
(string): The date to validate.
Returns:
string|null
: The validation error message, or null if valid.
Validates the reservation time.
Parameters:
date
(string): The date of the reservation.time
(string): The time of the reservation.
Returns:
string|null
: The validation error message, or null if valid.