diff --git a/src/invest.rs b/src/invest.rs index 25277f7..5458e74 100644 --- a/src/invest.rs +++ b/src/invest.rs @@ -4,6 +4,8 @@ use based::get_pg; use rocket::{form::Form, post, response::Redirect, FromForm}; use sqlx::prelude::FromRow; +use crate::PathSegment; + #[derive(Debug, Clone, FromRow)] pub struct Investment { pub id: i64, @@ -84,8 +86,9 @@ pub struct NewInvestForm { description: String, } -#[post("/prj//invest", data = "
")] -pub async fn post_new_invest(root: String, form: Form) -> Redirect { +#[post("/invest/", data = "")] +pub async fn post_new_invest(path: PathSegment, form: Form) -> Redirect { + let root = path.to_str(); Investment::new_investment( &root, form.amount.parse().unwrap(), diff --git a/src/main.rs b/src/main.rs index 2ee662d..691339b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -151,7 +151,7 @@ pub fn build_invest_timeline(investments: &[Investment]) -> PreEscaped { pub async fn invest_tab(prj: &Project, root: &str) -> PreEscaped { let (add_invest_id, add_invest_modal) = Modal( "Add Investment", - Form::new(&format!("/prj/{root}invest")) + Form::new(&format!("/invest/{root}")) .id("new_invest") .add_input(TextInput("title").required().placeholder("Title")) .add_input(