DeepLearning101 commited on
Commit
91b069f
·
verified ·
1 Parent(s): 5bb6039

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -0
app.py ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import datetime
3
+
4
+ # 自定義 CSS:打造高級黑金風格
5
+ custom_css = """
6
+ .gradio-container { background-color: #0c0c0c !important; color: #d4af37 !important; }
7
+ .gr-button-primary { background: linear-gradient(45deg, #af8f2c, #d4af37) !important; border: none !important; color: black !important; font-weight: bold !important; }
8
+ .gr-input, .gr-dropdown, .gr-number { background-color: #1a1a1a !important; border: 1px solid #333 !important; color: white !important; }
9
+ h1 { font-family: 'Playfair Display', serif; letter-spacing: 2px; }
10
+ .availability-box { padding: 10px; border: 1px solid #d4af37; border-radius: 5px; text-align: center; margin-bottom: 20px; }
11
+ """
12
+
13
+ def get_available_slots(date_str):
14
+ # 這裡未來會接 Supabase 查詢
15
+ # 範例邏輯:如果是假日就剩比較少位子
16
+ return [("18:00", "剩 4 位"), ("19:30", "剩 2 位"), ("21:00", "已客滿")]
17
+
18
+ def handle_booking(name, tel, pax, date, time):
19
+ if not name or not tel:
20
+ return "⚠️ 請完整填寫姓名與聯絡電話。"
21
+ # 這裡執行寫入 Supabase 的邏輯
22
+ return f"### 🥂 預約申請已提交!\n**{name}** 您好,我們已收到您的申請。請留意 Email 並於 24 小時內點擊「確認出席」以保留您的座位。"
23
+
24
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as demo:
25
+ gr.HTML("""
26
+ <div style="text-align: center; padding: 20px;">
27
+ <h1 style="font-size: 36px;">Cié Cié Taipei</h1>
28
+ <p style="color: #888;">品味精緻時光,期待您的蒞臨</p>
29
+ </div>
30
+ """)
31
+
32
+ with gr.Row():
33
+ with gr.Column(scale=1):
34
+ booking_date = gr.DateTime(label="1. 選擇日期", type="string")
35
+ pax_count = gr.Slider(minimum=1, maximum=8, value=2, step=1, label="2. 用餐人數")
36
+
37
+ with gr.Column(scale=1):
38
+ # 這裡顯示即時剩餘座位狀態
39
+ availability_display = gr.HTML("<div class='availability-box'>請先選擇日期以查看剩餘座位</div>")
40
+ time_slot = gr.Dropdown(choices=["18:00", "19:30", "21:00"], label="3. 選擇時段")
41
+
42
+ with gr.Group():
43
+ gr.Markdown("### 4. 聯絡資訊")
44
+ with gr.Row():
45
+ cust_name = gr.Textbox(label="姓名", placeholder="請輸入訂位人姓名")
46
+ cust_tel = gr.Textbox(label="電話", placeholder="請輸入手機號碼")
47
+
48
+ confirm_btn = gr.Button("探索味蕾之旅 (提交預約)", variant="primary")
49
+ result_output = gr.Markdown()
50
+
51
+ # 當日期或人數改變時,動態更新顯示(互動性體驗)
52
+ booking_date.change(lambda: "<div class='availability-box'>🔍 查詢中...</div>", outputs=availability_display)
53
+
54
+ confirm_btn.click(
55
+ handle_booking,
56
+ inputs=[cust_name, cust_tel, pax_count, booking_date, time_slot],
57
+ outputs=result_output
58
+ )
59
+
60
+ demo.launch()