Salon Appointment Scheduler - Build a Salon Appointment Scheduler

Tell us what’s happening:

i’ve already completed the project but the points where it requests to create rows into appointments, does not mark them as completed, my script is fine, the outouts are fine, i don’t know what happend

Your code so far

#! /bin/bash

PSQL=“psql -X --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(){
if [[ $1 ]]
then
echo -e “\n$1”
fi

echo -e "1) cut\n2) color\n3) perm\n4) style\n5) trim"

read SERVICE_ID_SELECTED

case  $SERVICE_ID_SELECTED in
    1) SCHEDULE $SERVICE_ID_SELECTED ;;
    2) SCHEDULE $SERVICE_ID_SELECTED ;;
    3) SCHEDULE $SERVICE_ID_SELECTED ;;
    4) SCHEDULE $SERVICE_ID_SELECTED ;;
    5) SCHEDULE $SERVICE_ID_SELECTED ;;
    *) MAIN_MENU "I could not find that service. What would you like today?" ;;
esac

}

SCHEDULE(){
SERVICE_ID_SELECTED=$1

SERVICE=$($PSQL "SELECT name FROM services WHERE service_id = $SERVICE_ID_SELECTED")

echo -e "\nWhat's your phone number?"
read CUSTOMER_PHONE

CUSTOMER_NAME=$($PSQL "SELECT name FROM customers WHERE phone = '$CUSTOMER_PHONE'")

if [[ -z $CUSTOMER_NAME ]]
then
    echo -e "\nI 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')")
fi

CUSTOMER_ID=$($PSQL "SELECT customer_id FROM customers WHERE phone = '$CUSTOMER_PHONE'")

echo -e "\nWhat time would you like your $(echo $SERVICE | sed -r 's/^ *| *$//g'), $(echo $CUSTOMER_NAME | sed -r 's/^ *| *$//g')?"
read SERVICE_TIME

INSERT_APPOINTMENT_RESULT=$($PSQL "INSERT INTO appointments(time, customer_id, service_id) VALUES('$SERVICE_TIME', $CUSTOMER_ID, $SERVICE_ID_SELECTED)")
echo -e "\nI have put you down for a $(echo $SERVICE | sed -r 's/^ *| *$//g') at $SERVICE_TIME, $(echo $CUSTOMER_NAME | sed -r 's/^ *| *$//g')."

}
MAIN_MENU

Your browser information:

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

Challenge Information:

Salon Appointment Scheduler - Build a Salon Appointment Scheduler

Make sure you used var char of 10 for the time.

2 Likes

it worked!!, thank you so much.

1 Like

Guys, this is so funny! I did all the code on my computer to save time on giotpod, then I imported all to the vm and I was so frustrated on the results because my code is simple but quite clean, so was not much to miss, then I saw two diferent ppl saying the varchar on time had to be 10, I was like ‘no way’ because I was counting on ##:## maximum, but some how this was the fix, love to you, cheers!

1 Like