diff --git a/src/components/trips/todos/mod.rs b/src/components/trips/todos/mod.rs index 5f84881..66479e8 100644 --- a/src/components/trips/todos/mod.rs +++ b/src/components/trips/todos/mod.rs @@ -94,7 +94,7 @@ impl From<(Uuid, Uuid)> for Filter { } #[derive(Debug, Copy, Clone)] -pub struct Id(pub Uuid); +pub struct Id(Uuid); impl std::fmt::Display for Id { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { @@ -102,6 +102,12 @@ impl std::fmt::Display for Id { } } +impl Id { + pub fn new(id: Uuid) -> Self { + Self(id) + } +} + impl From<(Uuid, Uuid)> for Id { fn from((_trip_id, todo_id): (Uuid, Uuid)) -> Self { Self(todo_id) @@ -902,7 +908,7 @@ impl crud::Toggle for StateUpdate { id: Self::Id, value: bool, ) -> Result<(), crate::Error> { - Todo::update(ctx, pool, filter, id, UpdateElement::State(value.into())).await?; + Todo::update(&ctx, &pool, filter, id, UpdateElement::State(value.into())).await?; Ok(()) } } @@ -977,10 +983,10 @@ impl route::ToggleHtmx for StateUpdate { async fn response( ctx: &Context, state: AppState, - (trip_id, todo_id): (Uuid, Uuid), + (trip_id, todo_id): Self::UrlParams, value: bool, ) -> Result, crate::Error> { - let todo_item = Todo::find(ctx, &state.database_pool, Filter { trip_id }, Id(todo_id)) + let todo_item = Todo::find(&ctx, &state.database_pool, Filter { trip_id }, Id(todo_id)) .await? .ok_or_else(|| { crate::Error::Request(RequestError::NotFound { diff --git a/src/routing/routes.rs b/src/routing/routes.rs index 70b26a2..f6f26af 100644 --- a/src/routing/routes.rs +++ b/src/routing/routes.rs @@ -441,7 +441,7 @@ pub async fn trip( &ctx, &state.database_pool, &todos::Filter { trip_id: id }, - components::trips::todos::Id(delete_todo), + components::trips::todos::Id::new(delete_todo), ) .await?;