diff --git a/backend/src/calendar.rs b/backend/src/calendar.rs index 2dad967..f602d1f 100644 --- a/backend/src/calendar.rs +++ b/backend/src/calendar.rs @@ -2,7 +2,7 @@ use askama::Template; use askama_axum::{IntoResponse, Response}; use axum::{ extract::State, - response::{Html, Redirect}, + response::{Html, Json, Redirect}, Extension, }; use http::StatusCode; @@ -69,12 +69,13 @@ pub async fn cottagecalendar( } } -async fn get_next_event(db_pool: &SqlitePool) -> Option { - let next_event = sqlx::query_as::<_, (String, String)>( - "SELECT date, title FROM events ORDER BY date ASC LIMIT 1", - ) - .fetch_one(db_pool) - .await; +pub async fn get_events( + Extension(user_data): Extension>, + State(db_pool): State, +) -> String { + let events = "[{\"title\": \"Chris and Terri\", \"start\": \"2024-12-23T14:00:00\", \"end\": \"2024-12-27T10:00:00\", \"allDay\": false}, {\"title\": \"Stephen\", \"start\": \"2024-12-27T14:00:00\", \"end\": \"2024-12-31T10:00:00\", \"allDay\": false}]"; - next_event.map(|(date, title)| format!("{} - {}", date, title)).ok() -} \ No newline at end of file + println!("{}", events); + + events.to_string() +} diff --git a/backend/src/main.rs b/backend/src/main.rs index 3b77e12..577e640 100644 --- a/backend/src/main.rs +++ b/backend/src/main.rs @@ -69,6 +69,7 @@ async fn main() { // Calendar .route("/cottagecalendar", get(cottagecalendar)) + .route("/getevents", get(calendar::get_events)) // Wishlist .route("/wishlists", get(wishlists)) diff --git a/backend/templates/cottagecalendar.html b/backend/templates/cottagecalendar.html index 92a5863..cc2a5c2 100644 --- a/backend/templates/cottagecalendar.html +++ b/backend/templates/cottagecalendar.html @@ -2,451 +2,50 @@ {% block links %} - - {% endblock links %} {% block center %}

Cottage Calendar

-
- - - - - - -