Bookings
This commit is contained in:
+60
-63
@@ -209,76 +209,73 @@ done
|
||||
echo ""
|
||||
echo "7️⃣ Creating 6 Demo Bookings..."
|
||||
|
||||
# Check if we have enough services created
|
||||
if [ ${#SERVICE_IDS[@]} -lt 6 ]; then
|
||||
echo "❌ ERROR: Only ${#SERVICE_IDS[@]} services were created successfully."
|
||||
echo " Need at least 6 services to create demo bookings."
|
||||
echo " Skipping booking creation..."
|
||||
echo ""
|
||||
else
|
||||
echo "✅ All 6 services available. Proceeding with booking creation..."
|
||||
# Function to create a booking
|
||||
create_booking() {
|
||||
local TOKEN=$1
|
||||
local START_TIME=$2
|
||||
local SERVICE_IDS_JSON=$3
|
||||
local NOTES=$4
|
||||
local BOOKING_NAME=$5
|
||||
|
||||
# Function to create a booking
|
||||
create_booking() {
|
||||
local TOKEN=$1
|
||||
local START_TIME=$2
|
||||
local SERVICE_IDS_JSON=$3
|
||||
local NOTES=$4
|
||||
local BOOKING_NAME=$5
|
||||
|
||||
local BOOKING_JSON="{\"start_time\":\"$START_TIME\",\"service_ids\":$SERVICE_IDS_JSON"
|
||||
if [ -n "$NOTES" ]; then
|
||||
BOOKING_JSON="$BOOKING_JSON,\"notes\":\"$NOTES\""
|
||||
local BOOKING_JSON="{\"start_time\":\"$START_TIME\",\"service_ids\":$SERVICE_IDS_JSON"
|
||||
if [ -n "$NOTES" ]; then
|
||||
BOOKING_JSON="$BOOKING_JSON,\"notes\":\"$NOTES\""
|
||||
fi
|
||||
BOOKING_JSON="$BOOKING_JSON}"
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "Creating: $BOOKING_NAME"
|
||||
echo "Time: $START_TIME"
|
||||
echo "Services: $SERVICE_IDS_JSON"
|
||||
|
||||
CREATE_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-d "$BOOKING_JSON" \
|
||||
"$BASE_URL/bookings")
|
||||
|
||||
HTTP_CODE=$(echo "$CREATE_RESPONSE" | tail -n1)
|
||||
RESPONSE_BODY=$(echo "$CREATE_RESPONSE" | sed '$d')
|
||||
|
||||
if [ "$HTTP_CODE" = "201" ]; then
|
||||
echo "✅ Created: $BOOKING_NAME"
|
||||
BOOKING_ID=$(echo "$RESPONSE_BODY" | grep -o '"id":"[^"]*' | cut -d'"' -f4)
|
||||
echo " Booking ID: $BOOKING_ID"
|
||||
else
|
||||
echo "❌ Failed to create: $BOOKING_NAME (HTTP $HTTP_CODE)"
|
||||
if [ -n "$RESPONSE_BODY" ]; then
|
||||
echo "Response body: $RESPONSE_BODY"
|
||||
fi
|
||||
BOOKING_JSON="$BOOKING_JSON}"
|
||||
|
||||
echo ""
|
||||
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
||||
echo "Creating: $BOOKING_NAME"
|
||||
echo "Time: $START_TIME"
|
||||
echo "Services: $SERVICE_IDS_JSON"
|
||||
|
||||
CREATE_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-d "$BOOKING_JSON" \
|
||||
"$BASE_URL/bookings")
|
||||
|
||||
HTTP_CODE=$(echo "$CREATE_RESPONSE" | tail -n1)
|
||||
RESPONSE_BODY=$(echo "$CREATE_RESPONSE" | sed '$d')
|
||||
|
||||
if [ "$HTTP_CODE" = "201" ]; then
|
||||
echo "✅ Created: $BOOKING_NAME"
|
||||
BOOKING_ID=$(echo "$RESPONSE_BODY" | grep -o '"id":"[^"]*' | cut -d'"' -f4)
|
||||
echo " Booking ID: $BOOKING_ID"
|
||||
else
|
||||
echo "❌ Failed to create: $BOOKING_NAME (HTTP $HTTP_CODE)"
|
||||
if [ -n "$RESPONSE_BODY" ]; then
|
||||
echo "Response body: $RESPONSE_BODY"
|
||||
fi
|
||||
fi
|
||||
|
||||
sleep 0.2
|
||||
}
|
||||
fi
|
||||
|
||||
sleep 0.2
|
||||
}
|
||||
|
||||
# 1. Establish the base day (Tomorrow) with a time that guarantees it's in the future.
|
||||
TOMORROW_BASE=$(date -u -d "tomorrow 08:00:00" +%Y-%m-%d)
|
||||
# Use TZ=Europe/London to generate London-local times with correct offset
|
||||
# Note: date command respects TZ for parsing and formatting
|
||||
|
||||
# 2. Calculate the date 7 days after the TOMORROW_BASE date
|
||||
NEXT_WEEK_DATE=$(date -u -d "$TOMORROW_BASE +7 days" +%Y-%m-%d)
|
||||
# Get tomorrow at 08:00 London time as base (ensures future)
|
||||
TOMORROW_BASE=$(TZ=Europe/London date -d "tomorrow 08:00" +%Y-%m-%d)
|
||||
|
||||
# 3. Calculate the date 14 days after the TOMORROW_BASE date
|
||||
WEEK_AFTER_DATE=$(date -u -d "$TOMORROW_BASE +14 days" +%Y-%m-%d)
|
||||
# Calculate future dates in London time
|
||||
NEXT_WEEK_DATE=$(TZ=Europe/London date -d "$TOMORROW_BASE +7 days" +%Y-%m-%d)
|
||||
WEEK_AFTER_DATE=$(TZ=Europe/London date -d "$TOMORROW_BASE +14 days" +%Y-%m-%d)
|
||||
|
||||
# Helper function to format a London time as RFC3339 with 'T' (required by Go backend)
|
||||
format_london_time() {
|
||||
local DATE_PART="$1"
|
||||
local TIME_PART="$2"
|
||||
TZ=Europe/London date -d "$DATE_PART $TIME_PART" +"%Y-%m-%dT%H:%M:%S%:z"
|
||||
}
|
||||
|
||||
# Create demo bookings using the full timestamp (using the fixed dates)
|
||||
create_booking "$USER_TOKEN" "$(date -u -d "$TOMORROW_BASE 10:00:00" +%Y-%m-%dT%H:%M:%SZ)" "[\"${SERVICE_IDS[0]}\"]" "" "Classic Manicure - Tomorrow 10:00"
|
||||
create_booking "$USER_TOKEN" "$(date -u -d "$TOMORROW_BASE 14:30:00" +%Y-%m-%dT%H:%M:%SZ)" "[\"${SERVICE_IDS[1]}\",\"${SERVICE_IDS[5]}\"]" "Want French manicure with simple nail art on accent fingers" "Gel Manicure + Nail Art - Tomorrow 14:30"
|
||||
create_booking "$USER_TOKEN" "$(date -u -d "$NEXT_WEEK_DATE 11:00:00" +%Y-%m-%dT%H:%M:%SZ)" "[\"${SERVICE_IDS[2]}\"]" "Special treat for myself" "Luxury Pedicure - Next Week 11:00"
|
||||
create_booking "$USER_TOKEN" "$(date -u -d "$NEXT_WEEK_DATE 15:45:00" +%Y-%m-%dT%H:%M:%SZ)" "[\"${SERVICE_IDS[3]}\"]" "Need quick refresh before event" "Express Mani & Pedi - Next Week 15:45"
|
||||
create_booking "$USER_TOKEN" "$(date -u -d "$WEEK_AFTER_DATE 13:15:00" +%Y-%m-%dT%H:%M:%SZ)" "[\"${SERVICE_IDS[4]}\",\"${SERVICE_IDS[1]}\"]" "Remove old gel and apply new BIAB" "Gel Removal + New Gel - Week After 13:15"
|
||||
create_booking "$USER_TOKEN" "$(date -u -d "$WEEK_AFTER_DATE 16:30:00" +%Y-%m-%dT%H:%M:%SZ)" "[\"${SERVICE_IDS[0]}\",\"${SERVICE_IDS[5]}\"]" "Birthday celebration - want something special!" "Classic + Nail Art - Week After 16:30"
|
||||
fi
|
||||
# Create demo bookings using London time with proper offset
|
||||
create_booking "$USER_TOKEN" "$(format_london_time "$TOMORROW_BASE" "10:00:00")" "[\"${SERVICE_IDS[0]}\"]" "" "Classic Manicure - Tomorrow 10:00"
|
||||
create_booking "$USER_TOKEN" "$(format_london_time "$TOMORROW_BASE" "14:30:00")" "[\"${SERVICE_IDS[1]}\",\"${SERVICE_IDS[5]}\"]" "Want French manicure with simple nail art on accent fingers" "Gel Manicure + Nail Art - Tomorrow 14:30"
|
||||
create_booking "$USER_TOKEN" "$(format_london_time "$NEXT_WEEK_DATE" "11:00:00")" "[\"${SERVICE_IDS[2]}\"]" "Special treat for myself" "Luxury Pedicure - Next Week 11:00"
|
||||
create_booking "$USER_TOKEN" "$(format_london_time "$NEXT_WEEK_DATE" "15:45:00")" "[\"${SERVICE_IDS[3]}\"]" "Need quick refresh before event" "Express Mani & Pedi - Next Week 15:45"
|
||||
create_booking "$USER_TOKEN" "$(format_london_time "$WEEK_AFTER_DATE" "13:15:00")" "[\"${SERVICE_IDS[4]}\",\"${SERVICE_IDS[1]}\"]" "Remove old gel and apply new BIAB" "Gel Removal + New Gel - Week After 13:15"
|
||||
create_booking "$USER_TOKEN" "$(format_london_time "$WEEK_AFTER_DATE" "16:30:00")" "[\"${SERVICE_IDS[0]}\",\"${SERVICE_IDS[5]}\"]" "Birthday celebration - want something special!" "Classic + Nail Art - Week After 16:30"
|
||||
|
||||
# --- 8️⃣ Create Holiday Exceptional Groups ---
|
||||
echo ""
|
||||
|
||||
Reference in New Issue
Block a user