add dancer select

This commit is contained in:
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::{ use cm_lib::{
hx_request::HxRequest, hx_request::HxRequest,
models::{Drink, Shift}, models::{Drink, Shift, Dancer},
render, render,
report::GenerateDrinkReport, report::GenerateDrinkReport,
schema::shifts, schema::shifts,
@ -162,6 +162,14 @@ async fn ada() -> impl IntoResponse {
render!(ada_html) render!(ada_html)
} }
async fn shows(Path(id): Path<u32>) -> impl IntoResponse { async fn shows(State(state): State<AppState>, Path(id): Path<u32>) -> impl IntoResponse {
render!(shows_html, id) 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::base_html;
@use super::components::return_to_main_html; @use super::components::return_to_main_html;
@use cm_lib::models::Dancer;
@(shift_id: u32) @(shift_id: u32, dancers: Vec<Dancer>)
@:base_html({ @: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"> <div class="fixed right-0 top-0 pr-4 pt-4">
@:return_to_main_html() @:return_to_main_html()
</div> </div>
<form hx-post="/api/drinks" class="h-full flex items-center justify-center gap-28"> <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" /> <input type="hidden" id="shift" name="shift" value="@shift_id" />
<button type="submit" <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"> 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 Submit
</button> </button>
</form> </form>
</div> </div>
}) })