Tell us what’s happening:
My shell script appears to operating just as it should but CodeRoad isnt recognizing it or im making an error that I dont realize.
Your code so far
#!/bin/bash
PSQL=“psql --username=freecodecamp --dbname=salon --tuples-only -c”
echo -e “\n~~~~~ My Salon ~~~~~\n”
MAIN_MENU(){
if [[ $1 ]]
then
echo -e “\n$1”
fi
echo -e “\nWelcome to my salon, How can I help you?”
echo -e “\n1) Cut\n2) Color\n3) Perm\n4) Style\n5) Trim\n6) Exit”
read SERVICE_ID_SELECTED
case $SERVICE_ID_SELECTED in
-
CUT_MENU ;;
-
COLOR_MENU ;;
-
PERM_MENU ;;
-
STYLE_MENU ;;
-
TRIM_MENU ;;
-
EXIT ;;
*) MAIN_MENU “\nI could not find that service. What would you like today?\n”;;
esac
}
CUT_MENU(){
get customer info
echo -e “\nWhat’s your phone number?”
read CUSTOMER_PHONE
CUSTOMER_NAME=$($PSQL “SELECT name FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
if customer doesn’t exist
if [[ -z $CUSTOMER_NAME ]]
then
notify that we dont have record of phone number
echo -e “\nI don’t have a record for that phone number, what’s your name?”
read CUSTOMER_NAME
insert new customer
INSERT_CUSTOMER_INFO=$($PSQL “INSERT INTO customers(phone, name) VALUES(‘$CUSTOMER_PHONE’, ‘$CUSTOMER_NAME’);”)
set appointment time
echo -e “\nWhat time would you like your cut, $CUSTOMER_NAME?”
read SERVICE_TIME
insert service selected
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values((SELECT customer_id FROM customers WHERE name = ‘$CUSTOMER_NAME’), $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a cut at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
else
#if customer is in the database
echo -e “\nWhat time would you like your Cut, $CUSTOMER_NAME?”
read SERVICE_TIME
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values((SELECT customer_id FROM customers WHERE name = ‘$CUSTOMER_NAME’), $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a cut at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
fi
}
COLOR_MENU(){
get customer info
echo -e “\nWhat’s your phone number?”
read CUSTOMER_PHONE
CUSTOMER_NAME=$($PSQL “SELECT name FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
if customer doesn’t exist
if [[ -z $CUSTOMER_NAME ]]
then
notify that we dont have record of phone number
echo -e “\nI don’t have a record for that phone number, what’s your name?”
read CUSTOMER_NAME
insert new customer
INSERT_CUSTOMER_INFO=$($PSQL “INSERT INTO customers(phone, name) VALUES(‘$CUSTOMER_PHONE’, ‘$CUSTOMER_NAME’);”)
set appointment time
echo -e “\nWhat time would you like your color, $CUSTOMER_NAME?”
read SERVICE_TIME
insert service selected
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values((SELECT customer_id FROM customers WHERE name = ‘$CUSTOMER_NAME’), $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a color at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
else
#if customer is in the database
echo -e “\nWhat time would you like your color, $CUSTOMER_NAME?”
read SERVICE_TIME
CUSTOMER_ID=$($PSQL “SELECT customer_id FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values($CUSTOMER_ID, $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a color at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
fi
}
PERM_MENU(){
get customer info
echo -e “\nWhat’s your phone number?”
read CUSTOMER_PHONE
CUSTOMER_NAME=$($PSQL “SELECT name FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
#if customer doesnt exist
if [[ -z $CUSTOMER_NAME ]]
then
#notify that we dont have record of phone number
echo -e “\nI don’t have a record for that phone number, what’s your name?”
read CUSTOMER_NAME
insert new customer
INSERT_CUSTOMER_INFO=$($PSQL “INSERT INTO customers(phone, name) VALUES(‘$CUSTOMER_PHONE’, ‘$CUSTOMER_NAME’);”)
set appointment time
echo -e “\nWhat time would you like your perm, $CUSTOMER_NAME?”
read SERVICE_TIME
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) VALUES((SELECT customer_id FROM customers WHERE name = ‘$CUSTOMER_NAME’), $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a perm at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
else
#if customer is in the database
echo -e “\nWhat time would you like your perm, $CUSTOMER_NAME?”
read SERVICE_TIME
CUSTOMER_ID=$($PSQL “SELECT customer_id FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) VALUES($CUSTOMER_ID, $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a perm at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
fi
}
STYLE_MENU(){
get customer info
echo -e “\nWhat’s your phone number?”
read CUSTOMER_PHONE
CUSTOMER_NAME=$($PSQL “SELECT name FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
if customer doesn’t exist
if [[ -z $CUSTOMER_NAME ]]
then
notify that we dont have record of phone number
echo -e “\nI don’t have a record for that phone number, what’s your name?”
read CUSTOMER_NAME
insert new customer
INSERT_CUSTOMER_INFO=$($PSQL “INSERT INTO customers(phone, name) VALUES(‘$CUSTOMER_PHONE’, ‘$CUSTOMER_NAME’);”)
set appointment time
echo -e “\nWhat time would you like your style, $CUSTOMER_NAME?”
read SERVICE_TIME
insert service selected
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values((SELECT customer_id FROM customers WHERE name = ‘$CUSTOMER_NAME’), $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a style at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
else
#if customer is in the database
echo -e “\nWhat time would you like your style, $CUSTOMER_NAME?”
read SERVICE_TIME
CUSTOMER_ID=$($PSQL “SELECT customer_id FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values($CUSTOMER_ID, $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a style at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
fi
}
TRIM_MENU(){
get customer info
echo -e “\nWhat’s your phone number?”
read CUSTOMER_PHONE
CUSTOMER_NAME=$($PSQL “SELECT name FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
if customer doesn’t exist
if [[ -z $CUSTOMER_NAME ]]
then
notify that we dont have record of phone number
echo -e “\nI don’t have a record for that phone number, what’s your name?”
read CUSTOMER_NAME
insert new customer
INSERT_CUSTOMER_INFO=$($PSQL “INSERT INTO customers(phone, name) VALUES(‘$CUSTOMER_PHONE’, ‘$CUSTOMER_NAME’);”)
set appointment time
echo -e “\nWhat time would you like your trim, $CUSTOMER_NAME?”
read SERVICE_TIME
insert service selected
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values((SELECT customer_id FROM customers WHERE name = ‘$CUSTOMER_NAME’), $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a trim at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
else
#if customer is in the database
echo -e “\nWhat time would you like your trim, $CUSTOMER_NAME?”
read SERVICE_TIME
CUSTOMER_ID=$($PSQL “SELECT customer_id FROM customers WHERE phone = ‘$CUSTOMER_PHONE’;”)
INSERT_APPOINTMENT=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) Values($CUSTOMER_ID, $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’);”)
echo -e “\nI have put you down for a trim at $SERVICE_TIME, $CUSTOMER_NAME.”
MAIN_MENU
fi
}
EXIT(){
echo -e “\nThank you for stopping in.\n”
}
MAIN_MENU
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36 Edg/123.0.0.0
Challenge Information:
Salon Appointment Scheduler - Build a Salon Appointment Scheduler