File size: 2,008 Bytes
2437cb8
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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()