From c279ee24f2eeaffede630932dedacbb16639d655 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sun, 23 Feb 2025 05:01:02 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=91=EF=B8=8F=20invest=20sub=20prj?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/invest.rs | 7 +++++-- src/main.rs | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) 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(