import streamlit as st
import os
# ── 1. CONFIG & ASSETS ────────────────────────────────────────────────────────
st.set_page_config(page_title="Wercore | App Generator", page_icon="🏢", layout="wide")
st.markdown("""
""", unsafe_allow_html=True)
st.logo("WERCORE logo.png")
# ── 2. LOGIN SYSTEM ───────────────────────────────────────────────────────────
if not st.session_state.get("authenticated", False):
# CRITICAL FIX: Hide the sidebar and its toggle button entirely until logged in
st.markdown("""
""", unsafe_allow_html=True)
col1, col2, col3 = st.columns([1, 2, 1])
with col2:
st.title("🔒 Wercore Portal")
st.info("Please log in to access the reporting engines.")
password = st.text_input("Master Password", type="password")
if st.button("Secure Login", type="primary", use_container_width=True):
if password == "Wercore2026":
st.session_state["authenticated"] = True
st.rerun()
else:
st.error("❌ Incorrect Password.")
st.stop()
# ── 3. HEADER ─────────────────────────────────────────────────────────────────
st.title("Wercore App Generator")
st.markdown("Select a reporting engine below to begin generating compliance documentation.")
st.markdown("---")
# ── 4. NAVIGATION GRID (CRASH-PROOF) ──────────────────────────────────────────
# This function stops the app from crashing if a file name is misspelled
def safe_link(file_path, label, icon):
if os.path.exists(file_path):
st.page_link(file_path, label=label, icon=icon)
else:
st.warning(f"⚠️ **Missing File:** Please ensure `{file_path}` exists.")
col1, col2 = st.columns(2)
with col1:
safe_link("pages/1_Water_Tank_Report.py", "Water Tank Disinfection", "💧")
st.write("") # Spacer
safe_link("pages/4_Pipeline_Disinfection.py", "Pipeline Disinfection", "🚰")
with col2:
safe_link("pages/2_Pest_Control_Report.py", "Pest Control Report", "🪳")
st.write("") # Spacer
# Updated to the correct exact filename you provided
safe_link("pages/3_Termite_Control_Report.py", "Termite Control Report", "🐜")
st.markdown("---")
st.caption("© 2026 Sterdil Labs")