Repository navigation
Project 3 Wiki
Welcome to the project-3-team-9b repository! This project is a software solution designed for Panda Express to enhance operational efficiency and improve customer engagement. The system includes the following major components:
- Static Menu Board: A visually engaging menu display that updates in real-time.
- POS System with Manager Statistics: A robust point-of-sale system allowing managers to track inventory, employee productivity, and sales.
- Customer Ordering Kiosk: A self-service kiosk for customers to place their orders quickly and easily.
This sections provides the breakdown and organization of our project. While it is clearly large that is due to the fact that this is a very large project and took roughly two months of effort. It is import to note that many of the small file received a quick and concise summary while the larger files that we spent more time on received the class and function breakdown. The following is the project breakdown into the several folders and many files that make it up:
Contains preprocessed datasets used to simulate customer queries and provide assistant responses for training or testing conversational assistants.
-
dataset_prepared.jsonl: A JSONL file containing simulated conversations about Panda Express menu items.
Contains meeting notes documenting the progress and tasks discussed during Scrum meetings.
-
Scrum 10/25.pdf: Discusses the first meeting, where the team set up project organization and task assignments. -
Scrum 10/28.pdf: Reviews the first sprint's progress, including database interaction and basic feature implementation like the login page. -
Scrum 11/4.pdf: Reflects on Sprint 1 accomplishments, detailing progress on manager and cashier views, and planning for Sprint 2. -
Scrum 11/6.pdf: Discusses planning for Sprint 2, task assignments, and issues to address during the next phase of development. -
Scrum 11/13.pdf: Updates the team on tasks for accessibility, styling, and APIs, as well as refining views and functionality. -
Scrum 11/18.pdf: Focuses on progress with the shopping cart and manager view, along with accessibility improvements. -
Scrum 11/20.pdf: Marks the completion of shopping cart functionality, Google authentication, and plans for dynamic pricing. -
Scrum 11/22.pdf: Discusses major updates, including the manager view and additional features like chatbot API integration. -
Scrum 11/25.pdf: A final check-in before the presentation, focusing on completing and testing tasks, especially related to the manager view and chatbot dataset.
Contains all image assets used across the project, including menu items, weather icons, and system graphics.
-
Menu Items:
-
ApplePieRoll.png: Image of Panda Express Apple Pie Roll dessert. -
BeijingBeef.png: Beijing Beef dish with crispy beef and peppers. -
BlackPepperSirloinSteak.png: Black Pepper Sirloin Steak entree. -
BroccoliBeef.png: Broccoli and beef entree. -
ChickenEggRoll.png: Fried Chicken Egg Rolls. -
ChowMein.png: Panda Express Chow Mein side dish. -
CreamCheeseRangoon.png: Cream Cheese Rangoons appetizer. -
Dumplings.png: Dumplings served as an appetizer. -
FriedRice.png: Classic Fried Rice side dish. -
GrilledTeriyakiChicken.png: Grilled Teriyaki Chicken entree. -
HoneySesameChickenBreast.png: Honey Sesame Chicken Breast entree. -
HoneyWalnutShrimp.png: Honey Walnut Shrimp entree. -
HotOnesBlazingBourbonChicken.png: Blazing Bourbon Chicken entree from Hot Ones. -
KungPaoChicken.png: Kung Pao Chicken entree with peanuts and veggies. -
MushroomChicken.png: Mushroom Chicken entree with vegetables. -
StringBeanChickenBreast.png: String Bean Chicken Breast entree. -
SweetFireChickenBreast.png: Sweet Fire Chicken Breast entree with pineapple. -
TheOriginalOrangeChicken.png: Iconic Original Orange Chicken entree. -
VeggieOrangeChicken.png: Plant-based Veggie Orange Chicken entree. -
VeggieSpringRoll.png: Fried Veggie Spring Rolls served as an appetizer. -
WhiteSteamedRice.png: Classic White Steamed Rice side dish.
-
-
Drinks:
-
Coca-Cola.png: Glass of Coca-Cola. -
DietCoke.png: Glass of Diet Coke. -
IcedTea.png: Glass of iced tea. -
MinuteMaidLemonade.png: Glass of Minute Maid Lemonade. -
Sprite.png: Glass of Sprite. -
FantaOrange.png: Glass of Fanta Orange soda. -
BottledWater.png: Bottled water available in Panda Express.
-
-
Weather Icons:
-
cloudy.png: Icon representing cloudy weather. -
rainy.png: Icon representing rainy weather. -
sunny.png: Icon representing sunny weather.
-
-
Other Pictures:
-
a_la_carte.png: Represents the customizable a la carte menu. -
bigger_plate.png: Panda Express Bigger Plate combination image. -
Bowl.png: Example of a Panda Express bowl option. -
ShoppingCart.png: Icon representing a shopping cart. -
MenuBoard.png: Screenshot of the Panda Express menu board. -
Plate.png: Example of a Panda Express plate option.
-
-
_components/:-
login.js: Manages Google Login, decodes JWT tokens, and fetches employee data from the backend. -
logout.js: Handles Google Logout by clearing session data and providing user feedback. -
shoppingCart.tsx: Displays and manages the shopping cart, including item adjustments and dynamic price updates. -
shoppingData.tsx: Manages the data structure and logic for items in the shopping cart, including quantity updates and data synchronization.
-
-
api/:-
chatBot/:-
route.ts:-
Function:
POST(req: Request)- Purpose: Handles POST requests to the API route, processes user input, and returns a response from the OpenAI API.
-
Parameters:
-
req(Request): The incoming HTTP request object containing the user's message in the body.
-
-
Logic:
- Parses the request body to extract the
messagefield. - Validates the presence of the
message. If missing, returns a400 Bad Requestresponse with an error message. - Sends the message to the OpenAI API using the fine-tuned GPT-3.5-turbo model.
- Retrieves the assistant's reply from the API response.
- If the reply is missing, returns a
500 Internal Server Errorresponse with an error message. - Returns the generated reply in a JSON response.
- Parses the request body to extract the
-
Error Handling:
- Logs errors to the console and returns a
500 Internal Server Errorresponse if the request fails.
- Logs errors to the console and returns a
-
Function:
-
-
checkout/:-
route.ts:-
Function:
POST(request: Request)- Purpose: Processes a list of food items from the request, decrements their quantities in the database, and handles errors with transaction management.
-
Parameters:
-
request(Request): The incoming HTTP request containing a JSON array of food names.
-
-
Logic:
- Establishes a connection to the PostgreSQL database using a connection pool.
- Begins a transaction with
BEGIN. - Iterates through the array of food names from the request body:
- Executes an
UPDATEquery to decrement the quantity of each food item. - Throws an error if the food item is not found in the database.
- Executes an
- Commits the transaction if all updates succeed.
- Rolls back the transaction if any error occurs during processing.
- Releases the database client after the operation.
- Returns a success message or an error response depending on the outcome.
-
Error Handling:
- Logs and rolls back the transaction on errors during processing.
- Logs errors in establishing database connections or transaction handling.
- Returns a
500 Internal Server Errorresponse if the operation fails.
-
Function:
-
-
decrementIngredients/:-
route.ts:-
Function:
POST(request: Request)- Purpose: Processes a list of customer orders, retrieves the ingredients required for each food item, and updates the ingredient inventory in the database.
-
Parameters:
-
request(Request): The incoming HTTP request containing a JSON object with anordersarray.
-
-
Logic:
- Extracts the
ordersarray from the request body. - Establishes a connection to the PostgreSQL database using a connection pool.
- Begins a transaction with
BEGIN. - Iterates through each order and its associated items:
- Retrieves the
food_idfor each item. - Fetches the
ingredient_idfor all ingredients required for the food item. - Decrements the quantity of each ingredient in the database.
- Retrieves the
- Commits the transaction if all updates succeed.
- Rolls back the transaction if an error occurs during processing.
- Releases the database client after the operation.
- Returns a success message or an error response depending on the outcome.
- Extracts the
-
Error Handling:
- Logs errors encountered during database interactions or transaction handling.
- Returns a
500 Internal Server Errorresponse if the operation fails.
-
Function:
-
-
employeeLookup/:-
route.ts:-
Function:
POST(request: Request)- Purpose: Looks up an employee in the database by email and returns their details.
-
Parameters:
-
request(Request): The incoming HTTP request containing a JSON object with anemailfield.
-
-
Logic:
- Extracts the
emailfield from the request body. - Validates the presence of the
email. If missing, returns a400 Bad Requestresponse. - Queries the
employeestable in the database for the provided email. - If a match is found, returns the employee's details (
employee_id,name,position,email) in a JSON response.
- Extracts the
-
Error Handling:
- If no match is found, returns a
404 Not Foundresponse. - Handles errors by logging them and returning a
500 Internal Server Errorresponse.
- If no match is found, returns a
-
Function:
-
-
fetchAppetizers/:-
route.ts:-
Function:
GET()- Purpose: Fetches all food items categorized as "appetizers" from the database.
-
Logic:
- Executes a parameterized SQL query to select all records from the
foodtable wheretype = 'appetizer'. - Returns the list of appetizers in a JSON response.
- Executes a parameterized SQL query to select all records from the
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchDrinks/:-
route.ts:-
Function:
GET()- Purpose: Fetches all food items categorized as "drinks" from the database.
-
Logic:
- Executes a parameterized SQL query to select all records from the
foodtable wheretype = 'drink'. - Returns the list of drinks in a JSON response.
- Executes a parameterized SQL query to select all records from the
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchEmployees/:-
route.ts:-
Function:
GET()- Purpose: Fetches all employee records from the database.
-
Logic:
- Executes a SQL query (
SELECT * FROM employees;) to retrieve all rows from theemployeestable. - Returns the list of employees in a JSON response.
- Executes a SQL query (
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchEntrees/:-
route.ts:-
Function:
GET()- Purpose: Fetches all food items categorized as "entrees" from the database.
-
Logic:
- Executes a parameterized SQL query to select all records from the
foodtable wheretype = 'entree'. - Returns the list of entrees in a JSON response.
- Executes a parameterized SQL query to select all records from the
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchInventory/:-
route.ts:-
Function:
GET()- Purpose: Fetches all ingredient records from the database.
-
Logic:
- Executes a SQL query (
SELECT * FROM ingredients;) to retrieve all rows from theingredientstable. - Returns the list of ingredients in a JSON response.
- Executes a SQL query (
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchItemIngredientCount/:-
route.ts:-
Function:
GET()- Purpose: Fetches the total number of ingredients used in each menu item from the database.
-
Logic:
- Executes a SQL query that joins the
Food,Food_Ingredients, andIngredientstables to count the number of ingredients associated with each menu item (Food_Name). - Groups the results by
Food_Nameto calculate the total ingredients used per menu item. - Returns the results in a JSON response.
- Executes a SQL query that joins the
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchPeakSalesDay/:-
route.ts:-
Function:
GET()- Purpose: Fetches the top 10 days with the highest total sales from the database.
-
Logic:
- Executes a SQL query that:
- Groups transactions by their date (
Transaction_Date). - Sums the total prices (
Total_Price) of transactions for each date. - Orders the results in descending order of total sales.
- Limits the results to the top 10 days with the highest sales.
- Groups transactions by their date (
- Returns the results in a JSON response.
- Executes a SQL query that:
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchRealisticSalesHistory/:-
route.ts:-
Function:
GET()- Purpose: Fetches hourly sales data, including total orders and revenue, grouped by hour of the day.
-
Logic:
- Executes a SQL query that:
- Extracts the hour from the transaction time (
Time). - Groups transactions by the hour of the day.
- Counts the total number of transactions (
Transaction_ID) for each hour. - Sums the total prices (
Total_Price) of transactions for each hour. - Orders the results by the hour of the day.
- Extracts the hour from the transaction time (
- Returns the results in a JSON response.
- Executes a SQL query that:
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchSides/:-
route.ts:-
Function:
GET()- Purpose: Fetches all food items categorized as "sides" from the database.
-
Logic:
- Executes a parameterized SQL query to select all records from the
foodtable wheretype = 'side'. - Returns the list of sides in a JSON response.
- Executes a parameterized SQL query to select all records from the
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchSizes/:-
route.ts:-
Function:
GET()- Purpose: Fetches all size records from the database.
-
Logic:
- Executes a SQL query (
SELECT * FROM sizes;) to retrieve all rows from thesizestable. - Returns the list of sizes in a JSON response.
- Executes a SQL query (
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchWeather/:-
route.ts:-
Function:
GET(request: Request)- Purpose: Retrieves current weather information for a specified city.
-
Logic:
- Parses the city name from the query parameters in the request URL.
- Validates the presence of the
cityparameter. - Fetches the latitude and longitude for the city using the
open-meteogeocoding API. - Fetches the current weather data for the city's coordinates using the
open-meteoweather API. - Maps the weather condition to an appropriate icon URL and structures the response.
- Returns the weather data as a JSON object.
-
Error Handling:
- Returns a
400 Bad Requestif thecityparameter is missing. - Logs errors and returns a
500 Internal Server Errorresponse for failures during geolocation or weather data fetching.
- Returns a
-
Function:
-
-
fetchWeeklySalesHistory/:-
route.ts:-
Function:
GET()- Purpose: Retrieves the weekly sales history, including the total number of orders grouped by week number.
-
Logic:
- Executes a SQL query that:
- Extracts the week number from the
Transaction_Datefield usingEXTRACT(WEEK FROM Transaction_Date). - Groups transactions by week number.
- Counts the total number of transactions (
Transaction_ID) for each week. - Orders the results by week number in ascending order.
- Extracts the week number from the
- Returns the grouped data as a JSON response.
- Executes a SQL query that:
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails.
- Logs errors and returns a
-
Function:
-
-
fetchXReport/:-
route.ts:-
Function:
GET()- Purpose: Generates an X-Report summarizing hourly sales and the top employee for each hour on a specific transaction date.
-
Logic:
- Defines a
WITHquery using two Common Table Expressions (CTEs):-
RankedEmployees:- Calculates the total orders and sales for each employee grouped by the hour of the day.
- Ranks employees for each hour based on the number of orders they handled.
-
HourlyTotals:- Aggregates total sales for each hour of the specified transaction date.
-
- Joins the CTEs to retrieve the top-ranked employee for each hour along with the total sales.
- Formats the
total_sales_for_hourfield as a string with two decimal places. - Returns the report as a JSON response.
- Defines a
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query or formatting fails.
- Logs errors and returns a
-
Function:
-
-
fetchZReport/:-
route.ts:-
Function:
GET()- Purpose: Generates a Z-Report summarizing total sales for the day and details about the top-performing employee.
-
Logic:
- Defines a
WITHquery using two Common Table Expressions (CTEs):-
DaySummary:- Groups transactions by employee and calculates the total orders and sales for each employee.
- Assigns a rank to each employee based on the number of orders they handled (descending).
-
TotalSalesForDay:- Calculates the total sales for the specified transaction date.
-
- Combines the CTEs to retrieve the top-ranked employee and the total sales for the day.
- Returns the report as a JSON response.
- Defines a
-
Error Handling:
- Logs errors and returns a
500 Internal Server Errorresponse if the query fails. - Returns a message if no transactions are found for the specified date.
- Logs errors and returns a
-
Function:
-
-
finishCashierTransaction/:-
route.ts:-
Function:
POST(req: Request)- Purpose: Submits a new transaction, including associated orders and food items, to the database.
-
Logic:
- Parses the transaction details (
employeeId,orders, andtotalPrice) from the request body. - Begins a database transaction to ensure all operations are atomic.
- Retrieves and increments the last
transaction_idfrom thetransactionstable. - Inserts the transaction details into the
transactionstable. - Retrieves and increments the last
order_idfrom theorderstable. - For each item in the order:
- Fetches the corresponding
food_idfrom thefoodtable. - Calculates the price for premium or appetizer items.
- Inserts the order details into the
orderstable with the incrementedorder_id.
- Fetches the corresponding
- Commits the transaction if all operations are successful.
- Rolls back the transaction if an error occurs.
- Returns the transaction ID and a success message as a JSON response.
- Parses the transaction details (
-
Error Handling:
- Rolls back the transaction on any error during database operations.
- Logs errors and returns a
500 Internal Server Errorresponse with an appropriate message.
-
Function:
getSizeId(size: string): number- Purpose: Maps size names (e.g., "Bowl", "Plate") to their corresponding size IDs.
-
Logic:
- Uses a
switchstatement to return the appropriate size ID. - Throws an error if the size is invalid.
- Uses a
-
-
-
appetizers/:-
page.tsx:-
Component:
Appetizers- Purpose: Displays available appetizers, allows customers to select an appetizer, and adds it to the shopping cart.
-
Logic:
- Fetches appetizers using
/api/fetchAppetizersAPI. - Updates the shopping cart with the selected appetizer and its price.
- Highlights the selected appetizer with a visual indicator.
- Fetches appetizers using
-
State Variables:
-
appetizers: Array of appetizers fetched from the backend. -
selectedAppetizer: Tracks the currently selected appetizer. -
shoppingData: Context for managing cart data, including items and total price.
-
-
Function:
removeSpace(str: string)- Purpose: Removes spaces from a string (used to format image file paths).
-
Logic:
- Uses
str.replace(/\s/g, '')to replace all spaces with an empty string.
- Uses
-
Function:
useEffect(Fetching Appetizers)- Purpose: Fetches appetizer data from the backend when the component mounts.
-
Logic:
- Sends a
GETrequest to/api/fetchAppetizers. - Updates the
appetizersstate with the fetched data.
- Sends a
-
Function:
handleAppetizerSelect(foodId: number)-
Purpose: Toggles the selection of an appetizer by its
food_id. -
Logic:
- If the clicked appetizer is already selected, deselect it.
- Otherwise, set it as the selected appetizer.
-
Purpose: Toggles the selection of an appetizer by its
-
Function:
handleAddToCart()- Purpose: Adds the selected appetizer to the shopping cart.
-
Logic:
- Finds the currently selected appetizer from the
appetizersarray. - Updates
shoppingData:- Increments the total price by
$2. - Adds the selected appetizer (formatted as
food_name + "/a") to the cart.
- Increments the total price by
- Deselects the appetizer after adding it to the cart.
- Finds the currently selected appetizer from the
-
-
-
-
cashierView/:-
page.tsx:-
Component:
CashierView- Purpose: Renders the cashier interface for managing customer orders and transactions.
-
Logic:
- Displays tabs for menu categories (sides, entrees, appetizers, drinks).
- Handles order creation, size selection, item addition, and transaction submission.
- Integrates with backend APIs for fetching menu items and submitting transaction data.
-
State Variables:
-
activeTab: Tracks the currently selected menu tab. -
selectedSize: The chosen size for the current order. -
currentOrder: Stores items added to the current order. -
previousOrders: Maintains a list of completed orders in the current transaction. -
totalCost: Accumulates the total transaction cost. -
currentOrderSubtotal: Tracks the subtotal for the current order. -
items: Holds the fetched menu items for the selected tab. -
loading: Indicates loading state for menu item fetching. -
error: Stores any errors encountered during item fetching. -
isALaCarte: Determines if the current order is "A La Carte."
-
-
Function:
useEffect(Fetching Menu Items)- Purpose: Fetches menu items for the active tab (e.g., sides, entrees) when the tab changes.
-
Logic:
- Determines the API endpoint based on the active tab.
- Fetches menu data and processes it to mark item availability.
- Updates the
itemsstate or sets an error message.
-
Function:
handleTabChange(tab: string)- Purpose: Changes the active menu tab and resets the item state.
-
Logic:
- Sets the new active tab.
- Resets the
itemsstate and error state. - Triggers the loading state for fetching new data.
-
Function:
handleSizeSelection(size: 'Bowl' | 'Plate' | 'Bigger Plate' | 'A La Carte')- Purpose: Selects the size for the current order and resets order-specific states.
-
Logic:
- Updates
selectedSizeand initializes thecurrentOrder. - Sets the base price for the selected size.
- Updates the total transaction cost.
- Updates
-
Function:
handleAddToOrder(item: Food)- Purpose: Adds a selected item to the current order.
-
Logic:
- Checks if the item can be added based on size limits and availability.
- Calculates additional costs for premium items, appetizers, drinks, and "A La Carte" pricing.
- Updates
currentOrder,currentOrderSubtotal, andtotalCost.
-
Function:
handleSubmitOrder()- Purpose: Submits the current order after validating size and item requirements.
-
Logic:
- Ensures the order meets size limits or is "A La Carte."
- Alerts the cashier if more items are needed.
- Finalizes the order by adding it to
previousOrdersand resetting the order state.
-
Function:
handleFinishTransaction()- Purpose: Finalizes the transaction by submitting all orders and updating the backend.
-
Logic:
- Checks if there are orders to submit.
- Sends the transaction data to the backend via the
/api/finishCashierTransactionendpoint. - Updates inventory ingredient quantities by calling
/api/decrementIngredients. - Resets all transaction-related states.
-
Function:
handleReset()- Purpose: Resets the current order without affecting the total transaction cost.
-
Logic:
- Clears the selected size and current order.
- Deducts the current order subtotal from the total cost.
-
-
-
chatBotView/:-
page.tsx:-
Component:
Chatbot- Purpose: Provides an interactive chatbot UI for user input and bot responses.
-
Logic:
- Accepts user input via a text field.
- Sends the input to the chatbot API (
/api/chatBot) for processing. - Displays the conversation history with styled messages for the user and bot.
- Supports toggling between minimized and expanded states.
-
Function:
handleInputChange- Purpose: Updates the state with the user's input.
-
Logic:
- Captures the value entered in the text input field.
- Updates the
inputstate with the new value.
-
Function:
handleSubmit- Purpose: Sends the user's message to the chatbot API and displays the response.
-
Logic:
- Validates that the input is not empty.
- Sends a POST request to the
/api/chatBotendpoint with the message. - Parses the response and appends both the user's message and the bot's reply to the
responsesstate. - Clears the input field after submission.
- Handles errors by displaying an error message in the chat window.
-
Function:
toggleMinimize- Purpose: Toggles the chatbot UI between minimized and expanded states.
-
Logic:
- Updates the
isMinimizedstate to show or hide the chat content.
- Updates the
-
-
-
customerView/:-
page.tsx:-
Component:
CustomerView- Purpose: Enables customers to view and choose meal sizes while dynamically updating the shopping data context for the selected size.
-
Logic:
- Fetches meal size data from the
/api/fetchSizesendpoint on component load. - Displays meal size options as clickable cards.
- Updates the shopping data context to reflect the selected size, price, and number of entrees.
- Redirects customers to the sides selection page upon choosing a size.
- Fetches meal size data from the
-
Function:
useEffect- Purpose: Fetches meal size data from the server when the component is mounted.
-
Logic:
- Sends a
GETrequest to/api/fetchSizes. - Stores the fetched data in the
sizesstate. - Handles potential errors by logging them to the console.
- Sends a
-
Function:
changeShoppingData(viaLinkclick handler)- Purpose: Updates the shopping data context with the selected size details.
-
Logic:
- Determines the selected size based on
size_id. - Updates the shopping data context (
shoppingData) with:- Number of entrees (
numEntrees). - Current price (
currentPrice). - Selected size ID (
size).
- Number of entrees (
- Determines the selected size based on
-
-
-
drinks/:-
page.tsx:-
Component:
Drinks- Purpose: Displays a list of drink options for customers to select and add to their shopping cart.
-
Logic:
- Fetches drink data from the
/api/fetchDrinksendpoint on component load. - Displays each drink as a card with its image, name, calorie count, and availability status.
- Updates the shopping cart context upon selecting a drink.
- Fetches drink data from the
-
Function:
useEffect- Purpose: Fetches the list of drinks from the backend when the component is mounted.
-
Logic:
- Sends a
GETrequest to/api/fetchDrinks. - Processes the response and stores the drink data in the
drinksstate. - Logs the fetched data for debugging purposes.
- Sends a
-
Function:
removeSpace- Purpose: Removes spaces from a string to generate valid file paths for images.
-
Logic:
- Accepts a string as input.
- Replaces all spaces with empty strings.
- Returns the modified string.
-
Function:
handleDrinkSelect- Purpose: Toggles the selection of a drink.
-
Logic:
- Checks if the selected drink is already active.
- Toggles selection by updating the
selectedDrinkstate.
-
Function:
handleAddToCart- Purpose: Adds the selected drink to the shopping cart.
-
Logic:
- Finds the selected drink in the
drinksstate using theselectedDrinkID. - Updates the
shoppingDatacontext:- Increments the current price by $2.
- Appends the selected drink to the cart items.
- Resets the
selectedDrinkstate.
- Finds the selected drink in the
-
-
-
employees/:-
page.tsx:-
Component:
EmployeesPage- Purpose: Displays a list of employees with details such as name, position, gender, and salary in a card format.
-
Logic:
- Fetches employee data from the
/api/fetchEmployeesendpoint when the component mounts. - Maps the fetched data to display employee information in individual cards.
- Fetches employee data from the
-
Function:
useEffect- Purpose: Fetches the list of employees from the backend on component mount.
-
Logic:
- Sends a
GETrequest to/api/fetchEmployees. - Parses the response JSON to retrieve employee data.
- Updates the
employeesstate with the retrieved data. - Logs any errors that occur during the fetch.
- Sends a
-
-
-
entrees/:-
page.tsx:-
Component:
Entrees- Purpose: Displays a list of entree items for selection and integrates with the shopping cart to manage selections.
-
Function:
useEffect- Purpose: Fetches entree data from the server upon component mount.
-
Logic:
- Sends a
GETrequest to/api/fetchEntrees. - Parses the response JSON to retrieve entree data.
- Updates the
entreesstate with the fetched data.
- Sends a
-
Function:
removeSpace- Purpose: Removes spaces from a string (used to format file paths for images).
-
Logic:
- Takes a string as input and returns a new string with all spaces removed.
-
Function:
handleEntreeSelect- Purpose: Handles the selection of an entree.
-
Logic:
- Toggles selection of the entree when clicked.
- Allows only one entree to be selected at a time.
-
Function:
handleAddToCart- Purpose: Adds the selected entree to the shopping cart.
-
Logic:
- Checks if an entree is selected and available.
- Adjusts the price based on:
- Premium status.
- Meal size.
- Updates the shopping cart context with the selected entree and updated price.
- Resets the
selectedEntreestate tonull.
-
-
-
inventory/:-
page.tsx:-
Component:
InventoryPage- Purpose: Provides an overview of the ingredient inventory, including their names and quantities.
-
Function:
useEffect- Purpose: Fetches ingredient data from the server upon component mount.
-
Logic:
- Sends a
GETrequest to/api/fetchInventory. - Parses the response JSON to retrieve ingredient data.
- Updates the
ingredientsstate with the fetched data. - Handles and logs errors if the API call fails.
- Sends a
-
-
-
itemIngredientCount/:-
page.tsx:-
Component:
ItemIngredientCountPage- Purpose: Provides a breakdown of the number of ingredients used for each menu item.
-
Function:
useEffect- Purpose: Fetches menu item ingredient count data from the server upon component mount.
-
Logic:
- Sends a
GETrequest to/api/fetchItemIngredientCount. - Parses the response JSON to retrieve menu item data.
- Updates the
itemsstate with the fetched data. - Handles and logs errors if the API call fails.
- Sends a
-
-
-
managerView/:-
page.tsx:-
Component:
ManagerView- Purpose: To provide a comprehensive dashboard for managers to manage and monitor business operations.
-
Function:
fetchData- Purpose: Fetches data for the active tab when the tab changes.
-
Logic:
- Determines the API endpoint based on the
activeTab. - Fetches data and updates the corresponding state variable.
- Handles errors gracefully by logging them.
- Determines the API endpoint based on the
-
Function:
handleTabChange- Purpose: Changes the active tab.
-
Logic:
- Updates the
activeTabstate to the selected tab.
- Updates the
-
Function:
handleUpdatePrice- Purpose: Updates the price of a menu item based on the input.
-
Logic:
- Sends a
POSTrequest with the new price and size ID. - Updates the local state with the new price.
- Sends a
-
-
-
menuBoardView/:-
page.tsx:-
Component:
MenuBoardView- Purpose: Displays the full menu board for users in an organized and visually appealing format.
-
Function:
foodDisplaySquare- Purpose: Creates a visual display for a single menu item, including its image and name.
-
Parameters:
-
urlName: A string representing the URL of the menu item's image. -
name: A string representing the menu item's name.
-
- Return Value: A JSX element displaying the menu item's image and name in a styled container.
-
-
-
peakSalesDay/:-
page.tsx:-
Component:
PeakSalesDayPage- Purpose: Displays a historical list of peak sales days and their associated revenue.
-
Features:
- Fetches peak sales data from the
/api/fetchPeakSalesDayendpoint. - Renders the sales date and total revenue for each record in a visually appealing card format.
- Fetches peak sales data from the
-
Component:
-
-
realisticSalesHistory/:-
page.tsx:-
Component:
RealisticSalesHistoryPage- Purpose: Presents a breakdown of sales data on an hourly basis, including the number of orders and revenue for each hour.
-
Features:
- Fetches sales history data from the
/api/fetchRealisticSalesHistoryendpoint. - Displays the data in responsive cards for each hour of the day.
- Fetches sales history data from the
-
Component:
-
-
sides/:-
page.tsx:-
Component:
Sides- Purpose: Displays available sides and allows customers to add selected sides to their shopping cart.
-
Features:
- Fetches sides data dynamically from the API.
- Supports interactive selection and visual feedback for selected items.
- Integrates with a global shopping cart context to track selected items.
-
Component:
-
-
weather/:-
page.tsx:-
Component:
Sides- Purpose: Displays available sides and allows customers to add selected sides to their shopping cart.
-
Features:
- Fetches sides data dynamically from the API.
- Supports interactive selection and visual feedback for selected items.
- Integrates with a global shopping cart context to track selected items.
-
Component:
-
WeatherWidget.tsx:-
Component:
WeatherWidget- Purpose: Displays current weather data for College Station in a compact widget.
-
Features:
- Fetches weather data from an API endpoint.
- Handles errors gracefully with user-friendly messages.
- Displays weather details, including temperature, condition, and an icon.
-
Component:
-
-
weeklySalesHistory/:-
page.tsx:-
Component:
WeeklySalesHistoryPage- Purpose: Fetch and display the weekly sales history, including the total orders processed for each week.
-
Features:
- Dynamically fetches sales data for each week.
- Displays the data in a grid layout with a card for each week.
- Provides responsive design and hover effects for a polished look.
-
Component:
-
-
xReport/:-
page.tsx:-
Component:
XReportPage- Purpose: Fetch and display hourly sales and employee data for the X Report.
-
Features:
- Retrieves hourly sales data and the top-performing employee for each hour.
- Renders the data in an intuitive card-based layout.
-
Component:
-
-
zReport/:-
page.tsx:- Page is not used.
-
The root directory contains configuration and setup files essential for managing and running the Panda Express POS project. Below is a detailed description of each file:
-
.env: Environment configuration file for storing sensitive data like API keys and environment variables. -
.eslintrc.json: ESLint configuration file that enforces coding standards and best practices for the project. -
.gitignore: A file specifying files and directories to be ignored by Git. -
next.config.ts: A configuration file for customizing the Next.js framework. -
next-env.d.ts: A TypeScript declaration file for enabling type definitions specific to Next.js. -
package.json: Metadata file for managing the project's dependencies, scripts, and settings. -
package-lock.json: Locks the exact versions of dependencies installed, ensuring consistency across environments. -
postcss.config.mjs: Configures PostCSS for processing CSS files and enabling Tailwind CSS. -
README.md: A markdown file providing a high-level overview of the project. -
tailwind.config.ts: Tailwind CSS configuration file for customizing the framework’s styling. -
tsconfig.json: The TypeScript configuration file. -
upload.py: A Python script used for uploading datasets and fine-tuning models using OpenAI's API.