Implemented booking overview.
This commit is contained in:
+40
-9
@@ -1,6 +1,6 @@
|
||||
#![allow(unused_variables)]
|
||||
|
||||
use std::fmt::Display;
|
||||
use std::fmt::{Display, Formatter};
|
||||
use std::str::FromStr;
|
||||
use chrono::{Local, NaiveDate, NaiveTime, Weekday};
|
||||
use lazy_static::lazy_static;
|
||||
@@ -310,15 +310,20 @@ fn def_true() -> bool {
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct ResProperty {
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
id: i32,
|
||||
#[validate(length(min = 1,message = "Name cannot be empty"))]
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub price: Decimal,
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub slot: SlotType,
|
||||
#[serde(default = "def_true")]
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub allow_multi: bool,
|
||||
#[serde(default = "def_true")]
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub active: bool
|
||||
}
|
||||
|
||||
@@ -409,10 +414,12 @@ impl CrReservation {
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct Customer {
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
id: i32,
|
||||
pub full_name: String,
|
||||
pub email: String,
|
||||
pub phone: String,
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub discount: i32
|
||||
}
|
||||
|
||||
@@ -437,30 +444,36 @@ pub enum ReservationState {
|
||||
Canceled,
|
||||
}
|
||||
|
||||
impl Display for ReservationState {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
write!(f, "{}", match self {
|
||||
ReservationState::New => {"New"}
|
||||
ReservationState::Approved => {"Approved"}
|
||||
ReservationState::Canceled => {"Canceled"}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct Reservation {
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
id: i32,
|
||||
pub from: NaiveTime,
|
||||
pub to: NaiveTime,
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub property: i32,
|
||||
#[cfg_attr(feature = "ssr", sqlx(default))]
|
||||
pub summary: i32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct ResPropertyView {
|
||||
pub name: String,
|
||||
pub description: String
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct ResWithProperty {
|
||||
#[cfg_attr(feature = "ssr", sqlx(flatten))]
|
||||
pub reservation: Reservation,
|
||||
#[cfg_attr(feature = "ssr", sqlx(flatten))]
|
||||
pub property: ResPropertyView
|
||||
pub property: ResProperty
|
||||
}
|
||||
|
||||
pub struct Reservations(Vec<Reservation>);
|
||||
@@ -538,6 +551,17 @@ pub struct ResSumWithItems {
|
||||
pub reservations: Vec<ResWithProperty>
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct ResAllView {
|
||||
#[cfg_attr(feature = "ssr", sqlx(flatten))]
|
||||
pub reservation: ResWithProperty,
|
||||
#[cfg_attr(feature = "ssr", sqlx(flatten))]
|
||||
pub summary: ReservationSum,
|
||||
#[cfg_attr(feature = "ssr", sqlx(flatten))]
|
||||
pub customer: Customer,
|
||||
}
|
||||
|
||||
#[derive(Clone, Serialize, Deserialize, Debug, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::Type))]
|
||||
#[cfg_attr(feature = "ssr", sqlx(type_name = "message_type"))]
|
||||
@@ -576,3 +600,10 @@ impl Message {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
pub struct ChartData {
|
||||
pub count: i64,
|
||||
pub period: f64
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user