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
This commit is contained in:
Benjamin Slingo 2025-08-30 11:50:21 -04:00
parent 72a776b431
commit adacf443e5
2 changed files with 9 additions and 0 deletions

View file

@ -24,3 +24,11 @@ pub async fn get_admin_config(State(state): State<AppState>) -> Result<Json<ApiR
pub async fn get_recurring_types() -> Json<Vec<&'static str>> {
Json(crate::utils::validation::get_valid_recurring_types())
}
pub async fn update_config(
State(state): State<AppState>,
Json(config): Json<ChurchConfig>,
) -> Result<Json<ApiResponse<ChurchConfig>>> {
let updated_config = ConfigService::update_config(&state.pool, config).await?;
Ok(success_response(updated_config))
}

View file

@ -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))