From 087916a9bc8b76e53a4962f1d9a6725971e29a5d Mon Sep 17 00:00:00 2001 From: Zynh0722 Date: Thu, 19 Oct 2023 03:16:16 -0700 Subject: [PATCH] commiting old work --- dist/app.css | 39 +++++++++++++++++++++++++++++++++++++++ src/api.rs | 20 ++++++++++++++++++-- templates/drinks.rs.html | 32 ++++++++++++++++++-------------- 3 files changed, 75 insertions(+), 16 deletions(-) diff --git a/dist/app.css b/dist/app.css index 8b13789..abe3d05 100644 --- a/dist/app.css +++ b/dist/app.css @@ -1 +1,40 @@ +fieldset { + all: unset; + display: flex; + flex-direction: column; + font-size: 2rem; + text-align: center; + border: 1px solid black; + border-radius: 1rem; + overflow: hidden; +} +input[type="radio"]+label { + padding: 1rem; +} + +input[type="radio"]+label:hover { + background-color: lightblue; + filter: brightness(1.1); +} + +input[type="radio"]:checked+label { + background-color: lightblue; +} + +form { + height: 100%; + display: flex; + align-items: center; + justify-content: center; + gap: 7rem; +} + +body { + all: unset; + height: 100%; +} + +html { + height: 100%; +} diff --git a/src/api.rs b/src/api.rs index cc4023d..703880d 100644 --- a/src/api.rs +++ b/src/api.rs @@ -79,7 +79,18 @@ async fn add_drink( ) -> impl IntoResponse { let mut conn = state.connection.get().await.unwrap(); - tracing::debug!("{form:?}"); + let open_shift: Option = { + use cm_lib::schema::shifts::dsl::*; + + shifts + .filter(end.is_null()) + .select(Shift::as_select()) + .first(&mut conn) + .await + .optional() + .expect("Query failed: No open shifts found") + }; + let open_shift = open_shift.unwrap(); async { use cm_lib::schema::drinks::dsl::*; @@ -92,5 +103,10 @@ async fn add_drink( } .await; - axum::response::Redirect::to("/") + let mut headers = axum::http::HeaderMap::new(); + headers.insert("HX-Push-Url", "/".parse().unwrap()); + ( + headers, + render!(crate::templates::home_html, Some(open_shift)), + ) } diff --git a/templates/drinks.rs.html b/templates/drinks.rs.html index bfe5bf6..e0bea53 100644 --- a/templates/drinks.rs.html +++ b/templates/drinks.rs.html @@ -4,26 +4,30 @@ @:base_html({ -
- - + +
+ + - - + + - - + + - - + + - - + + +
- - +
+ + - + +