IAMTFRMZA commited on
Commit
fc5dce8
Β·
verified Β·
1 Parent(s): d5bcf89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -4
app.py CHANGED
@@ -2,6 +2,7 @@ import pandas as pd
2
  import gspread
3
  import gradio as gr
4
  from oauth2client.service_account import ServiceAccountCredentials
 
5
 
6
  # ------------------ AUTH ------------------
7
  VALID_USERS = {
@@ -27,12 +28,12 @@ def load_sheet(sheet_name):
27
  # ------------------ REPORTS TAB ------------------
28
  def filter_calls_by_date(date):
29
  df = load_sheet("Calls")
30
- df['Date'] = pd.to_datetime(df['Date'], errors='coerce').dt.date.astype(str)
31
  return df[df['Date'] == date]
32
 
33
  def filter_appointments_by_date(date):
34
  df = load_sheet("Appointments")
35
- df['Date'] = pd.to_datetime(df['Date'], errors='coerce').dt.date.astype(str)
36
  return df[df['Date'] == date]
37
 
38
  # ------------------ APPOINTED LEADS ------------------
@@ -63,12 +64,12 @@ with gr.Blocks() as app:
63
  gr.Markdown("## πŸ—‚οΈ Graffiti Admin Dashboard")
64
 
65
  with gr.Tab("πŸ“… Calls Report"):
66
- calls_date = gr.Textbox(label="Enter Date (YYYY-MM-DD)")
67
  calls_table = gr.Dataframe()
68
  calls_date.change(lambda d: filter_calls_by_date(d), inputs=calls_date, outputs=calls_table)
69
 
70
  with gr.Tab("πŸ“… Appointments Report"):
71
- appt_date = gr.Textbox(label="Enter Date (YYYY-MM-DD)")
72
  appt_table = gr.Dataframe()
73
  appt_date.change(lambda d: filter_appointments_by_date(d), inputs=appt_date, outputs=appt_table)
74
 
 
2
  import gspread
3
  import gradio as gr
4
  from oauth2client.service_account import ServiceAccountCredentials
5
+ from datetime import datetime
6
 
7
  # ------------------ AUTH ------------------
8
  VALID_USERS = {
 
28
  # ------------------ REPORTS TAB ------------------
29
  def filter_calls_by_date(date):
30
  df = load_sheet("Calls")
31
+ df['Date'] = pd.to_datetime(df['Date'], errors='coerce').dt.date
32
  return df[df['Date'] == date]
33
 
34
  def filter_appointments_by_date(date):
35
  df = load_sheet("Appointments")
36
+ df['Date'] = pd.to_datetime(df['Date'], errors='coerce').dt.date
37
  return df[df['Date'] == date]
38
 
39
  # ------------------ APPOINTED LEADS ------------------
 
64
  gr.Markdown("## πŸ—‚οΈ Graffiti Admin Dashboard")
65
 
66
  with gr.Tab("πŸ“… Calls Report"):
67
+ calls_date = gr.Date(label="Select Date")
68
  calls_table = gr.Dataframe()
69
  calls_date.change(lambda d: filter_calls_by_date(d), inputs=calls_date, outputs=calls_table)
70
 
71
  with gr.Tab("πŸ“… Appointments Report"):
72
+ appt_date = gr.Date(label="Select Date")
73
  appt_table = gr.Dataframe()
74
  appt_date.change(lambda d: filter_appointments_by_date(d), inputs=appt_date, outputs=appt_table)
75