diff --git a/src/handlers/events.rs b/src/handlers/events.rs index 1111f76..d588709 100644 --- a/src/handlers/events.rs +++ b/src/handlers/events.rs @@ -24,7 +24,7 @@ use crate::{ services::EventService, error::Result, models::{Event, PendingEvent, ApiResponse, PaginatedResponse}, - AppState, db, + AppState, }; // Use shared ListQueryParams instead of custom EventQuery @@ -210,8 +210,8 @@ pub async fn approve( State(state): State, Json(req): Json, ) -> Result>> { - let pending_event = db::events::get_pending_by_id(&state.pool, &id).await? - .ok_or_else(|| ApiError::NotFound("Pending event not found".to_string()))?; + let pending_event = EventService::get_pending_by_id(&state.pool, &id).await? + .ok_or_else(|| ApiError::event_not_found(&id))?; let event = EventService::approve_pending_event(&state.pool, &id).await?; @@ -231,8 +231,8 @@ pub async fn reject( State(state): State, Json(req): Json, ) -> Result>> { - let pending_event = db::events::get_pending_by_id(&state.pool, &id).await? - .ok_or_else(|| ApiError::NotFound("Pending event not found".to_string()))?; + let pending_event = EventService::get_pending_by_id(&state.pool, &id).await? + .ok_or_else(|| ApiError::event_not_found(&id))?; EventService::reject_pending_event(&state.pool, &id, req.admin_notes.clone()).await?; diff --git a/src/services/events.rs b/src/services/events.rs index 9e0a373..8ee8be9 100644 --- a/src/services/events.rs +++ b/src/services/events.rs @@ -127,4 +127,10 @@ impl EventService { // Future: Add business logic like authorization checks, cleanup, etc. db::events::delete_pending(pool, id).await } + + /// Get pending event by ID + pub async fn get_pending_by_id(pool: &PgPool, id: &Uuid) -> Result> { + // Future: Add business logic like authorization checks, etc. + db::events::get_pending_by_id(pool, id).await + } } \ No newline at end of file