Akshayram1 commited on
Commit
5d347a3
·
verified ·
1 Parent(s): 737dc7a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -12
app.py CHANGED
@@ -3,7 +3,6 @@ import firebase_admin
3
  from firebase_admin import credentials, auth, db
4
  import pandas as pd
5
  import plotly.express as px
6
- from datetime import datetime
7
 
8
  # Initialize Firebase
9
  try:
@@ -29,7 +28,7 @@ def login():
29
  user = auth.get_user_by_email(email)
30
  st.session_state['user'] = user
31
  st.success("Logged in successfully!")
32
- st.experimental_rerun()
33
  except Exception as e:
34
  st.error("Invalid credentials. Please try again.")
35
  return submit_button
@@ -75,13 +74,11 @@ def main():
75
 
76
  st.title("💰 Financial Dashboard")
77
 
78
- # Add logout button
79
  # Add logout button
80
  if st.sidebar.button("Logout"):
81
  st.session_state.pop('user', None)
82
  st.rerun() # Updated line
83
 
84
-
85
  # Get user data
86
  user = st.session_state['user']
87
  df = get_user_transactions(user.uid)
@@ -95,15 +92,19 @@ def main():
95
  months = sorted(df['month'].unique())
96
  selected_months = st.sidebar.multiselect("Select Months", months, default=months)
97
 
98
- # Transaction type filter
99
  transaction_types = sorted(df['transactionType'].unique())
100
- selected_types = st.sidebar.multiselect("Transaction Types", transaction_types, default=transaction_types)
101
-
 
102
  # Filter data
103
- filtered_df = df[
104
- (df['month'].isin(selected_months)) &
105
- (df['transactionType'].isin(selected_types))
106
- ]
 
 
 
107
 
108
  # Dashboard layout
109
  col1, col2, col3 = st.columns(3)
@@ -182,4 +183,4 @@ def main():
182
  )
183
 
184
  if __name__ == "__main__":
185
- main()
 
3
  from firebase_admin import credentials, auth, db
4
  import pandas as pd
5
  import plotly.express as px
 
6
 
7
  # Initialize Firebase
8
  try:
 
28
  user = auth.get_user_by_email(email)
29
  st.session_state['user'] = user
30
  st.success("Logged in successfully!")
31
+ st.rerun() # Use st.rerun() instead of st.experimental_rerun()
32
  except Exception as e:
33
  st.error("Invalid credentials. Please try again.")
34
  return submit_button
 
74
 
75
  st.title("💰 Financial Dashboard")
76
 
 
77
  # Add logout button
78
  if st.sidebar.button("Logout"):
79
  st.session_state.pop('user', None)
80
  st.rerun() # Updated line
81
 
 
82
  # Get user data
83
  user = st.session_state['user']
84
  df = get_user_transactions(user.uid)
 
92
  months = sorted(df['month'].unique())
93
  selected_months = st.sidebar.multiselect("Select Months", months, default=months)
94
 
95
+ # Transaction type filter with "All" option
96
  transaction_types = sorted(df['transactionType'].unique())
97
+ transaction_types.insert(0, "All") # Add "All" option at the beginning
98
+ selected_types = st.sidebar.multiselect("Transaction Types", transaction_types, default=transaction_types[1:])
99
+
100
  # Filter data
101
+ if "All" in selected_types:
102
+ filtered_df = df[df['month'].isin(selected_months)]
103
+ else:
104
+ filtered_df = df[
105
+ (df['month'].isin(selected_months)) &
106
+ (df['transactionType'].isin(selected_types))
107
+ ]
108
 
109
  # Dashboard layout
110
  col1, col2, col3 = st.columns(3)
 
183
  )
184
 
185
  if __name__ == "__main__":
186
+ main()