This commit is contained in:
2023-09-17 22:54:59 +02:00
parent 903219a7d2
commit e0f14f0b9e
2 changed files with 11 additions and 5 deletions

View File

@@ -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<Response<BoxBody>, 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 {

View File

@@ -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?;