Added setting for closing days.
This commit is contained in:
+26
-1
@@ -348,7 +348,8 @@ impl ResProperty {
|
||||
pub struct PublicFormData {
|
||||
pub property: ResProperty,
|
||||
pub hours: Vec<DayHour>,
|
||||
pub reservations: Vec<Reservation>
|
||||
pub reservations: Vec<Reservation>,
|
||||
pub closing_days: Option<ClosingTime>
|
||||
}
|
||||
|
||||
fn empty_slots() -> Vec<String> {
|
||||
@@ -637,3 +638,27 @@ impl Appearance {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
pub fn validate_closing_time(time: &ClosingTime) -> Result<(), ValidationError> {
|
||||
if time.from_date > time.to_date {
|
||||
let mut err = ValidationError::new("to date in past");
|
||||
err.message = Some("To date must be after from date".into());
|
||||
Err(err)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize, Validate, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "ssr", derive(sqlx::FromRow))]
|
||||
#[validate(schema(function = "validate_closing_time"))]
|
||||
pub struct ClosingTime {
|
||||
id: i32,
|
||||
pub from_date: NaiveDate,
|
||||
pub to_date: NaiveDate
|
||||
}
|
||||
impl ClosingTime {
|
||||
pub fn id(&self) -> i32 {
|
||||
self.id
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user