send triptype to frontend

This commit is contained in:
2023-04-28 21:19:51 +02:00
parent bd5a28b342
commit 3d5ad30904
8 changed files with 109 additions and 21 deletions

View File

@ -18,6 +18,7 @@ struct AddPlannedEventForm {
planned_starting_time: String,
max_people: i32,
notes: Option<String>,
trip_type: Option<i64>,
}
#[post("/planned-event", data = "<data>")]
@ -33,6 +34,7 @@ async fn create(
data.max_people,
data.day.clone(),
data.notes.clone(),
data.trip_type,
)
.await;

View File

@ -21,6 +21,7 @@ struct AddTripForm {
planned_starting_time: String,
max_people: i32,
notes: Option<String>,
trip_type: Option<i64>,
}
#[post("/trip", data = "<data>")]
@ -32,6 +33,7 @@ async fn create(db: &State<SqlitePool>, data: Form<AddTripForm>, cox: CoxUser) -
data.max_people,
data.day.clone(),
data.notes.clone(),
data.trip_type,
)
.await;
let trip_details = TripDetails::find_by_id(db, trip_details_id).await.unwrap(); //Okay, bc just

View File

@ -13,6 +13,7 @@ use sqlx::SqlitePool;
use crate::model::{
log::Log,
tripdetails::TripDetails,
triptype::TripType,
user::User,
usertrip::{UserTrip, UserTripError},
Day,
@ -26,6 +27,8 @@ mod cox;
async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_>>) -> Template {
let mut days = Vec::new();
let mut context = Context::new();
let mut show_next_n_days = 6;
if user.is_cox {
let end_of_year = NaiveDate::from_ymd_opt(Local::now().year(), 12, 31).unwrap();
@ -34,14 +37,16 @@ async fn index(db: &State<SqlitePool>, user: User, flash: Option<FlashMessage<'_
.num_days()
+ 1;
}
if user.is_cox || user.is_admin {
let triptypes = TripType::all(db).await;
context.insert("trip_types", &triptypes);
}
for i in 0..show_next_n_days {
let date = (Local::now() + Duration::days(i)).date_naive();
days.push(Day::new(db, date).await);
}
let mut context = Context::new();
if let Some(msg) = flash {
context.insert("flash", &msg.into_inner());
}