Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -120,22 +120,31 @@ def handle_booking(name, tel, email, date_str, time, pax, remarks, line_id):
|
|
| 120 |
return """<div style='text-align: center; color: #fff; padding: 20px; border: 1px solid #d4af37; border-radius: 8px; background: #222;'><h2 style='color: #d4af37; margin: 0;'>Request Received</h2><p style='margin: 10px 0;'>🥂 預約申請已提交</p><p style='font-size: 0.9em; color: #aaa;'>請留意 Email 確認信。</p></div>"""
|
| 121 |
except Exception as e: return f"❌ 系統錯誤: {str(e)}"
|
| 122 |
|
| 123 |
-
# --- 5. Webhook (
|
| 124 |
def check_confirmation(request: gr.Request):
|
| 125 |
if not request: return ""
|
| 126 |
action = request.query_params.get('action')
|
| 127 |
bid = request.query_params.get('id')
|
| 128 |
|
|
|
|
|
|
|
|
|
|
| 129 |
if action == 'confirm' and bid:
|
| 130 |
try:
|
| 131 |
supabase.table("bookings").update({"status": "顧客已確認"}).eq("id", bid).execute()
|
| 132 |
-
|
| 133 |
-
|
|
|
|
|
|
|
|
|
|
| 134 |
elif action == 'cancel' and bid:
|
| 135 |
try:
|
| 136 |
supabase.table("bookings").update({"status": "顧客已取消"}).eq("id", bid).execute()
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
| 139 |
return ""
|
| 140 |
|
| 141 |
# --- 6. 介面 ---
|
|
|
|
| 120 |
return """<div style='text-align: center; color: #fff; padding: 20px; border: 1px solid #d4af37; border-radius: 8px; background: #222;'><h2 style='color: #d4af37; margin: 0;'>Request Received</h2><p style='margin: 10px 0;'>🥂 預約申請已提交</p><p style='font-size: 0.9em; color: #aaa;'>請留意 Email 確認信。</p></div>"""
|
| 121 |
except Exception as e: return f"❌ 系統錯誤: {str(e)}"
|
| 122 |
|
| 123 |
+
# --- 5. Webhook (確認/取消邏輯 + 自動轉址到首頁) ---
|
| 124 |
def check_confirmation(request: gr.Request):
|
| 125 |
if not request: return ""
|
| 126 |
action = request.query_params.get('action')
|
| 127 |
bid = request.query_params.get('id')
|
| 128 |
|
| 129 |
+
# ✅ 修改這裡:目標改為官網首頁 (index.html)
|
| 130 |
+
OFFICIAL_SITE = "https://ciecietaipei.github.io/index.html"
|
| 131 |
+
|
| 132 |
if action == 'confirm' and bid:
|
| 133 |
try:
|
| 134 |
supabase.table("bookings").update({"status": "顧客已確認"}).eq("id", bid).execute()
|
| 135 |
+
# 成功後,跳轉回首頁並帶上 status=confirmed
|
| 136 |
+
return f"""<script>window.location.href = "{OFFICIAL_SITE}?status=confirmed";</script>"""
|
| 137 |
+
except:
|
| 138 |
+
return "系統錯誤"
|
| 139 |
+
|
| 140 |
elif action == 'cancel' and bid:
|
| 141 |
try:
|
| 142 |
supabase.table("bookings").update({"status": "顧客已取消"}).eq("id", bid).execute()
|
| 143 |
+
# 取消後,跳轉回首頁並帶上 status=canceled
|
| 144 |
+
return f"""<script>window.location.href = "{OFFICIAL_SITE}?status=canceled";</script>"""
|
| 145 |
+
except:
|
| 146 |
+
return "系統錯誤"
|
| 147 |
+
|
| 148 |
return ""
|
| 149 |
|
| 150 |
# --- 6. 介面 ---
|