commiting old work

This commit is contained in:
Zynh0722 2023-10-19 03:16:16 -07:00
parent 5f1cc358fd
commit 087916a9bc
3 changed files with 75 additions and 16 deletions

39
dist/app.css vendored
View file

@ -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%;
}

View file

@ -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<Shift> = {
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)),
)
}

View file

@ -4,26 +4,30 @@
@:base_html({
<form action="/api/drinks" method="post">
<input required type="radio" id="two" name="price" value="2" />
<label for="two">$2</label>
<form hx-swap="outerHTML" hx-post="/api/drinks">
<fieldset>
<input hidden required type="radio" id="two" name="price" value="2" />
<label for="two">$2</label>
<input type="radio" id="three" name="price" value="3" />
<label for="three">$3</label>
<input hidden type="radio" id="three" name="price" value="3" />
<label for="three">$3</label>
<input type="radio" id="five" name="price" value="5" />
<label for="five">$5</label>
<input hidden type="radio" id="five" name="price" value="5" />
<label for="five">$5</label>
<input type="radio" id="eight" name="price" value="8" />
<label for="eight">$8</label>
<input hidden type="radio" id="eight" name="price" value="8" />
<label for="eight">$8</label>
<input type="radio" id="fifteen" name="price" value="15" />
<label for="fifteen">$15</label>
<input hidden type="radio" id="fifteen" name="price" value="15" />
<label for="fifteen">$15</label>
</fieldset>
<label for="quantity">Quantity: </label>
<input type="number" id="quantity" name="quantity" value="1" />
<div>
<label for="quantity">Quantity: </label>
<input type="number" id="quantity" name="quantity" step="1" value="1" />
<input type="hidden" id="shift_id" name="shift_id" value="@shift_id" />
<input type="hidden" id="shift_id" name="shift_id" value="@shift_id" />
<div>
<button type="submit">
submit