Spaces:
Sleeping
Sleeping
Trying
Browse files- demoapp.py +102 -173
demoapp.py
CHANGED
|
@@ -1,27 +1,36 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
-
import os
|
| 3 |
-
|
| 4 |
|
| 5 |
# --- LOGIN & SIGN-UP FUNCTIONS ---
|
| 6 |
def community_login(username, password):
|
| 7 |
if username and password:
|
|
|
|
| 8 |
return (
|
| 9 |
-
gr.update(visible=False), # Hide
|
| 10 |
-
gr.update(visible=False), # Hide
|
| 11 |
-
gr.update(visible=True), # Show
|
| 12 |
f"✅ Welcome back, {username}!"
|
| 13 |
)
|
| 14 |
return gr.update(), gr.update(), gr.update(), "⚠️ Please enter both username and password."
|
| 15 |
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
|
| 18 |
|
| 19 |
def corporate_login(username, password):
|
| 20 |
if username == "admin" and password == "1234":
|
| 21 |
return (
|
| 22 |
-
gr.update(visible=False),
|
| 23 |
-
gr.update(visible=False),
|
| 24 |
-
gr.update(visible=True),
|
| 25 |
"✅ Corporate access granted. Welcome!"
|
| 26 |
)
|
| 27 |
elif username and password:
|
|
@@ -34,51 +43,16 @@ def corporate_login(username, password):
|
|
| 34 |
return gr.update(), gr.update(), gr.update(), "⚠️ Please enter both username and password."
|
| 35 |
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
def community_signup(first, last, email, zip_code, interests):
|
| 40 |
-
if not (first and last and email):
|
| 41 |
-
return "⚠️ Please fill in all required fields (First, Last, Email)."
|
| 42 |
-
return (
|
| 43 |
-
f"🎉 Thanks for signing up, {first} {last}!\n"
|
| 44 |
-
f"📧 {email}\n📍 {zip_code or 'Not provided'}\n"
|
| 45 |
-
f"🎯 Interests: {', '.join(interests) if interests else 'None'}"
|
| 46 |
-
)
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
def logout():
|
| 52 |
return (
|
| 53 |
-
gr.update(visible=True), # Show intro
|
| 54 |
gr.update(visible=False), # Hide community dashboard
|
| 55 |
-
gr.update(visible=False)
|
| 56 |
)
|
| 57 |
|
| 58 |
|
| 59 |
-
# Demo account helper (returns username, password)
|
| 60 |
-
_DEMO_ACCOUNTS = {
|
| 61 |
-
"alice@example.com": "alicepw",
|
| 62 |
-
"bob@example.com": "bobpw",
|
| 63 |
-
"charlie@example.com": "charliepw",
|
| 64 |
-
}
|
| 65 |
-
|
| 66 |
-
def _fill_demo(account_key):
|
| 67 |
-
if not account_key:
|
| 68 |
-
return "", ""
|
| 69 |
-
return account_key, _DEMO_ACCOUNTS.get(account_key, "")
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
# --- MAIN INTERFACE ---
|
| 75 |
-
_HERE = os.path.dirname(__file__)
|
| 76 |
-
_HERO_PATH = os.path.join(_HERE, "hero_photo.png")
|
| 77 |
-
_HERO_EXISTS = os.path.exists(_HERO_PATH)
|
| 78 |
-
|
| 79 |
-
_HERE = os.path.dirname(__file__)
|
| 80 |
-
_LOGO_PATH = os.path.join(_HERE, "liftlocall.png") if os.path.exists(os.path.join(_HERE, "liftlocall.png")) else "liftlocall.png"
|
| 81 |
-
|
| 82 |
with gr.Blocks(
|
| 83 |
title="LiftLocal Login",
|
| 84 |
css="""
|
|
@@ -86,30 +60,29 @@ with gr.Blocks(
|
|
| 86 |
background-color: #f5f1e6 !important;
|
| 87 |
color: #000000 !important;
|
| 88 |
}
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
| 92 |
#logo {
|
| 93 |
display: flex;
|
| 94 |
justify-content: center;
|
| 95 |
align-items: center;
|
| 96 |
-
|
| 97 |
-
|
|
|
|
|
|
|
|
|
|
| 98 |
box-shadow: none !important;
|
| 99 |
-
|
| 100 |
}
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
height: 100px !important; /* increased size */
|
| 106 |
-
width: auto !important;
|
| 107 |
-
position: absolute;
|
| 108 |
-
top: 20px;
|
| 109 |
-
left: 25px;
|
| 110 |
}
|
| 111 |
-
|
| 112 |
-
|
| 113 |
#user_button, #employee_button {
|
| 114 |
font-size: 18px;
|
| 115 |
padding: 10px 18px;
|
|
@@ -121,143 +94,108 @@ with gr.Blocks(
|
|
| 121 |
transition: all 0.3s ease;
|
| 122 |
width: 180px;
|
| 123 |
}
|
| 124 |
-
|
| 125 |
-
|
| 126 |
#user_button:hover, #employee_button:hover {
|
| 127 |
background-color: #e0d6c3;
|
| 128 |
border-color: #8a7f6b;
|
| 129 |
transform: scale(1.05);
|
| 130 |
}
|
| 131 |
-
|
| 132 |
-
|
| 133 |
h1, h2, h3, p {
|
| 134 |
text-align: center !important;
|
| 135 |
color: #000000 !important;
|
| 136 |
}
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
.logout-btn {
|
| 141 |
position: absolute;
|
| 142 |
-
top:
|
| 143 |
-
right:
|
| 144 |
-
background: #
|
| 145 |
-
|
| 146 |
-
border: 2px solid #000000 !important;
|
| 147 |
border-radius: 8px;
|
| 148 |
padding: 6px 14px;
|
| 149 |
font-size: 15px;
|
| 150 |
cursor: pointer;
|
| 151 |
transition: 0.3s;
|
| 152 |
}
|
| 153 |
-
|
| 154 |
-
|
| 155 |
.logout-btn:hover {
|
| 156 |
-
background-color: #
|
| 157 |
-
border-color: #333333 !important;
|
| 158 |
-
}
|
| 159 |
-
/* Hero background (vignette) */
|
| 160 |
-
#intro {
|
| 161 |
-
position: relative;
|
| 162 |
-
padding: 60px 20px;
|
| 163 |
-
overflow: hidden;
|
| 164 |
-
}
|
| 165 |
-
#hero_img img {
|
| 166 |
-
position: absolute !important;
|
| 167 |
-
top: 0;
|
| 168 |
-
left: 0;
|
| 169 |
-
width: 100% !important;
|
| 170 |
-
height: 100% !important;
|
| 171 |
-
object-fit: cover !important;
|
| 172 |
-
opacity: 0.12 !important;
|
| 173 |
-
z-index: 0 !important;
|
| 174 |
-
}
|
| 175 |
-
#logo, #intro h2, #intro .gr-markdown {
|
| 176 |
-
position: relative;
|
| 177 |
-
z-index: 2;
|
| 178 |
-
}
|
| 179 |
-
#motto {
|
| 180 |
-
position: absolute;
|
| 181 |
-
top: 50%;
|
| 182 |
-
left: 50%;
|
| 183 |
-
transform: translate(-50%,-50%);
|
| 184 |
-
z-index: 3;
|
| 185 |
-
background: transparent !important; /* remove box */
|
| 186 |
-
padding: 8px 12px;
|
| 187 |
-
border-radius: 8px;
|
| 188 |
-
font-size: 1.05rem;
|
| 189 |
-
text-align: center;
|
| 190 |
-
max-width: 900px;
|
| 191 |
-
color: #222222 !important; /* darker, readable text */
|
| 192 |
-
font-weight: 600;
|
| 193 |
-
text-shadow: 0 1px 2px rgba(0,0,0,0.08);
|
| 194 |
-
box-shadow: none !important;
|
| 195 |
-
border: none !important;
|
| 196 |
}
|
| 197 |
"""
|
| 198 |
) as demo:
|
| 199 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 200 |
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
hero_src = _HERO_PATH if _HERO_EXISTS else _LOGO_PATH
|
| 205 |
-
gr.Image(value=hero_src, show_label=False, show_download_button=False, elem_id="hero_img", interactive=False)
|
| 206 |
-
|
| 207 |
-
# Transparent logo (overlay)
|
| 208 |
-
gr.Image(value=_LOGO_PATH, show_label=False, show_download_button=False, elem_id="logo", height=220)
|
| 209 |
|
| 210 |
-
|
| 211 |
-
# Motto overlay
|
| 212 |
-
gr.Markdown("<div id='motto'>LifeLocal unites food access and opportunity, offering education and incentives that empower real, lasting growth in every community we serve.</div>", elem_id="motto")
|
| 213 |
-
gr.Markdown("## Login Portal")
|
| 214 |
-
gr.Markdown("---")
|
| 215 |
-
gr.Markdown("### Are you joining as a community user or an organization partner?")
|
| 216 |
-
with gr.Row():
|
| 217 |
-
user_btn = gr.Button("👤 Community User", elem_id="user_button")
|
| 218 |
-
corp_btn = gr.Button("🏢 Organization Partner", elem_id="employee_button")
|
| 219 |
-
|
| 220 |
-
|
| 221 |
-
# --- Community Dashboard ---
|
| 222 |
with gr.Group(visible=False) as community_dashboard:
|
| 223 |
-
gr.Image(value=_LOGO_PATH, show_label=False, elem_id="dash_logo", height=100)
|
| 224 |
gr.Markdown("<h2>🌿 Community Dashboard</h2>")
|
| 225 |
-
gr.Markdown("Welcome to LiftLocal! Explore food programs, events, and learning resources.")
|
| 226 |
logout_btn1 = gr.Button("Logout", elem_classes=["logout-btn"])
|
| 227 |
|
| 228 |
-
|
| 229 |
-
# --- Corporate Dashboard ---
|
| 230 |
with gr.Group(visible=False) as corporate_dashboard:
|
| 231 |
-
gr.Image(value=_LOGO_PATH, show_label=False, elem_id="dash_logo", height=100)
|
| 232 |
gr.Markdown("<h2>🏢 Corporate Partner Dashboard</h2>")
|
| 233 |
-
gr.Markdown("Manage
|
| 234 |
logout_btn2 = gr.Button("Logout", elem_classes=["logout-btn"])
|
| 235 |
|
| 236 |
-
|
| 237 |
-
# --- Community Portal ---
|
| 238 |
with gr.Group(visible=False) as community_portal:
|
| 239 |
gr.Markdown("## 👤 Community User Portal")
|
| 240 |
with gr.Tab("Login"):
|
| 241 |
-
# Example/demo accounts dropdown (fills username/password)
|
| 242 |
-
c_user_preset = gr.Dropdown(choices=list(_DEMO_ACCOUNTS.keys()), label="Example accounts (click to fill)")
|
| 243 |
c_user = gr.Textbox(label="", placeholder="Enter your username or email")
|
| 244 |
c_pass = gr.Textbox(label="", type="password", placeholder="Enter your password")
|
| 245 |
-
# When a demo account is selected, populate both fields
|
| 246 |
-
c_user_preset.change(fn=_fill_demo, inputs=c_user_preset, outputs=[c_user, c_pass])
|
| 247 |
c_button = gr.Button("Login")
|
| 248 |
c_output = gr.Textbox(label="Login Message", interactive=False)
|
| 249 |
c_button.click(
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
)
|
| 254 |
|
| 255 |
-
|
| 256 |
with gr.Tab("Sign Up"):
|
| 257 |
f_name = gr.Textbox(label="", placeholder="Enter your first name")
|
| 258 |
l_name = gr.Textbox(label="", placeholder="Enter your last name")
|
| 259 |
email = gr.Textbox(label="", placeholder="Enter your email")
|
| 260 |
-
zip_code = gr.Textbox(label="", placeholder="Enter your zip code (optional)")
|
| 261 |
interests = gr.CheckboxGroup(
|
| 262 |
["Cooking", "Budgeting", "Job Skills", "Health & Wellness", "Technology"],
|
| 263 |
label="Learning Interests",
|
|
@@ -271,8 +209,7 @@ with gr.Blocks(
|
|
| 271 |
outputs=s_output,
|
| 272 |
)
|
| 273 |
|
| 274 |
-
|
| 275 |
-
# --- Corporate Portal ---
|
| 276 |
with gr.Group(visible=False) as corporate_portal:
|
| 277 |
gr.Markdown("## 🏢 Corporate Partner Login")
|
| 278 |
corp_user = gr.Textbox(label="", placeholder="Enter your username")
|
|
@@ -282,30 +219,22 @@ with gr.Blocks(
|
|
| 282 |
corp_button.click(
|
| 283 |
fn=corporate_login,
|
| 284 |
inputs=[corp_user, corp_pass],
|
| 285 |
-
outputs=[
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
# --- Logout Buttons ---
|
| 290 |
-
logout_btn1.click(fn=logout, outputs=[intro_screen, community_dashboard, corporate_dashboard])
|
| 291 |
-
logout_btn2.click(fn=logout, outputs=[intro_screen, community_dashboard, corporate_dashboard])
|
| 292 |
|
|
|
|
|
|
|
|
|
|
| 293 |
|
| 294 |
-
# ---
|
| 295 |
def open_user_portal():
|
| 296 |
-
return gr.update(visible=
|
| 297 |
def open_corporate_portal():
|
| 298 |
return gr.update(visible=False), gr.update(visible=True)
|
| 299 |
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
corp_btn.click(fn=open_corporate_portal, outputs=[intro_screen, corporate_portal])
|
| 303 |
-
|
| 304 |
|
| 305 |
# --- Run app ---
|
| 306 |
if __name__ == "__main__":
|
| 307 |
demo.launch()
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
|
|
|
| 1 |
import gradio as gr
|
|
|
|
|
|
|
| 2 |
|
| 3 |
# --- LOGIN & SIGN-UP FUNCTIONS ---
|
| 4 |
def community_login(username, password):
|
| 5 |
if username and password:
|
| 6 |
+
# Hide intro screen + community portal, show dashboard
|
| 7 |
return (
|
| 8 |
+
gr.update(visible=False), # Hide intro_buttons
|
| 9 |
+
gr.update(visible=False), # Hide community_portal
|
| 10 |
+
gr.update(visible=True), # Show community_dashboard
|
| 11 |
f"✅ Welcome back, {username}!"
|
| 12 |
)
|
| 13 |
return gr.update(), gr.update(), gr.update(), "⚠️ Please enter both username and password."
|
| 14 |
|
| 15 |
|
| 16 |
+
def community_signup(first, last, email, zip_code, interests):
|
| 17 |
+
if not (first and last and email):
|
| 18 |
+
return "⚠️ Please fill in all required fields (First, Last, Email)."
|
| 19 |
+
return (
|
| 20 |
+
f"🎉 Thanks for signing up, {first} {last}!\n"
|
| 21 |
+
f"📧 Email: {email}\n"
|
| 22 |
+
f"📍 Zip Code: {zip_code or 'Not provided'}\n"
|
| 23 |
+
f"🎯 Interests: {', '.join(interests) if interests else 'None selected'}\n"
|
| 24 |
+
"Welcome to LiftLocal!"
|
| 25 |
+
)
|
| 26 |
|
| 27 |
|
| 28 |
def corporate_login(username, password):
|
| 29 |
if username == "admin" and password == "1234":
|
| 30 |
return (
|
| 31 |
+
gr.update(visible=False), # Hide intro_buttons
|
| 32 |
+
gr.update(visible=False), # Hide corporate_portal
|
| 33 |
+
gr.update(visible=True), # Show corporate_dashboard
|
| 34 |
"✅ Corporate access granted. Welcome!"
|
| 35 |
)
|
| 36 |
elif username and password:
|
|
|
|
| 43 |
return gr.update(), gr.update(), gr.update(), "⚠️ Please enter both username and password."
|
| 44 |
|
| 45 |
|
| 46 |
+
# ✅ FIX: logout returns the updates, not used inline
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
def logout():
|
| 48 |
return (
|
| 49 |
+
gr.update(visible=True), # Show intro
|
| 50 |
gr.update(visible=False), # Hide community dashboard
|
| 51 |
+
gr.update(visible=False) # Hide corporate dashboard
|
| 52 |
)
|
| 53 |
|
| 54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 55 |
# --- MAIN INTERFACE ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
with gr.Blocks(
|
| 57 |
title="LiftLocal Login",
|
| 58 |
css="""
|
|
|
|
| 60 |
background-color: #f5f1e6 !important;
|
| 61 |
color: #000000 !important;
|
| 62 |
}
|
| 63 |
+
#logo, #logo * {
|
| 64 |
+
border: none !important;
|
| 65 |
+
box-shadow: none !important;
|
| 66 |
+
outline: none !important;
|
| 67 |
+
background: none !important;
|
| 68 |
+
}
|
| 69 |
#logo {
|
| 70 |
display: flex;
|
| 71 |
justify-content: center;
|
| 72 |
align-items: center;
|
| 73 |
+
margin: 0 auto 10px auto;
|
| 74 |
+
padding: 0 !important;
|
| 75 |
+
}
|
| 76 |
+
.gr-image {
|
| 77 |
+
background: transparent !important;
|
| 78 |
box-shadow: none !important;
|
| 79 |
+
border: none !important;
|
| 80 |
}
|
| 81 |
+
img {
|
| 82 |
+
background: transparent !important;
|
| 83 |
+
border: none !important;
|
| 84 |
+
box-shadow: none !important;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 85 |
}
|
|
|
|
|
|
|
| 86 |
#user_button, #employee_button {
|
| 87 |
font-size: 18px;
|
| 88 |
padding: 10px 18px;
|
|
|
|
| 94 |
transition: all 0.3s ease;
|
| 95 |
width: 180px;
|
| 96 |
}
|
|
|
|
|
|
|
| 97 |
#user_button:hover, #employee_button:hover {
|
| 98 |
background-color: #e0d6c3;
|
| 99 |
border-color: #8a7f6b;
|
| 100 |
transform: scale(1.05);
|
| 101 |
}
|
|
|
|
|
|
|
| 102 |
h1, h2, h3, p {
|
| 103 |
text-align: center !important;
|
| 104 |
color: #000000 !important;
|
| 105 |
}
|
| 106 |
+
label, .gr-label, .gradio-input label, .wrap label, .form label {
|
| 107 |
+
color: #000000 !important;
|
| 108 |
+
font-weight: 600 !important;
|
| 109 |
+
text-align: left !important;
|
| 110 |
+
}
|
| 111 |
+
input, textarea, select {
|
| 112 |
+
background-color: #ffffff !important;
|
| 113 |
+
color: #000000 !important;
|
| 114 |
+
border: 1.5px solid #b0a999 !important;
|
| 115 |
+
border-radius: 6px !important;
|
| 116 |
+
font-size: 16px !important;
|
| 117 |
+
caret-color: #000000 !important;
|
| 118 |
+
}
|
| 119 |
+
input::placeholder, textarea::placeholder {
|
| 120 |
+
color: #7a7a7a !important;
|
| 121 |
+
opacity: 1 !important;
|
| 122 |
+
}
|
| 123 |
+
input:focus, textarea:focus, select:focus {
|
| 124 |
+
border-color: #8a7f6b !important;
|
| 125 |
+
outline: none !important;
|
| 126 |
+
box-shadow: 0 0 5px rgba(138, 127, 107, 0.4) !important;
|
| 127 |
+
}
|
| 128 |
+
.block {
|
| 129 |
+
display: flex;
|
| 130 |
+
flex-direction: column;
|
| 131 |
+
align-items: center;
|
| 132 |
+
}
|
| 133 |
+
.gradio-container .form {
|
| 134 |
+
background-color: transparent !important;
|
| 135 |
+
box-shadow: none !important;
|
| 136 |
+
}
|
| 137 |
+
.tabs {
|
| 138 |
+
background-color: transparent !important;
|
| 139 |
+
}
|
| 140 |
.logout-btn {
|
| 141 |
position: absolute;
|
| 142 |
+
top: 15px;
|
| 143 |
+
right: 20px;
|
| 144 |
+
background: #ffffff;
|
| 145 |
+
border: 2px solid #b0a999;
|
|
|
|
| 146 |
border-radius: 8px;
|
| 147 |
padding: 6px 14px;
|
| 148 |
font-size: 15px;
|
| 149 |
cursor: pointer;
|
| 150 |
transition: 0.3s;
|
| 151 |
}
|
|
|
|
|
|
|
| 152 |
.logout-btn:hover {
|
| 153 |
+
background-color: #e0d6c3;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 154 |
}
|
| 155 |
"""
|
| 156 |
) as demo:
|
| 157 |
|
| 158 |
+
# --- INTRO SECTION ---
|
| 159 |
+
gr.Image("liftlocall.png", show_label=False, show_download_button=False, elem_id="logo", height=300)
|
| 160 |
+
gr.Markdown("<h2><b>LiftLocal</b></h2>")
|
| 161 |
+
gr.Markdown("## Login Portal")
|
| 162 |
+
gr.Markdown("---")
|
| 163 |
+
gr.Markdown("### Are you joining as a community user or an organization partner?")
|
| 164 |
|
| 165 |
+
with gr.Row() as intro_buttons:
|
| 166 |
+
user_btn = gr.Button("👤 Community User", elem_id="user_button")
|
| 167 |
+
corp_btn = gr.Button("🏢 Organization Partner", elem_id="employee_button")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 168 |
|
| 169 |
+
# --- DASHBOARDS ---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
with gr.Group(visible=False) as community_dashboard:
|
|
|
|
| 171 |
gr.Markdown("<h2>🌿 Community Dashboard</h2>")
|
| 172 |
+
gr.Markdown("Welcome to LiftLocal! Explore food programs, local events, and learning resources.")
|
| 173 |
logout_btn1 = gr.Button("Logout", elem_classes=["logout-btn"])
|
| 174 |
|
|
|
|
|
|
|
| 175 |
with gr.Group(visible=False) as corporate_dashboard:
|
|
|
|
| 176 |
gr.Markdown("<h2>🏢 Corporate Partner Dashboard</h2>")
|
| 177 |
+
gr.Markdown("Manage partnerships, sponsorships, and community projects.")
|
| 178 |
logout_btn2 = gr.Button("Logout", elem_classes=["logout-btn"])
|
| 179 |
|
| 180 |
+
# --- COMMUNITY LOGIN PORTAL ---
|
|
|
|
| 181 |
with gr.Group(visible=False) as community_portal:
|
| 182 |
gr.Markdown("## 👤 Community User Portal")
|
| 183 |
with gr.Tab("Login"):
|
|
|
|
|
|
|
| 184 |
c_user = gr.Textbox(label="", placeholder="Enter your username or email")
|
| 185 |
c_pass = gr.Textbox(label="", type="password", placeholder="Enter your password")
|
|
|
|
|
|
|
| 186 |
c_button = gr.Button("Login")
|
| 187 |
c_output = gr.Textbox(label="Login Message", interactive=False)
|
| 188 |
c_button.click(
|
| 189 |
+
fn=community_login,
|
| 190 |
+
inputs=[c_user, c_pass],
|
| 191 |
+
outputs=[intro_buttons, community_portal, community_dashboard, c_output]
|
| 192 |
)
|
| 193 |
|
|
|
|
| 194 |
with gr.Tab("Sign Up"):
|
| 195 |
f_name = gr.Textbox(label="", placeholder="Enter your first name")
|
| 196 |
l_name = gr.Textbox(label="", placeholder="Enter your last name")
|
| 197 |
email = gr.Textbox(label="", placeholder="Enter your email")
|
| 198 |
+
zip_code = gr.Textbox(label="", placeholder="Enter your zip code (optional) e.g., 36088")
|
| 199 |
interests = gr.CheckboxGroup(
|
| 200 |
["Cooking", "Budgeting", "Job Skills", "Health & Wellness", "Technology"],
|
| 201 |
label="Learning Interests",
|
|
|
|
| 209 |
outputs=s_output,
|
| 210 |
)
|
| 211 |
|
| 212 |
+
# --- CORPORATE LOGIN PORTAL ---
|
|
|
|
| 213 |
with gr.Group(visible=False) as corporate_portal:
|
| 214 |
gr.Markdown("## 🏢 Corporate Partner Login")
|
| 215 |
corp_user = gr.Textbox(label="", placeholder="Enter your username")
|
|
|
|
| 219 |
corp_button.click(
|
| 220 |
fn=corporate_login,
|
| 221 |
inputs=[corp_user, corp_pass],
|
| 222 |
+
outputs=[intro_buttons, corporate_portal, corporate_dashboard, corp_output]
|
| 223 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 224 |
|
| 225 |
+
# ✅ Proper logout buttons now reference the logout() function
|
| 226 |
+
logout_btn1.click(fn=logout, outputs=[intro_buttons, community_dashboard, corporate_dashboard])
|
| 227 |
+
logout_btn2.click(fn=logout, outputs=[intro_buttons, community_dashboard, corporate_dashboard])
|
| 228 |
|
| 229 |
+
# --- BUTTON LOGIC ---
|
| 230 |
def open_user_portal():
|
| 231 |
+
return gr.update(visible=True), gr.update(visible=False)
|
| 232 |
def open_corporate_portal():
|
| 233 |
return gr.update(visible=False), gr.update(visible=True)
|
| 234 |
|
| 235 |
+
user_btn.click(fn=open_user_portal, outputs=[community_portal, corporate_portal])
|
| 236 |
+
corp_btn.click(fn=open_corporate_portal, outputs=[community_portal, corporate_portal])
|
|
|
|
|
|
|
| 237 |
|
| 238 |
# --- Run app ---
|
| 239 |
if __name__ == "__main__":
|
| 240 |
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|