Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import time
|
|
|
|
| 4 |
|
| 5 |
# Sample user data for login
|
| 6 |
users = {
|
|
@@ -9,137 +10,96 @@ users = {
|
|
| 9 |
"customer789": {"password": "customerpass", "role": "Customer"},
|
| 10 |
}
|
| 11 |
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
/* Sidebar title color */
|
| 28 |
-
section[data-testid="stSidebar"] p {
|
| 29 |
-
color: white; /* Title text color for "Navigation" */
|
| 30 |
-
}
|
| 31 |
-
|
| 32 |
-
/* Input fields styling */
|
| 33 |
-
input, textarea, .stFileUploader {
|
| 34 |
-
background-color: white !important; /* White background */
|
| 35 |
-
border: 2px solid #084C3C !important; /* Dark green border */
|
| 36 |
-
color: #084C3C !important; /* Dark green text */
|
| 37 |
-
border-radius: 5px !important; /* Rounded corners */
|
| 38 |
-
}
|
| 39 |
-
|
| 40 |
-
/* Submit button styling */
|
| 41 |
-
div[data-testid="stFormSubmitButton"] button, div.stButton > button {
|
| 42 |
-
background-color: #084C3C !important; /* Dark green background */
|
| 43 |
-
color: white !important; /* White text */
|
| 44 |
-
border-radius: 5px !important;
|
| 45 |
-
padding: 10px 20px !important;
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
div[data-testid="stFormSubmitButton"] button:hover, div.stButton > button:hover {
|
| 49 |
-
background-color: #066B4E !important; /* Lighter green on hover */
|
| 50 |
-
}
|
| 51 |
-
|
| 52 |
-
/* Text color */
|
| 53 |
-
.stApp div:not([data-testid="stSidebar"]) label {
|
| 54 |
-
color: #084C3C;
|
| 55 |
-
}
|
| 56 |
-
|
| 57 |
-
/* Table styles */
|
| 58 |
-
table {
|
| 59 |
-
border-collapse: collapse;
|
| 60 |
-
width: 100%;
|
| 61 |
-
}
|
| 62 |
-
|
| 63 |
-
th, td {
|
| 64 |
-
text-align: left;
|
| 65 |
-
padding: 8px;
|
| 66 |
-
color: #084C3C;
|
| 67 |
-
border: 1px solid #084C3C;
|
| 68 |
-
}
|
| 69 |
-
|
| 70 |
-
th {
|
| 71 |
-
background-color: #E4ECE3;
|
| 72 |
-
}
|
| 73 |
-
|
| 74 |
-
tr:nth-child(even) {
|
| 75 |
-
background-color: #f9f9f9;
|
| 76 |
-
}
|
| 77 |
-
</style>
|
| 78 |
-
""",
|
| 79 |
-
unsafe_allow_html=True
|
| 80 |
-
)
|
| 81 |
-
|
| 82 |
-
if "logged_in" not in st.session_state:
|
| 83 |
-
st.session_state["logged_in"] = False
|
| 84 |
-
st.session_state["user_role"] = None
|
| 85 |
-
|
| 86 |
-
if not st.session_state["logged_in"]:
|
| 87 |
-
login_page()
|
| 88 |
-
else:
|
| 89 |
-
user_role = st.session_state["user_role"]
|
| 90 |
-
st.sidebar.title("Navigation")
|
| 91 |
-
if user_role == "Customer":
|
| 92 |
-
page = st.sidebar.radio(
|
| 93 |
-
"Go to", ["Submit Ticket", "Check Ticket Status", "FAQ & Info"]
|
| 94 |
-
)
|
| 95 |
-
elif user_role == "Manager":
|
| 96 |
-
page = st.sidebar.radio(
|
| 97 |
-
"Go to",
|
| 98 |
-
["Management Dashboard", "Ticket Dashboard", "Customer Dashboard"],
|
| 99 |
-
)
|
| 100 |
-
elif user_role == "Employee":
|
| 101 |
-
page = st.sidebar.radio(
|
| 102 |
-
"Go to", ["Respond to a Ticket", "Ticket Status"]
|
| 103 |
-
)
|
| 104 |
-
else:
|
| 105 |
-
st.error("Unknown user role!")
|
| 106 |
-
return
|
| 107 |
-
|
| 108 |
-
if page == "Submit Ticket":
|
| 109 |
-
submit_ticket_page()
|
| 110 |
-
elif page == "Check Ticket Status":
|
| 111 |
-
check_ticket_status_page()
|
| 112 |
-
elif page == "FAQ & Info":
|
| 113 |
-
faq_info_page()
|
| 114 |
-
elif page == "Management Dashboard":
|
| 115 |
-
management_dashboard_page()
|
| 116 |
-
elif page == "Ticket Dashboard":
|
| 117 |
-
ticket_dashboard_page()
|
| 118 |
-
elif page == "Customer Dashboard":
|
| 119 |
-
customer_dashboard_page()
|
| 120 |
-
elif page == "Respond to a Ticket":
|
| 121 |
-
respond_to_ticket_page()
|
| 122 |
-
elif page == "Ticket Status":
|
| 123 |
-
employee_ticket_status_page()
|
| 124 |
|
| 125 |
def login_page():
|
|
|
|
| 126 |
st.title("Login Page")
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
def submit_ticket_page():
|
|
|
|
| 141 |
st.title("Submit a Ticket")
|
| 142 |
with st.form(key="submit_ticket_form"):
|
|
|
|
| 143 |
st.text_input("First Name")
|
| 144 |
st.text_input("Last Name")
|
| 145 |
st.text_input("National ID / Residency Number")
|
|
@@ -149,18 +109,15 @@ def submit_ticket_page():
|
|
| 149 |
st.text_area("Describe your issue/request")
|
| 150 |
st.file_uploader("Upload Attachments (if any)", accept_multiple_files=True)
|
| 151 |
if st.form_submit_button("Submit"):
|
| 152 |
-
st.success("Your ticket has been submitted.")
|
| 153 |
|
| 154 |
def check_ticket_status_page():
|
|
|
|
| 155 |
st.title("Check Ticket Status")
|
| 156 |
-
|
| 157 |
if st.button("Check Status"):
|
| 158 |
-
if
|
| 159 |
-
st.
|
| 160 |
-
f"<p style='color: #084C3C;'>Displaying tickets for National ID: {national_id}</p>",
|
| 161 |
-
unsafe_allow_html=True,
|
| 162 |
-
)
|
| 163 |
-
# Simulated data
|
| 164 |
ticket_data = {
|
| 165 |
"Ticket Number": ["141", "565", "999"],
|
| 166 |
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
|
@@ -168,23 +125,56 @@ def check_ticket_status_page():
|
|
| 168 |
"Status": ["Resolved", "Pending", "In Progress"],
|
| 169 |
}
|
| 170 |
df = pd.DataFrame(ticket_data)
|
| 171 |
-
st.
|
| 172 |
else:
|
| 173 |
-
st.warning("Please enter your
|
| 174 |
|
| 175 |
def faq_info_page():
|
|
|
|
| 176 |
st.title("FAQ & Information")
|
| 177 |
-
|
| 178 |
("How to open a new account?", "Visit your nearest branch or use our app."),
|
| 179 |
("Branch Operating Hours", "Sunday to Thursday, 9:00 AM to 4:00 PM."),
|
| 180 |
]
|
| 181 |
-
for question, answer in
|
| 182 |
st.subheader(question)
|
| 183 |
st.write(answer)
|
| 184 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 185 |
def management_dashboard_page():
|
| 186 |
st.title("Management Dashboard")
|
| 187 |
-
st.write("
|
| 188 |
|
| 189 |
def ticket_dashboard_page():
|
| 190 |
st.title("Ticket Dashboard")
|
|
@@ -192,15 +182,7 @@ def ticket_dashboard_page():
|
|
| 192 |
|
| 193 |
def customer_dashboard_page():
|
| 194 |
st.title("Customer Dashboard")
|
| 195 |
-
st.write("
|
| 196 |
-
|
| 197 |
-
def respond_to_ticket_page():
|
| 198 |
-
st.title("Respond to a Ticket")
|
| 199 |
-
st.write("Respond to tickets submitted by customers.")
|
| 200 |
-
|
| 201 |
-
def employee_ticket_status_page():
|
| 202 |
-
st.title("Ticket Status")
|
| 203 |
-
st.write("View ticket statuses for employees.")
|
| 204 |
|
| 205 |
if __name__ == "__main__":
|
| 206 |
main()
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
import pandas as pd
|
| 3 |
import time
|
| 4 |
+
import requests
|
| 5 |
|
| 6 |
# Sample user data for login
|
| 7 |
users = {
|
|
|
|
| 10 |
"customer789": {"password": "customerpass", "role": "Customer"},
|
| 11 |
}
|
| 12 |
|
| 13 |
+
# Function to load a Lottie animation from a URL
|
| 14 |
+
def load_lottie_url(url: str):
|
| 15 |
+
r = requests.get(url)
|
| 16 |
+
if r.status_code != 200:
|
| 17 |
+
return None
|
| 18 |
+
return r.json()
|
| 19 |
+
|
| 20 |
+
# URL for the Lottie animation
|
| 21 |
+
lottie_url = "https://assets6.lottiefiles.com/packages/lf20_5hhtik.json"
|
| 22 |
+
lottie_json = load_lottie_url(lottie_url)
|
| 23 |
+
|
| 24 |
+
# Function to display the Lottie animation
|
| 25 |
+
def show_loading_animation():
|
| 26 |
+
if lottie_json:
|
| 27 |
+
st_lottie(lottie_json, height=300, key="loading")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
def login_page():
|
| 30 |
+
st.set_page_config(page_title="Login", layout="centered")
|
| 31 |
st.title("Login Page")
|
| 32 |
+
|
| 33 |
+
if "login_success" not in st.session_state:
|
| 34 |
+
st.session_state["login_success"] = False
|
| 35 |
+
|
| 36 |
+
if not st.session_state["login_success"]:
|
| 37 |
+
username = st.text_input("Username")
|
| 38 |
+
password = st.text_input("Password", type="password")
|
| 39 |
+
|
| 40 |
+
if st.button("Login"):
|
| 41 |
+
if username in users and users[username]["password"] == password:
|
| 42 |
+
st.session_state["user_type"] = users[username]["role"]
|
| 43 |
+
st.session_state["logged_in"] = True
|
| 44 |
+
st.session_state["login_success"] = True
|
| 45 |
+
st.success(f"Logged in successfully as {users[username]['role']}")
|
| 46 |
+
time.sleep(1)
|
| 47 |
+
else:
|
| 48 |
+
st.error("Invalid username or password.")
|
| 49 |
+
|
| 50 |
+
def add_return_to_login():
|
| 51 |
+
if "logged_in" in st.session_state and st.session_state["logged_in"]:
|
| 52 |
+
if st.sidebar.button("Return to Login Page"):
|
| 53 |
+
st.session_state.clear()
|
| 54 |
+
st.rerun()
|
| 55 |
+
|
| 56 |
+
def main():
|
| 57 |
+
if "logged_in" not in st.session_state or not st.session_state["logged_in"]:
|
| 58 |
+
login_page()
|
| 59 |
+
return
|
| 60 |
+
|
| 61 |
+
st.set_page_config(page_title="Ticket System", layout="centered", initial_sidebar_state="expanded")
|
| 62 |
+
add_return_to_login()
|
| 63 |
+
|
| 64 |
+
user_type = st.session_state.get("user_type", "Customer")
|
| 65 |
+
st.sidebar.title("Navigation")
|
| 66 |
+
|
| 67 |
+
if user_type == "Customer":
|
| 68 |
+
page = st.sidebar.radio("Go to", ["Submit Ticket", "Check Ticket Status", "FAQ & Info"])
|
| 69 |
+
elif user_type == "Manager":
|
| 70 |
+
page = st.sidebar.radio("Go to", ["Management Dashboard", "Ticket Dashboard", "Customer Dashboard"])
|
| 71 |
+
elif user_type == "Employee":
|
| 72 |
+
page = st.sidebar.radio("Go to", ["Respond to a Ticket", "Ticket Status"])
|
| 73 |
+
else:
|
| 74 |
+
st.sidebar.write("No pages available for this user type.")
|
| 75 |
+
return
|
| 76 |
+
|
| 77 |
+
with st.spinner("Loading..."):
|
| 78 |
+
show_loading_animation()
|
| 79 |
+
time.sleep(0.5)
|
| 80 |
+
|
| 81 |
+
if page == "Submit Ticket":
|
| 82 |
+
submit_ticket_page()
|
| 83 |
+
elif page == "Check Ticket Status":
|
| 84 |
+
check_ticket_status_page()
|
| 85 |
+
elif page == "FAQ & Info":
|
| 86 |
+
faq_info_page()
|
| 87 |
+
elif page == "Management Dashboard":
|
| 88 |
+
management_dashboard_page()
|
| 89 |
+
elif page == "Ticket Dashboard":
|
| 90 |
+
ticket_dashboard_page()
|
| 91 |
+
elif page == "Customer Dashboard":
|
| 92 |
+
customer_dashboard_page()
|
| 93 |
+
elif page == "Respond to a Ticket":
|
| 94 |
+
respond_to_ticket_page()
|
| 95 |
+
elif page == "Ticket Status":
|
| 96 |
+
employee_ticket_status_page()
|
| 97 |
|
| 98 |
def submit_ticket_page():
|
| 99 |
+
st.image("logo.png", width=200)
|
| 100 |
st.title("Submit a Ticket")
|
| 101 |
with st.form(key="submit_ticket_form"):
|
| 102 |
+
customer_id = st.text_input("Customer ID")
|
| 103 |
st.text_input("First Name")
|
| 104 |
st.text_input("Last Name")
|
| 105 |
st.text_input("National ID / Residency Number")
|
|
|
|
| 109 |
st.text_area("Describe your issue/request")
|
| 110 |
st.file_uploader("Upload Attachments (if any)", accept_multiple_files=True)
|
| 111 |
if st.form_submit_button("Submit"):
|
| 112 |
+
st.success(f"Your ticket has been submitted successfully. Customer ID: {customer_id}")
|
| 113 |
|
| 114 |
def check_ticket_status_page():
|
| 115 |
+
st.image("logo.png", width=200)
|
| 116 |
st.title("Check Ticket Status")
|
| 117 |
+
customer_id = st.text_input("Customer ID")
|
| 118 |
if st.button("Check Status"):
|
| 119 |
+
if customer_id:
|
| 120 |
+
st.success(f"Displaying tickets for Customer ID: {customer_id}")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
ticket_data = {
|
| 122 |
"Ticket Number": ["141", "565", "999"],
|
| 123 |
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
|
|
|
| 125 |
"Status": ["Resolved", "Pending", "In Progress"],
|
| 126 |
}
|
| 127 |
df = pd.DataFrame(ticket_data)
|
| 128 |
+
st.dataframe(df)
|
| 129 |
else:
|
| 130 |
+
st.warning("Please enter your Customer ID.")
|
| 131 |
|
| 132 |
def faq_info_page():
|
| 133 |
+
st.image("logo.png", width=200)
|
| 134 |
st.title("FAQ & Information")
|
| 135 |
+
faq_data = [
|
| 136 |
("How to open a new account?", "Visit your nearest branch or use our app."),
|
| 137 |
("Branch Operating Hours", "Sunday to Thursday, 9:00 AM to 4:00 PM."),
|
| 138 |
]
|
| 139 |
+
for question, answer in faq_data:
|
| 140 |
st.subheader(question)
|
| 141 |
st.write(answer)
|
| 142 |
|
| 143 |
+
def respond_to_ticket_page():
|
| 144 |
+
st.image("logo.png", width=200)
|
| 145 |
+
st.title("Respond to a Ticket")
|
| 146 |
+
ticket_data = {
|
| 147 |
+
"Ticket Number": ["141", "565", "999"],
|
| 148 |
+
"Customer ID": ["C001", "C002", "C003"],
|
| 149 |
+
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
| 150 |
+
"Type": ["General", "Billing", "Technical"],
|
| 151 |
+
"Status": ["Pending", "Pending", "In Progress"],
|
| 152 |
+
}
|
| 153 |
+
df = pd.DataFrame(ticket_data)
|
| 154 |
+
st.dataframe(df)
|
| 155 |
+
ticket_to_respond = st.selectbox("Select a ticket to respond to:", df["Ticket Number"].tolist())
|
| 156 |
+
if st.button("Respond to Ticket"):
|
| 157 |
+
st.text_area("Response:", placeholder="Write your response here...")
|
| 158 |
+
st.button("Submit Response")
|
| 159 |
+
|
| 160 |
+
def employee_ticket_status_page():
|
| 161 |
+
st.image("logo.png", width=200)
|
| 162 |
+
st.title("Ticket Status")
|
| 163 |
+
customer_id = st.text_input("Customer ID")
|
| 164 |
+
if st.button("Check Ticket Status"):
|
| 165 |
+
if customer_id:
|
| 166 |
+
st.success(f"Displaying tickets for Customer ID: {customer_id}")
|
| 167 |
+
ticket_data = {
|
| 168 |
+
"Ticket Number": ["141", "565", "999"],
|
| 169 |
+
"Date": ["2025-01-18", "2025-03-28", "2025-04-01"],
|
| 170 |
+
"Status": ["Resolved", "Pending", "In Progress"],
|
| 171 |
+
}
|
| 172 |
+
df = pd.DataFrame(ticket_data)
|
| 173 |
+
st.dataframe(df)
|
| 174 |
+
|
| 175 |
def management_dashboard_page():
|
| 176 |
st.title("Management Dashboard")
|
| 177 |
+
st.write("Employee and department overviews.")
|
| 178 |
|
| 179 |
def ticket_dashboard_page():
|
| 180 |
st.title("Ticket Dashboard")
|
|
|
|
| 182 |
|
| 183 |
def customer_dashboard_page():
|
| 184 |
st.title("Customer Dashboard")
|
| 185 |
+
st.write("Insights and data on customer interactions.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
if __name__ == "__main__":
|
| 188 |
main()
|