added workout viewing simple view

This commit is contained in:
2025-07-15 17:31:29 +02:00
parent d1029485d4
commit 5c0bb602f5
5 changed files with 171 additions and 7 deletions

View File

@@ -2,13 +2,14 @@ use crate::{AppError, icons, layouts, util::AppState};
use axum::{Router, extract::State, routing::get};
use maud::{Markup, html};
mod id;
mod new;
pub fn routes() -> Router<AppState> {
Router::new()
.route("/", get(page))
.nest("/new", new::routes())
// .nest("/{id}", id::routes())
.nest("/{id}", id::routes())
}
async fn page(State(state): State<AppState>) -> Result<Markup, AppError> {
@@ -22,15 +23,15 @@ async fn page(State(state): State<AppState>) -> Result<Markup, AppError> {
let content = html! {
h1 { "Workouts" }
a href="/workouts/new" { "new workout +" }
ul class="list" {
div class="list" {
@for workout in workouts {
li hx-get={ "/workouts/" (workout.workout_id) } hx-target="body" hx-push-url="true" class="list-row" {
a href={ "/workouts/" (workout.workout_id) } class="list-row" {
div {}
div {
div class="font-bold" { (workout.name) }
div class="text-xs" { (workout.description) }
}
a class="btn btn-square btn-ghost" {
div class="btn btn-square btn-ghost" {
div class="size-[1.6em]" {
(icons::eye())
}
@@ -40,5 +41,5 @@ async fn page(State(state): State<AppState>) -> Result<Markup, AppError> {
}
};
Ok(layouts::desktop(content, "Exercises"))
Ok(layouts::desktop(content, "Workouts"))
}