Spaces:
Runtime error
Runtime error
| from streamlit_calendar import calendar | |
| import streamlit as st | |
| from datetime import datetime | |
| from zoneinfo import ZoneInfo | |
| from data.solicitar_data import (get_event) | |
| import pandas as pd | |
| import json | |
| from pandasql import sqldf | |
| from auth import (get_id_cliente_reciclador) | |
| import url64 | |
| st.set_page_config(page_title="Lista de recolecciones", page_icon="📆", layout="wide") | |
| query_params = st.experimental_get_query_params() | |
| auth_token = url64.decode(query_params.get("t", [""])[0]) | |
| id_clientereciclador = None | |
| if query_params.get("demo", [None])[0] == "true": | |
| id_clientereciclador = 2 | |
| else: | |
| raw_token = query_params.get("t", [None])[0] | |
| if raw_token is not None: | |
| # Get user id from token | |
| id_clientereciclador = get_id_cliente_reciclador(raw_token) | |
| if id_clientereciclador is None: | |
| st.write("🔒 Parece que no tienes permiso para ver esto.") | |
| else: | |
| st.title("Lista de Recolección 🚚 📆") | |
| st.markdown('### <span style="color:#9656E2; text-align: center">© Blau tecnología para residuos | blaucorp.com </span>', unsafe_allow_html=True) | |
| data = get_event(id_clientereciclador) | |
| now = datetime.now(ZoneInfo('America/Mexico_City')) | |
| mode = st.selectbox( | |
| "Modo de calendario:", | |
| ( | |
| "Vista por dia y semana", | |
| "Vista de lista", | |
| "Vista Mensual", | |
| ) | |
| ) | |
| st.markdown('Significado de colores: <span style="color:#2ECC71;"> Completado </span>, <span style="color:#F1C40F;"> Pendiente </span>, <span style="color:#E67E22;"> Servicio con incidencia</span>, <span style="color:#E74C3C;"> Servicio Cancelado </span>', | |
| unsafe_allow_html=True | |
| ) | |
| calendar_options = { | |
| "editable": "false", | |
| "locale": "es", | |
| "firstDay": 1 | |
| } | |
| if mode == "Vista por dia y semana": | |
| calendar_options = { | |
| "editable": "false", | |
| "headerToolbar": { | |
| "left": "today prev,next", | |
| "center": "title", | |
| "right": "dayGridDay,dayGridWeek", | |
| }, | |
| "navLinks": "true", | |
| "initialDate": str(now), | |
| "initialView": "dayGridWeek", | |
| "locale": "es", | |
| "firstDay": 1 | |
| } | |
| elif mode == "Vista de lista": | |
| calendar_options = { | |
| "editable": "false", | |
| "navLinks": "false", | |
| "initialDate": str(now), | |
| "initialView": "listDay", | |
| "locale": "es", | |
| "firstDay": 1 | |
| } | |
| elif mode == "Vista Mensual": | |
| calendar_options = { | |
| "editable": "false", | |
| "navLinks": "true", | |
| "initialView": "multiMonthYear", | |
| "locale": "es", | |
| "firstDay": 1 | |
| } | |
| data_json = json.loads(data.to_json(orient='records', date_format='iso')) | |
| state = calendar( | |
| events=st.session_state.get("events", data_json), | |
| options=calendar_options, | |
| key=mode | |
| ) | |
| #Show the log of the click | |
| #st.write(state) |