Salon Appointment Scheduler - Build a Salon Appointment Scheduler

Tell us what’s happening:
Hello I can’t get the you should display a list of services test to pass after resetting and I’m also having trouble inserting the name please help

Your code so far
SQL/salon.sh at main · DennisWainaina/SQL (github.com)
Here’s a screenshot of my freecodecamp

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36 Edg/109.0.1518.55

Challenge: Salon Appointment Scheduler - Build a Salon Appointment Scheduler

Link to the challenge:

Hi !
i’m not an expert ,but i alredy finished this project , my advice ( after looking at your code ) it is way too long and complecated , it took me onle 68 lines of code in the ’ .sh ’ file to finish this project , and to pass the tests it’s better to look at examples.txt file and return the same text , copy and past it with modifying the variables names to match what you have.
walk throgh the tests one by one until you pass then work on the next one .

1 Like

This project is much simpler than the build a bike store project prior.

The test requirements do not require as much checking as you were doing, this could be complicating your logic a little bit.

For example, this bit of code can simply be condense to inserting the time and checking to see if there is a result.

Since time is unique, your database will not allow you to insert at overlapping time.

However, it is very simplified since time is being used as a text and it’s easy to put in. “ 11am” as well as “11:00” and both would be allowed.

But this project is just a simplified version of the bike store project. Try reviewing this code, and see if you can simplify other parts of your solution.

echo -e “\nWhat time would you like your $SERVICE_NAME_TO_SELECT, ‘$CUSTOMER_NAME’”
read SERVICE_TIME
TIME_IN_DATABASE=$($PSQL “SELECT time FROM appointments WHERE time = ‘$SERVICE_TIME’”)
if [[ -z $TIME_IN_DATABASE ]]
then
INSERT_APPOINTMENT_TIME=$($PSQL “INSERT INTO appointments(customer_id, service_id, time) VALUES($NEW_CUSTOMER_ID, $SERVICE_ID_SELECTED, ‘$SERVICE_TIME’)”)
echo $INSERT_APPOINTMENT_TYPE
echo -e “\nI have put you down for a$SERVICE_NAME_TO_SELECT at $SERVICE_TIME, $CUSTOMER_NAME.”
fi

your case statements are also unnecessary, simply use the number entered to get the service ID.

Finally, it seems like you were checking the entered, phone number twice, which doesn’t seem necessary to me. There are a lot of lines you could aluminate, which will help you see what’s really going on.

Try writing it out on paper reviewing the test requirements. Using pseudo code, that could help.

I wrote the majority of this code, while the power was out in a notepad on my laptop.

I simply went through each test and wrote the code for that test, and for the most part, it worked pretty well with a few corrections. But it was not nearly as complicated as yours.