From adacf443e574b3d000713e069bd91fce909c3687 Mon Sep 17 00:00:00 2001 From: Benjamin Slingo Date: Sat, 30 Aug 2025 11:50:21 -0400 Subject: [PATCH] Add config update endpoint for admin panel - Add update_config handler in config.rs (6 lines) - Add PUT /config route in main.rs (1 line) - Enables admin panel to update church configuration - Follows existing DRY/KISS architecture patterns --- src/handlers/config.rs | 8 ++++++++ src/main.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/src/handlers/config.rs b/src/handlers/config.rs index 015ac8c..7a5ed12 100644 --- a/src/handlers/config.rs +++ b/src/handlers/config.rs @@ -24,3 +24,11 @@ pub async fn get_admin_config(State(state): State) -> Result Json> { Json(crate::utils::validation::get_valid_recurring_types()) } + +pub async fn update_config( + State(state): State, + Json(config): Json, +) -> Result>> { + let updated_config = ConfigService::update_config(&state.pool, config).await?; + Ok(success_response(updated_config)) +} diff --git a/src/main.rs b/src/main.rs index 8abdb1b..de8db0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -88,6 +88,7 @@ async fn main() -> Result<()> { .route("/events/pending/:id", delete(handlers::events::delete_pending)) .route("/events/:id", delete(handlers::events::delete)) .route("/config", get(handlers::config::get_admin_config)) + .route("/config", put(handlers::config::update_config)) .route("/schedule", post(handlers::schedule::create_schedule)) .route("/schedule/:date", put(handlers::schedule::update_schedule)) .route("/schedule/:date", delete(handlers::schedule::delete_schedule))