Tell us what’s happening:
In VM (CodeAlly), so far my progress stucked in multiple steps in the .sh file but is very strange because locally I completed the test one time.
I saw the similar post with the following solution, but it didn’t work for me:
"There is a problem with the tests on this particular course I think. I had the same issue recently but eventually, after I’d spammed the ‘Run’ button many times, all of the tests suddenly passed and I was able to complete the project.
I spoilered your code, only because it’s likely a full solution to the project."
I tried changing the browser and connection for hours but absolutely nothing.
Thank you if someone have another solution for me! Thanks for your attention.
Your code so far
#! /bin/bash
PSQL="psql --username=freecodecamp --dbname=salon --tuples-only -c"
echo -e "\n~~~~~ MY SALON ~~~~~\n"
echo -e "Welcome to My Salon, how can I help you?\n"
#main menu
MAIN_MENU(){
if [[ $1 ]]
then
echo -e "\n$1"
fi
SERVICES_LIST=$($PSQL "SELECT service_id, name FROM services")
#show list of services
echo "$SERVICES_LIST" | while read SERVICE_ID BAR SERVICE
do
echo "$SERVICE_ID) $SERVICE"
done
#get service requested
echo "which service?"
read SERVICE_ID_SELECTED
#check if SERVICE_REQUESTED is a number
if [[ ! $SERVICE_ID_SELECTED =~ ^[0-9]+$ ]]
then
MAIN_MENU "I could not find that service. What would you like today?"
else
#get SERVICE_NAME if one exists
SERVICE_NAME=$($PSQL"SELECT name FROM services WHERE service_id=$SERVICE_ID_SELECTED")
#check is a SERVICE_NAME exisits
if [[ -z $SERVICE_NAME ]]
then
#If not then return to the main menu
MAIN_MENU "I could not find that service. What would you like today?"
fi
echo -e "\nWhat's your phone number?"
read CUSTOMER_PHONE
CUSTOMER_ID=$($PSQL"SELECT customer_id FROM customers WHERE phone='$CUSTOMER_PHONE'")
if [[ -z $CUSTOMER_ID ]]
then
echo "I don't have a record for that phone number, what's your name?"
read CUSTOMER_NAME
INSERT_CUSTOMER_RESULT=$($PSQL "INSERT INTO customers(name, phone) VALUES('$CUSTOMER_NAME', '$CUSTOMER_PHONE')")
CUSTOMER_ID=$($PSQL"SELECT customer_id FROM customers WHERE name='$CUSTOMER_NAME'")
else
CUSTOMER_NAME=$($PSQL"SELECT name FROM customers WHERE phone='$CUSTOMER_PHONE'")
fi
echo -e "\nWhat time would you like your$SERVICE_NAME,$CUSTOMER_NAME?"
read SERVICE_TIME
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$SERVICE_NAME at $SERVICE_TIME, $CUSTOMER_NAME."
fi
}
MAIN_MENU
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36
Challenge: Salon Appointment Scheduler - Build a Salon Appointment Scheduler
Link to the challenge: