diff options
author | Joris | 2023-11-25 08:59:39 +0100 |
---|---|---|
committer | Joris | 2023-11-25 08:59:39 +0100 |
commit | bb906d8ecc796f6b71dda1851d6bd0aa91c6bce5 (patch) | |
tree | cf98c0d9466e0338992c94060d09ac90862178c5 /src/controller/incomes.rs | |
parent | 936871e6ba92a23b1956b30272af8c96951c7c2d (diff) |
Upgrade dependencies
Diffstat (limited to 'src/controller/incomes.rs')
-rw-r--r-- | src/controller/incomes.rs | 23 |
1 files changed, 14 insertions, 9 deletions
diff --git a/src/controller/incomes.rs b/src/controller/incomes.rs index cc66ed6..f22098b 100644 --- a/src/controller/incomes.rs +++ b/src/controller/incomes.rs @@ -1,6 +1,8 @@ use chrono::Datelike; use chrono::Utc; -use hyper::{Body, Response}; +use http_body_util::Full; +use hyper::body::Bytes; +use hyper::Response; use std::collections::HashMap; use tera::Context; @@ -13,7 +15,10 @@ use crate::validation; static PER_PAGE: i64 = 10; -pub async fn table(wallet: &Wallet, query: queries::Incomes) -> Response<Body> { +pub async fn table( + wallet: &Wallet, + query: queries::Incomes, +) -> Response<Full<Bytes>> { let page = query.page.unwrap_or(1); let count = db::incomes::count(&wallet.pool).await; let incomes = db::incomes::list(&wallet.pool, page, PER_PAGE).await; @@ -53,7 +58,7 @@ static MONTHS: [&str; 12] = [ pub async fn create_form( wallet: &Wallet, query: queries::Incomes, -) -> Response<Body> { +) -> Response<Full<Bytes>> { create_form_feedback(wallet, query, HashMap::new(), None).await } @@ -62,7 +67,7 @@ async fn create_form_feedback( query: queries::Incomes, form: HashMap<String, String>, error: Option<String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let users = db::users::list(&wallet.pool).await; let mut context = Context::new(); @@ -87,7 +92,7 @@ pub async fn create( wallet: &Wallet, query: queries::Incomes, form: HashMap<String, String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let error = |e: &str| { create_form_feedback(wallet, query, form.clone(), Some(e.to_string())) }; @@ -125,7 +130,7 @@ pub async fn update_form( id: i64, wallet: &Wallet, query: queries::Incomes, -) -> Response<Body> { +) -> Response<Full<Bytes>> { update_form_feedback(id, wallet, query, HashMap::new(), None).await } @@ -135,7 +140,7 @@ async fn update_form_feedback( query: queries::Incomes, form: HashMap<String, String>, error: Option<String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let users = db::users::list(&wallet.pool).await; let income = db::incomes::get(&wallet.pool, id).await; @@ -163,7 +168,7 @@ pub async fn update( wallet: &Wallet, query: queries::Incomes, form: HashMap<String, String>, -) -> Response<Body> { +) -> Response<Full<Bytes>> { let error = |e: &str| { update_form_feedback( id, @@ -203,7 +208,7 @@ pub async fn delete( id: i64, wallet: &Wallet, query: queries::Incomes, -) -> Response<Body> { +) -> Response<Full<Bytes>> { if db::incomes::delete(&wallet.pool, id).await { utils::redirect(&format!("/incomes?page={}", query.page.unwrap_or(1))) } else { |