import gradio as gr import pandas as pd from datetime import datetime # Simulated Database (In a real app, this would be Firebase or a CSV) rooms_data = { "Hotel Name": ["Beach Breeze Hulhumale", "Male City Inn", "Villi Garden"], "Location": ["Hulhumale Phase 1", "Male City", "Villingili"], "Price (MVR)": [850, 1200, 700], "Status": ["Available", "Available", "Full"], "Contact": ["+960 7771234", "+960 7785678", "+960 7799101"] } df = pd.DataFrame(rooms_data) def update_status(hotel_index, new_status): df.at[hotel_index, "Status"] = new_status df.at[hotel_index, "Last Update"] = datetime.now().strftime("%H:%M:%S") return df def get_available_rooms(): return df[df["Status"] == "Available"] # UI Design with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("# 🏝️ Hulhumale Real-Time Room Finder") gr.Markdown("Direct contact for rooms in Male', Hulhumale, and Villingili.") with gr.Tab("Traveler View (User Side)"): gr.Markdown("### 🔍 Live Availability") output_table = gr.DataFrame(value=get_available_rooms(), interactive=False) refresh_btn = gr.Button("🔄 Refresh Live Availability") gr.Markdown("> **Tip:** Tap the number to call/Viber the owner directly.") with gr.Tab("Hotel Owner (Client Side)"): gr.Markdown("### 🔑 Owner Dashboard (350 MVR/mo)") hotel_id = gr.Dropdown(choices=list(df["Hotel Name"]), label="Select Your Hotel", type="index") status_radio = gr.Radio(["Available", "Full"], label="Change Room Status") update_btn = gr.Button("Update Availability Now", variant="primary") promo_input = gr.Textbox(label="Add Promotion (e.g., 10% Off Tonight!)") promo_btn = gr.Button("Send Notification to Users") # Logic update_btn.click(update_status, inputs=[hotel_id, status_radio], outputs=output_table) refresh_btn.click(lambda: df[df["Status"] == "Available"], outputs=output_table) demo.launch()