| 
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -5,7 +5,7 @@ use leptos_router::*;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use rust_decimal::Decimal;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::backend::appearance::get_appearance;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::backend::customer::get_remembered;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::backend::data::{ApiResponse, Customer, DayHour, Reservation, ResProperty, SlotType, TmCheck};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::backend::data::{ApiResponse, ClosingTime, Customer, DayHour, Reservation, ResProperty, SlotType, TmCheck};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::backend::reservation::{CreateReservation, get_public_form_data, is_reserved};
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::backend::user::get_pow;
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				use crate::components::data_form::ForValidation;
 | 
			
		
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
			
			 | 
			 | 
			
				@ -20,51 +20,62 @@ fn time_selector(
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    reservations: Vec<Reservation>,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    property: ResProperty,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    slots: RwSignal<Vec<String>>,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    price: RwSignal<Decimal>) -> impl IntoView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let checks = hours.into_iter().map(|h| {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        match property.slot {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            SlotType::Quarter => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                logging::log!("quarter");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                for n in 0..(h.to() - h.from()).num_minutes() * 4 / 60 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        from: h.from() + Duration::minutes(n * 15),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        to: h.from() + Duration::minutes((n + 1) * 15)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    price: RwSignal<Decimal>,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    day: ReadSignal<NaiveDate>,
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    closing_days: Option<ClosingTime>) -> impl IntoView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let closed = if let Some(c) = closing_days {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        day.get() >= c.from_date && day.get() <= c.to_date
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    } else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        false
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    };
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let checks = if !closed {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        hours.into_iter().map(|h| {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            match property.slot {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                SlotType::Quarter => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    logging::log!("quarter");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    for n in 0..(h.to() - h.from()).num_minutes() * 4 / 60 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            from: h.from() + Duration::minutes(n * 15),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            to: h.from() + Duration::minutes((n + 1) * 15)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            SlotType::Half => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                logging::log!("half");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                for n in 0..(h.to() - h.from()).num_minutes() * 2 / 60 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        from: h.from() + Duration::minutes(n * 30),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        to: h.from() + Duration::minutes((n + 1) * 30)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                SlotType::Half => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    logging::log!("half");
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    for n in 0..(h.to() - h.from()).num_minutes() * 2 / 60 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            from: h.from() + Duration::minutes(n * 30),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            to: h.from() + Duration::minutes((n + 1) * 30)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            SlotType::Hour => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                for n in 0..(h.to() - h.from()).num_minutes() / 60 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                SlotType::Hour => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    for n in 0..(h.to() - h.from()).num_minutes() / 60 {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            from: h.from() + Duration::minutes(n * 60),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                            to: h.from() + Duration::minutes((n + 1) * 60)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                SlotType::Day => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        from: h.from() + Duration::minutes(n * 60),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        to: h.from() + Duration::minutes((n + 1) * 60)
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        from: NaiveTime::from_hms_opt(0, 0, 0).unwrap(),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                        to: NaiveTime::from_hms_opt(23, 59, 59).unwrap()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            SlotType::Day => {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                let mut ret: Vec<TmCheck> = vec![];
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                ret.push(TmCheck {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    from: NaiveTime::from_hms_opt(0,0,0).unwrap(),
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                    to: NaiveTime::from_hms_opt(23, 59, 59).unwrap()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                });
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                ret
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				            }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    }).collect::<Vec<_>>().into_iter().flatten().collect::<Vec<_>>();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        }).collect::<Vec<_>>().into_iter().flatten().collect::<Vec<_>>()
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    } else {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				        vec![]
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    };
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let prop_id = property.id();
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				    let closed = checks.is_empty();
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
			
			 | 
			 | 
			
				@ -222,6 +233,8 @@ pub fn Public() -> impl IntoView {
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    hours={data.hours.clone()}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    reservations={data.reservations.clone()}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    property={data.property.clone()}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    day={day.read_only()}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    closing_days={data.closing_days.clone()}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    slots={slots}
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                                    price={price}/>
 | 
			
		
		
	
		
			
				 | 
				 | 
			
			 | 
			 | 
			
				                                            </div>
 | 
			
		
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
			
			 | 
			 | 
			
				
 
 |