Added setting for closing days.

This commit is contained in:
2024-05-26 21:07:09 +02:00
parent 084911c992
commit 9f9b716781
8 changed files with 236 additions and 50 deletions
+26 -1
View File
@@ -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
}
}