File size: 12,025 Bytes
9842f45
b8b9959
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
import gradio as gr # type: ignore
import matplotlib.pyplot as plt

# --- LOGIN & SIGN-UP FUNCTIONS ---
def community_login(username, password):
    if username and password:
        return (
            gr.update(visible=False),  # Hide intro
            gr.update(visible=False),  # Hide community portal
            gr.update(visible=True),   # Show community dashboard
            f"βœ… Welcome back, {username}!"
        )
    return gr.update(), gr.update(), gr.update(), "⚠️ Please enter both username and password."


def corporate_login(username, password):
    if username == "admin" and password == "1234":
        return (
            gr.update(visible=False),
            gr.update(visible=False),
            gr.update(visible=True),
            "βœ… Corporate access granted. Welcome!"
        )
    elif username and password:
        return (
            gr.update(visible=False),
            gr.update(visible=False),
            gr.update(visible=True),
            f"Hello {username}! (Demo login only)"
        )
    return gr.update(), gr.update(), gr.update(), "⚠️ Please enter both username and password."


def community_signup(first, last, email, zip_code, interests):
    if not (first and last and email):
        return "⚠️ Please fill in all required fields (First, Last, Email)."
    return (
        f"πŸŽ‰ Thanks for signing up, {first} {last}!\n"
        f"πŸ“§ {email}\nπŸ“ {zip_code or 'Not provided'}\n"
        f"🎯 Interests: {', '.join(interests) if interests else 'None'}"
    )


def logout():
    return (
        gr.update(visible=True),
        gr.update(visible=False),
        gr.update(visible=False),
    )


# --- MAIN INTERFACE ---
with gr.Blocks(
    title="LiftLocal Login",
    css="""
        body, .gradio-container, .block, .wrap {
            background-color: #f5f1e6 !important;
            color: #000000 !important;
        }
        #logo {
            display: flex;
            justify-content: center;
            align-items: center;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            margin: 0px auto 2px auto;
            padding: 0px !important;
        }
        #hero {
            display: flex;
            justify-content: center;
            align-items: center;
            background: transparent !important;
            border: none !important;
            box-shadow: none !important;
            margin: 25px auto 12px auto;
            padding: 0 !important;
        }
        .navbar {
            width: 100%;
            background-color: #efe9d5;
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 10px 40px;
            box-shadow: 0 2px 6px rgba(0,0,0,0.08);
            position: relative;
        }
        .navbar img {
            height: 80px;
            width: auto;
        }
        .menu-links {
            display: flex;
            gap: 30px;
        }
        .menu-links a {
            text-decoration: none;
            color: #000000;
            font-weight: 600;
            font-size: 16px;
            transition: 0.3s;
        }
        .menu-links a:hover {
            color: #5a5143;
        }
        .logout-btn {
            background: #ffffff !important;
            color: #000000 !important;
            border: 2px solid #000000 !important;
            border-radius: 8px;
            padding: 6px 14px;
            font-size: 15px;
            cursor: pointer;
            transition: 0.2s;
        }
        .logout-btn:hover {
            background-color: #333333 !important;
            border-color: #333333 !important;
            color: #ffffff !important;
        }
        #user_button, #employee_button {
            font-size: 18px;
            padding: 10px 18px;
            margin: 10px;
            background-color: #ffffff;
            border: 2px solid #b0a999;
            border-radius: 10px;
            color: #000000;
            transition: all 0.3s ease;
            width: 180px;
        }
        #user_button:hover, #employee_button:hover {
            background-color: #e0d6c3;
            border-color: #8a7f6b;
            transform: scale(1.05);
        }
        h1, h2, h3, p {
            text-align: center !important;
            color: #000000 !important;
        }
    """
) as demo:

    # --- INTRO SCREEN ---
    gr.Image("liftlocall.png", show_label=False, elem_id="logo", height=350)
    gr.Image("hero_photo.png", show_label=False, elem_id="hero", height=300)
    gr.Markdown("## LiftLocal unites food access and opportunity, offering education and incentives that empower real, lasting growth in EVERY community we serve.")
    gr.Markdown("## Login Portal")
    gr.Markdown("---")
    gr.Markdown("### Are you joining as a community user or an organization partner?")
    with gr.Row() as intro_buttons:
        user_btn = gr.Button("πŸ‘€ Community User", elem_id="user_button")
        corp_btn = gr.Button("🏒 Organization Partner", elem_id="employee_button")

    # --- COMMUNITY DASHBOARD ---
    with gr.Group(visible=False) as community_dashboard:
        gr.HTML("""
        <div class="navbar">
            <img src="liftlocall.png" alt="LiftLocal Logo">
            <div class="menu-links">
                <a href="#">Food Resources</a>
                <a href="#">Education Resources</a>
                <a href="#">Promotions / Rewards</a>
                <a href="#">Donate</a>
            </div>
            <button class="logout-btn" id="logout1">Logout</button>
        </div>
        """)
        gr.Markdown("<h2>🌿 Community Dashboard</h2>")
        gr.Markdown("Welcome to LiftLocal! Explore food programs, events, and learning opportunities below.")
        with gr.Tabs():
            with gr.Tab("πŸ₯— Food Resources"):
                gr.Markdown("### Local Food Assistance Programs")
                gr.Textbox(label="Search by ZIP Code", placeholder="e.g., 36088")
                gr.Button("Search")
            with gr.Tab("πŸ“š Education Resources"):
                gr.Markdown("### Learn and Grow")
                gr.Button("Explore Opportunities")
            with gr.Tab("🎁 Promotions / Rewards"):
                gr.Markdown("### Earn and Redeem Your LiftPoints")
                gr.Slider(label="Your LiftPoints", value=50, minimum=0, maximum=100, interactive=False)
                gr.Button("Redeem Rewards")

    # --- CORPORATE DASHBOARD ---
    with gr.Group(visible=False) as corporate_dashboard:
        gr.HTML("""
        <div class="navbar">
            <img src="liftlocall.png" alt="LiftLocal Logo" style="height:70px;">
            <div class="menu-links">
                <a href="#">Home</a>
                <a href="#">Reports</a>
                <a href="#">Sponsorships</a>
                <a href="#">Impact</a>
            </div>
            <button class="logout-btn" id="logout2">Logout</button>
        </div>
        """)
        gr.Markdown("<h2>🏒 Corporate Partner Dashboard</h2>")
        with gr.Tabs():
            with gr.Tab("πŸ“Š Reports"):
                gr.Markdown("### Analytics Overview")
                with gr.Row():
                    gr.HTML("<div style='background-color:#efe9d5;padding:15px;border-radius:10px;'>Top 5 ZIPs - Rewards</div>")
                    gr.HTML("<div style='background-color:#efe9d5;padding:15px;border-radius:10px;'>Top 5 ZIPs - Learning Scores</div>")
                # Static example plots
                zip_codes = ["36088", "36104", "36701", "36801", "35124"]
                rewards = [45, 25, 50, 35, 30]
                scores = [88, 65, 92, 74, 80]
                fig1, ax1 = plt.subplots()
                ax1.bar(zip_codes, rewards, color="#a89f91")
                ax1.set_title("Rewards by ZIP Code")
                fig2, ax2 = plt.subplots()
                ax2.bar(zip_codes, scores, color="#b3aa99")
                ax2.set_title("Learning Scores by ZIP")
                gr.Plot(fig1)
                gr.Plot(fig2)

            with gr.Tab("πŸ’Ό Sponsorships"):
                gr.Markdown("### Manage sponsorship initiatives and upcoming campaigns here.")
                sponsorship_idea = gr.Textbox(
                    label="New Sponsorship Idea",
                    placeholder="Describe a potential partnership...",
                    lines=2
                )
                submit_btn = gr.Button("Submit Proposal")
                confirmation = gr.Textbox(label="Submission Status", interactive=False)

                def submit_sponsorship(idea):
                    if idea.strip() == "":
                        return "⚠️ Please describe your sponsorship idea before submitting."
                    return f"βœ… Thanks for your idea: \"{idea}\" β€” our partnerships team will review it soon!"

                submit_btn.click(fn=submit_sponsorship, inputs=sponsorship_idea, outputs=confirmation)

            with gr.Tab("🌍 Impact"):
                gr.Markdown("### Community Impact Overview")
                gr.Markdown("- **Families Supported:** 2,450\n- **Workshops Completed:** 1,220\n- **Corporate Hours Donated:** 890")

    # --- COMMUNITY PORTAL ---
    with gr.Group(visible=False) as community_portal:
        gr.Markdown("## πŸ‘€ Community User Portal")
        with gr.Tab("Login"):
            c_user = gr.Textbox(label="", placeholder="Enter your username or email")
            c_pass = gr.Textbox(label="", type="password", placeholder="Enter your password")
            c_button = gr.Button("Login")
            c_output = gr.Textbox(label="Login Message", interactive=False)
            c_button.click(
                fn=community_login,
                inputs=[c_user, c_pass],
                outputs=[intro_buttons, community_portal, community_dashboard, c_output],
            )
        with gr.Tab("Sign Up"):
            f_name = gr.Textbox(label="", placeholder="Enter your first name")
            l_name = gr.Textbox(label="", placeholder="Enter your last name")
            email = gr.Textbox(label="", placeholder="Enter your email")
            zip_code = gr.Textbox(label="", placeholder="Enter your zip code (optional)")
            interests = gr.CheckboxGroup(
                ["Cooking", "Budgeting", "Job Skills", "Health & Wellness", "Technology"],
                label="Learning Interests", interactive=True,
            )
            s_button = gr.Button("Sign Up")
            s_output = gr.Textbox(label="Registration Result", interactive=False)
            s_button.click(
                fn=community_signup,
                inputs=[f_name, l_name, email, zip_code, interests],
                outputs=s_output,
            )

    # --- CORPORATE PORTAL ---
    with gr.Group(visible=False) as corporate_portal:
        gr.Markdown("## 🏒 Corporate Partner Login")
        corp_user = gr.Textbox(label="", placeholder="Enter your username")
        corp_pass = gr.Textbox(label="", type="password", placeholder="Enter your password")
        corp_button = gr.Button("Login")
        corp_output = gr.Textbox(label="Login Status", interactive=False)
        corp_button.click(
            fn=corporate_login,
            inputs=[corp_user, corp_pass],
            outputs=[intro_buttons, corporate_portal, corporate_dashboard, corp_output],
        )

    # --- LOGOUT + BUTTON LOGIC ---
    logout_btn = gr.Button(visible=False)
    logout_btn.click(fn=logout, outputs=[intro_buttons, community_dashboard, corporate_dashboard])

    def open_user_portal():
        return gr.update(visible=True), gr.update(visible=False)
    def open_corporate_portal():
        return gr.update(visible=False), gr.update(visible=True)

    user_btn.click(fn=open_user_portal, outputs=[community_portal, corporate_portal])
    corp_btn.click(fn=open_corporate_portal, outputs=[community_portal, corporate_portal])


# --- RUN APP ---
if __name__ == "__main__":
    demo.launch()