File size: 3,017 Bytes
eb0b2fd
 
 
 
133970f
eb0b2fd
 
 
 
caf951b
eb0b2fd
 
 
 
 
caf951b
eb0b2fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5b54d38
eb0b2fd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7f9b0d5
eb0b2fd
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
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)