|
|
@ -24,6 +24,7 @@ cfg_if! { if #[cfg(feature = "ssr")] {
|
|
|
|
use sqlx::PgPool;
|
|
|
|
use sqlx::PgPool;
|
|
|
|
use crate::backend::user::admin_email;
|
|
|
|
use crate::backend::user::admin_email;
|
|
|
|
use crate::backend::user::emails_for_notify;
|
|
|
|
use crate::backend::user::emails_for_notify;
|
|
|
|
|
|
|
|
use crate::locales::trl;
|
|
|
|
use rust_decimal::prelude::ToPrimitive;
|
|
|
|
use rust_decimal::prelude::ToPrimitive;
|
|
|
|
|
|
|
|
|
|
|
|
async fn find_sum_by_uuid(uuid: &Uuid, tx: &mut Transaction<'_, Postgres>) -> Result<ReservationSum, Error> {
|
|
|
|
async fn find_sum_by_uuid(uuid: &Uuid, tx: &mut Transaction<'_, Postgres>) -> Result<ReservationSum, Error> {
|
|
|
@ -446,7 +447,7 @@ fn chart(data: &Vec<ChartData>, title: &str, month: bool) -> String {
|
|
|
|
let mut chart = BarChart::new_with_theme(
|
|
|
|
let mut chart = BarChart::new_with_theme(
|
|
|
|
vec![("Bookings", data.iter().map(|d| d.count.to_f32().unwrap_or_default()).collect()).into()],
|
|
|
|
vec![("Bookings", data.iter().map(|d| d.count.to_f32().unwrap_or_default()).collect()).into()],
|
|
|
|
if month {
|
|
|
|
if month {
|
|
|
|
data.iter().map(|d| Month::try_from(d.period.to_u8().unwrap_or_default()).unwrap_or(Month::January).name().to_string()).collect()
|
|
|
|
data.iter().map(|d| trl(Month::try_from(d.period.to_u8().unwrap_or_default()).unwrap_or(Month::January).name())()).collect()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
data.iter().map(|d| d.period.to_string()).collect()
|
|
|
|
data.iter().map(|d| d.period.to_string()).collect()
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -472,7 +473,7 @@ pub async fn month_chart(year: i32) -> Result<ApiResponse<String>, ServerFnError
|
|
|
|
perm_check!(is_logged_in);
|
|
|
|
perm_check!(is_logged_in);
|
|
|
|
|
|
|
|
|
|
|
|
let data = month_chart_data(year).await?;
|
|
|
|
let data = month_chart_data(year).await?;
|
|
|
|
Ok(ApiResponse::Data(chart(&data, "Month bookings", true)))
|
|
|
|
Ok(ApiResponse::Data(chart(&data, &trl("Month bookings")(), true)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[server]
|
|
|
|
#[server]
|
|
|
@ -481,7 +482,7 @@ pub async fn year_chart() -> Result<ApiResponse<String>, ServerFnError> {
|
|
|
|
perm_check!(is_logged_in);
|
|
|
|
perm_check!(is_logged_in);
|
|
|
|
|
|
|
|
|
|
|
|
let data = year_chart_data().await?;
|
|
|
|
let data = year_chart_data().await?;
|
|
|
|
Ok(ApiResponse::Data(chart(&data, "Year bookings", false)))
|
|
|
|
Ok(ApiResponse::Data(chart(&data, &trl("Year bookings")(), false)))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[server]
|
|
|
|
#[server]
|
|
|
|