This commit is contained in:
parent
453e195a7a
commit
c279ee24f2
2 changed files with 6 additions and 3 deletions
|
@ -4,6 +4,8 @@ use based::get_pg;
|
||||||
use rocket::{form::Form, post, response::Redirect, FromForm};
|
use rocket::{form::Form, post, response::Redirect, FromForm};
|
||||||
use sqlx::prelude::FromRow;
|
use sqlx::prelude::FromRow;
|
||||||
|
|
||||||
|
use crate::PathSegment;
|
||||||
|
|
||||||
#[derive(Debug, Clone, FromRow)]
|
#[derive(Debug, Clone, FromRow)]
|
||||||
pub struct Investment {
|
pub struct Investment {
|
||||||
pub id: i64,
|
pub id: i64,
|
||||||
|
@ -84,8 +86,9 @@ pub struct NewInvestForm {
|
||||||
description: String,
|
description: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[post("/prj/<root>/invest", data = "<form>")]
|
#[post("/invest/<path..>", data = "<form>")]
|
||||||
pub async fn post_new_invest(root: String, form: Form<NewInvestForm>) -> Redirect {
|
pub async fn post_new_invest(path: PathSegment, form: Form<NewInvestForm>) -> Redirect {
|
||||||
|
let root = path.to_str();
|
||||||
Investment::new_investment(
|
Investment::new_investment(
|
||||||
&root,
|
&root,
|
||||||
form.amount.parse().unwrap(),
|
form.amount.parse().unwrap(),
|
||||||
|
|
|
@ -151,7 +151,7 @@ pub fn build_invest_timeline(investments: &[Investment]) -> PreEscaped<String> {
|
||||||
pub async fn invest_tab(prj: &Project, root: &str) -> PreEscaped<String> {
|
pub async fn invest_tab(prj: &Project, root: &str) -> PreEscaped<String> {
|
||||||
let (add_invest_id, add_invest_modal) = Modal(
|
let (add_invest_id, add_invest_modal) = Modal(
|
||||||
"Add Investment",
|
"Add Investment",
|
||||||
Form::new(&format!("/prj/{root}invest"))
|
Form::new(&format!("/invest/{root}"))
|
||||||
.id("new_invest")
|
.id("new_invest")
|
||||||
.add_input(TextInput("title").required().placeholder("Title"))
|
.add_input(TextInput("title").required().placeholder("Title"))
|
||||||
.add_input(
|
.add_input(
|
||||||
|
|
Loading…
Add table
Reference in a new issue