use crate::{ app::AppState, error::AppResult, models::club::Club, services::{club as club_svc, profile as profile_svc}, }; use axum::{extract::State, Json}; use serde::Deserialize; use serde_json::{json, Value}; pub async fn get_club(State(state): State) -> AppResult> { let profile = profile_svc::get_active_profile(&state.pool).await?; let club = club_svc::get_club_by_profile(&state.pool, &profile.id).await?; Ok(Json(club)) } #[derive(Deserialize)] pub struct UpdateClubRequest { pub name: Option, pub manager_name: Option, } pub async fn put_club( State(state): State, Json(req): Json, ) -> AppResult> { let profile = profile_svc::get_active_profile(&state.pool).await?; let club = club_svc::get_club_by_profile(&state.pool, &profile.id).await?; let updated = club_svc::update_club( &state.pool, &club.id, req.name.as_deref(), req.manager_name.as_deref(), ) .await?; Ok(Json(json!({ "club": updated }))) }