commiting old work
parent
5f1cc358fd
commit
087916a9bc
|
@ -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%;
|
||||
}
|
||||
|
|
20
src/api.rs
20
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<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)),
|
||||
)
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue