Salon Appointment Scheduler - Build a Salon Appointment Scheduler

Tell us what’s happening:

I have passed every single test apart from the one to correctly rerender the options menu but my code does rerender it it just won’t pass it. How do I fix this?

Your code so far

Blockquote
#! /bin/bash
PSQL=“psql --username=freecodecamp --dbname=salon --tuples-only -c”
echo -e “\n~~ Sean’s Salon ~~\n”

MAIN_MENU() {
if [[ $1 ]]
then
echo -e “\n$1”
fi

echo Choose a service:

display services dynamically

SERVICES_LIST=$($PSQL “SELECT * FROM SERVICES”)
if [[ -z $SERVICES_LIST ]]
then
echo -e “\nSorry there are no services available”
else
echo “$SERVICES_LIST” | while read SERVICE_NAME BAR SERVICE_ID
do
echo -e “$SERVICE_ID) $SERVICE_NAME”
done
# get user input
read SERVICE_ID_SELECTED
# is the input valid?
if [[ ! $SERVICE_ID_SELECTED =~ [1]+$ ]]
then
MAIN_MENU “I could not find that service. What would you like today?”
fi

CHOSEN_SERVICE_NAME=$($PSQL "SELECT NAME FROM SERVICES WHERE SERVICE_ID=$SERVICE_ID_SELECTED")
if [[ -z $CHOSEN_SERVICE_NAME ]]
then
  MAIN_MENU "I could not find that service. What would you like today?"
fi

echo enter your number:
read CUSTOMER_PHONE
CUSTOMER_NAME=$($PSQL "SELECT NAME FROM CUSTOMERS WHERE PHONE='$CUSTOMER_PHONE'")
# check if customer exists
if [[ -z $CUSTOMER_NAME ]]
then
  echo enter your name:
  read CUSTOMER_NAME
  INSERT_NEW_CUSTOMER=$($PSQL "INSERT INTO CUSTOMERS(NAME,PHONE) VALUES('$CUSTOMER_NAME','$CUSTOMER_PHONE')")
fi
CUSTOMER_ID=$($PSQL "SELECT CUSTOMER_ID FROM CUSTOMERS WHERE PHONE='$CUSTOMER_PHONE'")

# set appointment for customer
echo What time would you like your $CHOSEN_SERVICE_NAME, $CUSTOMER_NAME? 
read SERVICE_TIME
INSERT_NEW_APPOINTMENT=$($PSQL "INSERT INTO APPOINTMENTS(CUSTOMER_ID,SERVICE_ID,TIME) VALUES($CUSTOMER_ID,$SERVICE_ID_SELECTED,'$SERVICE_TIME')")

echo I have put you down for a $CHOSEN_SERVICE_NAME at $SERVICE_TIME, $CUSTOMER_NAME.

fi
}

MAIN_MENU

Your browser information:

User Agent is: Mozilla/5.0 (X11; CrOS x86_64 14541.0.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36

Challenge Information:

Salon Appointment Scheduler - Build a Salon Appointment Scheduler


  1. 0-9 ↩︎

sorry it is a bit of a mess format wise but I would really appreciate some help.