add dancer select

main
Zynh0722 2023-11-17 14:37:56 -08:00
parent 5f6e05371c
commit 9e721cacfe
2 changed files with 31 additions and 16 deletions

View File

@ -5,7 +5,7 @@ mod tracing_handler;
use cm_lib::{
hx_request::HxRequest,
models::{Drink, Shift},
models::{Drink, Shift, Dancer},
render,
report::GenerateDrinkReport,
schema::shifts,
@ -162,6 +162,14 @@ async fn ada() -> impl IntoResponse {
render!(ada_html)
}
async fn shows(Path(id): Path<u32>) -> impl IntoResponse {
render!(shows_html, id)
async fn shows(State(state): State<AppState>, Path(id): Path<u32>) -> impl IntoResponse {
let dancers: Vec<Dancer> = {
use cm_lib::schema::dancers::dsl::*;
let mut conn = state.connection.get().await.unwrap();
dancers.load(&mut conn).await.unwrap()
};
render!(shows_html, id, dancers)
}

View File

@ -1,22 +1,29 @@
@use super::base_html;
@use super::components::return_to_main_html;
@use cm_lib::models::Dancer;
@(shift_id: u32)
@(shift_id: u32, dancers: Vec<Dancer>)
@:base_html({
<div hx-swap="outerHTML" hx-target="this" class="h-full">
<div hx-swap="outerHTML" hx-target="this" class="h-full">
<div class="fixed right-0 top-0 pr-4 pt-4">
@:return_to_main_html()
</div>
<form hx-post="/api/drinks" class="h-full flex items-center justify-center gap-28">
<select>
@for dancer in dancers {
<option value="@dancer.id">@dancer.stage_name</option>
}
</select>
<input type="hidden" id="shift" name="shift" value="@shift_id" />
<button type="submit"
class="focus:outline-none text-white bg-green-700 hover:bg-green-800 focus:ring-4 focus:ring-green-300 font-medium rounded-lg text-sm px-5 py-2.5 dark:bg-green-600 dark:hover:bg-green-700 dark:focus:ring-green-800">
Submit
</button>
</form>
</div>
</div>
})